Loading include/media/IMediaRecorder.h +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ public: virtual status_t setAudioEncoder(int ae) = 0; virtual status_t setOutputFile(const char* path) = 0; virtual status_t setOutputFile(int fd, int64_t offset, int64_t length) = 0; virtual status_t setOutputFileAuxiliary(int fd) = 0; virtual status_t setVideoSize(int width, int height) = 0; virtual status_t setVideoFrameRate(int frames_per_second) = 0; virtual status_t setParameters(const String8& params) = 0; Loading include/media/MediaRecorderBase.h +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ struct MediaRecorderBase { virtual status_t setPreviewSurface(const sp<Surface>& surface) = 0; virtual status_t setOutputFile(const char *path) = 0; virtual status_t setOutputFile(int fd, int64_t offset, int64_t length) = 0; virtual status_t setOutputFileAuxiliary(int fd) {return INVALID_OPERATION;} virtual status_t setParameters(const String8& params) = 0; virtual status_t setListener(const sp<IMediaRecorderClient>& listener) = 0; virtual status_t prepare() = 0; Loading include/media/mediarecorder.h +2 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,7 @@ public: status_t setAudioEncoder(int ae); status_t setOutputFile(const char* path); status_t setOutputFile(int fd, int64_t offset, int64_t length); status_t setOutputFileAuxiliary(int fd); status_t setVideoSize(int width, int height); status_t setVideoFrameRate(int frames_per_second); status_t setParameters(const String8& params); Loading @@ -196,6 +197,7 @@ private: bool mIsAudioEncoderSet; bool mIsVideoEncoderSet; bool mIsOutputFileSet; bool mIsAuxiliaryOutputFileSet; Mutex mLock; Mutex mNotifyLock; }; Loading media/java/android/media/MediaRecorder.java +53 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,9 @@ public class MediaRecorder private String mPath; private FileDescriptor mFd; private boolean mPrepareAuxiliaryFile = false; private String mPathAux; private FileDescriptor mFdAux; private EventHandler mEventHandler; private OnErrorListener mOnErrorListener; private OnInfoListener mOnInfoListener; Loading Loading @@ -479,6 +482,38 @@ public class MediaRecorder setParameter(String.format("video-param-encoder-level=%d", encoderLevel)); } /** * Pass in the file descriptor of the auxiliary file to be written. Call this after * setOutputFormat() but before prepare(). * * @param fd an open file descriptor to be written into. * @throws IllegalStateException if it is called before * setOutputFormat() or after prepare() * @hide */ public void setAuxiliaryOutputFile(FileDescriptor fd) throws IllegalStateException { mPrepareAuxiliaryFile = true; mPathAux = null; mFdAux = fd; } /** * Sets the path of the auxiliary output file to be produced. Call this after * setOutputFormat() but before prepare(). * * @param path The pathname to use. * @throws IllegalStateException if it is called before * setOutputFormat() or after prepare() * @hide */ public void setAuxiliaryOutputFile(String path) throws IllegalStateException { mPrepareAuxiliaryFile = true; mFdAux = null; mPathAux = path; } /** * Pass in the file descriptor of the file to be written. Call this after * setOutputFormat() but before prepare(). Loading Loading @@ -510,6 +545,8 @@ public class MediaRecorder // native implementation private native void _setOutputFile(FileDescriptor fd, long offset, long length) throws IllegalStateException, IOException; private native void _setOutputFileAux(FileDescriptor fd) throws IllegalStateException, IOException; private native void _prepare() throws IllegalStateException, IOException; /** Loading @@ -535,6 +572,22 @@ public class MediaRecorder } else { throw new IOException("No valid output file"); } if (mPrepareAuxiliaryFile) { if (mPathAux != null) { FileOutputStream fos = new FileOutputStream(mPathAux); try { _setOutputFileAux(fos.getFD()); } finally { fos.close(); } } else if (mFdAux != null) { _setOutputFileAux(mFdAux); } else { throw new IOException("No valid output file"); } } _prepare(); } Loading media/jni/android_media_MediaRecorder.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,20 @@ android_media_MediaRecorder_setOutputFileFD(JNIEnv *env, jobject thiz, jobject f process_media_recorder_call(env, opStatus, "java/io/IOException", "setOutputFile failed."); } static void android_media_MediaRecorder_setOutputFileAuxFD(JNIEnv *env, jobject thiz, jobject fileDescriptor) { LOGV("setOutputFile"); if (fileDescriptor == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return; } int fd = getParcelFileDescriptorFD(env, fileDescriptor); sp<MediaRecorder> mr = getMediaRecorder(env, thiz); status_t opStatus = mr->setOutputFileAuxiliary(fd); process_media_recorder_call(env, opStatus, "java/io/IOException", "setOutputFile failed."); } static void android_media_MediaRecorder_setVideoSize(JNIEnv *env, jobject thiz, jint width, jint height) { Loading Loading @@ -466,6 +480,7 @@ static JNINativeMethod gMethods[] = { {"setAudioEncoder", "(I)V", (void *)android_media_MediaRecorder_setAudioEncoder}, {"setParameter", "(Ljava/lang/String;)V", (void *)android_media_MediaRecorder_setParameter}, {"_setOutputFile", "(Ljava/io/FileDescriptor;JJ)V", (void *)android_media_MediaRecorder_setOutputFileFD}, {"_setOutputFileAux", "(Ljava/io/FileDescriptor;)V", (void *)android_media_MediaRecorder_setOutputFileAuxFD}, {"setVideoSize", "(II)V", (void *)android_media_MediaRecorder_setVideoSize}, {"setVideoFrameRate", "(I)V", (void *)android_media_MediaRecorder_setVideoFrameRate}, {"setMaxDuration", "(I)V", (void *)android_media_MediaRecorder_setMaxDuration}, Loading Loading
include/media/IMediaRecorder.h +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ public: virtual status_t setAudioEncoder(int ae) = 0; virtual status_t setOutputFile(const char* path) = 0; virtual status_t setOutputFile(int fd, int64_t offset, int64_t length) = 0; virtual status_t setOutputFileAuxiliary(int fd) = 0; virtual status_t setVideoSize(int width, int height) = 0; virtual status_t setVideoFrameRate(int frames_per_second) = 0; virtual status_t setParameters(const String8& params) = 0; Loading
include/media/MediaRecorderBase.h +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ struct MediaRecorderBase { virtual status_t setPreviewSurface(const sp<Surface>& surface) = 0; virtual status_t setOutputFile(const char *path) = 0; virtual status_t setOutputFile(int fd, int64_t offset, int64_t length) = 0; virtual status_t setOutputFileAuxiliary(int fd) {return INVALID_OPERATION;} virtual status_t setParameters(const String8& params) = 0; virtual status_t setListener(const sp<IMediaRecorderClient>& listener) = 0; virtual status_t prepare() = 0; Loading
include/media/mediarecorder.h +2 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,7 @@ public: status_t setAudioEncoder(int ae); status_t setOutputFile(const char* path); status_t setOutputFile(int fd, int64_t offset, int64_t length); status_t setOutputFileAuxiliary(int fd); status_t setVideoSize(int width, int height); status_t setVideoFrameRate(int frames_per_second); status_t setParameters(const String8& params); Loading @@ -196,6 +197,7 @@ private: bool mIsAudioEncoderSet; bool mIsVideoEncoderSet; bool mIsOutputFileSet; bool mIsAuxiliaryOutputFileSet; Mutex mLock; Mutex mNotifyLock; }; Loading
media/java/android/media/MediaRecorder.java +53 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,9 @@ public class MediaRecorder private String mPath; private FileDescriptor mFd; private boolean mPrepareAuxiliaryFile = false; private String mPathAux; private FileDescriptor mFdAux; private EventHandler mEventHandler; private OnErrorListener mOnErrorListener; private OnInfoListener mOnInfoListener; Loading Loading @@ -479,6 +482,38 @@ public class MediaRecorder setParameter(String.format("video-param-encoder-level=%d", encoderLevel)); } /** * Pass in the file descriptor of the auxiliary file to be written. Call this after * setOutputFormat() but before prepare(). * * @param fd an open file descriptor to be written into. * @throws IllegalStateException if it is called before * setOutputFormat() or after prepare() * @hide */ public void setAuxiliaryOutputFile(FileDescriptor fd) throws IllegalStateException { mPrepareAuxiliaryFile = true; mPathAux = null; mFdAux = fd; } /** * Sets the path of the auxiliary output file to be produced. Call this after * setOutputFormat() but before prepare(). * * @param path The pathname to use. * @throws IllegalStateException if it is called before * setOutputFormat() or after prepare() * @hide */ public void setAuxiliaryOutputFile(String path) throws IllegalStateException { mPrepareAuxiliaryFile = true; mFdAux = null; mPathAux = path; } /** * Pass in the file descriptor of the file to be written. Call this after * setOutputFormat() but before prepare(). Loading Loading @@ -510,6 +545,8 @@ public class MediaRecorder // native implementation private native void _setOutputFile(FileDescriptor fd, long offset, long length) throws IllegalStateException, IOException; private native void _setOutputFileAux(FileDescriptor fd) throws IllegalStateException, IOException; private native void _prepare() throws IllegalStateException, IOException; /** Loading @@ -535,6 +572,22 @@ public class MediaRecorder } else { throw new IOException("No valid output file"); } if (mPrepareAuxiliaryFile) { if (mPathAux != null) { FileOutputStream fos = new FileOutputStream(mPathAux); try { _setOutputFileAux(fos.getFD()); } finally { fos.close(); } } else if (mFdAux != null) { _setOutputFileAux(mFdAux); } else { throw new IOException("No valid output file"); } } _prepare(); } Loading
media/jni/android_media_MediaRecorder.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,20 @@ android_media_MediaRecorder_setOutputFileFD(JNIEnv *env, jobject thiz, jobject f process_media_recorder_call(env, opStatus, "java/io/IOException", "setOutputFile failed."); } static void android_media_MediaRecorder_setOutputFileAuxFD(JNIEnv *env, jobject thiz, jobject fileDescriptor) { LOGV("setOutputFile"); if (fileDescriptor == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return; } int fd = getParcelFileDescriptorFD(env, fileDescriptor); sp<MediaRecorder> mr = getMediaRecorder(env, thiz); status_t opStatus = mr->setOutputFileAuxiliary(fd); process_media_recorder_call(env, opStatus, "java/io/IOException", "setOutputFile failed."); } static void android_media_MediaRecorder_setVideoSize(JNIEnv *env, jobject thiz, jint width, jint height) { Loading Loading @@ -466,6 +480,7 @@ static JNINativeMethod gMethods[] = { {"setAudioEncoder", "(I)V", (void *)android_media_MediaRecorder_setAudioEncoder}, {"setParameter", "(Ljava/lang/String;)V", (void *)android_media_MediaRecorder_setParameter}, {"_setOutputFile", "(Ljava/io/FileDescriptor;JJ)V", (void *)android_media_MediaRecorder_setOutputFileFD}, {"_setOutputFileAux", "(Ljava/io/FileDescriptor;)V", (void *)android_media_MediaRecorder_setOutputFileAuxFD}, {"setVideoSize", "(II)V", (void *)android_media_MediaRecorder_setVideoSize}, {"setVideoFrameRate", "(I)V", (void *)android_media_MediaRecorder_setVideoFrameRate}, {"setMaxDuration", "(I)V", (void *)android_media_MediaRecorder_setMaxDuration}, Loading