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

Side by Side 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: fixing commnets 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/media/encrypted_media_message_filter_android.h"
6
7 #include <string>
8
9 #include "chrome/common/encrypted_media_messages_android.h"
10 #include "ipc/ipc_message_macros.h"
11 #include "media/base/android/media_codec_bridge.h"
12 #include "media/base/android/media_drm_bridge.h"
13
14 using content::BrowserThread;
15 using media::MediaCodecBridge;
16 using media::MediaDrmBridge;
17
18 namespace chrome {
19
20 // Check whether the available codecs are supported.
21 static android::SupportedCodecs GetSupportedCodecs(
22 android::SupportedCodecs requested_codecs,
23 bool video_must_be_compositable) {
24 android::SupportedCodecs supported_codecs = android::NO_SUPPORTED_CODECS;
25 // TODO(qinmin): Remove this DCHECK and query VP8/Vorbis capabilities
26 // once webm support is added to Android.
27 DCHECK(!(requested_codecs & android::WEBM_VP8_AND_VORBIS));
28
29 #if defined(USE_PROPRIETARY_CODECS)
30 if ((requested_codecs & android::MP4_AAC) &&
31 MediaCodecBridge::CanDecode("mp4a", false)) {
32 supported_codecs = static_cast<android::SupportedCodecs>(
33 supported_codecs | android::MP4_AAC);
34 }
35
36 // TODO(qinmin): Remove the composition logic when secure contents can be
37 // composited.
38 if ((requested_codecs & android::MP4_AVC1) &&
39 MediaCodecBridge::CanDecode("avc1", !video_must_be_compositable)) {
40 supported_codecs = static_cast<android::SupportedCodecs>(
41 supported_codecs | android::MP4_AVC1);
42 }
43 #endif // defined(USE_PROPRIETARY_CODECS)
44
45 return supported_codecs;
46 }
47
48 EncryptedMediaMessageFilterAndroid::EncryptedMediaMessageFilterAndroid() {}
49
50 EncryptedMediaMessageFilterAndroid::~EncryptedMediaMessageFilterAndroid() {}
51
52 bool EncryptedMediaMessageFilterAndroid::OnMessageReceived(
53 const IPC::Message& message, bool* message_was_ok) {
54 bool handled = true;
55 IPC_BEGIN_MESSAGE_MAP_EX(
56 EncryptedMediaMessageFilterAndroid, message, *message_was_ok)
57 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_GetSupportedKeySystems,
58 OnGetSupportedKeySystems)
59 IPC_MESSAGE_UNHANDLED(handled = false)
60 IPC_END_MESSAGE_MAP_EX()
61 return handled;
62 }
63
64 void EncryptedMediaMessageFilterAndroid::OverrideThreadForMessage(
65 const IPC::Message& message, BrowserThread::ID* thread) {
66 // Move the IPC handling to FILE thread as it is not very cheap.
67 if (message.type() == ChromeViewHostMsg_GetSupportedKeySystems::ID)
68 *thread = BrowserThread::FILE;
69 }
70
71 void EncryptedMediaMessageFilterAndroid::OnGetSupportedKeySystems(
72 const android::SupportedKeySystemRequest& request,
73 android::SupportedKeySystemResponse* response) {
74 if (!MediaDrmBridge::IsAvailable() || !MediaCodecBridge::IsAvailable())
75 return;
76
77 // TODO(qinmin): Convert codecs to container types and check whether they
78 // are supported with the key system.
79 if (!MediaDrmBridge::IsCryptoSchemeSupported(request.uuid, ""))
80 return;
81
82 DCHECK_EQ(request.codecs >> 3, 0) << "unrecognized codec";
83 response->uuid = request.uuid;
84 // TODO(qinmin): check composition is supported or not.
85 response->compositing_codecs =
86 GetSupportedCodecs(request.codecs, true);
87 response->non_compositing_codecs =
88 GetSupportedCodecs(request.codecs, false);
89 }
90
91 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698