Chromium Code Reviews| Index: media/base/android/java/src/org/chromium/media/MediaCodecBridge.java |
| diff --git a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java |
| index ecc90018c2082a81a8690e084c629be3028ee3b7..6e1ff9079995ae7a481d5895912f2e005d8b3708 100644 |
| --- a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java |
| +++ b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java |
| @@ -7,6 +7,7 @@ package org.chromium.media; |
| import android.annotation.TargetApi; |
| import android.media.AudioFormat; |
| import android.media.MediaCodec; |
| +import android.media.MediaCodec.CryptoInfo; |
| import android.media.MediaCrypto; |
| import android.media.MediaFormat; |
| import android.os.Build; |
| @@ -384,14 +385,28 @@ class MediaCodecBridge { |
| } |
| @CalledByNative |
| - private int queueSecureInputBuffer( |
| - int index, int offset, byte[] iv, byte[] keyId, int[] numBytesOfClearData, |
| - int[] numBytesOfEncryptedData, int numSubSamples, long presentationTimeUs) { |
| + private int queueSecureInputBuffer(int index, int offset, byte[] iv, byte[] keyId, |
| + int[] numBytesOfClearData, int[] numBytesOfEncryptedData, int numSubSamples, |
| + int cipherMode, int patternEncrypt, int patternSkip, long presentationTimeUs) { |
|
xhwang
2016/10/20 23:52:07
How can you make sure the Java cipherMode enums ar
dougsteed
2016/10/21 17:15:05
Hard to "make sure" but I will draw more attention
|
| resetLastPresentationTimeIfNeeded(presentationTimeUs); |
| try { |
| - MediaCodec.CryptoInfo cryptoInfo = new MediaCodec.CryptoInfo(); |
| - cryptoInfo.set(numSubSamples, numBytesOfClearData, numBytesOfEncryptedData, |
| - keyId, iv, MediaCodec.CRYPTO_MODE_AES_CTR); |
| + boolean usesCbcs = cipherMode == MediaCodec.CRYPTO_MODE_AES_CBC; |
| + if (usesCbcs && !MediaCodecUtil.platformSupportsCbcsEncryption()) { |
| + Log.e(TAG, "Encryption scheme 'cbcs' not supported on this platform."); |
| + return MEDIA_CODEC_ERROR; |
| + } |
| + CryptoInfo cryptoInfo = new CryptoInfo(); |
| + cryptoInfo.set(numSubSamples, numBytesOfClearData, numBytesOfEncryptedData, keyId, iv, |
| + cipherMode); |
| + if (patternEncrypt != 0 && patternSkip != 0) { |
| + if (usesCbcs) { |
| + // Above platform check ensured that setting the pattern is indeed supported. |
| + MediaCodecUtil.setPatternIfSupported(cryptoInfo, patternEncrypt, patternSkip); |
| + } else { |
| + Log.e(TAG, "Pattern encryption only supported for 'cbcs' scheme (CBC mode)."); |
| + return MEDIA_CODEC_ERROR; |
| + } |
| + } |
| mMediaCodec.queueSecureInputBuffer(index, offset, cryptoInfo, presentationTimeUs, 0); |
| } catch (MediaCodec.CryptoException e) { |
| if (e.getErrorCode() == MediaCodec.CryptoException.ERROR_NO_KEY) { |