Chromium Code Reviews| 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 |