OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/cdm/browser/cdm_message_filter_android.h" | 5 #include "components/cdm/browser/cdm_message_filter_android.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "components/cdm/common/cdm_messages_android.h" | 13 #include "components/cdm/common/cdm_messages_android.h" |
14 #include "ipc/ipc_message_macros.h" | 14 #include "ipc/ipc_message_macros.h" |
15 #include "media/base/android/media_codec_util.h" | 15 #include "media/base/android/media_codec_util.h" |
16 #include "media/base/android/media_drm_bridge.h" | 16 #include "media/base/android/media_drm_bridge.h" |
17 #include "media/base/audio_codecs.h" | |
18 #include "media/base/video_codecs.h" | |
17 #include "media/media_features.h" | 19 #include "media/media_features.h" |
18 | 20 |
19 using content::BrowserThread; | 21 using content::BrowserThread; |
20 using media::MediaDrmBridge; | 22 using media::MediaDrmBridge; |
21 using media::SupportedCodecs; | 23 using media::SupportedCodecs; |
22 | 24 |
23 namespace cdm { | 25 namespace cdm { |
24 | 26 |
25 const size_t kMaxKeySystemLength = 256; | 27 const size_t kMaxKeySystemLength = 256; |
26 | 28 |
27 enum CodecType { | 29 enum CodecType { |
28 CODEC_AUDIO, | 30 CODEC_AUDIO, |
29 CODEC_VIDEO | 31 CODEC_VIDEO |
30 }; | 32 }; |
31 | 33 |
32 struct CodecInfo { | 34 struct CodecInfo { |
33 SupportedCodecs codec; | 35 SupportedCodecs codec; |
34 CodecType codec_type; | 36 CodecType codec_type; |
35 const char* codec_name; | 37 const std::string mime_type; |
36 const char* container_mime_type; | 38 const char* container_mime_type; |
37 }; | 39 }; |
38 | 40 |
39 const CodecInfo kCodecsToQuery[] = { | 41 const CodecInfo kCodecsToQuery[] = { |
40 {media::EME_CODEC_WEBM_OPUS, CODEC_AUDIO, "opus", "video/webm"}, | 42 {media::EME_CODEC_WEBM_OPUS, CODEC_AUDIO, |
watk
2017/02/14 01:40:50
By passing the mime type instead of names we can r
| |
41 {media::EME_CODEC_WEBM_VORBIS, CODEC_AUDIO, "vorbis", "video/webm"}, | 43 media::MediaCodecUtil::CodecToAndroidMimeType(media::kCodecOpus), |
42 {media::EME_CODEC_WEBM_VP8, CODEC_VIDEO, "vp8", "video/webm"}, | 44 "video/webm"}, |
43 {media::EME_CODEC_WEBM_VP9, CODEC_VIDEO, "vp9", "video/webm"}, | 45 {media::EME_CODEC_WEBM_VORBIS, CODEC_AUDIO, |
46 media::MediaCodecUtil::CodecToAndroidMimeType(media::kCodecVorbis), | |
47 "video/webm"}, | |
48 {media::EME_CODEC_WEBM_VP8, CODEC_VIDEO, | |
49 media::MediaCodecUtil::CodecToAndroidMimeType(media::kCodecVP8), | |
50 "video/webm"}, | |
51 {media::EME_CODEC_WEBM_VP9, CODEC_VIDEO, | |
52 media::MediaCodecUtil::CodecToAndroidMimeType(media::kCodecVP9), | |
53 "video/webm"}, | |
44 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 54 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
45 {media::EME_CODEC_MP4_AAC, CODEC_AUDIO, "mp4a", "video/mp4"}, | 55 {media::EME_CODEC_MP4_AAC, CODEC_AUDIO, |
46 {media::EME_CODEC_MP4_AVC1, CODEC_VIDEO, "avc1", "video/mp4"}, | 56 media::MediaCodecUtil::CodecToAndroidMimeType(media::kCodecAAC), |
57 "video/mp4"}, | |
58 {media::EME_CODEC_MP4_AVC1, CODEC_VIDEO, | |
59 media::MediaCodecUtil::CodecToAndroidMimeType(media::kCodecH264), | |
60 "video/mp4"}, | |
47 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 61 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
48 {media::EME_CODEC_MP4_HEVC, CODEC_VIDEO, "hvc1", "video/mp4"}, | 62 {media::EME_CODEC_MP4_HEVC, CODEC_VIDEO, |
63 media::MediaCodecUtil::CodecToAndroidMimeType(media::kCodecHevc), | |
64 "video/mp4"}, | |
49 #endif | 65 #endif |
50 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 66 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
51 }; | 67 }; |
52 | 68 |
53 static SupportedCodecs GetSupportedCodecs( | 69 static SupportedCodecs GetSupportedCodecs( |
54 const SupportedKeySystemRequest& request, | 70 const SupportedKeySystemRequest& request, |
55 bool video_must_be_compositable) { | 71 bool video_must_be_compositable) { |
56 const std::string& key_system = request.key_system; | 72 const std::string& key_system = request.key_system; |
57 SupportedCodecs supported_codecs = media::EME_CODEC_NONE; | 73 SupportedCodecs supported_codecs = media::EME_CODEC_NONE; |
58 | 74 |
59 for (size_t i = 0; i < arraysize(kCodecsToQuery); ++i) { | 75 for (size_t i = 0; i < arraysize(kCodecsToQuery); ++i) { |
60 const CodecInfo& info = kCodecsToQuery[i]; | 76 const CodecInfo& info = kCodecsToQuery[i]; |
61 // TODO(qinmin): Remove the composition logic when secure contents can be | 77 // TODO(qinmin): Remove the composition logic when secure contents can be |
62 // composited. | 78 // composited. |
63 bool is_secure = (info.codec_type == CODEC_VIDEO) | 79 bool is_secure = (info.codec_type == CODEC_VIDEO) |
64 ? (!video_must_be_compositable) : false; | 80 ? (!video_must_be_compositable) : false; |
65 if ((request.codecs & info.codec) && | 81 if ((request.codecs & info.codec) && |
66 MediaDrmBridge::IsKeySystemSupportedWithType( | 82 MediaDrmBridge::IsKeySystemSupportedWithType( |
67 key_system, info.container_mime_type) && | 83 key_system, info.container_mime_type) && |
68 media::MediaCodecUtil::CanDecode(info.codec_name, is_secure)) { | 84 media::MediaCodecUtil::CanDecode(info.mime_type, is_secure)) { |
69 supported_codecs |= info.codec; | 85 supported_codecs |= info.codec; |
70 } | 86 } |
71 } | 87 } |
72 | 88 |
73 return supported_codecs; | 89 return supported_codecs; |
74 } | 90 } |
75 | 91 |
76 CdmMessageFilterAndroid::CdmMessageFilterAndroid() | 92 CdmMessageFilterAndroid::CdmMessageFilterAndroid() |
77 : BrowserMessageFilter(EncryptedMediaMsgStart) {} | 93 : BrowserMessageFilter(EncryptedMediaMsgStart) {} |
78 | 94 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 response->is_persistent_license_supported = | 138 response->is_persistent_license_supported = |
123 MediaDrmBridge::IsPersistentLicenseTypeSupported(request.key_system); | 139 MediaDrmBridge::IsPersistentLicenseTypeSupported(request.key_system); |
124 } | 140 } |
125 | 141 |
126 void CdmMessageFilterAndroid::OnGetPlatformKeySystemNames( | 142 void CdmMessageFilterAndroid::OnGetPlatformKeySystemNames( |
127 std::vector<std::string>* key_systems) { | 143 std::vector<std::string>* key_systems) { |
128 *key_systems = MediaDrmBridge::GetPlatformKeySystemNames(); | 144 *key_systems = MediaDrmBridge::GetPlatformKeySystemNames(); |
129 } | 145 } |
130 | 146 |
131 } // namespace cdm | 147 } // namespace cdm |
OLD | NEW |