Index: chrome/browser/media/encrypted_media_message_filter_android.cc |
diff --git a/chrome/browser/media/encrypted_media_message_filter_android.cc b/chrome/browser/media/encrypted_media_message_filter_android.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..89ec0b39ebf456bb639deaace4b57a38f33d7f37 |
--- /dev/null |
+++ b/chrome/browser/media/encrypted_media_message_filter_android.cc |
@@ -0,0 +1,82 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/media/encrypted_media_message_filter_android.h" |
+ |
+#include <string> |
+ |
+#include "chrome/common/encrypted_media_messages_android.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "ipc/ipc_message_macros.h" |
+#include "media/base/android/media_codec_bridge.h" |
+#include "media/base/android/media_drm_bridge.h" |
+ |
+using content::BrowserThread; |
+using media::MediaCodecBridge; |
+using media::MediaDrmBridge; |
+ |
+namespace chrome { |
+ |
+// UUID for widevine. |
+static const uint8 kWidevineUuid[16] = |
ddorwin
2013/09/16 17:58:10
Should this be in widevine_cdm_constants.h? It app
qinmin
2013/09/17 19:21:06
passing UUID from IPC instead
On 2013/09/16 17:58:
|
+ { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, |
+ 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; |
+ |
+EncryptedMediaMessageFilterAndroid::EncryptedMediaMessageFilterAndroid() {} |
+ |
+EncryptedMediaMessageFilterAndroid::~EncryptedMediaMessageFilterAndroid() {} |
+ |
+bool EncryptedMediaMessageFilterAndroid::OnMessageReceived( |
+ const IPC::Message& message, bool* message_was_ok) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
jam
2013/09/17 20:26:02
nit: this check isn't necessary, you're checking h
qinmin
2013/09/17 21:26:23
Done.
|
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP_EX( |
+ EncryptedMediaMessageFilterAndroid, message, *message_was_ok) |
+ IPC_MESSAGE_HANDLER(ChromeViewHostMsg_GetSupportedKeySystems, |
+ OnGetSupportedKeySystems) |
+ IPC_MESSAGE_UNHANDLED(handled = false) |
+ IPC_END_MESSAGE_MAP_EX() |
+ return handled; |
+} |
+ |
+void EncryptedMediaMessageFilterAndroid::OnGetSupportedKeySystems( |
ddorwin
2013/09/16 17:58:10
We should think about the best way to poll for the
qinmin
2013/09/17 19:21:06
Ok. passing the UUID and SupportedCodecs in the IP
|
+ std::vector<SupportedKeySystem>* result) { |
+ if (!MediaDrmBridge::IsAvailable() || !MediaCodecBridge::IsAvailable()) |
+ return; |
+ |
+ std::vector<uint8> widevine_uuid(kWidevineUuid, kWidevineUuid + 16); |
ddorwin
2013/09/16 17:58:10
Why does this code need to know about Widevine? Sh
qinmin
2013/09/17 21:26:23
Passing UUIDs in IPC instead, so no more widevine
|
+ if (!MediaDrmBridge::IsCryptoSchemeSupported(widevine_uuid)) |
+ return; |
+ |
+ // Treat secure decoders with a separate key system due to video composition. |
+ SupportedKeySystem video_composition_enabled_system; |
+ SupportedKeySystem video_composition_disabled_system; |
+ std::vector<MediaCodecBridge::CodecsInfo> codecs_info; |
+ MediaCodecBridge::GetCodecsInfo(&codecs_info); |
+ for (unsigned i = 0; i < codecs_info.size(); ++i) { |
+ video_composition_enabled_system.codecs.push_back(codecs_info[i].codecs); |
ddorwin
2013/09/16 17:58:10
We can't just all all codecs because the platform
qinmin
2013/09/17 21:26:23
The renderer will send a list of available codecs
|
+ if (codecs_info[i].secure_decoder_supported) |
+ video_composition_disabled_system.codecs.push_back(codecs_info[i].codecs); |
ddorwin
2013/09/16 17:58:10
TODO/bug to check whether composition is actually
qinmin
2013/09/17 21:26:23
Done.
|
+ } |
+ |
+ if (video_composition_enabled_system.codecs.size() > 0) { |
+ video_composition_enabled_system.uuid = widevine_uuid; |
+ video_composition_enabled_system.key_system = "com.widevine.alpha"; |
ddorwin
2013/09/16 17:58:10
These two strings should not be known at this leve
qinmin
2013/09/17 19:21:06
Done.
|
+ video_composition_enabled_system.parent_key_system = "com.widevine"; |
+ video_composition_enabled_system.video_composition_enabled = true; |
+ result->push_back(video_composition_enabled_system); |
+ } |
+ |
+ if (video_composition_disabled_system.codecs.size() > 0) { |
+ // TODO(qinmin): we may use a different key_system for non-compositable |
+ // video. |
+ video_composition_disabled_system.uuid = widevine_uuid; |
+ video_composition_disabled_system.key_system = "com.widevine.alpha"; |
+ video_composition_enabled_system.parent_key_system = "com.widevine"; |
+ video_composition_disabled_system.video_composition_enabled = false; |
+ result->push_back(video_composition_disabled_system); |
+ } |
+} |
+ |
+} // namespace chrome |