Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97825a4f authored by Robert Shih's avatar Robert Shih
Browse files

MediaCodec.CryptoInfo: expose subsample encryption pattern

Bug: 31215085
Test: com.google.android.media.gts.WidevineMp4TempTests
Change-Id: I6965adc646684053633530e39258b171724b34bc
parent c3a7ab32
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2530,6 +2530,10 @@ final public class MediaCodec {
            pattern = newPattern;
        }

        private void setPattern(int blocksToEncrypt, int blocksToSkip) {
            pattern = new Pattern(blocksToEncrypt, blocksToSkip);
        }

        @Override
        public String toString() {
            StringBuilder builder = new StringBuilder();
+14 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ struct fields_t {
    jfieldID context;

    jmethodID cryptoInfoSetID;
    jmethodID cryptoInfoSetPatternID;
};

static fields_t gFields;
@@ -654,6 +655,16 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo(
            ivObj,
            mode);

    int32_t encryptedByteBlock = 0, skipByteBlock = 0;
    meta->findInt32(kKeyEncryptedByteBlock, &encryptedByteBlock);
    meta->findInt32(kKeySkipByteBlock, &skipByteBlock);

    env->CallVoidMethod(
            cryptoInfoObj,
            gFields.cryptoInfoSetPatternID,
            encryptedByteBlock,
            skipByteBlock);

    return JNI_TRUE;
}

@@ -669,6 +680,9 @@ static void android_media_MediaExtractor_native_init(JNIEnv *env) {

    gFields.cryptoInfoSetID =
        env->GetMethodID(clazz, "set", "(I[I[I[B[BI)V");

    gFields.cryptoInfoSetPatternID =
        env->GetMethodID(clazz, "setPattern", "(II)V");
}

static void android_media_MediaExtractor_native_setup(