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

Side by Side Diff: media/base/key_systems.cc

Issue 2643333002: Convert USE_PROPRIETARY_CODECS to a buildflag header. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « media/base/eme_constants.h ('k') | media/base/media_file_checker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
25 #include "third_party/widevine/cdm/widevine_cdm_common.h" 26 #include "third_party/widevine/cdm/widevine_cdm_common.h"
26 27
27 namespace media { 28 namespace media {
28 29
29 const char kClearKeyKeySystem[] = "org.w3.clearkey"; 30 const char kClearKeyKeySystem[] = "org.w3.clearkey";
30 31
31 // These names are used by UMA. Do not change them! 32 // These names are used by UMA. Do not change them!
32 const char kClearKeyKeySystemNameForUMA[] = "ClearKey"; 33 const char kClearKeyKeySystemNameForUMA[] = "ClearKey";
33 const char kUnknownKeySystemNameForUMA[] = "Unknown"; 34 const char kUnknownKeySystemNameForUMA[] = "Unknown";
34 35
35 struct NamedCodec { 36 struct NamedCodec {
36 const char* name; 37 const char* name;
37 EmeCodec type; 38 EmeCodec type;
38 }; 39 };
39 40
40 // Mapping between containers and their codecs. 41 // Mapping between containers and their codecs.
41 // Only audio codecs can belong to a "audio/*" mime_type, and only video codecs 42 // Only audio codecs can belong to a "audio/*" mime_type, and only video codecs
42 // can belong to a "video/*" mime_type. 43 // can belong to a "video/*" mime_type.
43 static const NamedCodec kMimeTypeToCodecMasks[] = { 44 static const NamedCodec kMimeTypeToCodecMasks[] = {
44 {"audio/webm", EME_CODEC_WEBM_AUDIO_ALL}, 45 {"audio/webm", EME_CODEC_WEBM_AUDIO_ALL},
45 {"video/webm", EME_CODEC_WEBM_VIDEO_ALL}, 46 {"video/webm", EME_CODEC_WEBM_VIDEO_ALL},
46 #if defined(USE_PROPRIETARY_CODECS) 47 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
47 {"audio/mp4", EME_CODEC_MP4_AUDIO_ALL}, 48 {"audio/mp4", EME_CODEC_MP4_AUDIO_ALL},
48 {"video/mp4", EME_CODEC_MP4_VIDEO_ALL} 49 {"video/mp4", EME_CODEC_MP4_VIDEO_ALL}
49 #endif // defined(USE_PROPRIETARY_CODECS) 50 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
50 }; 51 };
51 52
52 // Mapping between codec names and enum values. 53 // Mapping between codec names and enum values.
53 static const NamedCodec kCodecStrings[] = { 54 static const NamedCodec kCodecStrings[] = {
54 {"opus", EME_CODEC_WEBM_OPUS}, // Opus. 55 {"opus", EME_CODEC_WEBM_OPUS}, // Opus.
55 {"vorbis", EME_CODEC_WEBM_VORBIS}, // Vorbis. 56 {"vorbis", EME_CODEC_WEBM_VORBIS}, // Vorbis.
56 {"vp8", EME_CODEC_WEBM_VP8}, // VP8. 57 {"vp8", EME_CODEC_WEBM_VP8}, // VP8.
57 {"vp8.0", EME_CODEC_WEBM_VP8}, // VP8. 58 {"vp8.0", EME_CODEC_WEBM_VP8}, // VP8.
58 {"vp9", EME_CODEC_WEBM_VP9}, // VP9. 59 {"vp9", EME_CODEC_WEBM_VP9}, // VP9.
59 {"vp9.0", EME_CODEC_WEBM_VP9}, // VP9. 60 {"vp9.0", EME_CODEC_WEBM_VP9}, // VP9.
60 #if defined(USE_PROPRIETARY_CODECS) 61 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
61 {"vp09", EME_CODEC_MP4_VP9}, // VP9 in MP4. 62 {"vp09", EME_CODEC_MP4_VP9}, // VP9 in MP4.
62 {"mp4a", EME_CODEC_MP4_AAC}, // AAC. 63 {"mp4a", EME_CODEC_MP4_AAC}, // AAC.
63 {"avc1", EME_CODEC_MP4_AVC1}, // AVC1. 64 {"avc1", EME_CODEC_MP4_AVC1}, // AVC1.
64 {"avc3", EME_CODEC_MP4_AVC1}, // AVC3. 65 {"avc3", EME_CODEC_MP4_AVC1}, // AVC3.
65 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 66 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
66 {"hev1", EME_CODEC_MP4_HEVC}, // HEV1. 67 {"hev1", EME_CODEC_MP4_HEVC}, // HEV1.
67 {"hvc1", EME_CODEC_MP4_HEVC}, // HVC1. 68 {"hvc1", EME_CODEC_MP4_HEVC}, // HVC1.
68 #endif 69 #endif
69 #endif // defined(USE_PROPRIETARY_CODECS) 70 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
70 }; 71 };
71 72
72 class ClearKeyProperties : public KeySystemProperties { 73 class ClearKeyProperties : public KeySystemProperties {
73 public: 74 public:
74 std::string GetKeySystemName() const override { return kClearKeyKeySystem; } 75 std::string GetKeySystemName() const override { return kClearKeyKeySystem; }
75 76
76 bool IsSupportedInitDataType(EmeInitDataType init_data_type) const override { 77 bool IsSupportedInitDataType(EmeInitDataType init_data_type) const override {
77 #if defined(USE_PROPRIETARY_CODECS) 78 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
78 if (init_data_type == EmeInitDataType::CENC) 79 if (init_data_type == EmeInitDataType::CENC)
79 return true; 80 return true;
80 #endif 81 #endif
81 return init_data_type == EmeInitDataType::WEBM || 82 return init_data_type == EmeInitDataType::WEBM ||
82 init_data_type == EmeInitDataType::KEYIDS; 83 init_data_type == EmeInitDataType::KEYIDS;
83 } 84 }
84 85
85 SupportedCodecs GetSupportedCodecs() const override { 86 SupportedCodecs GetSupportedCodecs() const override {
86 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec: 87 // On Android, Vorbis, VP8, AAC and AVC1 are supported in MediaCodec:
87 // http://developer.android.com/guide/appendix/media-formats.html 88 // http://developer.android.com/guide/appendix/media-formats.html
88 // VP9 support is device dependent. 89 // VP9 support is device dependent.
89 SupportedCodecs codecs = EME_CODEC_WEBM_ALL; 90 SupportedCodecs codecs = EME_CODEC_WEBM_ALL;
90 91
91 #if defined(USE_PROPRIETARY_CODECS) 92 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
92 codecs |= EME_CODEC_MP4_ALL; 93 codecs |= EME_CODEC_MP4_ALL;
93 #endif // defined(USE_PROPRIETARY_CODECS) 94 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
94 95
95 return codecs; 96 return codecs;
96 } 97 }
97 98
98 EmeConfigRule GetRobustnessConfigRule( 99 EmeConfigRule GetRobustnessConfigRule(
99 EmeMediaType media_type, 100 EmeMediaType media_type,
100 const std::string& requested_robustness) const override { 101 const std::string& requested_robustness) const override {
101 return requested_robustness.empty() ? EmeConfigRule::SUPPORTED 102 return requested_robustness.empty() ? EmeConfigRule::SUPPORTED
102 : EmeConfigRule::NOT_SUPPORTED; 103 : EmeConfigRule::NOT_SUPPORTED;
103 } 104 }
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 uint32_t mask) { 736 uint32_t mask) {
736 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask); 737 KeySystemsImpl::GetInstance()->AddCodecMask(media_type, codec, mask);
737 } 738 }
738 739
739 MEDIA_EXPORT void AddMimeTypeCodecMask(const std::string& mime_type, 740 MEDIA_EXPORT void AddMimeTypeCodecMask(const std::string& mime_type,
740 uint32_t mask) { 741 uint32_t mask) {
741 KeySystemsImpl::GetInstance()->AddMimeTypeCodecMask(mime_type, mask); 742 KeySystemsImpl::GetInstance()->AddMimeTypeCodecMask(mime_type, mask);
742 } 743 }
743 744
744 } // namespace media 745 } // namespace media
OLDNEW
« no previous file with comments | « media/base/eme_constants.h ('k') | media/base/media_file_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698