| 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 <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" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/strings/pattern.h" | 12 #include "base/strings/pattern.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "media/base/media_switches.h" | 17 #include "media/base/media_switches.h" |
| 18 #include "media/formats/mpeg/adts_stream_parser.h" | 18 #include "media/formats/mpeg/adts_stream_parser.h" |
| 19 #include "media/formats/mpeg/mpeg1_audio_stream_parser.h" | 19 #include "media/formats/mpeg/mpeg1_audio_stream_parser.h" |
| 20 #include "media/formats/webm/webm_stream_parser.h" | 20 #include "media/formats/webm/webm_stream_parser.h" |
| 21 #include "media/media_features.h" |
| 21 | 22 |
| 22 #if defined(OS_ANDROID) | 23 #if defined(OS_ANDROID) |
| 23 #include "base/android/build_info.h" | 24 #include "base/android/build_info.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 #if defined(USE_PROPRIETARY_CODECS) | 27 #if defined(USE_PROPRIETARY_CODECS) |
| 27 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) | 28 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
| 28 #include "media/formats/mp2t/mp2t_stream_parser.h" | 29 #include "media/formats/mp2t/mp2t_stream_parser.h" |
| 29 #endif | 30 #endif |
| 30 #include "media/formats/mp4/es_descriptor.h" | 31 #include "media/formats/mp4/es_descriptor.h" |
| 31 #include "media/formats/mp4/mp4_stream_parser.h" | 32 #include "media/formats/mp4/mp4_stream_parser.h" |
| 32 #endif | 33 #endif |
| 33 | 34 |
| 34 namespace media { | 35 namespace media { |
| 35 | 36 |
| 36 typedef bool (*CodecIDValidatorFunction)( | 37 typedef bool (*CodecIDValidatorFunction)( |
| 37 const std::string& codecs_id, | 38 const std::string& codecs_id, |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 static const CodecInfo* kAudioADTSCodecs[] = { | 229 static const CodecInfo* kAudioADTSCodecs[] = { |
| 229 &kADTSCodecInfo, | 230 &kADTSCodecInfo, |
| 230 NULL | 231 NULL |
| 231 }; | 232 }; |
| 232 | 233 |
| 233 static StreamParser* BuildADTSParser(const std::vector<std::string>& codecs, | 234 static StreamParser* BuildADTSParser(const std::vector<std::string>& codecs, |
| 234 const scoped_refptr<MediaLog>& media_log) { | 235 const scoped_refptr<MediaLog>& media_log) { |
| 235 return new ADTSStreamParser(); | 236 return new ADTSStreamParser(); |
| 236 } | 237 } |
| 237 | 238 |
| 238 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) | 239 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
| 239 static const CodecInfo* kVideoMP2TCodecs[] = { | 240 static const CodecInfo* kVideoMP2TCodecs[] = { |
| 240 &kH264AVC1CodecInfo, | 241 &kH264AVC1CodecInfo, |
| 241 &kH264AVC3CodecInfo, | 242 &kH264AVC3CodecInfo, |
| 242 &kMPEG4AACCodecInfo, | 243 &kMPEG4AACCodecInfo, |
| 243 &kMPEG2AACLCCodecInfo, | 244 &kMPEG2AACLCCodecInfo, |
| 244 NULL | 245 NULL |
| 245 }; | 246 }; |
| 246 | 247 |
| 247 static StreamParser* BuildMP2TParser(const std::vector<std::string>& codecs, | 248 static StreamParser* BuildMP2TParser(const std::vector<std::string>& codecs, |
| 248 const scoped_refptr<MediaLog>& media_log) { | 249 const scoped_refptr<MediaLog>& media_log) { |
| 249 bool has_sbr = false; | 250 bool has_sbr = false; |
| 250 for (size_t i = 0; i < codecs.size(); ++i) { | 251 for (size_t i = 0; i < codecs.size(); ++i) { |
| 251 std::string codec_id = codecs[i]; | 252 std::string codec_id = codecs[i]; |
| 252 if (base::MatchPattern(codec_id, kMPEG4AACCodecInfo.pattern)) { | 253 if (base::MatchPattern(codec_id, kMPEG4AACCodecInfo.pattern)) { |
| 253 int audio_object_type = GetMP4AudioObjectType(codec_id, media_log); | 254 int audio_object_type = GetMP4AudioObjectType(codec_id, media_log); |
| 254 if (audio_object_type == kAACSBRObjectType || | 255 if (audio_object_type == kAACSBRObjectType || |
| 255 audio_object_type == kAACPSObjectType) { | 256 audio_object_type == kAACPSObjectType) { |
| 256 has_sbr = true; | 257 has_sbr = true; |
| 257 } | 258 } |
| 258 } | 259 } |
| 259 } | 260 } |
| 260 | 261 |
| 261 return new media::mp2t::Mp2tStreamParser(has_sbr); | 262 return new media::mp2t::Mp2tStreamParser(has_sbr); |
| 262 } | 263 } |
| 263 #endif | 264 #endif |
| 264 #endif | 265 #endif |
| 265 | 266 |
| 266 | |
| 267 static const SupportedTypeInfo kSupportedTypeInfo[] = { | 267 static const SupportedTypeInfo kSupportedTypeInfo[] = { |
| 268 { "video/webm", &BuildWebMParser, kVideoWebMCodecs }, | 268 {"video/webm", &BuildWebMParser, kVideoWebMCodecs}, |
| 269 { "audio/webm", &BuildWebMParser, kAudioWebMCodecs }, | 269 {"audio/webm", &BuildWebMParser, kAudioWebMCodecs}, |
| 270 #if defined(USE_PROPRIETARY_CODECS) | 270 #if defined(USE_PROPRIETARY_CODECS) |
| 271 { "audio/aac", &BuildADTSParser, kAudioADTSCodecs }, | 271 {"audio/aac", &BuildADTSParser, kAudioADTSCodecs}, |
| 272 { "audio/mpeg", &BuildMP3Parser, kAudioMP3Codecs }, | 272 {"audio/mpeg", &BuildMP3Parser, kAudioMP3Codecs}, |
| 273 { "video/mp4", &BuildMP4Parser, kVideoMP4Codecs }, | 273 {"video/mp4", &BuildMP4Parser, kVideoMP4Codecs}, |
| 274 { "audio/mp4", &BuildMP4Parser, kAudioMP4Codecs }, | 274 {"audio/mp4", &BuildMP4Parser, kAudioMP4Codecs}, |
| 275 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) | 275 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
| 276 { "video/mp2t", &BuildMP2TParser, kVideoMP2TCodecs }, | 276 {"video/mp2t", &BuildMP2TParser, kVideoMP2TCodecs}, |
| 277 #endif | 277 #endif |
| 278 #endif | 278 #endif |
| 279 }; | 279 }; |
| 280 | 280 |
| 281 // Verify that |codec_info| is supported on this platform. | 281 // Verify that |codec_info| is supported on this platform. |
| 282 // | 282 // |
| 283 // Returns true if |codec_info| is a valid audio/video codec and is allowed. | 283 // Returns true if |codec_info| is a valid audio/video codec and is allowed. |
| 284 // |audio_codecs| has |codec_info|.tag added to its list if |codec_info| is an | 284 // |audio_codecs| has |codec_info|.tag added to its list if |codec_info| is an |
| 285 // audio codec. |audio_codecs| may be NULL, in which case it is not updated. | 285 // audio codec. |audio_codecs| may be NULL, in which case it is not updated. |
| 286 // |video_codecs| has |codec_info|.tag added to its list if |codec_info| is a | 286 // |video_codecs| has |codec_info|.tag added to its list if |codec_info| is a |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 CodecInfo::HISTOGRAM_MAX + 1); | 432 CodecInfo::HISTOGRAM_MAX + 1); |
| 433 } | 433 } |
| 434 | 434 |
| 435 stream_parser.reset(factory_function(codecs, media_log)); | 435 stream_parser.reset(factory_function(codecs, media_log)); |
| 436 } | 436 } |
| 437 | 437 |
| 438 return stream_parser; | 438 return stream_parser; |
| 439 } | 439 } |
| 440 | 440 |
| 441 } // namespace media | 441 } // namespace media |
| OLD | NEW |