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/pattern.h" | 9 #include "base/strings/pattern.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 HISTOGRAM_VP8, | 46 HISTOGRAM_VP8, |
47 HISTOGRAM_VP9, | 47 HISTOGRAM_VP9, |
48 HISTOGRAM_VORBIS, | 48 HISTOGRAM_VORBIS, |
49 HISTOGRAM_H264, | 49 HISTOGRAM_H264, |
50 HISTOGRAM_MPEG2AAC, | 50 HISTOGRAM_MPEG2AAC, |
51 HISTOGRAM_MPEG4AAC, | 51 HISTOGRAM_MPEG4AAC, |
52 HISTOGRAM_EAC3, | 52 HISTOGRAM_EAC3, |
53 HISTOGRAM_MP3, | 53 HISTOGRAM_MP3, |
54 HISTOGRAM_OPUS, | 54 HISTOGRAM_OPUS, |
55 HISTOGRAM_HEVC, | 55 HISTOGRAM_HEVC, |
56 HISTOGRAM_MAX = HISTOGRAM_HEVC // Must be equal to largest logged entry. | 56 HISTOGRAM_AC3, |
57 HISTOGRAM_MAX = HISTOGRAM_AC3 // Must be equal to largest logged entry. | |
57 }; | 58 }; |
58 | 59 |
59 const char* pattern; | 60 const char* pattern; |
60 Type type; | 61 Type type; |
61 CodecIDValidatorFunction validator; | 62 CodecIDValidatorFunction validator; |
62 HistogramTag tag; | 63 HistogramTag tag; |
63 }; | 64 }; |
64 | 65 |
65 typedef StreamParser* (*ParserFactoryFunction)( | 66 typedef StreamParser* (*ParserFactoryFunction)( |
66 const std::vector<std::string>& codecs, | 67 const std::vector<std::string>& codecs, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 CodecInfo::HISTOGRAM_HEVC }; | 155 CodecInfo::HISTOGRAM_HEVC }; |
155 static const CodecInfo kHEVCHVC1CodecInfo = { "hvc1.*", CodecInfo::VIDEO, NULL, | 156 static const CodecInfo kHEVCHVC1CodecInfo = { "hvc1.*", CodecInfo::VIDEO, NULL, |
156 CodecInfo::HISTOGRAM_HEVC }; | 157 CodecInfo::HISTOGRAM_HEVC }; |
157 #endif | 158 #endif |
158 static const CodecInfo kMPEG4AACCodecInfo = { "mp4a.40.*", CodecInfo::AUDIO, | 159 static const CodecInfo kMPEG4AACCodecInfo = { "mp4a.40.*", CodecInfo::AUDIO, |
159 &ValidateMP4ACodecID, | 160 &ValidateMP4ACodecID, |
160 CodecInfo::HISTOGRAM_MPEG4AAC }; | 161 CodecInfo::HISTOGRAM_MPEG4AAC }; |
161 static const CodecInfo kMPEG2AACLCCodecInfo = { "mp4a.67", CodecInfo::AUDIO, | 162 static const CodecInfo kMPEG2AACLCCodecInfo = { "mp4a.67", CodecInfo::AUDIO, |
162 NULL, | 163 NULL, |
163 CodecInfo::HISTOGRAM_MPEG2AAC }; | 164 CodecInfo::HISTOGRAM_MPEG2AAC }; |
165 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
166 // The 'ac-3' and 'ec-3' are mime codec ids for AC3 and EAC3 according to | |
167 // http://www.mp4ra.org/codecs.html | |
168 // The object types for AC3 and EAC3 in MP4 container are 0xa5 and 0xa6, so | |
169 // according to RFC 6381 this corresponds to codec ids 'mp4a.A5' and 'mp4a.A6'. | |
170 // Codec ids with lower case oti (mp4a.a5 and mp4a.a6) are supported for | |
171 // backward compatibility. | |
172 static const CodecInfo kAC3CodecInfo1 = {"ac-3", CodecInfo::AUDIO, NULL, | |
173 CodecInfo::HISTOGRAM_AC3}; | |
174 static const CodecInfo kAC3CodecInfo2 = {"mp4a.a5", CodecInfo::AUDIO, NULL, | |
175 CodecInfo::HISTOGRAM_AC3}; | |
176 static const CodecInfo kAC3CodecInfo3 = {"mp4a.A5", CodecInfo::AUDIO, NULL, | |
177 CodecInfo::HISTOGRAM_AC3}; | |
178 static const CodecInfo kEAC3CodecInfo1 = {"ec-3", CodecInfo::AUDIO, NULL, | |
179 CodecInfo::HISTOGRAM_EAC3}; | |
180 static const CodecInfo kEAC3CodecInfo2 = {"mp4a.a6", CodecInfo::AUDIO, NULL, | |
181 CodecInfo::HISTOGRAM_EAC3}; | |
182 static const CodecInfo kEAC3CodecInfo3 = {"mp4a.A6", CodecInfo::AUDIO, NULL, | |
183 CodecInfo::HISTOGRAM_EAC3}; | |
184 #endif | |
164 | 185 |
165 static const CodecInfo* kVideoMP4Codecs[] = { | 186 static const CodecInfo* kVideoMP4Codecs[] = { |
166 &kH264AVC1CodecInfo, | 187 &kH264AVC1CodecInfo, |
167 &kH264AVC3CodecInfo, | 188 &kH264AVC3CodecInfo, |
168 #if defined(ENABLE_HEVC_DEMUXING) | 189 #if defined(ENABLE_HEVC_DEMUXING) |
169 &kHEVCHEV1CodecInfo, | 190 &kHEVCHEV1CodecInfo, |
170 &kHEVCHVC1CodecInfo, | 191 &kHEVCHVC1CodecInfo, |
171 #endif | 192 #endif |
172 &kMPEG4AACCodecInfo, | 193 &kMPEG4AACCodecInfo, |
173 &kMPEG2AACLCCodecInfo, | 194 &kMPEG2AACLCCodecInfo, |
174 NULL | 195 NULL |
175 }; | 196 }; |
176 | 197 |
177 static const CodecInfo* kAudioMP4Codecs[] = { | 198 static const CodecInfo* kAudioMP4Codecs[] = {&kMPEG4AACCodecInfo, |
178 &kMPEG4AACCodecInfo, | 199 &kMPEG2AACLCCodecInfo, |
179 &kMPEG2AACLCCodecInfo, | 200 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
180 NULL | 201 &kAC3CodecInfo1, |
181 }; | 202 &kAC3CodecInfo2, |
203 &kAC3CodecInfo3, | |
204 &kEAC3CodecInfo1, | |
205 &kEAC3CodecInfo2, | |
206 &kEAC3CodecInfo3, | |
207 #endif | |
208 NULL}; | |
182 | 209 |
183 static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs, | 210 static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs, |
184 const scoped_refptr<MediaLog>& media_log) { | 211 const scoped_refptr<MediaLog>& media_log) { |
185 std::set<int> audio_object_types; | 212 std::set<int> audio_object_types; |
186 | 213 |
187 bool has_sbr = false; | 214 bool has_sbr = false; |
188 for (size_t i = 0; i < codecs.size(); ++i) { | 215 for (size_t i = 0; i < codecs.size(); ++i) { |
189 std::string codec_id = codecs[i]; | 216 std::string codec_id = codecs[i]; |
190 if (base::MatchPattern(codec_id, kMPEG2AACLCCodecInfo.pattern)) { | 217 if (base::MatchPattern(codec_id, kMPEG2AACLCCodecInfo.pattern)) { |
191 audio_object_types.insert(mp4::kISO_13818_7_AAC_LC); | 218 audio_object_types.insert(mp4::kISO_13818_7_AAC_LC); |
192 } else if (base::MatchPattern(codec_id, kMPEG4AACCodecInfo.pattern)) { | 219 } else if (base::MatchPattern(codec_id, kMPEG4AACCodecInfo.pattern)) { |
193 int audio_object_type = GetMP4AudioObjectType(codec_id, media_log); | 220 int audio_object_type = GetMP4AudioObjectType(codec_id, media_log); |
194 DCHECK_GT(audio_object_type, 0); | 221 DCHECK_GT(audio_object_type, 0); |
195 | 222 |
196 audio_object_types.insert(mp4::kISO_14496_3); | 223 audio_object_types.insert(mp4::kISO_14496_3); |
197 | 224 |
198 if (audio_object_type == kAACSBRObjectType || | 225 if (audio_object_type == kAACSBRObjectType || |
199 audio_object_type == kAACPSObjectType) { | 226 audio_object_type == kAACPSObjectType) { |
200 has_sbr = true; | 227 has_sbr = true; |
201 break; | 228 break; |
202 } | 229 } |
230 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
231 } else if (MatchPattern(codec_id, kAC3CodecInfo1.pattern) || | |
232 MatchPattern(codec_id, kAC3CodecInfo2.pattern) || | |
ddorwin
2016/01/04 23:22:17
We could do direct string comparisons, but that mo
servolk
2016/01/07 02:30:04
Looking at https://code.google.com/p/chromium/code
ddorwin
2016/01/07 19:12:43
Acknowledged.
| |
233 MatchPattern(codec_id, kAC3CodecInfo3.pattern)) { | |
234 audio_object_types.insert(mp4::kAC3); | |
235 } else if (MatchPattern(codec_id, kEAC3CodecInfo1.pattern) || | |
236 MatchPattern(codec_id, kEAC3CodecInfo2.pattern) || | |
237 MatchPattern(codec_id, kEAC3CodecInfo3.pattern)) { | |
238 audio_object_types.insert(mp4::kEAC3); | |
239 #endif | |
203 } | 240 } |
204 } | 241 } |
205 | 242 |
206 return new mp4::MP4StreamParser(audio_object_types, has_sbr); | 243 return new mp4::MP4StreamParser(audio_object_types, has_sbr); |
207 } | 244 } |
208 | 245 |
209 static const CodecInfo kMP3CodecInfo = { NULL, CodecInfo::AUDIO, NULL, | 246 static const CodecInfo kMP3CodecInfo = { NULL, CodecInfo::AUDIO, NULL, |
210 CodecInfo::HISTOGRAM_MP3 }; | 247 CodecInfo::HISTOGRAM_MP3 }; |
211 | 248 |
212 static const CodecInfo* kAudioMP3Codecs[] = { | 249 static const CodecInfo* kAudioMP3Codecs[] = { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 CodecInfo::HISTOGRAM_MAX + 1); | 465 CodecInfo::HISTOGRAM_MAX + 1); |
429 } | 466 } |
430 | 467 |
431 stream_parser.reset(factory_function(codecs, media_log)); | 468 stream_parser.reset(factory_function(codecs, media_log)); |
432 } | 469 } |
433 | 470 |
434 return stream_parser.Pass(); | 471 return stream_parser.Pass(); |
435 } | 472 } |
436 | 473 |
437 } // namespace media | 474 } // namespace media |
OLD | NEW |