Skip to content

Commit

Permalink
Document some quirks of media MIME type code and reference related bugs
Browse files Browse the repository at this point in the history
BUG=461009,461012

Review URL: https://codereview.chromium.org/952673002

Cr-Commit-Position: refs/heads/master@{#317870}
  • Loading branch information
ddorwin authored and Commit bot committed Feb 24, 2015
1 parent 4e2f22b commit 1d7ceee
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions net/base/mime_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,18 @@ static const char kMP4AudioCodecsExpression[] =
"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";
static const char kMP4VideoCodecsExpression[] =
// This is not a complete list of supported avc1 codecs. It is simply used
// to register support for the corresponding Codec enum. Instead of using
// strings in these three arrays, we should use the Codec enum values.
// This will avoid confusion and unnecessary parsing at runtime.
// kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only
// mapping from strings to codecs. See crbug.com/461009.
"avc1.42E00A,avc1.4D400A,avc1.64000A,"
"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";

// These containers are also included in
// common_media_types/proprietary_media_types. See crbug.com/461012.
static const MediaFormatStrict format_codec_mappings[] = {
{"video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0"},
{"audio/webm", "opus,vorbis"},
Expand Down Expand Up @@ -561,8 +569,9 @@ struct CodecIDMappings {
// codec and profile being requested.
//
// The "mp4a" strings come from RFC 6381.
static const CodecIDMappings kUnambiguousCodecIDs[] = {
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().
{"mp3", MimeUtil::MP3},
{"mp4a.66", MimeUtil::MPEG2_AAC_MAIN},
{"mp4a.67", MimeUtil::MPEG2_AAC_LC},
Expand All @@ -586,10 +595,11 @@ static const CodecIDMappings kUnambiguousCodecIDs[] = {
// enough information to determine the codec and profile.
// The codec in these entries indicate the codec and profile
// we assume the user is trying to indicate.
static const CodecIDMappings kAmbiguousCodecIDs[] = {
{ "mp4a.40", MimeUtil::MPEG4_AAC_LC },
{ "avc1", MimeUtil::H264_BASELINE },
{ "avc3", MimeUtil::H264_BASELINE },
static const CodecIDMappings kAmbiguousCodecStringMap[] = {
{"mp4a.40", MimeUtil::MPEG4_AAC_LC},
{"avc1", MimeUtil::H264_BASELINE},
{"avc3", MimeUtil::H264_BASELINE},
// avc1/avc3.XXXXXX may be ambiguous; handled by ParseH264CodecID().
};

MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) {
Expand Down Expand Up @@ -664,14 +674,14 @@ void MimeUtil::InitializeMimeTypeMaps() {
for (size_t i = 0; i < arraysize(supported_javascript_types); ++i)
javascript_map_.insert(supported_javascript_types[i]);

for (size_t i = 0; i < arraysize(kUnambiguousCodecIDs); ++i) {
string_to_codec_map_[kUnambiguousCodecIDs[i].codec_id] =
CodecEntry(kUnambiguousCodecIDs[i].codec, false);
for (size_t i = 0; i < arraysize(kUnambiguousCodecStringMap); ++i) {
string_to_codec_map_[kUnambiguousCodecStringMap[i].codec_id] =
CodecEntry(kUnambiguousCodecStringMap[i].codec, false);
}

for (size_t i = 0; i < arraysize(kAmbiguousCodecIDs); ++i) {
string_to_codec_map_[kAmbiguousCodecIDs[i].codec_id] =
CodecEntry(kAmbiguousCodecIDs[i].codec, true);
for (size_t i = 0; i < arraysize(kAmbiguousCodecStringMap); ++i) {
string_to_codec_map_[kAmbiguousCodecStringMap[i].codec_id] =
CodecEntry(kAmbiguousCodecStringMap[i].codec, true);
}

// Initialize the strict supported media types.
Expand Down

0 comments on commit 1d7ceee

Please sign in to comment.