Merge "MediaCodec: LinearBlock API for optional crypto" into rvc-dev am: 968b1066e5 am: af875a130b

Change-Id: I38ec88da49956ac5c2bc50de069a26246446a460
This commit is contained in:
TreeHugger Robot
2020-03-25 01:23:23 +00:00
committed by Automerger Merge Worker
2 changed files with 37 additions and 4 deletions

View File

@@ -25341,11 +25341,12 @@ package android.media {
public final class MediaCodec.QueueRequest {
method public void queue();
method @NonNull public android.media.MediaCodec.QueueRequest setByteBufferParameter(@NonNull String, @NonNull java.nio.ByteBuffer);
method @NonNull public android.media.MediaCodec.QueueRequest setEncryptedLinearBlock(@NonNull android.media.MediaCodec.LinearBlock, int, int, @NonNull android.media.MediaCodec.CryptoInfo);
method @NonNull public android.media.MediaCodec.QueueRequest setFlags(int);
method @NonNull public android.media.MediaCodec.QueueRequest setFloatParameter(@NonNull String, float);
method @NonNull public android.media.MediaCodec.QueueRequest setHardwareBuffer(@NonNull android.hardware.HardwareBuffer);
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, @Nullable android.media.MediaCodec.CryptoInfo);
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 @NonNull public android.media.MediaCodec.QueueRequest setPresentationTimeUs(long);
method @NonNull public android.media.MediaCodec.QueueRequest setStringParameter(@NonNull String, @NonNull String);

View File

@@ -46,6 +46,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
@@ -3048,16 +3049,47 @@ final public class MediaCodec {
* @param block The linear block object
* @param offset The byte offset into the input buffer at which the data starts.
* @param size The number of bytes of valid input data.
* @param cryptoInfo Metadata describing the structure of the encrypted input sample.
* may be null for non-encrypted content.
* @return this object
* @throws IllegalStateException if a buffer is already set
*/
public @NonNull QueueRequest setLinearBlock(
@NonNull LinearBlock block,
int offset,
int size) {
if (!isAccessible()) {
throw new IllegalStateException("The request is stale");
}
if (mLinearBlock != null || mHardwareBuffer != null) {
throw new IllegalStateException("Cannot set block twice");
}
mLinearBlock = block;
mOffset = offset;
mSize = size;
mCryptoInfo = null;
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}. It is possible
* to use the same {@link LinearBlock} object for multiple queue
* requests. The behavior is undefined if the range of the buffer
* overlaps for multiple requests, or the application writes into the
* region being processed by the codec.
*
* @param block The linear block object
* @param offset The byte offset into the input buffer at which the data starts.
* @param size The number of bytes of valid input data.
* @param cryptoInfo Metadata describing the structure of the encrypted input sample.
* @return this object
* @throws IllegalStateException if a buffer is already set
*/
public @NonNull QueueRequest setEncryptedLinearBlock(
@NonNull LinearBlock block,
int offset,
int size,
@Nullable MediaCodec.CryptoInfo cryptoInfo) {
@NonNull MediaCodec.CryptoInfo cryptoInfo) {
Objects.requireNonNull(cryptoInfo);
if (!isAccessible()) {
throw new IllegalStateException("The request is stale");
}