Chromium Code Reviews| Index: media/base/mime_util.cc |
| diff --git a/media/base/mime_util.cc b/media/base/mime_util.cc |
| index ff1d3369e1d6017a2274a0aeef4ef2d90f50d18f..f0c5199965c03e338fc6c02f25f9cbee3e6508de 100644 |
| --- a/media/base/mime_util.cc |
| +++ b/media/base/mime_util.cc |
| @@ -44,8 +44,10 @@ class MimeUtil { |
| H264_MAIN, |
| H264_HIGH, |
| HEVC_MAIN, |
| - VP8, |
| - VP9, |
| + WEBM_VP8, |
|
ddorwin
2016/02/24 22:44:33
We may not need these anymore. We can now (after r
kqyang
2016/03/01 01:18:52
Removed and pass MIME type to StringToCodec instea
|
| + WEBM_VP9, |
| + MPEG4_VP8, |
|
ddorwin
2016/02/24 22:44:33
As discussed, unless there is a demand for VP8 in
kqyang
2016/03/01 01:18:52
Removed.
|
| + MPEG4_VP9, |
| THEORA |
| }; |
| @@ -151,7 +153,7 @@ static bool IsCodecSupportedOnAndroid(MimeUtil::Codec codec) { |
| case MimeUtil::H264_BASELINE: |
| case MimeUtil::H264_MAIN: |
| case MimeUtil::H264_HIGH: |
| - case MimeUtil::VP8: |
| + case MimeUtil::WEBM_VP8: |
| return true; |
| case MimeUtil::AC3: |
| @@ -178,12 +180,18 @@ static bool IsCodecSupportedOnAndroid(MimeUtil::Codec codec) { |
| return false; |
| #endif |
| - case MimeUtil::VP9: |
| + case MimeUtil::WEBM_VP9: |
| // VP9 is supported only in KitKat+ (API Level 19). |
| return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; |
| case MimeUtil::THEORA: |
| return false; |
| + |
| + case MimeUtil::MPEG4_VP8: |
| + case MimeUtil::MPEG4_VP9: |
| + // TODO(kqyang): Verify if it is supported in Android. Return false for |
|
ddorwin
2016/02/25 00:27:47
This will work with the unified pipeline (see new
|
| + // now. |
| + return false; |
| } |
| return false; |
| @@ -215,6 +223,8 @@ struct MediaFormat { |
| // avc1.42E0xx - H.264 Baseline |
| // avc1.4D40xx - H.264 Main |
| // avc1.6400xx - H.264 High |
| +// vp08.... - MPEG4 VP8 |
| +// vp09.... - MPEG4 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,12 +246,17 @@ static const char kMP4VideoCodecsExpression[] = |
| // are parsed and mapped to MimeUtil::Codec enum values. |
| "hev1.1.6.L93.B0," |
| #endif |
| - "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, |
| // since these strings are parsed and mapped to MimeUtil::Codec enum values. |
| "ac-3,ec-3," |
| #endif |
| +#if BUILDFLAG(ENABLE_MP4_VP8_VP9_DEMUXING) |
| + // This is not a complete list of supported vpx codecs. Similar to avc1 |
| + // comments above. |
| + "vp08.00.00.08.01.01.00.00,vp09.00.00.08.00.01.00.00," |
| +#endif |
| + "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," |
| "mp4a.40.05,mp4a.40.29"; |
| #endif // USE_PROPRIETARY_CODECS |
| @@ -297,6 +312,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}, |
| @@ -324,10 +341,10 @@ static const CodecIDMappings kUnambiguousCodecStringMap[] = { |
| #endif |
| {"vorbis", MimeUtil::VORBIS}, |
| {"opus", MimeUtil::OPUS}, |
| - {"vp8", MimeUtil::VP8}, |
| - {"vp8.0", MimeUtil::VP8}, |
| - {"vp9", MimeUtil::VP9}, |
| - {"vp9.0", MimeUtil::VP9}, |
| + {"vp8", MimeUtil::WEBM_VP8}, |
| + {"vp8.0", MimeUtil::WEBM_VP8}, |
| + {"vp9", MimeUtil::WEBM_VP9}, |
| + {"vp9.0", MimeUtil::WEBM_VP9}, |
| {"theora", MimeUtil::THEORA}}; |
| // List of codec IDs that are ambiguous and don't provide |
| @@ -633,6 +650,74 @@ static bool ParseHEVCCodecID(const std::string& codec_id, |
| } |
| #endif |
| +#if BUILDFLAG(ENABLE_MP4_VP8_VP9_DEMUXING) |
| +// 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); |
| + if (fields.size() < 1) |
| + return false; |
| + |
| + if (fields[0] == "vp08") { |
| + *codec = MimeUtil::MPEG4_VP8; |
| + } else if (fields[0] == "vp09") { |
| + *codec = MimeUtil::MPEG4_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 not allowed. |
| + if (fields[i] == "") |
| + return false; |
| + int value; |
| + if (!base::StringToInt(fields[i], &value)) |
| + return false; |
| + if (value < 0) |
| + return false; |
| + values.push_back(value); |
| + } |
| + |
| + // The spec specifies 8 fields (7 values excluding the first codec field). |
| + // We do not allow missing fields. |
| + if (values.size() < 7) |
| + return false; |
| + |
| + const int profile = values[0]; |
| + if (profile > 3) |
| + return false; |
| + |
| + const int bit_depth = values[2]; |
| + if (bit_depth != 8 && bit_depth != 10 && bit_depth != 12) |
| + return false; |
| + |
| + const int color_space = values[3]; |
| + if (color_space > 7) |
| + return false; |
| + |
| + const int chroma_subsampling = values[4]; |
| + if (chroma_subsampling > 3) |
| + return false; |
| + |
| + const int transfer_function = values[5]; |
| + if (transfer_function > 1) |
| + return false; |
| + |
| + const int video_full_range_flag = values[6]; |
| + if (video_full_range_flag > 1) |
| + return false; |
| + |
| + *is_ambiguous = false; |
| + return true; |
| +} |
| +#endif |
| + |
| bool MimeUtil::StringToCodec(const std::string& codec_id, |
| Codec* codec, |
| bool* is_ambiguous) const { |
| @@ -645,14 +730,23 @@ 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 H.264, HEVC/H.265, VP8 or VP9 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 BUILDFLAG(ENABLE_MP4_VP8_VP9_DEMUXING) |
| + if (ParseVpxCodecID(codec_id, codec, is_ambiguous)) { |
| + return true; |
| + } |
| +#endif |
| + return false; |
| } |
| bool MimeUtil::IsCodecSupported(Codec codec) const { |
| @@ -682,13 +776,15 @@ bool MimeUtil::IsCodecProprietary(Codec codec) const { |
| case H264_MAIN: |
| case H264_HIGH: |
| case HEVC_MAIN: |
| + case MPEG4_VP8: |
|
ddorwin
2016/02/24 22:44:33
These codecs aren't actually proprietary. Really,
kqyang
2016/03/01 01:18:52
Removed.
|
| + case MPEG4_VP9: |
| return true; |
| case PCM: |
| case VORBIS: |
| case OPUS: |
| - case VP8: |
| - case VP9: |
| + case WEBM_VP8: |
| + case WEBM_VP9: |
| case THEORA: |
| return false; |
| } |