Loading media/java/android/media/MediaCodec.java +27 −6 Original line number Diff line number Diff line Loading @@ -92,14 +92,12 @@ public class MediaCodec * "width" - Integer * "height" - Integer * optional "max-input-size" - Integer * optional "csd-0", "csd-1" ... - ByteBuffer * * Audio formats have the following fields: * "mime" - String * "channel-count" - Integer * "sample-rate" - Integer * optional "max-input-size" - Integer * optional "csd-0", "csd-1" ... - ByteBuffer * * If the format is used to configure an encoder, additional * fields must be included: Loading @@ -114,7 +112,7 @@ public class MediaCodec * * @param surface Specify a surface on which to render the output of this * decoder. * @param flags Specify {@see #CONFIGURE_FLAG_ENCODE} to configure the * @param flags Specify {@link #CONFIGURE_FLAG_ENCODE} to configure the * component as an encoder. */ public void configure( Loading Loading @@ -155,6 +153,19 @@ public class MediaCodec /** After filling a range of the input buffer at the specified index * submit it to the component. * * Many decoders require the actual compressed data stream to be * preceded by "codec specific data", i.e. setup data used to initialize * the codec such as PPS/SPS in the case of AVC video or code tables * in the case of vorbis audio. * The class MediaExtractor provides codec specific data as part of * the returned track format in entries named "csd-0", "csd-1" ... * * These buffers should be submitted using the flag {@link #FLAG_CODECCONFIG}. * * To indicate that this is the final piece of input data (or rather that * no more input data follows unless the decoder is subsequently flushed) * specify the flag {@link FLAG_EOS}. */ public native final void queueInputBuffer( int index, Loading Loading @@ -184,15 +195,25 @@ public class MediaCodec public native final void releaseOutputBuffer(int index, boolean render); /** Call this after dequeueOutputBuffer signals a format change by returning * {@see #INFO_OUTPUT_FORMAT_CHANGED} * {@link #INFO_OUTPUT_FORMAT_CHANGED} */ public native final Map<String, Object> getOutputFormat(); /** Call this after start() returns. */ public ByteBuffer[] getInputBuffers() { return getBuffers(true /* input */); } /** Call this after start() returns and whenever dequeueOutputBuffer * signals an output buffer change by returning * {@see #INFO_OUTPUT_BUFFERS_CHANGED} * {@link #INFO_OUTPUT_BUFFERS_CHANGED} */ public native final ByteBuffer[] getBuffers(boolean input); public ByteBuffer[] getOutputBuffers() { return getBuffers(false /* input */); } private native final ByteBuffer[] getBuffers(boolean input); private static native final void native_init(); Loading media/java/android/media/MediaExtractor.java +1 −1 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ public class MediaExtractor public native boolean advance(); // Retrieve the current encoded sample and store it in the byte buffer // starting at the given offset. // starting at the given offset. Returns the sample size. public native int readSampleData(ByteBuffer byteBuf, int offset); // Returns the track index the current sample originates from. Loading media/jni/android_media_MediaCodec.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -134,7 +134,7 @@ status_t JMediaCodec::dequeueOutputBuffer( uint32_t flags; status_t err; if ((err = mCodec->dequeueOutputBuffer( index, &size, &offset, &timeUs, &flags, timeoutUs)) != OK) { index, &offset, &size, &timeUs, &flags, timeoutUs)) != OK) { return err; } Loading media/jni/android_media_MediaExtractor.cpp +31 −4 Original line number Diff line number Diff line Loading @@ -101,14 +101,37 @@ status_t JMediaExtractor::readSampleData( void *dst = env->GetDirectBufferAddress(byteBuf); jlong dstSize; jbyteArray byteArray = NULL; if (dst == NULL) { // XXX if dst is NULL also fall back to "array()" jclass byteBufClass = env->FindClass("java/nio/ByteBuffer"); CHECK(byteBufClass != NULL); jmethodID arrayID = env->GetMethodID(byteBufClass, "array", "()[B"); CHECK(arrayID != NULL); byteArray = (jbyteArray)env->CallObjectMethod(byteBuf, arrayID); if (byteArray == NULL) { return INVALID_OPERATION; } jlong dstSize = env->GetDirectBufferCapacity(byteBuf); jboolean isCopy; dst = env->GetByteArrayElements(byteArray, &isCopy); dstSize = env->GetArrayLength(byteArray); } else { dstSize = env->GetDirectBufferCapacity(byteBuf); } if (dstSize < offset) { if (byteArray != NULL) { env->ReleaseByteArrayElements(byteArray, (jbyte *)dst, 0); } return -ERANGE; } Loading @@ -116,6 +139,10 @@ status_t JMediaExtractor::readSampleData( status_t err = mImpl->readSampleData(buffer); if (byteArray != NULL) { env->ReleaseByteArrayElements(byteArray, (jbyte *)dst, 0); } if (err != OK) { return err; } Loading Loading
media/java/android/media/MediaCodec.java +27 −6 Original line number Diff line number Diff line Loading @@ -92,14 +92,12 @@ public class MediaCodec * "width" - Integer * "height" - Integer * optional "max-input-size" - Integer * optional "csd-0", "csd-1" ... - ByteBuffer * * Audio formats have the following fields: * "mime" - String * "channel-count" - Integer * "sample-rate" - Integer * optional "max-input-size" - Integer * optional "csd-0", "csd-1" ... - ByteBuffer * * If the format is used to configure an encoder, additional * fields must be included: Loading @@ -114,7 +112,7 @@ public class MediaCodec * * @param surface Specify a surface on which to render the output of this * decoder. * @param flags Specify {@see #CONFIGURE_FLAG_ENCODE} to configure the * @param flags Specify {@link #CONFIGURE_FLAG_ENCODE} to configure the * component as an encoder. */ public void configure( Loading Loading @@ -155,6 +153,19 @@ public class MediaCodec /** After filling a range of the input buffer at the specified index * submit it to the component. * * Many decoders require the actual compressed data stream to be * preceded by "codec specific data", i.e. setup data used to initialize * the codec such as PPS/SPS in the case of AVC video or code tables * in the case of vorbis audio. * The class MediaExtractor provides codec specific data as part of * the returned track format in entries named "csd-0", "csd-1" ... * * These buffers should be submitted using the flag {@link #FLAG_CODECCONFIG}. * * To indicate that this is the final piece of input data (or rather that * no more input data follows unless the decoder is subsequently flushed) * specify the flag {@link FLAG_EOS}. */ public native final void queueInputBuffer( int index, Loading Loading @@ -184,15 +195,25 @@ public class MediaCodec public native final void releaseOutputBuffer(int index, boolean render); /** Call this after dequeueOutputBuffer signals a format change by returning * {@see #INFO_OUTPUT_FORMAT_CHANGED} * {@link #INFO_OUTPUT_FORMAT_CHANGED} */ public native final Map<String, Object> getOutputFormat(); /** Call this after start() returns. */ public ByteBuffer[] getInputBuffers() { return getBuffers(true /* input */); } /** Call this after start() returns and whenever dequeueOutputBuffer * signals an output buffer change by returning * {@see #INFO_OUTPUT_BUFFERS_CHANGED} * {@link #INFO_OUTPUT_BUFFERS_CHANGED} */ public native final ByteBuffer[] getBuffers(boolean input); public ByteBuffer[] getOutputBuffers() { return getBuffers(false /* input */); } private native final ByteBuffer[] getBuffers(boolean input); private static native final void native_init(); Loading
media/java/android/media/MediaExtractor.java +1 −1 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ public class MediaExtractor public native boolean advance(); // Retrieve the current encoded sample and store it in the byte buffer // starting at the given offset. // starting at the given offset. Returns the sample size. public native int readSampleData(ByteBuffer byteBuf, int offset); // Returns the track index the current sample originates from. Loading
media/jni/android_media_MediaCodec.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -134,7 +134,7 @@ status_t JMediaCodec::dequeueOutputBuffer( uint32_t flags; status_t err; if ((err = mCodec->dequeueOutputBuffer( index, &size, &offset, &timeUs, &flags, timeoutUs)) != OK) { index, &offset, &size, &timeUs, &flags, timeoutUs)) != OK) { return err; } Loading
media/jni/android_media_MediaExtractor.cpp +31 −4 Original line number Diff line number Diff line Loading @@ -101,14 +101,37 @@ status_t JMediaExtractor::readSampleData( void *dst = env->GetDirectBufferAddress(byteBuf); jlong dstSize; jbyteArray byteArray = NULL; if (dst == NULL) { // XXX if dst is NULL also fall back to "array()" jclass byteBufClass = env->FindClass("java/nio/ByteBuffer"); CHECK(byteBufClass != NULL); jmethodID arrayID = env->GetMethodID(byteBufClass, "array", "()[B"); CHECK(arrayID != NULL); byteArray = (jbyteArray)env->CallObjectMethod(byteBuf, arrayID); if (byteArray == NULL) { return INVALID_OPERATION; } jlong dstSize = env->GetDirectBufferCapacity(byteBuf); jboolean isCopy; dst = env->GetByteArrayElements(byteArray, &isCopy); dstSize = env->GetArrayLength(byteArray); } else { dstSize = env->GetDirectBufferCapacity(byteBuf); } if (dstSize < offset) { if (byteArray != NULL) { env->ReleaseByteArrayElements(byteArray, (jbyte *)dst, 0); } return -ERANGE; } Loading @@ -116,6 +139,10 @@ status_t JMediaExtractor::readSampleData( status_t err = mImpl->readSampleData(buffer); if (byteArray != NULL) { env->ReleaseByteArrayElements(byteArray, (jbyte *)dst, 0); } if (err != OK) { return err; } Loading