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

Side by Side Diff: media/filters/stream_parser_factory.cc

Issue 812643005: Re-add AC3/EAC3 audio demuxing support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: buildfix Created 4 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/filters/ffmpeg_demuxer_unittest.cc ('k') | media/formats/mp4/es_descriptor.h » ('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 (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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 HISTOGRAM_VP8, 51 HISTOGRAM_VP8,
52 HISTOGRAM_VP9, 52 HISTOGRAM_VP9,
53 HISTOGRAM_VORBIS, 53 HISTOGRAM_VORBIS,
54 HISTOGRAM_H264, 54 HISTOGRAM_H264,
55 HISTOGRAM_MPEG2AAC, 55 HISTOGRAM_MPEG2AAC,
56 HISTOGRAM_MPEG4AAC, 56 HISTOGRAM_MPEG4AAC,
57 HISTOGRAM_EAC3, 57 HISTOGRAM_EAC3,
58 HISTOGRAM_MP3, 58 HISTOGRAM_MP3,
59 HISTOGRAM_OPUS, 59 HISTOGRAM_OPUS,
60 HISTOGRAM_HEVC, 60 HISTOGRAM_HEVC,
61 HISTOGRAM_MAX = HISTOGRAM_HEVC // Must be equal to largest logged entry. 61 HISTOGRAM_AC3,
62 HISTOGRAM_MAX = HISTOGRAM_AC3 // Must be equal to largest logged entry.
62 }; 63 };
63 64
64 const char* pattern; 65 const char* pattern;
65 Type type; 66 Type type;
66 CodecIDValidatorFunction validator; 67 CodecIDValidatorFunction validator;
67 HistogramTag tag; 68 HistogramTag tag;
68 }; 69 };
69 70
70 typedef StreamParser* (*ParserFactoryFunction)( 71 typedef StreamParser* (*ParserFactoryFunction)(
71 const std::vector<std::string>& codecs, 72 const std::vector<std::string>& codecs,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 CodecInfo::HISTOGRAM_HEVC }; 160 CodecInfo::HISTOGRAM_HEVC };
160 static const CodecInfo kHEVCHVC1CodecInfo = { "hvc1.*", CodecInfo::VIDEO, NULL, 161 static const CodecInfo kHEVCHVC1CodecInfo = { "hvc1.*", CodecInfo::VIDEO, NULL,
161 CodecInfo::HISTOGRAM_HEVC }; 162 CodecInfo::HISTOGRAM_HEVC };
162 #endif 163 #endif
163 static const CodecInfo kMPEG4AACCodecInfo = { "mp4a.40.*", CodecInfo::AUDIO, 164 static const CodecInfo kMPEG4AACCodecInfo = { "mp4a.40.*", CodecInfo::AUDIO,
164 &ValidateMP4ACodecID, 165 &ValidateMP4ACodecID,
165 CodecInfo::HISTOGRAM_MPEG4AAC }; 166 CodecInfo::HISTOGRAM_MPEG4AAC };
166 static const CodecInfo kMPEG2AACLCCodecInfo = { "mp4a.67", CodecInfo::AUDIO, 167 static const CodecInfo kMPEG2AACLCCodecInfo = { "mp4a.67", CodecInfo::AUDIO,
167 NULL, 168 NULL,
168 CodecInfo::HISTOGRAM_MPEG2AAC }; 169 CodecInfo::HISTOGRAM_MPEG2AAC };
170 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
171 // The 'ac-3' and 'ec-3' are mime codec ids for AC3 and EAC3 according to
172 // http://www.mp4ra.org/codecs.html
173 // The object types for AC3 and EAC3 in MP4 container are 0xa5 and 0xa6, so
174 // according to RFC 6381 this corresponds to codec ids 'mp4a.A5' and 'mp4a.A6'.
175 // Codec ids with lower case oti (mp4a.a5 and mp4a.a6) are supported for
176 // backward compatibility.
177 static const CodecInfo kAC3CodecInfo1 = {"ac-3", CodecInfo::AUDIO, NULL,
178 CodecInfo::HISTOGRAM_AC3};
179 static const CodecInfo kAC3CodecInfo2 = {"mp4a.a5", CodecInfo::AUDIO, NULL,
180 CodecInfo::HISTOGRAM_AC3};
181 static const CodecInfo kAC3CodecInfo3 = {"mp4a.A5", CodecInfo::AUDIO, NULL,
182 CodecInfo::HISTOGRAM_AC3};
183 static const CodecInfo kEAC3CodecInfo1 = {"ec-3", CodecInfo::AUDIO, NULL,
184 CodecInfo::HISTOGRAM_EAC3};
185 static const CodecInfo kEAC3CodecInfo2 = {"mp4a.a6", CodecInfo::AUDIO, NULL,
186 CodecInfo::HISTOGRAM_EAC3};
187 static const CodecInfo kEAC3CodecInfo3 = {"mp4a.A6", CodecInfo::AUDIO, NULL,
188 CodecInfo::HISTOGRAM_EAC3};
189 #endif
169 190
170 static const CodecInfo* kVideoMP4Codecs[] = { 191 static const CodecInfo* kVideoMP4Codecs[] = {
171 &kH264AVC1CodecInfo, 192 &kH264AVC1CodecInfo,
172 &kH264AVC3CodecInfo, 193 &kH264AVC3CodecInfo,
173 #if defined(ENABLE_HEVC_DEMUXING) 194 #if defined(ENABLE_HEVC_DEMUXING)
174 &kHEVCHEV1CodecInfo, 195 &kHEVCHEV1CodecInfo,
175 &kHEVCHVC1CodecInfo, 196 &kHEVCHVC1CodecInfo,
176 #endif 197 #endif
177 &kMPEG4AACCodecInfo, 198 &kMPEG4AACCodecInfo,
178 &kMPEG2AACLCCodecInfo, 199 &kMPEG2AACLCCodecInfo,
179 NULL 200 NULL
180 }; 201 };
181 202
182 static const CodecInfo* kAudioMP4Codecs[] = { 203 static const CodecInfo* kAudioMP4Codecs[] = {&kMPEG4AACCodecInfo,
183 &kMPEG4AACCodecInfo, 204 &kMPEG2AACLCCodecInfo,
184 &kMPEG2AACLCCodecInfo, 205 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
185 NULL 206 &kAC3CodecInfo1,
186 }; 207 &kAC3CodecInfo2,
208 &kAC3CodecInfo3,
209 &kEAC3CodecInfo1,
210 &kEAC3CodecInfo2,
211 &kEAC3CodecInfo3,
212 #endif
213 NULL};
187 214
188 static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs, 215 static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs,
189 const scoped_refptr<MediaLog>& media_log) { 216 const scoped_refptr<MediaLog>& media_log) {
190 std::set<int> audio_object_types; 217 std::set<int> audio_object_types;
191 218
192 bool has_sbr = false; 219 bool has_sbr = false;
193 for (size_t i = 0; i < codecs.size(); ++i) { 220 for (size_t i = 0; i < codecs.size(); ++i) {
194 std::string codec_id = codecs[i]; 221 std::string codec_id = codecs[i];
195 if (base::MatchPattern(codec_id, kMPEG2AACLCCodecInfo.pattern)) { 222 if (base::MatchPattern(codec_id, kMPEG2AACLCCodecInfo.pattern)) {
196 audio_object_types.insert(mp4::kISO_13818_7_AAC_LC); 223 audio_object_types.insert(mp4::kISO_13818_7_AAC_LC);
197 } else if (base::MatchPattern(codec_id, kMPEG4AACCodecInfo.pattern)) { 224 } else if (base::MatchPattern(codec_id, kMPEG4AACCodecInfo.pattern)) {
198 int audio_object_type = GetMP4AudioObjectType(codec_id, media_log); 225 int audio_object_type = GetMP4AudioObjectType(codec_id, media_log);
199 DCHECK_GT(audio_object_type, 0); 226 DCHECK_GT(audio_object_type, 0);
200 227
201 audio_object_types.insert(mp4::kISO_14496_3); 228 audio_object_types.insert(mp4::kISO_14496_3);
202 229
203 if (audio_object_type == kAACSBRObjectType || 230 if (audio_object_type == kAACSBRObjectType ||
204 audio_object_type == kAACPSObjectType) { 231 audio_object_type == kAACPSObjectType) {
205 has_sbr = true; 232 has_sbr = true;
206 break; 233 break;
207 } 234 }
235 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
236 } else if (base::MatchPattern(codec_id, kAC3CodecInfo1.pattern) ||
237 base::MatchPattern(codec_id, kAC3CodecInfo2.pattern) ||
238 base::MatchPattern(codec_id, kAC3CodecInfo3.pattern)) {
239 audio_object_types.insert(mp4::kAC3);
240 } else if (base::MatchPattern(codec_id, kEAC3CodecInfo1.pattern) ||
241 base::MatchPattern(codec_id, kEAC3CodecInfo2.pattern) ||
242 base::MatchPattern(codec_id, kEAC3CodecInfo3.pattern)) {
243 audio_object_types.insert(mp4::kEAC3);
244 #endif
208 } 245 }
209 } 246 }
210 247
211 return new mp4::MP4StreamParser(audio_object_types, has_sbr); 248 return new mp4::MP4StreamParser(audio_object_types, has_sbr);
212 } 249 }
213 250
214 static const CodecInfo kMP3CodecInfo = { NULL, CodecInfo::AUDIO, NULL, 251 static const CodecInfo kMP3CodecInfo = { NULL, CodecInfo::AUDIO, NULL,
215 CodecInfo::HISTOGRAM_MP3 }; 252 CodecInfo::HISTOGRAM_MP3 };
216 253
217 static const CodecInfo* kAudioMP3Codecs[] = { 254 static const CodecInfo* kAudioMP3Codecs[] = {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 CodecInfo::HISTOGRAM_MAX + 1); 469 CodecInfo::HISTOGRAM_MAX + 1);
433 } 470 }
434 471
435 stream_parser.reset(factory_function(codecs, media_log)); 472 stream_parser.reset(factory_function(codecs, media_log));
436 } 473 }
437 474
438 return stream_parser; 475 return stream_parser;
439 } 476 }
440 477
441 } // namespace media 478 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | media/formats/mp4/es_descriptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698