OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "media/base/key_systems.h" | 5 #include "media/base/key_systems.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "media/base/key_system_names.h" | 19 #include "media/base/key_system_names.h" |
20 #include "media/base/key_system_properties.h" | 20 #include "media/base/key_system_properties.h" |
21 #include "media/base/media.h" | 21 #include "media/base/media.h" |
22 #include "media/base/media_switches.h" | 22 #include "media/base/media_switches.h" |
23 #include "ppapi/features/features.h" | 23 #include "ppapi/features/features.h" |
24 #include "media/base/media_client.h" | 24 #include "media/base/media_client.h" |
25 #include "media/media_features.h" | |
26 #include "third_party/widevine/cdm/widevine_cdm_common.h" | 25 #include "third_party/widevine/cdm/widevine_cdm_common.h" |
27 | 26 |
28 namespace media { | 27 namespace media { |
29 | 28 |
30 const char kClearKeyKeySystem[] = "org.w3.clearkey"; | 29 const char kClearKeyKeySystem[] = "org.w3.clearkey"; |
31 | 30 |
32 // These names are used by UMA. Do not change them! | 31 // These names are used by UMA. Do not change them! |
33 const char kClearKeyKeySystemNameForUMA[] = "ClearKey"; | 32 const char kClearKeyKeySystemNameForUMA[] = "ClearKey"; |
34 const char kUnknownKeySystemNameForUMA[] = "Unknown"; | 33 const char kUnknownKeySystemNameForUMA[] = "Unknown"; |
35 | 34 |
36 struct NamedCodec { | 35 struct NamedCodec { |
37 const char* name; | 36 const char* name; |
38 EmeCodec type; | 37 EmeCodec type; |
39 }; | 38 }; |
40 | 39 |
41 // Mapping between containers and their codecs. | 40 // Mapping between containers and their codecs. |
42 // Only audio codecs can belong to a "audio/*" mime_type, and only video codecs | 41 // Only audio codecs can belong to a "audio/*" mime_type, and only video codecs |
43 // can belong to a "video/*" mime_type. | 42 // can belong to a "video/*" mime_type. |
44 static const NamedCodec kMimeTypeToCodecMasks[] = { | 43 static const NamedCodec kMimeTypeToCodecMasks[] = { |
45 {"audio/webm", EME_CODEC_WEBM_AUDIO_ALL}, | 44 {"audio/webm", EME_CODEC_WEBM_AUDIO_ALL}, |
46 {"video/webm", EME_CODEC_WEBM_VIDEO_ALL}, | 45 {"video/webm", EME_CODEC_WEBM_VIDEO_ALL}, |
47 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 46 #if defined(USE_PROPRIETARY_CODECS) |
48 {"audio/mp4", EME_CODEC_MP4_AUDIO_ALL}, | 47 {"audio/mp4", EME_CODEC_MP4_AUDIO_ALL}, |
49 {"video/mp4", EME_CODEC_MP4_VIDEO_ALL} | 48 {"video/mp4", EME_CODEC_MP4_VIDEO_ALL} |
50 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 49 #endif // defined(USE_PROPRIETARY_CODECS) |
51 }; | 50 }; |
52 | 51 |
53 // Mapping between codec names and enum values. | 52 // Mapping between codec names and enum values. |
54 static const NamedCodec kCodecStrings[] = { | 53 static const NamedCodec kCodecStrings[] = { |
55 {"opus", EME_CODEC_WEBM_OPUS}, // Opus. | 54 {"opus", EME_CODEC_WEBM_OPUS}, // Opus. |
56 {"vorbis", EME_CODEC_WEBM_VORBIS}, // Vorbis. | 55 {"vorbis", EME_CODEC_WEBM_VORBIS}, // Vorbis. |
57 {"vp8", EME_CODEC_WEBM_VP8}, // VP8. | 56 {"vp8", EME_CODEC_WEBM_VP8}, // VP8. |
58 {"vp8.0", EME_CODEC_WEBM_VP8}, // VP8. | 57 {"vp8.0", EME_CODEC_WEBM_VP8}, // VP8. |
59 {"vp9", EME_CODEC_WEBM_VP9}, // VP9. | 58 {"vp9", EME_CODEC_WEBM_VP9}, // VP9. |
60 {"vp9.0", EME_CODEC_WEBM_VP9}, // VP9. | 59 {"vp9.0", EME_CODEC_WEBM_VP9}, // VP9. |
61 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 60 #if defined(USE_PROPRIETARY_CODECS) |
62 {"vp09", EME_CODEC_MP4_VP9}, // VP9 in MP4. | 61 {"vp09", EME_CODEC_MP4_VP9}, // VP9 in MP4. |
63 {"mp4a", EME_CODEC_MP4_AAC}, // AAC. | 62 {"mp4a", EME_CODEC_MP4_AAC}, // AAC. |
64 {"avc1", EME_CODEC_MP4_AVC1}, // AVC1. | 63 {"avc1", EME_CODEC_MP4_AVC1}, // AVC1. |
65 {"avc3", EME_CODEC_MP4_AVC1}, // AVC3. | 64 {"avc3", EME_CODEC_MP4_AVC1}, // AVC3. |
66 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 65 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
67 {"hev1", EME_CODEC_MP4_HEVC}, // HEV1. | 66 {"hev1", EME_CODEC_MP4_HEVC}, // HEV1. |
68 {"hvc1", EME_CODEC_MP4_HEVC}, // HVC1. | 67 {"hvc1", EME_CODEC_MP4_HEVC}, // HVC1. |
69 #endif | 68 #endif |
70 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 69 #endif // defined(USE_PROPRIETARY_CODECS) |
71 }; | 70 }; |
72 | 71 |
73 class ClearKeyProperties : public KeySystemProperties { | 72 class ClearKeyProperties : public KeySystemProperties { |
74 public: | 73 public: |
75 std::string GetKeySystemName() const override { return kClearKeyKeySystem; } | 74 std::string GetKeySystemName() const override { return kClearKeyKeySystem; } |
76 | 75 |
77 bool IsSupportedInitDataType(EmeInitDataType init_data_type) const override { | 76 bool IsSupportedInitDataType(EmeInitDataType init_data_type) const override { |
78 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 77 #if defined(USE_PROPRIETARY_CODECS) |
79 if (init_data_type == EmeInitDataType::CENC) | 78 if (init_data_type == EmeInitDataType::CENC) |
80 return true; | 79 return true; |
81 #endif | 80 #endif |
82 return init_data_type == EmeInitDataType::WEBM || | 81 return init_data_type == EmeInitDataType::WEBM || |
83 init_data_type == EmeInitDataType::KEYIDS; | 82 init_data_type == EmeInitDataType::KEYIDS; |
84 } | 83 } |
85 | 84 |
86 SupportedCodecs GetSupportedCodecs() const override { | 85 SupportedCodecs GetSupportedCodecs() const override { |
87 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec: | 86 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec: |
88 // http://developer.android.com/guide/appendix/media-formats.html | 87 // http://developer.android.com/guide/appendix/media-formats.html |
89 // VP9 support is device dependent. | 88 // VP9 support is device dependent. |
90 SupportedCodecs codecs = EME_CODEC_WEBM_ALL; | 89 SupportedCodecs codecs = EME_CODEC_WEBM_ALL; |
91 | 90 |
92 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 91 #if defined(USE_PROPRIETARY_CODECS) |
93 codecs |= EME_CODEC_MP4_ALL; | 92 codecs |= EME_CODEC_MP4_ALL; |
94 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 93 #endif // defined(USE_PROPRIETARY_CODECS) |
95 | 94 |
96 return codecs; | 95 return codecs; |
97 } | 96 } |
98 | 97 |
99 EmeConfigRule GetRobustnessConfigRule( | 98 EmeConfigRule GetRobustnessConfigRule( |
100 EmeMediaType media_type, | 99 EmeMediaType media_type, |
101 const std::string& requested_robustness) const override { | 100 const std::string& requested_robustness) const override { |
102 return requested_robustness.empty() ? EmeConfigRule::SUPPORTED | 101 return requested_robustness.empty() ? EmeConfigRule::SUPPORTED |
103 : EmeConfigRule::NOT_SUPPORTED; | 102 : EmeConfigRule::NOT_SUPPORTED; |
104 } | 103 } |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 uint32_t mask) { | 735 uint32_t mask) { |
737 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); | 736 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); |
738 } | 737 } |
739 | 738 |
740 MEDIA_EXPORT void AddMimeTypeCodecMask(const std::string& mime_type, | 739 MEDIA_EXPORT void AddMimeTypeCodecMask(const std::string& mime_type, |
741 uint32_t mask) { | 740 uint32_t mask) { |
742 KeySystemsImpl::GetInstance()->AddMimeTypeCodecMask(mime_type, mask); | 741 KeySystemsImpl::GetInstance()->AddMimeTypeCodecMask(mime_type, mask); |
743 } | 742 } |
744 | 743 |
745 } // namespace media | 744 } // namespace media |
OLD | NEW |