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..40ec0bc2af327ec100b34171ba0bb8fedb4fdf25 |
--- /dev/null |
+++ b/chrome/browser/media/encrypted_media_message_filter_android.cc |
@@ -0,0 +1,79 @@ |
+// 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 "chrome/common/widevine_cdm_constants.h" |
ddorwin
2013/09/17 22:29:08
We shouldn't include a widevine file here.
This C
qinmin
2013/09/18 00:45:44
ok, removed the include. Duplicated the enum and a
|
+#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 { |
+ |
+// Check whether the available codecs are supported. |
+static SupportedCodecs GetSupportedCodecs( |
+ SupportedCodecs supported_codecs, bool video_composition_allowed) { |
ddorwin
2013/09/17 22:29:08
I think the naming is backwards. The parameter sho
ddorwin
2013/09/17 22:29:08
is_video_composition_allowed
^^^
This doesn't see
qinmin
2013/09/18 00:45:44
Done.
qinmin
2013/09/18 00:45:44
Done.
|
+ SupportedCodecs codecs = NO_SUPPORTED_CODECS; |
+ if ((supported_codecs & WEBM_VP8_AND_VORBIS) && |
ddorwin
2013/09/17 22:29:08
Until Android supports encrypted WebM and we can c
qinmin
2013/09/18 00:45:44
Done.
|
+ MediaCodecBridge::CanDecode("vorbis", !video_composition_allowed) && |
ddorwin
2013/09/17 22:29:08
video_composition_allowed doesn't really apply to
qinmin
2013/09/18 00:45:44
the composition flag don't affect audio. Anyway, c
|
+ MediaCodecBridge::CanDecode("vp8", !video_composition_allowed)) { |
+ codecs = static_cast<SupportedCodecs>(codecs | WEBM_VP8_AND_VORBIS); |
+ } |
+ |
+#if defined(USE_PROPRIETARY_CODECS) |
+ if ((supported_codecs & MP4_AAC) && |
+ MediaCodecBridge::CanDecode("mp4a", !video_composition_allowed)) { |
ddorwin
2013/09/17 22:29:08
Same.
qinmin
2013/09/18 00:45:44
Done.
|
+ codecs = static_cast<SupportedCodecs>(codecs | MP4_AAC); |
+ } |
+ |
+ if ((supported_codecs & MP4_AVC1) && |
+ MediaCodecBridge::CanDecode("avc1", !video_composition_allowed)) { |
+ codecs = static_cast<SupportedCodecs>(codecs | MP4_AVC1); |
+ } |
+#endif // defined(USE_PROPRIETARY_CODECS) |
+ |
+ return codecs; |
+} |
+ |
+EncryptedMediaMessageFilterAndroid::EncryptedMediaMessageFilterAndroid() {} |
+ |
+EncryptedMediaMessageFilterAndroid::~EncryptedMediaMessageFilterAndroid() {} |
+ |
+bool EncryptedMediaMessageFilterAndroid::OnMessageReceived( |
+ const IPC::Message& message, bool* message_was_ok) { |
+ 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( |
+ const SupportedKeySystemRequest& request, |
+ SupportedKeySystemResponse* response) { |
+ if (!MediaDrmBridge::IsAvailable() || !MediaCodecBridge::IsAvailable()) |
+ return; |
+ |
+ if (!MediaDrmBridge::IsCryptoSchemeSupported(request.uuid, "")) |
ddorwin
2013/09/17 22:29:08
TODO: Check container types based on codecs in req
qinmin
2013/09/18 00:45:44
Done.
|
+ return; |
+ |
+ response->uuid = request.uuid; |
+ // TODO(qinmin): check composition is supported or not. |
+ response->compositing_codecs = |
+ GetSupportedCodecs(request.supported_codecs, true); |
+ response->non_compositing_codecs = |
+ GetSupportedCodecs(request.supported_codecs, false); |
+} |
+ |
+} // namespace chrome |