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

Unified Diff: chrome/browser/media/encrypted_media_message_filter_android.cc

Issue 23513055: Populate canPlayType to renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing ddorwin's comments Created 7 years, 3 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: 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..62aef2f5e3485e705801c2bd6956616eda2b42f8
--- /dev/null
+++ b/chrome/browser/media/encrypted_media_message_filter_android.cc
@@ -0,0 +1,83 @@
+// 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 "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 android::SupportedCodecs GetSupportedCodecs(
+ android::SupportedCodecs requested_codecs,
+ bool video_must_be_compositable) {
+ android::SupportedCodecs supported_codecs = android::NO_SUPPORTED_CODECS;
+ DCHECK(!(requested_codecs & android::WEBM_VP8_AND_VORBIS));
ddorwin 2013/09/18 03:58:31 This is probably worth commenting/reference other
qinmin 2013/09/18 05:08:21 Done.
+
+#if defined(USE_PROPRIETARY_CODECS)
+ if ((requested_codecs & android::MP4_AAC) &&
+ MediaCodecBridge::CanDecode("mp4a", false)) {
+ supported_codecs =
+ static_cast<android::SupportedCodecs>(
+ supported_codecs | android::MP4_AAC);
ddorwin 2013/09/18 03:58:31 This doesn't fit on 2 lines?
qinmin 2013/09/18 05:08:21 Done.
+ }
+
+ // TODO(qinmin): Remove the composition logic when secure contents can be
+ // composited.
+ if ((requested_codecs & android::MP4_AVC1) &&
+ MediaCodecBridge::CanDecode("avc1", !video_must_be_compositable)) {
+ supported_codecs =
+ static_cast<android::SupportedCodecs>(
+ supported_codecs | android::MP4_AVC1);
+ }
+#endif // defined(USE_PROPRIETARY_CODECS)
+
+ return supported_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 android::SupportedKeySystemRequest& request,
+ android::SupportedKeySystemResponse* response) {
+ if (!MediaDrmBridge::IsAvailable() || !MediaCodecBridge::IsAvailable())
+ return;
+
+ // TODO(qinmin): Convert codecs to container types and check whether they
+ // are supported with the key system.
+ if (!MediaDrmBridge::IsCryptoSchemeSupported(request.uuid, ""))
+ return;
+
+ response->uuid = request.uuid;
+ // TODO(qinmin): check composition is supported or not.
+ response->compositing_codecs =
+ GetSupportedCodecs(request.requested_codecs, true);
+ response->non_compositing_codecs =
+ GetSupportedCodecs(request.requested_codecs, false);
+}
+
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698