Loading core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -22749,6 +22749,7 @@ package android.media { method @NonNull public android.media.MediaCodec.QueueRequest setIntegerParameter(@NonNull String, int); method @NonNull public android.media.MediaCodec.QueueRequest setLinearBlock(@NonNull android.media.MediaCodec.LinearBlock, int, int); method @NonNull public android.media.MediaCodec.QueueRequest setLongParameter(@NonNull String, long); method @FlaggedApi("com.android.media.codec.flags.large_audio_frame") @NonNull public android.media.MediaCodec.QueueRequest setMultiFrameEncryptedLinearBlock(@NonNull android.media.MediaCodec.LinearBlock, @NonNull java.util.ArrayDeque<android.media.MediaCodec.BufferInfo>, @NonNull java.util.ArrayDeque<android.media.MediaCodec.CryptoInfo>); method @NonNull public android.media.MediaCodec.QueueRequest setPresentationTimeUs(long); method @NonNull public android.media.MediaCodec.QueueRequest setStringParameter(@NonNull String, @NonNull String); } media/java/android/media/MediaCodec.java +45 −6 Original line number Diff line number Diff line Loading @@ -3512,7 +3512,7 @@ final public class MediaCodec { mLinearBlock = block; mOffset = offset; mSize = size; mCryptoInfo = null; mCryptoInfos.clear(); return this; } Loading Loading @@ -3546,7 +3546,44 @@ final public class MediaCodec { mLinearBlock = block; mOffset = offset; mSize = size; mCryptoInfo = cryptoInfo; mCryptoInfos.clear(); mCryptoInfos.add(cryptoInfo); return this; } /** * Set an encrypted linear block to this queue request. Exactly one buffer must be * set for a queue request before calling {@link #queue}. The block can contain multiple * access units and if present should be laid out contiguously and without gaps. * * @param block The linear block object * @param bufferInfos ArrayDeque of {@link MediaCodec.BufferInfo} that describes the * contents in the buffer. The ArrayDeque and the BufferInfo objects * provided can be recycled by the caller for re-use. * @param cryptoInfos ArrayDeque of {@link MediaCodec.CryptoInfo} that describes the * structure of the encrypted input samples. The ArrayDeque and the * BufferInfo objects provided can be recycled by the caller for re-use. * @return this object * @throws IllegalStateException if a buffer is already set * @throws IllegalArgumentException upon if bufferInfos is empty, contains null, or if the * access units are not contiguous. */ @FlaggedApi(FLAG_LARGE_AUDIO_FRAME) public @NonNull QueueRequest setMultiFrameEncryptedLinearBlock( @NonNull LinearBlock block, @NonNull ArrayDeque<MediaCodec.BufferInfo> bufferInfos, @NonNull ArrayDeque<MediaCodec.CryptoInfo> cryptoInfos) { if (!isAccessible()) { throw new IllegalStateException("The request is stale"); } if (mLinearBlock != null || mHardwareBuffer != null) { throw new IllegalStateException("Cannot set block twice"); } mLinearBlock = block; mBufferInfos.clear(); mBufferInfos.addAll(bufferInfos); mCryptoInfos.clear(); mCryptoInfos.addAll(cryptoInfos); return this; } Loading Loading @@ -3756,8 +3793,10 @@ final public class MediaCodec { mBufferInfos.add(info); } if (mLinearBlock != null) { mCodec.native_queueLinearBlock( mIndex, mLinearBlock, mCryptoInfo, mIndex, mLinearBlock, mCryptoInfos.isEmpty() ? null : mCryptoInfos.toArray(), mBufferInfos.toArray(), mTuningKeys, mTuningValues); } else if (mHardwareBuffer != null) { Loading @@ -3772,11 +3811,11 @@ final public class MediaCodec { mLinearBlock = null; mOffset = 0; mSize = 0; mCryptoInfo = null; mHardwareBuffer = null; mPresentationTimeUs = 0; mFlags = 0; mBufferInfos.clear(); mCryptoInfos.clear(); mTuningKeys.clear(); mTuningValues.clear(); return this; Loading @@ -3796,11 +3835,11 @@ final public class MediaCodec { private LinearBlock mLinearBlock = null; private int mOffset = 0; private int mSize = 0; private MediaCodec.CryptoInfo mCryptoInfo = null; private HardwareBuffer mHardwareBuffer = null; private long mPresentationTimeUs = 0; private @BufferFlag int mFlags = 0; private final ArrayDeque<BufferInfo> mBufferInfos = new ArrayDeque<>(); private final ArrayDeque<CryptoInfo> mCryptoInfos = new ArrayDeque<>(); private final ArrayList<String> mTuningKeys = new ArrayList<>(); private final ArrayList<Object> mTuningValues = new ArrayList<>(); Loading @@ -3810,7 +3849,7 @@ final public class MediaCodec { private native void native_queueLinearBlock( int index, @NonNull LinearBlock block, @Nullable CryptoInfo cryptoInfo, @Nullable Object[] cryptoInfos, @NonNull Object[] bufferInfos, @NonNull ArrayList<String> keys, @NonNull ArrayList<Object> values); Loading media/jni/android_media_MediaCodec.cpp +22 −16 Original line number Diff line number Diff line Loading @@ -488,19 +488,16 @@ status_t JMediaCodec::queueEncryptedLinearBlock( size_t index, const sp<hardware::HidlMemory> &buffer, size_t offset, const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, const uint8_t key[16], const uint8_t iv[16], CryptoPlugin::Mode mode, const CryptoPlugin::Pattern &pattern, size_t size, const sp<RefBase> &infos, const sp<RefBase> &cryptoInfos_, const sp<AMessage> &tunings, AString *errorDetailMsg) { sp<BufferInfosWrapper> auInfo((BufferInfosWrapper *)infos.get()); sp<CryptoInfosWrapper> cryptoInfos((CryptoInfosWrapper *)cryptoInfos_.get()); return mCodec->queueEncryptedBuffer( index, buffer, offset, subSamples, numSubSamples, key, iv, mode, pattern, auInfo, tunings, errorDetailMsg); index, buffer, offset, size, auInfo, cryptoInfos, tunings, errorDetailMsg); } status_t JMediaCodec::dequeueInputBuffer(size_t *index, int64_t timeoutUs) { Loading Loading @@ -2928,7 +2925,7 @@ static void extractBufferFromContext( static void android_media_MediaCodec_native_queueLinearBlock( JNIEnv *env, jobject thiz, jint index, jobject bufferObj, jobject cryptoInfoObj, jobjectArray objArray, jobject keys, jobject values) { jobjectArray cryptoInfoArray, jobjectArray objArray, jobject keys, jobject values) { ALOGV("android_media_MediaCodec_native_queueLinearBlock"); sp<JMediaCodec> codec = getMediaCodec(env, thiz); Loading Loading @@ -2998,8 +2995,19 @@ static void android_media_MediaCodec_native_queueLinearBlock( "MediaCodec.LinearBlock#obtain method to obtain a compatible buffer."); return; } auto cryptoInfo = cryptoInfoObj ? NativeCryptoInfo{env, cryptoInfoObj} : NativeCryptoInfo{totalSize}; sp<CryptoInfosWrapper> cryptoInfos = new CryptoInfosWrapper{decltype(cryptoInfos->value)()}; jint sampleSize = 0; if (cryptoInfoArray != nullptr) { extractCryptoInfosFromObjectArray(env, &sampleSize, &cryptoInfos->value, cryptoInfoArray, &errorDetailMsg); } else { sampleSize = totalSize; std::unique_ptr<CodecCryptoInfo> cryptoInfo{new MediaCodecCryptoInfo(totalSize)}; cryptoInfos->value.push_back(std::move(cryptoInfo)); } if (env->ExceptionCheck()) { // Creation of cryptoInfo failed. Let the exception bubble up. return; Loading @@ -3008,11 +3016,9 @@ static void android_media_MediaCodec_native_queueLinearBlock( index, memory, initialOffset, cryptoInfo.mSubSamples, cryptoInfo.mNumSubSamples, (const uint8_t *)cryptoInfo.mKey, (const uint8_t *)cryptoInfo.mIv, cryptoInfo.mMode, cryptoInfo.mPattern, sampleSize, infos, cryptoInfos, tunings, &errorDetailMsg); ALOGI_IF(err != OK, "queueEncryptedLinearBlock returned err = %d", err); Loading Loading @@ -4126,7 +4132,7 @@ static const JNINativeMethod gMethods[] = { { "native_closeMediaImage", "(J)V", (void *)android_media_MediaCodec_closeMediaImage }, { "native_queueLinearBlock", "(ILandroid/media/MediaCodec$LinearBlock;Landroid/media/MediaCodec$CryptoInfo;" "(ILandroid/media/MediaCodec$LinearBlock;[Ljava/lang/Object;" "[Ljava/lang/Object;Ljava/util/ArrayList;Ljava/util/ArrayList;)V", (void *)android_media_MediaCodec_native_queueLinearBlock }, Loading media/jni/android_media_MediaCodec.h +2 −6 Original line number Diff line number Diff line Loading @@ -131,13 +131,9 @@ struct JMediaCodec : public AHandler { size_t index, const sp<hardware::HidlMemory> &buffer, size_t offset, const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, const uint8_t key[16], const uint8_t iv[16], CryptoPlugin::Mode mode, const CryptoPlugin::Pattern &pattern, size_t size, const sp<RefBase> &infos, const sp<RefBase> &cryptoInfos, const sp<AMessage> &tunings, AString *errorDetailMsg); Loading Loading
core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -22749,6 +22749,7 @@ package android.media { method @NonNull public android.media.MediaCodec.QueueRequest setIntegerParameter(@NonNull String, int); method @NonNull public android.media.MediaCodec.QueueRequest setLinearBlock(@NonNull android.media.MediaCodec.LinearBlock, int, int); method @NonNull public android.media.MediaCodec.QueueRequest setLongParameter(@NonNull String, long); method @FlaggedApi("com.android.media.codec.flags.large_audio_frame") @NonNull public android.media.MediaCodec.QueueRequest setMultiFrameEncryptedLinearBlock(@NonNull android.media.MediaCodec.LinearBlock, @NonNull java.util.ArrayDeque<android.media.MediaCodec.BufferInfo>, @NonNull java.util.ArrayDeque<android.media.MediaCodec.CryptoInfo>); method @NonNull public android.media.MediaCodec.QueueRequest setPresentationTimeUs(long); method @NonNull public android.media.MediaCodec.QueueRequest setStringParameter(@NonNull String, @NonNull String); }
media/java/android/media/MediaCodec.java +45 −6 Original line number Diff line number Diff line Loading @@ -3512,7 +3512,7 @@ final public class MediaCodec { mLinearBlock = block; mOffset = offset; mSize = size; mCryptoInfo = null; mCryptoInfos.clear(); return this; } Loading Loading @@ -3546,7 +3546,44 @@ final public class MediaCodec { mLinearBlock = block; mOffset = offset; mSize = size; mCryptoInfo = cryptoInfo; mCryptoInfos.clear(); mCryptoInfos.add(cryptoInfo); return this; } /** * Set an encrypted linear block to this queue request. Exactly one buffer must be * set for a queue request before calling {@link #queue}. The block can contain multiple * access units and if present should be laid out contiguously and without gaps. * * @param block The linear block object * @param bufferInfos ArrayDeque of {@link MediaCodec.BufferInfo} that describes the * contents in the buffer. The ArrayDeque and the BufferInfo objects * provided can be recycled by the caller for re-use. * @param cryptoInfos ArrayDeque of {@link MediaCodec.CryptoInfo} that describes the * structure of the encrypted input samples. The ArrayDeque and the * BufferInfo objects provided can be recycled by the caller for re-use. * @return this object * @throws IllegalStateException if a buffer is already set * @throws IllegalArgumentException upon if bufferInfos is empty, contains null, or if the * access units are not contiguous. */ @FlaggedApi(FLAG_LARGE_AUDIO_FRAME) public @NonNull QueueRequest setMultiFrameEncryptedLinearBlock( @NonNull LinearBlock block, @NonNull ArrayDeque<MediaCodec.BufferInfo> bufferInfos, @NonNull ArrayDeque<MediaCodec.CryptoInfo> cryptoInfos) { if (!isAccessible()) { throw new IllegalStateException("The request is stale"); } if (mLinearBlock != null || mHardwareBuffer != null) { throw new IllegalStateException("Cannot set block twice"); } mLinearBlock = block; mBufferInfos.clear(); mBufferInfos.addAll(bufferInfos); mCryptoInfos.clear(); mCryptoInfos.addAll(cryptoInfos); return this; } Loading Loading @@ -3756,8 +3793,10 @@ final public class MediaCodec { mBufferInfos.add(info); } if (mLinearBlock != null) { mCodec.native_queueLinearBlock( mIndex, mLinearBlock, mCryptoInfo, mIndex, mLinearBlock, mCryptoInfos.isEmpty() ? null : mCryptoInfos.toArray(), mBufferInfos.toArray(), mTuningKeys, mTuningValues); } else if (mHardwareBuffer != null) { Loading @@ -3772,11 +3811,11 @@ final public class MediaCodec { mLinearBlock = null; mOffset = 0; mSize = 0; mCryptoInfo = null; mHardwareBuffer = null; mPresentationTimeUs = 0; mFlags = 0; mBufferInfos.clear(); mCryptoInfos.clear(); mTuningKeys.clear(); mTuningValues.clear(); return this; Loading @@ -3796,11 +3835,11 @@ final public class MediaCodec { private LinearBlock mLinearBlock = null; private int mOffset = 0; private int mSize = 0; private MediaCodec.CryptoInfo mCryptoInfo = null; private HardwareBuffer mHardwareBuffer = null; private long mPresentationTimeUs = 0; private @BufferFlag int mFlags = 0; private final ArrayDeque<BufferInfo> mBufferInfos = new ArrayDeque<>(); private final ArrayDeque<CryptoInfo> mCryptoInfos = new ArrayDeque<>(); private final ArrayList<String> mTuningKeys = new ArrayList<>(); private final ArrayList<Object> mTuningValues = new ArrayList<>(); Loading @@ -3810,7 +3849,7 @@ final public class MediaCodec { private native void native_queueLinearBlock( int index, @NonNull LinearBlock block, @Nullable CryptoInfo cryptoInfo, @Nullable Object[] cryptoInfos, @NonNull Object[] bufferInfos, @NonNull ArrayList<String> keys, @NonNull ArrayList<Object> values); Loading
media/jni/android_media_MediaCodec.cpp +22 −16 Original line number Diff line number Diff line Loading @@ -488,19 +488,16 @@ status_t JMediaCodec::queueEncryptedLinearBlock( size_t index, const sp<hardware::HidlMemory> &buffer, size_t offset, const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, const uint8_t key[16], const uint8_t iv[16], CryptoPlugin::Mode mode, const CryptoPlugin::Pattern &pattern, size_t size, const sp<RefBase> &infos, const sp<RefBase> &cryptoInfos_, const sp<AMessage> &tunings, AString *errorDetailMsg) { sp<BufferInfosWrapper> auInfo((BufferInfosWrapper *)infos.get()); sp<CryptoInfosWrapper> cryptoInfos((CryptoInfosWrapper *)cryptoInfos_.get()); return mCodec->queueEncryptedBuffer( index, buffer, offset, subSamples, numSubSamples, key, iv, mode, pattern, auInfo, tunings, errorDetailMsg); index, buffer, offset, size, auInfo, cryptoInfos, tunings, errorDetailMsg); } status_t JMediaCodec::dequeueInputBuffer(size_t *index, int64_t timeoutUs) { Loading Loading @@ -2928,7 +2925,7 @@ static void extractBufferFromContext( static void android_media_MediaCodec_native_queueLinearBlock( JNIEnv *env, jobject thiz, jint index, jobject bufferObj, jobject cryptoInfoObj, jobjectArray objArray, jobject keys, jobject values) { jobjectArray cryptoInfoArray, jobjectArray objArray, jobject keys, jobject values) { ALOGV("android_media_MediaCodec_native_queueLinearBlock"); sp<JMediaCodec> codec = getMediaCodec(env, thiz); Loading Loading @@ -2998,8 +2995,19 @@ static void android_media_MediaCodec_native_queueLinearBlock( "MediaCodec.LinearBlock#obtain method to obtain a compatible buffer."); return; } auto cryptoInfo = cryptoInfoObj ? NativeCryptoInfo{env, cryptoInfoObj} : NativeCryptoInfo{totalSize}; sp<CryptoInfosWrapper> cryptoInfos = new CryptoInfosWrapper{decltype(cryptoInfos->value)()}; jint sampleSize = 0; if (cryptoInfoArray != nullptr) { extractCryptoInfosFromObjectArray(env, &sampleSize, &cryptoInfos->value, cryptoInfoArray, &errorDetailMsg); } else { sampleSize = totalSize; std::unique_ptr<CodecCryptoInfo> cryptoInfo{new MediaCodecCryptoInfo(totalSize)}; cryptoInfos->value.push_back(std::move(cryptoInfo)); } if (env->ExceptionCheck()) { // Creation of cryptoInfo failed. Let the exception bubble up. return; Loading @@ -3008,11 +3016,9 @@ static void android_media_MediaCodec_native_queueLinearBlock( index, memory, initialOffset, cryptoInfo.mSubSamples, cryptoInfo.mNumSubSamples, (const uint8_t *)cryptoInfo.mKey, (const uint8_t *)cryptoInfo.mIv, cryptoInfo.mMode, cryptoInfo.mPattern, sampleSize, infos, cryptoInfos, tunings, &errorDetailMsg); ALOGI_IF(err != OK, "queueEncryptedLinearBlock returned err = %d", err); Loading Loading @@ -4126,7 +4132,7 @@ static const JNINativeMethod gMethods[] = { { "native_closeMediaImage", "(J)V", (void *)android_media_MediaCodec_closeMediaImage }, { "native_queueLinearBlock", "(ILandroid/media/MediaCodec$LinearBlock;Landroid/media/MediaCodec$CryptoInfo;" "(ILandroid/media/MediaCodec$LinearBlock;[Ljava/lang/Object;" "[Ljava/lang/Object;Ljava/util/ArrayList;Ljava/util/ArrayList;)V", (void *)android_media_MediaCodec_native_queueLinearBlock }, Loading
media/jni/android_media_MediaCodec.h +2 −6 Original line number Diff line number Diff line Loading @@ -131,13 +131,9 @@ struct JMediaCodec : public AHandler { size_t index, const sp<hardware::HidlMemory> &buffer, size_t offset, const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, const uint8_t key[16], const uint8_t iv[16], CryptoPlugin::Mode mode, const CryptoPlugin::Pattern &pattern, size_t size, const sp<RefBase> &infos, const sp<RefBase> &cryptoInfos, const sp<AMessage> &tunings, AString *errorDetailMsg); Loading