Loading media/java/android/media/MediaMuxer.java +29 −6 Original line number Original line Diff line number Diff line Loading @@ -321,6 +321,21 @@ final public class MediaMuxer { @UnsupportedAppUsage @UnsupportedAppUsage private long mNativeObject; private long mNativeObject; private String convertMuxerStateCodeToString(int aState) { switch (aState) { case MUXER_STATE_UNINITIALIZED: return "UNINITIALIZED"; case MUXER_STATE_INITIALIZED: return "INITIALIZED"; case MUXER_STATE_STARTED: return "STARTED"; case MUXER_STATE_STOPPED: return "STOPPED"; default: return "UNKNOWN"; } } /** /** * Constructor. * Constructor. * Creates a media muxer that writes to the specified path. * Creates a media muxer that writes to the specified path. Loading Loading @@ -397,7 +412,7 @@ final public class MediaMuxer { nativeSetOrientationHint(mNativeObject, degrees); nativeSetOrientationHint(mNativeObject, degrees); } else { } else { throw new IllegalStateException("Can't set rotation degrees due" + throw new IllegalStateException("Can't set rotation degrees due" + " to wrong state."); " to wrong state(" + convertMuxerStateCodeToString(mState) + ")"); } } } } Loading Loading @@ -432,7 +447,8 @@ final public class MediaMuxer { if (mState == MUXER_STATE_INITIALIZED && mNativeObject != 0) { if (mState == MUXER_STATE_INITIALIZED && mNativeObject != 0) { nativeSetLocation(mNativeObject, latitudex10000, longitudex10000); nativeSetLocation(mNativeObject, latitudex10000, longitudex10000); } else { } else { throw new IllegalStateException("Can't set location due to wrong state."); throw new IllegalStateException("Can't set location due to wrong state(" + convertMuxerStateCodeToString(mState) + ")"); } } } } Loading @@ -451,7 +467,8 @@ final public class MediaMuxer { nativeStart(mNativeObject); nativeStart(mNativeObject); mState = MUXER_STATE_STARTED; mState = MUXER_STATE_STARTED; } else { } else { throw new IllegalStateException("Can't start due to wrong state."); throw new IllegalStateException("Can't start due to wrong state(" + convertMuxerStateCodeToString(mState) + ")"); } } } } Loading @@ -462,10 +479,16 @@ final public class MediaMuxer { */ */ public void stop() { public void stop() { if (mState == MUXER_STATE_STARTED) { if (mState == MUXER_STATE_STARTED) { try { nativeStop(mNativeObject); nativeStop(mNativeObject); } catch (Exception e) { throw e; } finally { mState = MUXER_STATE_STOPPED; mState = MUXER_STATE_STOPPED; } } else { } else { throw new IllegalStateException("Can't stop due to wrong state."); throw new IllegalStateException("Can't stop due to wrong state(" + convertMuxerStateCodeToString(mState) + ")"); } } } } Loading media/jni/android_media_MediaMuxer.cpp +5 −29 Original line number Original line Diff line number Diff line Loading @@ -26,15 +26,11 @@ #include <unistd.h> #include <unistd.h> #include <fcntl.h> #include <fcntl.h> #include <android/api-level.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/MediaErrors.h> #include <media/stagefright/MediaMuxer.h> #include <media/stagefright/MediaMuxer.h> extern "C" int android_get_application_target_sdk_version(); namespace android { namespace android { struct fields_t { struct fields_t { Loading Loading @@ -233,33 +229,13 @@ static void android_media_MediaMuxer_stop(JNIEnv *env, jclass /* clazz */, status_t err = muxer->stop(); status_t err = muxer->stop(); if (android_get_application_target_sdk_version() >= __ANDROID_API_R__) { switch (err) { case OK: break; case ERROR_IO: { jniThrowException(env, "java/lang/UncheckedIOException", "Muxer stopped unexpectedly"); return; } case ERROR_MALFORMED: { jniThrowException(env, "java/io/IOError", "Failure of reading or writing operation"); return; } default: { jniThrowException(env, "java/lang/IllegalStateException", "Failed to stop the muxer"); return; } } } else { if (err != OK) { if (err != OK) { jniThrowException(env, "java/lang/IllegalStateException", "Failed to stop the muxer"); ALOGE("Error during stop:%d", err); jniThrowException(env, "java/lang/IllegalStateException", "Error during stop(), muxer would have stopped already"); return; return; } } } } } static void android_media_MediaMuxer_native_release( static void android_media_MediaMuxer_native_release( JNIEnv* /* env */, jclass clazz, jlong nativeObject) { JNIEnv* /* env */, jclass clazz, jlong nativeObject) { Loading Loading
media/java/android/media/MediaMuxer.java +29 −6 Original line number Original line Diff line number Diff line Loading @@ -321,6 +321,21 @@ final public class MediaMuxer { @UnsupportedAppUsage @UnsupportedAppUsage private long mNativeObject; private long mNativeObject; private String convertMuxerStateCodeToString(int aState) { switch (aState) { case MUXER_STATE_UNINITIALIZED: return "UNINITIALIZED"; case MUXER_STATE_INITIALIZED: return "INITIALIZED"; case MUXER_STATE_STARTED: return "STARTED"; case MUXER_STATE_STOPPED: return "STOPPED"; default: return "UNKNOWN"; } } /** /** * Constructor. * Constructor. * Creates a media muxer that writes to the specified path. * Creates a media muxer that writes to the specified path. Loading Loading @@ -397,7 +412,7 @@ final public class MediaMuxer { nativeSetOrientationHint(mNativeObject, degrees); nativeSetOrientationHint(mNativeObject, degrees); } else { } else { throw new IllegalStateException("Can't set rotation degrees due" + throw new IllegalStateException("Can't set rotation degrees due" + " to wrong state."); " to wrong state(" + convertMuxerStateCodeToString(mState) + ")"); } } } } Loading Loading @@ -432,7 +447,8 @@ final public class MediaMuxer { if (mState == MUXER_STATE_INITIALIZED && mNativeObject != 0) { if (mState == MUXER_STATE_INITIALIZED && mNativeObject != 0) { nativeSetLocation(mNativeObject, latitudex10000, longitudex10000); nativeSetLocation(mNativeObject, latitudex10000, longitudex10000); } else { } else { throw new IllegalStateException("Can't set location due to wrong state."); throw new IllegalStateException("Can't set location due to wrong state(" + convertMuxerStateCodeToString(mState) + ")"); } } } } Loading @@ -451,7 +467,8 @@ final public class MediaMuxer { nativeStart(mNativeObject); nativeStart(mNativeObject); mState = MUXER_STATE_STARTED; mState = MUXER_STATE_STARTED; } else { } else { throw new IllegalStateException("Can't start due to wrong state."); throw new IllegalStateException("Can't start due to wrong state(" + convertMuxerStateCodeToString(mState) + ")"); } } } } Loading @@ -462,10 +479,16 @@ final public class MediaMuxer { */ */ public void stop() { public void stop() { if (mState == MUXER_STATE_STARTED) { if (mState == MUXER_STATE_STARTED) { try { nativeStop(mNativeObject); nativeStop(mNativeObject); } catch (Exception e) { throw e; } finally { mState = MUXER_STATE_STOPPED; mState = MUXER_STATE_STOPPED; } } else { } else { throw new IllegalStateException("Can't stop due to wrong state."); throw new IllegalStateException("Can't stop due to wrong state(" + convertMuxerStateCodeToString(mState) + ")"); } } } } Loading
media/jni/android_media_MediaMuxer.cpp +5 −29 Original line number Original line Diff line number Diff line Loading @@ -26,15 +26,11 @@ #include <unistd.h> #include <unistd.h> #include <fcntl.h> #include <fcntl.h> #include <android/api-level.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/MediaErrors.h> #include <media/stagefright/MediaMuxer.h> #include <media/stagefright/MediaMuxer.h> extern "C" int android_get_application_target_sdk_version(); namespace android { namespace android { struct fields_t { struct fields_t { Loading Loading @@ -233,33 +229,13 @@ static void android_media_MediaMuxer_stop(JNIEnv *env, jclass /* clazz */, status_t err = muxer->stop(); status_t err = muxer->stop(); if (android_get_application_target_sdk_version() >= __ANDROID_API_R__) { switch (err) { case OK: break; case ERROR_IO: { jniThrowException(env, "java/lang/UncheckedIOException", "Muxer stopped unexpectedly"); return; } case ERROR_MALFORMED: { jniThrowException(env, "java/io/IOError", "Failure of reading or writing operation"); return; } default: { jniThrowException(env, "java/lang/IllegalStateException", "Failed to stop the muxer"); return; } } } else { if (err != OK) { if (err != OK) { jniThrowException(env, "java/lang/IllegalStateException", "Failed to stop the muxer"); ALOGE("Error during stop:%d", err); jniThrowException(env, "java/lang/IllegalStateException", "Error during stop(), muxer would have stopped already"); return; return; } } } } } static void android_media_MediaMuxer_native_release( static void android_media_MediaMuxer_native_release( JNIEnv* /* env */, jclass clazz, jlong nativeObject) { JNIEnv* /* env */, jclass clazz, jlong nativeObject) { Loading