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

Unified Diff: media/base/android/media_drm_bridge.cc

Issue 185993004: Encrypted Media: Confine UUID code to MediaDrmBridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 9 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
« no previous file with comments | « media/base/android/media_drm_bridge.h ('k') | media/base/android/media_source_player.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/media_drm_bridge.cc
diff --git a/media/base/android/media_drm_bridge.cc b/media/base/android/media_drm_bridge.cc
index 1d9854d0c2c254303927a7e5c60e5fe481e8f98a..7e47c5d0f5f517ce4a0c0fc6a265d32f5429cbbf 100644
--- a/media/base/android/media_drm_bridge.cc
+++ b/media/base/android/media_drm_bridge.cc
@@ -15,6 +15,8 @@
#include "jni/MediaDrmBridge_jni.h"
#include "media/base/android/media_player_manager.h"
+#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
+
using base::android::AttachCurrentThread;
using base::android::ConvertUTF8ToJavaString;
using base::android::ConvertJavaStringToUTF8;
@@ -50,13 +52,26 @@ static uint64 ReadUint64(const uint8_t* data) {
// uint32 DataSize
// uint8[DataSize] Data
// }
-static const int kBoxHeaderSize = 8; // Box's header contains Size and Type.
-static const int kBoxLargeSizeSize = 8;
-static const int kPsshVersionFlagSize = 4;
-static const int kPsshSystemIdSize = 16;
-static const int kPsshDataSizeSize = 4;
-static const uint32 kTencType = 0x74656e63;
-static const uint32 kPsshType = 0x70737368;
+const int kBoxHeaderSize = 8; // Box's header contains Size and Type.
+const int kBoxLargeSizeSize = 8;
+const int kPsshVersionFlagSize = 4;
+const int kPsshSystemIdSize = 16;
+const int kPsshDataSizeSize = 4;
+const uint32 kTencType = 0x74656e63;
+const uint32 kPsshType = 0x70737368;
+const uint8 kWidevineUuid[16] = {
+ 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
+ 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
+
+static std::vector<uint8> GetUUID(const std::string& key_system) {
+ // For security reasons, we only do exact string comparisons here - we don't
+ // try to parse the |key_system| in any way.
+ if (key_system == kWidevineKeySystem) {
+ return std::vector<uint8>(kWidevineUuid,
+ kWidevineUuid + arraysize(kWidevineUuid));
+ }
+ return std::vector<uint8>();
+}
// Tries to find a PSSH box whose "SystemId" is |uuid| in |data|, parses the
// "Data" of the box and put it in |pssh_data|. Returns true if such a box is
@@ -175,22 +190,25 @@ bool MediaDrmBridge::IsSecureDecoderRequired(SecurityLevel security_level) {
return SECURITY_LEVEL_1 == security_level;
}
-bool MediaDrmBridge::IsSecurityLevelSupported(
- const std::vector<uint8>& scheme_uuid,
- SecurityLevel security_level) {
+bool MediaDrmBridge::IsSecurityLevelSupported(const std::string& key_system,
+ SecurityLevel security_level) {
// Pass 0 as |cdm_id| and NULL as |manager| as they are not used in
// creation time of MediaDrmBridge.
scoped_ptr<MediaDrmBridge> media_drm_bridge =
- MediaDrmBridge::Create(0, scheme_uuid, GURL(), NULL);
+ MediaDrmBridge::Create(0, key_system, GURL(), NULL);
if (!media_drm_bridge)
return false;
return media_drm_bridge->SetSecurityLevel(security_level);
}
-bool MediaDrmBridge::IsCryptoSchemeSupported(
- const std::vector<uint8>& scheme_uuid,
+bool MediaDrmBridge::IsKeySystemSupportedWithType(
+ const std::string& key_system,
const std::string& container_mime_type) {
+ std::vector<uint8> scheme_uuid = GetUUID(key_system);
+ if (scheme_uuid.empty())
+ return false;
+
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jbyteArray> j_scheme_uuid =
base::android::ToJavaByteArray(env, &scheme_uuid[0], scheme_uuid.size());
@@ -228,20 +246,22 @@ MediaDrmBridge::~MediaDrmBridge() {
}
// static
-scoped_ptr<MediaDrmBridge> MediaDrmBridge::Create(
- int cdm_id,
- const std::vector<uint8>& scheme_uuid,
- const GURL& frame_url,
- MediaPlayerManager* manager) {
+scoped_ptr<MediaDrmBridge> MediaDrmBridge::Create(int cdm_id,
+ const std::string& key_system,
+ const GURL& frame_url,
+ MediaPlayerManager* manager) {
scoped_ptr<MediaDrmBridge> media_drm_bridge;
+ if (!IsAvailable())
+ return media_drm_bridge.Pass();
- if (IsAvailable() && !scheme_uuid.empty()) {
- // TODO(qinmin): check whether the uuid is valid.
- media_drm_bridge.reset(
- new MediaDrmBridge(cdm_id, scheme_uuid, frame_url, manager));
- if (media_drm_bridge->j_media_drm_.is_null())
- media_drm_bridge.reset();
- }
+ std::vector<uint8> scheme_uuid = GetUUID(key_system);
+ if (scheme_uuid.empty())
+ return media_drm_bridge.Pass();
+
+ media_drm_bridge.reset(
+ new MediaDrmBridge(cdm_id, scheme_uuid, frame_url, manager));
+ if (media_drm_bridge->j_media_drm_.is_null())
+ media_drm_bridge.reset();
return media_drm_bridge.Pass();
}
« no previous file with comments | « media/base/android/media_drm_bridge.h ('k') | media/base/android/media_source_player.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698