Chromium Code Reviews| Index: media/filters/stream_parser_factory.cc |
| diff --git a/media/filters/stream_parser_factory.cc b/media/filters/stream_parser_factory.cc |
| index c1587699fef8d9148a94a64d17e8922a46270303..31169b608b0ab8907f71269c3e39c74d66088f81 100644 |
| --- a/media/filters/stream_parser_factory.cc |
| +++ b/media/filters/stream_parser_factory.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/strings/string_util.h" |
| #include "media/base/media_log.h" |
| #include "media/base/media_switches.h" |
| +#include "media/mp3/mp3_stream_parser.h" |
| #include "media/webm/webm_stream_parser.h" |
| #if defined(USE_PROPRIETARY_CODECS) |
| @@ -37,6 +38,7 @@ struct CodecInfo { |
| HISTOGRAM_MPEG2AAC, |
| HISTOGRAM_MPEG4AAC, |
| HISTOGRAM_EAC3, |
| + HISTOGRAM_MP3, |
|
scherkus (not reviewing)
2013/08/30 00:06:11
update histograms.xml
acolwell GONE FROM CHROMIUM
2013/08/30 01:42:22
Done and added a comment to remind future develope
|
| HISTOGRAM_MAX // Must be the last entry. |
| }; |
| @@ -147,6 +149,7 @@ static const CodecInfo* kAudioMP4Codecs[] = { |
| static StreamParser* BuildMP4Parser( |
| const std::vector<std::string>& codecs, const LogCB& log_cb) { |
| std::set<int> audio_object_types; |
| + |
| bool has_sbr = false; |
| #if defined(ENABLE_EAC3_PLAYBACK) |
| bool enable_eac3 = CommandLine::ForCurrentProcess()->HasSwitch( |
| @@ -177,10 +180,26 @@ static StreamParser* BuildMP4Parser( |
| } |
| #endif |
| + |
| +static const CodecInfo kMP3CodecInfo = { NULL, CodecInfo::AUDIO, NULL, |
| + CodecInfo::HISTOGRAM_MP3 }; |
| + |
| +static const CodecInfo* kAudioMP3Codecs[] = { |
| + &kMP3CodecInfo, |
| + NULL |
| +}; |
| + |
| +static StreamParser* BuildMP3Parser( |
| + const std::vector<std::string>& codecs, const LogCB& log_cb) { |
| + return new mp3::MP3StreamParser(); |
| +} |
| + |
| + |
| static const SupportedTypeInfo kSupportedTypeInfo[] = { |
| { "video/webm", &BuildWebMParser, kVideoWebMCodecs }, |
| { "audio/webm", &BuildWebMParser, kAudioWebMCodecs }, |
| #if defined(USE_PROPRIETARY_CODECS) |
| + { "audio/mpeg", &BuildMP3Parser, kAudioMP3Codecs }, |
| { "video/mp4", &BuildMP4Parser, kVideoMP4Codecs }, |
| { "audio/mp4", &BuildMP4Parser, kAudioMP4Codecs }, |
| #endif |
| @@ -208,6 +227,7 @@ static bool VerifyCodec( |
| return false; |
| } |
| #endif |
| + |
| if (audio_codecs) |
| audio_codecs->push_back(codec_info->tag); |
| return true; |
| @@ -249,8 +269,23 @@ static bool CheckTypeAndCodecs( |
| for (size_t i = 0; i < arraysize(kSupportedTypeInfo); ++i) { |
| const SupportedTypeInfo& type_info = kSupportedTypeInfo[i]; |
| if (type == type_info.type) { |
| + if (codecs.empty()) { |
| + if (type_info.codecs == kAudioMP3Codecs && |
| + !CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableMP3StreamParser)) { |
| + DVLOG(1) << "MP3StreamParser is not enabled."; |
| + return false; |
| + } |
| + |
| + const CodecInfo* codec_info = type_info.codecs[0]; |
| + if (codec_info && !codec_info->pattern && |
| + VerifyCodec(codec_info, audio_codecs, video_codecs)) { |
| + |
| + if (factory_function) |
| + *factory_function = type_info.factory_function; |
| + return true; |
| + } |
| - if (codecs.size() == 0u) { |
| MEDIA_LOG(log_cb) << "A codecs parameter must be provided for '" |
| << type << "'"; |
| return false; |
| @@ -271,6 +306,7 @@ static bool CheckTypeAndCodecs( |
| break; // Since only 1 pattern will match, no need to check others. |
| } |
| } |
| + |
| if (!found_codec) { |
| MEDIA_LOG(log_cb) << "Codec '" << codec_id |
| << "' is not supported for '" << type << "'"; |