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..58bca823f561594a0b181ea09021264172710c90 |
--- /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/media/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] = |
+ { 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)); |
+ 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( |
+ std::vector<SupportedKeySystem>* result) { |
+ if (!MediaDrmBridge::IsAvailable() || !MediaCodecBridge::IsAvailable()) |
+ return; |
+ |
+ std::vector<uint8> widevine_uuid(kWidevineUuid, kWidevineUuid + 16); |
+ 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); |
+ if (codecs_info[i].secure_decoder_supported) |
+ video_composition_disabled_system.codecs.push_back(codecs_info[i].codecs); |
+ } |
+ |
+ if (video_composition_enabled_system.codecs.size() > 0) { |
+ video_composition_enabled_system.uuid = widevine_uuid; |
+ video_composition_enabled_system.key_system = "com.widevine.alpha"; |
+ 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 |