Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: media/base/android/java/src/org/chromium/media/MediaCodecUtil.java

Issue 2058113002: Add 'cbcs' encryption scheme support in Android media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase redux Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
diff --git a/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java b/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
index 93da01007a8e9ec701e86e17021fc0f1c0a0d4c0..f892ceac9a4192b2279b9123e1c0a2f9aace6712 100644
--- a/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
+++ b/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
@@ -6,6 +6,7 @@ package org.chromium.media;
import android.annotation.TargetApi;
import android.media.MediaCodec;
+import android.media.MediaCodec.CryptoInfo;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.os.Build;
@@ -517,4 +518,27 @@ class MediaCodecUtil {
Log.w(TAG, "HW encoder for " + mime + " is not available on this device.");
return null;
}
+
+ /**
+ * Returns true if and only if the platform we are running on supports the 'cbcs'
+ * encryption scheme, specifically AES CBC encryption with possibility of pattern
+ * encryption.
+ * While 'cbcs' scheme was originally implemented in N, there was a bug (in the
+ * DRM code) which means that it didn't really work properly until post-N).
+ */
+ static boolean platformSupportsCbcsEncryption() {
+ return Build.VERSION.SDK_INT > Build.VERSION_CODES.N;
+ }
+
+ /**
+ * Sets the encryption pattern value if and only if CryptoInfo.setPattern method is
+ * supported.
+ * This method was introduced in Android N. Note that if platformSupportsCbcsEncryption
+ * returns true, then this function will set the pattern.
+ */
+ static void setPatternIfSupported(CryptoInfo cryptoInfo, int encrypt, int skip) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ cryptoInfo.setPattern(new CryptoInfo.Pattern(encrypt, skip));
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698