OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/mime_util_internal.h" | 5 #include "media/base/mime_util_internal.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 // mp4a.67 - MPEG-2 AAC LC | 34 // mp4a.67 - MPEG-2 AAC LC |
35 // mp4a.68 - MPEG-2 AAC SSR | 35 // mp4a.68 - MPEG-2 AAC SSR |
36 // mp4a.69 - MPEG-2 extension to MPEG-1 | 36 // mp4a.69 - MPEG-2 extension to MPEG-1 |
37 // mp4a.6B - MPEG-1 audio | 37 // mp4a.6B - MPEG-1 audio |
38 // mp4a.40.2 - MPEG-4 AAC LC | 38 // mp4a.40.2 - MPEG-4 AAC LC |
39 // mp4a.40.02 - MPEG-4 AAC LC (leading 0 in aud-oti for compatibility) | 39 // mp4a.40.02 - MPEG-4 AAC LC (leading 0 in aud-oti for compatibility) |
40 // mp4a.40.5 - MPEG-4 HE-AAC v1 (AAC LC + SBR) | 40 // mp4a.40.5 - MPEG-4 HE-AAC v1 (AAC LC + SBR) |
41 // mp4a.40.05 - MPEG-4 HE-AAC v1 (AAC LC + SBR) (leading 0 in aud-oti for | 41 // mp4a.40.05 - MPEG-4 HE-AAC v1 (AAC LC + SBR) (leading 0 in aud-oti for |
42 // compatibility) | 42 // compatibility) |
43 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS) | 43 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS) |
44 // | 44 #define ORIGINAL_MP4_AUDIO_CODECS \ |
45 // avc1.42E0xx - H.264 Baseline | 45 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," \ |
ddorwin
2016/02/25 01:09:47
These three lines were not necessary before either
|
servolk
2016/02/25 01:46:06
Let's clean up those lists a little, while we are
ddorwin
2016/03/04 01:26:29
Let's handle that in https://bugs.chromium.org/p/c
|
46 // avc1.4D40xx - H.264 Main | 46 "mp4a.40.05,mp4a.40.29" |
47 // avc1.6400xx - H.264 High | 47 |
48 static const char kMP4AudioCodecsExpression[] = | |
49 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," | |
50 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 48 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
51 // Only one variant each of ac3 and eac3 codec string is sufficient here, | 49 // Only one variant each of ac3 and eac3 codec string is sufficient here, |
52 // since these strings are parsed and mapped to MimeUtil::Codec enum values. | 50 // since these strings are parsed and mapped to MimeUtil::Codec enum values. |
53 "ac-3,ec-3," | 51 #define NEWER_MP4_AUDIO_CODECS ",ac-3,ec-3" |
52 #else | |
53 #define NEWER_MP4_AUDIO_CODECS | |
54 #endif | 54 #endif |
55 "mp4a.40.05,mp4a.40.29"; | 55 |
56 #define MP4_AUDIO_CODECS ORIGINAL_MP4_AUDIO_CODECS NEWER_MP4_AUDIO_CODECS | |
57 | |
58 // This is not a complete list of supported avc1 codecs. It is simply used | |
59 // to register support for the corresponding Codec enum. Instead of using | |
60 // strings in these three arrays, we should use the Codec enum values. | |
61 // This will avoid confusion and unnecessary parsing at runtime. | |
62 // kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only | |
63 // mapping from strings to codecs. See crbug.com/461009. | |
64 #define ORIGINAL_MP4_VIDEO_CODECS "avc1.42E00A,avc1.4D400A,avc1.64000A" | |
servolk
2016/02/25 01:46:06
Now that all three of these codec ids map to the s
ddorwin
2016/03/04 01:26:29
Done.
| |
65 | |
66 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | |
67 // Any valid unambiguous HEVC codec id will work here, since these strings | |
68 // are parsed and mapped to MimeUtil::Codec enum values. | |
69 #define NEWER_MP4_VIDEO_CODECS ",hev1.1.6.L93.B0," | |
70 #else | |
71 #define NEWER_MP4_VIDEO_CODECS | |
72 #endif | |
73 | |
74 #define MP4_VIDEO_CODECS ORIGINAL_MP4_VIDEO_CODECS NEWER_MP4_VIDEO_CODECS | |
75 | |
76 static const char kMP4AudioCodecsExpression[] = MP4_AUDIO_CODECS; | |
77 static const char kXM4AudioCodecsExpression[] = ORIGINAL_MP4_AUDIO_CODECS; | |
78 | |
56 static const char kMP4VideoCodecsExpression[] = | 79 static const char kMP4VideoCodecsExpression[] = |
57 // This is not a complete list of supported avc1 codecs. It is simply used | 80 MP4_VIDEO_CODECS "," MP4_AUDIO_CODECS; |
58 // to register support for the corresponding Codec enum. Instead of using | 81 static const char kOriginalMp4VideoCodecsExpression[] = |
servolk
2016/02/25 01:46:06
Each of k*Expression is only used once, so perhaps
ddorwin
2016/03/04 01:26:29
These are shorter. Also, this allows us to minimiz
| |
59 // strings in these three arrays, we should use the Codec enum values. | 82 ORIGINAL_MP4_VIDEO_CODECS "," ORIGINAL_MP4_AUDIO_CODECS; |
60 // This will avoid confusion and unnecessary parsing at runtime. | 83 |
61 // kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only | 84 #undef ORIGINAL_MP4_AUDIO_CODECS |
62 // mapping from strings to codecs. See crbug.com/461009. | 85 #undef NEWER_MP4_AUDIO_CODECS |
63 "avc1.42E00A,avc1.4D400A,avc1.64000A," | 86 #undef MP4_AUDIO_CODECS |
64 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 87 #undef ORIGINAL_MP4_VIDEO_CODECS |
65 // Any valid unambiguous HEVC codec id will work here, since these strings | 88 #undef NEWER_MP4_VIDEO_CODECS |
66 // are parsed and mapped to MimeUtil::Codec enum values. | 89 #undef MP4_VIDEO_CODECS |
67 "hev1.1.6.L93.B0," | |
68 #endif | |
69 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," | |
70 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
71 // Only one variant each of ac3 and eac3 codec string is sufficient here, | |
72 // since these strings are parsed and mapped to MimeUtil::Codec enum values. | |
73 "ac-3,ec-3," | |
74 #endif | |
75 "mp4a.40.05,mp4a.40.29"; | |
76 #endif // USE_PROPRIETARY_CODECS | 90 #endif // USE_PROPRIETARY_CODECS |
77 | 91 |
78 // A list of media types (https://en.wikipedia.org/wiki/Media_type) and | 92 // A list of media types (https://en.wikipedia.org/wiki/Media_type) and |
79 // corresponding media codecs supported by these types/containers. | 93 // corresponding media codecs supported by these types/containers. |
80 // Media formats marked as PROPRIETARY are not supported by Chromium, only | 94 // Media formats marked as PROPRIETARY are not supported by Chromium, only |
81 // Google Chrome browser supports them. | 95 // Google Chrome browser supports them. |
82 static const MediaFormat kFormatCodecMappings[] = { | 96 static const MediaFormat kFormatCodecMappings[] = { |
83 {"video/webm", COMMON, "opus,vorbis,vp8,vp8.0,vp9,vp9.0"}, | 97 {"video/webm", COMMON, "opus,vorbis,vp8,vp8.0,vp9,vp9.0"}, |
servolk
2016/02/25 01:46:06
vp8.0 and vp9.0 can be removed, those variants are
ddorwin
2016/03/04 01:26:29
Done.
| |
84 {"audio/webm", COMMON, "opus,vorbis"}, | 98 {"audio/webm", COMMON, "opus,vorbis"}, |
85 {"audio/wav", COMMON, "1"}, | 99 {"audio/wav", COMMON, "1"}, |
86 {"audio/x-wav", COMMON, "1"}, | 100 {"audio/x-wav", COMMON, "1"}, |
87 #if defined(OS_ANDROID) | 101 #if defined(OS_ANDROID) |
88 // Android does not support Opus in Ogg container. | 102 // Android does not support Opus in Ogg container. |
89 // Android does not support Theora and thus video/ogg. | 103 // Android does not support Theora and thus video/ogg. |
90 {"audio/ogg", COMMON, "vorbis"}, | 104 {"audio/ogg", COMMON, "vorbis"}, |
91 {"application/ogg", COMMON, "vorbis"}, | 105 {"application/ogg", COMMON, "vorbis"}, |
92 #else | 106 #else |
93 {"video/ogg", COMMON, "opus,theora,vorbis"}, | 107 {"video/ogg", COMMON, "opus,theora,vorbis"}, |
94 {"audio/ogg", COMMON, "opus,vorbis"}, | 108 {"audio/ogg", COMMON, "opus,vorbis"}, |
95 {"application/ogg", COMMON, "opus,theora,vorbis"}, | 109 {"application/ogg", COMMON, "opus,theora,vorbis"}, |
96 #endif | 110 #endif |
97 #if defined(USE_PROPRIETARY_CODECS) | 111 #if defined(USE_PROPRIETARY_CODECS) |
98 {"audio/mpeg", PROPRIETARY, "mp3"}, | 112 {"audio/mpeg", PROPRIETARY, "mp3"}, |
99 {"audio/mp3", PROPRIETARY, ""}, | 113 {"audio/mp3", PROPRIETARY, ""}, |
100 {"audio/x-mp3", PROPRIETARY, ""}, | 114 {"audio/x-mp3", PROPRIETARY, ""}, |
101 {"audio/aac", PROPRIETARY, ""}, // AAC / ADTS | 115 {"audio/aac", PROPRIETARY, ""}, // AAC / ADTS |
102 {"audio/mp4", PROPRIETARY, kMP4AudioCodecsExpression}, | 116 {"audio/mp4", PROPRIETARY, kMP4AudioCodecsExpression}, |
103 {"audio/x-m4a", PROPRIETARY, kMP4AudioCodecsExpression}, | 117 {"audio/x-m4a", PROPRIETARY, kXM4AudioCodecsExpression}, |
104 {"video/mp4", PROPRIETARY, kMP4VideoCodecsExpression}, | 118 {"video/mp4", PROPRIETARY, kMP4VideoCodecsExpression}, |
105 {"video/x-m4v", PROPRIETARY, kMP4VideoCodecsExpression}, | 119 {"video/x-m4v", PROPRIETARY, kOriginalMp4VideoCodecsExpression}, |
106 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 120 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
107 {"video/mp2t", PROPRIETARY, kMP4VideoCodecsExpression}, | 121 {"video/mp2t", PROPRIETARY, kMP4VideoCodecsExpression}, |
108 #endif | 122 #endif |
109 #if defined(OS_ANDROID) | 123 #if defined(OS_ANDROID) |
110 // HTTP Live Streaming (HLS) | 124 // HTTP Live Streaming (HLS) |
111 {"application/x-mpegurl", PROPRIETARY, kMP4VideoCodecsExpression}, | 125 {"application/x-mpegurl", PROPRIETARY, kOriginalMp4VideoCodecsExpression}, |
ddorwin
2016/02/25 01:09:47
servolk: We don't have tests for the newer codecs,
servolk
2016/02/25 01:46:06
Acknowledged. Yes, AFAIK neither HEVC nor AC3/EAC3
| |
112 {"application/vnd.apple.mpegurl", PROPRIETARY, kMP4VideoCodecsExpression} | 126 {"application/vnd.apple.mpegurl", PROPRIETARY, |
127 kOriginalMp4VideoCodecsExpression} | |
113 #endif | 128 #endif |
114 #endif // USE_PROPRIETARY_CODECS | 129 #endif // USE_PROPRIETARY_CODECS |
115 }; | 130 }; |
116 | 131 |
117 struct CodecIDMappings { | 132 struct CodecIDMappings { |
118 const char* const codec_id; | 133 const char* const codec_id; |
119 MimeUtil::Codec codec; | 134 MimeUtil::Codec codec; |
120 }; | 135 }; |
121 | 136 |
122 // List of codec IDs that provide enough information to determine the | 137 // List of codec IDs that provide enough information to determine the |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
652 const std::string& mime_type_lower_case, | 667 const std::string& mime_type_lower_case, |
653 bool is_encrypted) const { | 668 bool is_encrypted) const { |
654 Codec default_codec = Codec::INVALID_CODEC; | 669 Codec default_codec = Codec::INVALID_CODEC; |
655 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) | 670 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) |
656 return false; | 671 return false; |
657 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); | 672 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); |
658 } | 673 } |
659 | 674 |
660 } // namespace internal | 675 } // namespace internal |
661 } // namespace media | 676 } // namespace media |
OLD | NEW |