Support AES-CBC sample encryption in MediaDrm
bug:23719082 Change-Id: I1842bab291d6c86a87e46abbb98827c87f7f1d53
This commit is contained in:
@@ -24,6 +24,7 @@ import android.media.MediaCryptoException;
|
||||
import android.media.MediaCodec.CryptoException;
|
||||
import android.media.MediaCodecList;
|
||||
import android.media.MediaCodec.CryptoInfo;
|
||||
import android.media.MediaCodec.CryptoInfo.Pattern;
|
||||
import android.media.MediaCodecInfo;
|
||||
import android.media.MediaFormat;
|
||||
import android.media.NotProvisionedException;
|
||||
@@ -141,6 +142,7 @@ public class MediaDrmAPITest extends Activity {
|
||||
|
||||
testClearContentNoKeys();
|
||||
testEncryptedContent();
|
||||
testEncryptedAESSampleContent();
|
||||
testEncryptedContentSharingKeys();
|
||||
testEncryptedContentNoKeys();
|
||||
|
||||
@@ -332,6 +334,17 @@ public class MediaDrmAPITest extends Activity {
|
||||
stopDrm(drm);
|
||||
}
|
||||
|
||||
private void testEncryptedAESSampleContent() {
|
||||
Log.d(TAG, "testEncryptedAESSampleContent");
|
||||
MediaDrm drm = startDrm();
|
||||
byte[] sessionId = openSession(drm);
|
||||
if (getKeys(drm, sessionId)) {
|
||||
testAESSampleDecrypt(sessionId, kRequireKey);
|
||||
}
|
||||
drm.closeSession(sessionId);
|
||||
stopDrm(drm);
|
||||
}
|
||||
|
||||
private void testEncryptedContentSharingKeys() {
|
||||
MediaDrm drm = startDrm();
|
||||
drm.setPropertyString("sessionSharing", "enable");
|
||||
@@ -585,6 +598,18 @@ public class MediaDrmAPITest extends Activity {
|
||||
// do minimal codec setup to pass an encrypted buffer down the stack to see if it gets
|
||||
// decrypted correctly.
|
||||
public void testDecrypt(byte[] sessionId, boolean expectNoKey) {
|
||||
Pattern pattern = new Pattern(0, 0);
|
||||
testDecryptCommon(sessionId, expectNoKey, MediaCodec.CRYPTO_MODE_AES_CTR, pattern);
|
||||
}
|
||||
|
||||
// test AES CBC sample encryption mode
|
||||
public void testAESSampleDecrypt(byte[] sessionId, boolean expectNoKey) {
|
||||
Pattern pattern = new Pattern(1, 9);
|
||||
testDecryptCommon(sessionId, expectNoKey, MediaCodec.CRYPTO_MODE_AES_CBC, pattern);
|
||||
}
|
||||
|
||||
public void testDecryptCommon(byte[] sessionId, boolean expectNoKey,
|
||||
int mode, Pattern pattern) {
|
||||
Log.i(TAG, "testDecrypt");
|
||||
|
||||
MediaCrypto crypto = null;
|
||||
@@ -653,8 +678,8 @@ public class MediaDrmAPITest extends Activity {
|
||||
if (numSubSamples > 0) {
|
||||
// send the sample we have
|
||||
CryptoInfo info = new CryptoInfo();
|
||||
info.set(numSubSamples, clearSizes, encryptedSizes, keyID, iv,
|
||||
MediaCodec.CRYPTO_MODE_AES_CTR);
|
||||
info.set(numSubSamples, clearSizes, encryptedSizes, keyID, iv, mode);
|
||||
info.setPattern(pattern);
|
||||
|
||||
try {
|
||||
// Log.i(TAG,"Sending " + sampleSize + " bytes, numSubSamples=" + numSubSamples);
|
||||
|
||||
Reference in New Issue
Block a user