| Index: media/base/mime_util.cc
|
| diff --git a/media/base/mime_util.cc b/media/base/mime_util.cc
|
| index ff1d3369e1d6017a2274a0aeef4ef2d90f50d18f..69defba492cbad7cae7d7d97270816396335b949 100644
|
| --- a/media/base/mime_util.cc
|
| +++ b/media/base/mime_util.cc
|
| @@ -215,6 +215,8 @@ struct MediaFormat {
|
| // avc1.42E0xx - H.264 Baseline
|
| // avc1.4D40xx - H.264 Main
|
| // avc1.6400xx - H.264 High
|
| +// vp08.... - VP8
|
| +// vp09.... - VP9
|
| static const char kMP4AudioCodecsExpression[] =
|
| "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
|
| #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
|
| @@ -236,6 +238,8 @@ static const char kMP4VideoCodecsExpression[] =
|
| // are parsed and mapped to MimeUtil::Codec enum values.
|
| "hev1.1.6.L93.B0,"
|
| #endif
|
| + // This is not a complete list of supported vpx codecs.
|
| + "vp08.00.00.08.01.01.00.00,vp09.00.00.08.00.01.00.00,"
|
| "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
|
| #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
|
| // Only one variant each of ac3 and eac3 codec string is sufficient here,
|
| @@ -297,6 +301,8 @@ static const CodecIDMappings kUnambiguousCodecStringMap[] = {
|
| {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous.
|
| // avc1/avc3.XXXXXX may be unambiguous; handled by ParseH264CodecID().
|
| // hev1/hvc1.XXXXXX may be unambiguous; handled by ParseHEVCCodecID().
|
| + // vp08/vp09.xx.xx.xx.xx.xx.xx.xx may be unambiguous; handled by
|
| + // ParseVpxCodecID().
|
| {"mp3", MimeUtil::MP3},
|
| {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN},
|
| {"mp4a.67", MimeUtil::MPEG2_AAC_LC},
|
| @@ -339,6 +345,10 @@ static const CodecIDMappings kAmbiguousCodecStringMap[] = {
|
| {"avc1", MimeUtil::H264_BASELINE},
|
| {"avc3", MimeUtil::H264_BASELINE},
|
| // avc1/avc3.XXXXXX may be ambiguous; handled by ParseH264CodecID().
|
| + {"vp08", MimeUtil::VP8},
|
| + {"vp09", MimeUtil::VP9},
|
| + // vp08/vp09.xx.xx.xx.xx.xx.xx.xx may be ambiguous; handled by
|
| + // ParseVpxCodecID().
|
| };
|
|
|
| #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER)
|
| @@ -633,6 +643,73 @@ static bool ParseHEVCCodecID(const std::string& codec_id,
|
| }
|
| #endif
|
|
|
| +// Handle parsing of vpx codec IDs.
|
| +static bool ParseVpxCodecID(const std::string& codec_id,
|
| + MimeUtil::Codec* codec,
|
| + bool* is_ambiguous) {
|
| + std::vector<std::string> fields = base::SplitString(
|
| + codec_id, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
|
| + DCHECK_GE(fields.size(), 1u);
|
| + if (fields[0] == "vp08") {
|
| + *codec = MimeUtil::VP8;
|
| + } else if (fields[0] == "vp09") {
|
| + *codec = MimeUtil::VP9;
|
| + } else {
|
| + return false;
|
| + }
|
| +
|
| + if (fields.size() > 8)
|
| + return false;
|
| +
|
| + std::vector<int> values;
|
| + for (size_t i = 1; i < fields.size(); ++i) {
|
| + // Missing value is ambiguous.
|
| + if (fields[i] == "") {
|
| + *is_ambiguous = true;
|
| + return true;
|
| + }
|
| + int value;
|
| + if (!base::StringToInt(fields[i], &value))
|
| + return false;
|
| + if (value < 0)
|
| + return false;
|
| + values.push_back(value);
|
| + }
|
| +
|
| + *is_ambiguous = true;
|
| + // The spec specifies 8 fields (7 values excluding the first codec field).
|
| + // It is ambiguous with missing fields.
|
| + if (values.size() < 7)
|
| + return true;
|
| +
|
| + const int profile = values[0];
|
| + if (profile > 3)
|
| + return true;
|
| +
|
| + const int bit_depth = values[2];
|
| + if (bit_depth != 8 && bit_depth != 10 && bit_depth != 12)
|
| + return true;
|
| +
|
| + const int color_space = values[3];
|
| + if (color_space > 7)
|
| + return true;
|
| +
|
| + const int chroma_subsampling = values[4];
|
| + if (chroma_subsampling > 3)
|
| + return true;
|
| +
|
| + const int transfer_function = values[5];
|
| + if (transfer_function > 1)
|
| + return true;
|
| +
|
| + const int video_full_range_flag = values[6];
|
| + if (video_full_range_flag > 1)
|
| + return true;
|
| +
|
| + *is_ambiguous = false;
|
| + return true;
|
| +}
|
| +
|
| bool MimeUtil::StringToCodec(const std::string& codec_id,
|
| Codec* codec,
|
| bool* is_ambiguous) const {
|
| @@ -645,14 +722,21 @@ bool MimeUtil::StringToCodec(const std::string& codec_id,
|
| }
|
|
|
| // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is
|
| - // either H.264 or HEVC/H.265 codec ID because currently those are the only
|
| - // ones that are not added to the |string_to_codec_map_| and require parsing.
|
| + // either VPx, H.264 or HEVC/H.265 codec ID because currently those are the
|
| + // only ones that are not added to the |string_to_codec_map_| and require
|
| + // parsing.
|
| #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
|
| if (ParseHEVCCodecID(codec_id, codec, is_ambiguous)) {
|
| return true;
|
| }
|
| #endif
|
| - return ParseH264CodecID(codec_id, codec, is_ambiguous);
|
| + if (ParseH264CodecID(codec_id, codec, is_ambiguous)) {
|
| + return true;
|
| + }
|
| + if (ParseVpxCodecID(codec_id, codec, is_ambiguous)) {
|
| + return true;
|
| + }
|
| + return false;
|
| }
|
|
|
| bool MimeUtil::IsCodecSupported(Codec codec) const {
|
|
|