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

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: rebase 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
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 HISTOGRAM_VP8, 50 HISTOGRAM_VP8,
51 HISTOGRAM_VP9, 51 HISTOGRAM_VP9,
52 HISTOGRAM_VORBIS, 52 HISTOGRAM_VORBIS,
53 HISTOGRAM_H264, 53 HISTOGRAM_H264,
54 HISTOGRAM_MPEG2AAC, 54 HISTOGRAM_MPEG2AAC,
55 HISTOGRAM_MPEG4AAC, 55 HISTOGRAM_MPEG4AAC,
56 HISTOGRAM_EAC3, 56 HISTOGRAM_EAC3,
57 HISTOGRAM_MP3, 57 HISTOGRAM_MP3,
58 HISTOGRAM_OPUS, 58 HISTOGRAM_OPUS,
59 HISTOGRAM_HEVC, 59 HISTOGRAM_HEVC,
60 HISTOGRAM_MAX = HISTOGRAM_HEVC // Must be equal to largest logged entry. 60 HISTOGRAM_AC3,
61 HISTOGRAM_MAX = HISTOGRAM_AC3 // Must be equal to largest logged entry.
61 }; 62 };
62 63
63 const char* pattern; 64 const char* pattern;
64 Type type; 65 Type type;
65 CodecIDValidatorFunction validator; 66 CodecIDValidatorFunction validator;
66 HistogramTag tag; 67 HistogramTag tag;
67 }; 68 };
68 69
69 typedef StreamParser* (*ParserFactoryFunction)( 70 typedef StreamParser* (*ParserFactoryFunction)(
70 const std::vector<std::string>& codecs, 71 const std::vector<std::string>& codecs,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 CodecInfo::HISTOGRAM_HEVC }; 159 CodecInfo::HISTOGRAM_HEVC };
159 static const CodecInfo kHEVCHVC1CodecInfo = { "hvc1.*", CodecInfo::VIDEO, NULL, 160 static const CodecInfo kHEVCHVC1CodecInfo = { "hvc1.*", CodecInfo::VIDEO, NULL,
160 CodecInfo::HISTOGRAM_HEVC }; 161 CodecInfo::HISTOGRAM_HEVC };
161 #endif 162 #endif
162 static const CodecInfo kMPEG4AACCodecInfo = { "mp4a.40.*", CodecInfo::AUDIO, 163 static const CodecInfo kMPEG4AACCodecInfo = { "mp4a.40.*", CodecInfo::AUDIO,
163 &ValidateMP4ACodecID, 164 &ValidateMP4ACodecID,
164 CodecInfo::HISTOGRAM_MPEG4AAC }; 165 CodecInfo::HISTOGRAM_MPEG4AAC };
165 static const CodecInfo kMPEG2AACLCCodecInfo = { "mp4a.67", CodecInfo::AUDIO, 166 static const CodecInfo kMPEG2AACLCCodecInfo = { "mp4a.67", CodecInfo::AUDIO,
166 NULL, 167 NULL,
167 CodecInfo::HISTOGRAM_MPEG2AAC }; 168 CodecInfo::HISTOGRAM_MPEG2AAC };
169 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
170 // The 'ac-3' and 'ec-3' are mime codec ids for AC3 and EAC3 according to
171 // http://www.mp4ra.org/codecs.html
172 // The object types for AC3 and EAC3 in MP4 container are 0xa5 and 0xa6, so
173 // according to RFC 6381 this corresponds to codec ids 'mp4a.A5' and 'mp4a.A6'.
174 // Codec ids with lower case oti (mp4a.a5 and mp4a.a6) are supported for
175 // backward compatibility.
176 static const CodecInfo kAC3CodecInfo1 = {"ac-3", CodecInfo::AUDIO, NULL,
177 CodecInfo::HISTOGRAM_AC3};
178 static const CodecInfo kAC3CodecInfo2 = {"mp4a.a5", CodecInfo::AUDIO, NULL,
179 CodecInfo::HISTOGRAM_AC3};
180 static const CodecInfo kAC3CodecInfo3 = {"mp4a.A5", CodecInfo::AUDIO, NULL,
181 CodecInfo::HISTOGRAM_AC3};
182 static const CodecInfo kEAC3CodecInfo1 = {"ec-3", CodecInfo::AUDIO, NULL,
183 CodecInfo::HISTOGRAM_EAC3};
184 static const CodecInfo kEAC3CodecInfo2 = {"mp4a.a6", CodecInfo::AUDIO, NULL,
185 CodecInfo::HISTOGRAM_EAC3};
186 static const CodecInfo kEAC3CodecInfo3 = {"mp4a.A6", CodecInfo::AUDIO, NULL,
187 CodecInfo::HISTOGRAM_EAC3};
188 #endif
168 189
169 static const CodecInfo* kVideoMP4Codecs[] = { 190 static const CodecInfo* kVideoMP4Codecs[] = {
170 &kH264AVC1CodecInfo, 191 &kH264AVC1CodecInfo,
171 &kH264AVC3CodecInfo, 192 &kH264AVC3CodecInfo,
172 #if defined(ENABLE_HEVC_DEMUXING) 193 #if defined(ENABLE_HEVC_DEMUXING)
173 &kHEVCHEV1CodecInfo, 194 &kHEVCHEV1CodecInfo,
174 &kHEVCHVC1CodecInfo, 195 &kHEVCHVC1CodecInfo,
175 #endif 196 #endif
176 &kMPEG4AACCodecInfo, 197 &kMPEG4AACCodecInfo,
177 &kMPEG2AACLCCodecInfo, 198 &kMPEG2AACLCCodecInfo,
178 NULL 199 NULL
179 }; 200 };
180 201
181 static const CodecInfo* kAudioMP4Codecs[] = { 202 static const CodecInfo* kAudioMP4Codecs[] = {&kMPEG4AACCodecInfo,
182 &kMPEG4AACCodecInfo, 203 &kMPEG2AACLCCodecInfo,
183 &kMPEG2AACLCCodecInfo, 204 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
184 NULL 205 &kAC3CodecInfo1,
185 }; 206 &kAC3CodecInfo2,
207 &kAC3CodecInfo3,
208 &kEAC3CodecInfo1,
209 &kEAC3CodecInfo2,
210 &kEAC3CodecInfo3,
211 #endif
212 NULL};
186 213
187 static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs, 214 static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs,
188 const scoped_refptr<MediaLog>& media_log) { 215 const scoped_refptr<MediaLog>& media_log) {
189 std::set<int> audio_object_types; 216 std::set<int> audio_object_types;
190 217
191 bool has_sbr = false; 218 bool has_sbr = false;
192 for (size_t i = 0; i < codecs.size(); ++i) { 219 for (size_t i = 0; i < codecs.size(); ++i) {
193 std::string codec_id = codecs[i]; 220 std::string codec_id = codecs[i];
194 if (base::MatchPattern(codec_id, kMPEG2AACLCCodecInfo.pattern)) { 221 if (base::MatchPattern(codec_id, kMPEG2AACLCCodecInfo.pattern)) {
195 audio_object_types.insert(mp4::kISO_13818_7_AAC_LC); 222 audio_object_types.insert(mp4::kISO_13818_7_AAC_LC);
196 } else if (base::MatchPattern(codec_id, kMPEG4AACCodecInfo.pattern)) { 223 } else if (base::MatchPattern(codec_id, kMPEG4AACCodecInfo.pattern)) {
197 int audio_object_type = GetMP4AudioObjectType(codec_id, media_log); 224 int audio_object_type = GetMP4AudioObjectType(codec_id, media_log);
198 DCHECK_GT(audio_object_type, 0); 225 DCHECK_GT(audio_object_type, 0);
199 226
200 audio_object_types.insert(mp4::kISO_14496_3); 227 audio_object_types.insert(mp4::kISO_14496_3);
201 228
202 if (audio_object_type == kAACSBRObjectType || 229 if (audio_object_type == kAACSBRObjectType ||
203 audio_object_type == kAACPSObjectType) { 230 audio_object_type == kAACPSObjectType) {
204 has_sbr = true; 231 has_sbr = true;
205 break; 232 break;
206 } 233 }
234 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
235 } else if (base::MatchPattern(codec_id, kAC3CodecInfo1.pattern) ||
236 base::MatchPattern(codec_id, kAC3CodecInfo2.pattern) ||
237 base::MatchPattern(codec_id, kAC3CodecInfo3.pattern)) {
238 audio_object_types.insert(mp4::kAC3);
239 } else if (base::MatchPattern(codec_id, kEAC3CodecInfo1.pattern) ||
240 base::MatchPattern(codec_id, kEAC3CodecInfo2.pattern) ||
241 base::MatchPattern(codec_id, kEAC3CodecInfo3.pattern)) {
242 audio_object_types.insert(mp4::kEAC3);
243 #endif
207 } 244 }
208 } 245 }
209 246
210 return new mp4::MP4StreamParser(audio_object_types, has_sbr); 247 return new mp4::MP4StreamParser(audio_object_types, has_sbr);
211 } 248 }
212 249
213 static const CodecInfo kMP3CodecInfo = { NULL, CodecInfo::AUDIO, NULL, 250 static const CodecInfo kMP3CodecInfo = { NULL, CodecInfo::AUDIO, NULL,
214 CodecInfo::HISTOGRAM_MP3 }; 251 CodecInfo::HISTOGRAM_MP3 };
215 252
216 static const CodecInfo* kAudioMP3Codecs[] = { 253 static const CodecInfo* kAudioMP3Codecs[] = {
(...skipping 215 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

Powered by Google App Engine
This is Rietveld 408576698