OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/filters/stream_parser_factory.h" | 5 #include "media/filters/stream_parser_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 HISTOGRAM_UNKNOWN, | 43 HISTOGRAM_UNKNOWN, |
44 HISTOGRAM_VP8, | 44 HISTOGRAM_VP8, |
45 HISTOGRAM_VP9, | 45 HISTOGRAM_VP9, |
46 HISTOGRAM_VORBIS, | 46 HISTOGRAM_VORBIS, |
47 HISTOGRAM_H264, | 47 HISTOGRAM_H264, |
48 HISTOGRAM_MPEG2AAC, | 48 HISTOGRAM_MPEG2AAC, |
49 HISTOGRAM_MPEG4AAC, | 49 HISTOGRAM_MPEG4AAC, |
50 HISTOGRAM_EAC3, | 50 HISTOGRAM_EAC3, |
51 HISTOGRAM_MP3, | 51 HISTOGRAM_MP3, |
52 HISTOGRAM_OPUS, | 52 HISTOGRAM_OPUS, |
53 HISTOGRAM_MAX = HISTOGRAM_OPUS // Must be equal to largest logged entry. | 53 HISTOGRAM_AC3, |
| 54 HISTOGRAM_MAX = HISTOGRAM_AC3 // Must be equal to largest logged entry. |
54 }; | 55 }; |
55 | 56 |
56 const char* pattern; | 57 const char* pattern; |
57 Type type; | 58 Type type; |
58 CodecIDValidatorFunction validator; | 59 CodecIDValidatorFunction validator; |
59 HistogramTag tag; | 60 HistogramTag tag; |
60 }; | 61 }; |
61 | 62 |
62 typedef StreamParser* (*ParserFactoryFunction)( | 63 typedef StreamParser* (*ParserFactoryFunction)( |
63 const std::vector<std::string>& codecs, | 64 const std::vector<std::string>& codecs, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 static const CodecInfo kH264AVC1CodecInfo = { "avc1.*", CodecInfo::VIDEO, NULL, | 144 static const CodecInfo kH264AVC1CodecInfo = { "avc1.*", CodecInfo::VIDEO, NULL, |
144 CodecInfo::HISTOGRAM_H264 }; | 145 CodecInfo::HISTOGRAM_H264 }; |
145 static const CodecInfo kH264AVC3CodecInfo = { "avc3.*", CodecInfo::VIDEO, NULL, | 146 static const CodecInfo kH264AVC3CodecInfo = { "avc3.*", CodecInfo::VIDEO, NULL, |
146 CodecInfo::HISTOGRAM_H264 }; | 147 CodecInfo::HISTOGRAM_H264 }; |
147 static const CodecInfo kMPEG4AACCodecInfo = { "mp4a.40.*", CodecInfo::AUDIO, | 148 static const CodecInfo kMPEG4AACCodecInfo = { "mp4a.40.*", CodecInfo::AUDIO, |
148 &ValidateMP4ACodecID, | 149 &ValidateMP4ACodecID, |
149 CodecInfo::HISTOGRAM_MPEG4AAC }; | 150 CodecInfo::HISTOGRAM_MPEG4AAC }; |
150 static const CodecInfo kMPEG2AACLCCodecInfo = { "mp4a.67", CodecInfo::AUDIO, | 151 static const CodecInfo kMPEG2AACLCCodecInfo = { "mp4a.67", CodecInfo::AUDIO, |
151 NULL, | 152 NULL, |
152 CodecInfo::HISTOGRAM_MPEG2AAC }; | 153 CodecInfo::HISTOGRAM_MPEG2AAC }; |
| 154 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 155 // The 'ac-3' and 'ec-3' are mime codec ids for AC3 and EAC3 according to |
| 156 // http://www.mp4ra.org/codecs.html |
| 157 // The object types for AC3 and EAC3 in MP4 container are 0xa5 and 0xa6, so |
| 158 // according to RFC 6381 this corresponds to codec ids 'mp4a.a5' and 'mp4a.a6'. |
| 159 // Different applications use different codec ids. |
| 160 static const CodecInfo kAC3CodecInfo1 = { "ac-3", CodecInfo::AUDIO, NULL, |
| 161 CodecInfo::HISTOGRAM_AC3 }; |
| 162 static const CodecInfo kAC3CodecInfo2 = { "mp4a.a5", CodecInfo::AUDIO, NULL, |
| 163 CodecInfo::HISTOGRAM_AC3 }; |
| 164 static const CodecInfo kEAC3CodecInfo1 = { "ec-3", CodecInfo::AUDIO, NULL, |
| 165 CodecInfo::HISTOGRAM_EAC3 }; |
| 166 static const CodecInfo kEAC3CodecInfo2 = { "mp4a.a6", CodecInfo::AUDIO, NULL, |
| 167 CodecInfo::HISTOGRAM_EAC3 }; |
| 168 #endif |
153 | 169 |
154 static const CodecInfo* kVideoMP4Codecs[] = { | 170 static const CodecInfo* kVideoMP4Codecs[] = { |
155 &kH264AVC1CodecInfo, | 171 &kH264AVC1CodecInfo, |
156 &kH264AVC3CodecInfo, | 172 &kH264AVC3CodecInfo, |
157 &kMPEG4AACCodecInfo, | 173 &kMPEG4AACCodecInfo, |
158 &kMPEG2AACLCCodecInfo, | 174 &kMPEG2AACLCCodecInfo, |
159 NULL | 175 NULL |
160 }; | 176 }; |
161 | 177 |
162 static const CodecInfo* kAudioMP4Codecs[] = { | 178 static const CodecInfo* kAudioMP4Codecs[] = { |
163 &kMPEG4AACCodecInfo, | 179 &kMPEG4AACCodecInfo, |
164 &kMPEG2AACLCCodecInfo, | 180 &kMPEG2AACLCCodecInfo, |
| 181 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 182 &kAC3CodecInfo1, |
| 183 &kAC3CodecInfo2, |
| 184 &kEAC3CodecInfo1, |
| 185 &kEAC3CodecInfo2, |
| 186 #endif |
165 NULL | 187 NULL |
166 }; | 188 }; |
167 | 189 |
168 static StreamParser* BuildMP4Parser( | 190 static StreamParser* BuildMP4Parser( |
169 const std::vector<std::string>& codecs, const LogCB& log_cb) { | 191 const std::vector<std::string>& codecs, const LogCB& log_cb) { |
170 std::set<int> audio_object_types; | 192 std::set<int> audio_object_types; |
171 | 193 |
172 bool has_sbr = false; | 194 bool has_sbr = false; |
173 for (size_t i = 0; i < codecs.size(); ++i) { | 195 for (size_t i = 0; i < codecs.size(); ++i) { |
174 std::string codec_id = codecs[i]; | 196 std::string codec_id = codecs[i]; |
175 if (MatchPattern(codec_id, kMPEG2AACLCCodecInfo.pattern)) { | 197 if (MatchPattern(codec_id, kMPEG2AACLCCodecInfo.pattern)) { |
176 audio_object_types.insert(mp4::kISO_13818_7_AAC_LC); | 198 audio_object_types.insert(mp4::kISO_13818_7_AAC_LC); |
177 } else if (MatchPattern(codec_id, kMPEG4AACCodecInfo.pattern)) { | 199 } else if (MatchPattern(codec_id, kMPEG4AACCodecInfo.pattern)) { |
178 int audio_object_type = GetMP4AudioObjectType(codec_id, log_cb); | 200 int audio_object_type = GetMP4AudioObjectType(codec_id, log_cb); |
179 DCHECK_GT(audio_object_type, 0); | 201 DCHECK_GT(audio_object_type, 0); |
180 | 202 |
181 audio_object_types.insert(mp4::kISO_14496_3); | 203 audio_object_types.insert(mp4::kISO_14496_3); |
182 | 204 |
183 if (audio_object_type == kAACSBRObjectType || | 205 if (audio_object_type == kAACSBRObjectType || |
184 audio_object_type == kAACPSObjectType) { | 206 audio_object_type == kAACPSObjectType) { |
185 has_sbr = true; | 207 has_sbr = true; |
186 break; | 208 break; |
187 } | 209 } |
| 210 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 211 } else if (MatchPattern(codec_id, kAC3CodecInfo1.pattern) || |
| 212 MatchPattern(codec_id, kAC3CodecInfo2.pattern)) { |
| 213 audio_object_types.insert(mp4::kAC3); |
| 214 } else if (MatchPattern(codec_id, kEAC3CodecInfo1.pattern) || |
| 215 MatchPattern(codec_id, kEAC3CodecInfo2.pattern)) { |
| 216 audio_object_types.insert(mp4::kEAC3); |
| 217 #endif |
188 } | 218 } |
189 } | 219 } |
190 | 220 |
191 return new mp4::MP4StreamParser(audio_object_types, has_sbr); | 221 return new mp4::MP4StreamParser(audio_object_types, has_sbr); |
192 } | 222 } |
193 | 223 |
194 static const CodecInfo kMP3CodecInfo = { NULL, CodecInfo::AUDIO, NULL, | 224 static const CodecInfo kMP3CodecInfo = { NULL, CodecInfo::AUDIO, NULL, |
195 CodecInfo::HISTOGRAM_MP3 }; | 225 CodecInfo::HISTOGRAM_MP3 }; |
196 | 226 |
197 static const CodecInfo* kAudioMP3Codecs[] = { | 227 static const CodecInfo* kAudioMP3Codecs[] = { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 CodecInfo::HISTOGRAM_MAX + 1); | 447 CodecInfo::HISTOGRAM_MAX + 1); |
418 } | 448 } |
419 | 449 |
420 stream_parser.reset(factory_function(codecs, log_cb)); | 450 stream_parser.reset(factory_function(codecs, log_cb)); |
421 } | 451 } |
422 | 452 |
423 return stream_parser.Pass(); | 453 return stream_parser.Pass(); |
424 } | 454 } |
425 | 455 |
426 } // namespace media | 456 } // namespace media |
OLD | NEW |