Chromium Code Reviews| Index: net/base/mime_util.cc |
| diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc |
| index 85f5d15b9411898e9fac2d44ef33f8a8307c4253..e058c1b1c350441d1127a544bbeb363c15adedff 100644 |
| --- a/net/base/mime_util.cc |
| +++ b/net/base/mime_util.cc |
| @@ -234,7 +234,8 @@ static const char* const supported_image_types[] = { |
| // A list of media types: http://en.wikipedia.org/wiki/Internet_media_type |
| // A comprehensive mime type list: http://plugindoc.mozdev.org/winmime.php |
| -static const char* const supported_media_types[] = { |
| +// This set of codecs is supported by all variations of Chromium. |
| +static const char* const common_media_types[] = { |
| // Ogg. |
| "audio/ogg", |
| "application/ogg", |
| @@ -247,8 +248,10 @@ static const char* const supported_media_types[] = { |
| "audio/webm", |
| "audio/wav", |
| "audio/x-wav", |
| +}; |
| -#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| +// List of proprietary types only supported by Google Chrome. |
| +static const char* const proprietary_media_types[] = { |
| // MPEG-4. |
| "video/mp4", |
| "video/x-m4v", |
| @@ -259,21 +262,17 @@ static const char* const supported_media_types[] = { |
| "audio/mp3", |
| "audio/x-mp3", |
| "audio/mpeg", |
| -#endif |
| }; |
| // List of supported codecs when passed in with <source type="...">. |
| +// This set of codecs is supported by all variations of Chromium. |
| // |
| // Refer to http://wiki.whatwg.org/wiki/Video_type_parameters#Browser_Support |
| // for more information. |
| // |
| // The codecs for WAV are integers as defined in Appendix A of RFC2361: |
| // http://tools.ietf.org/html/rfc2361 |
| -static const char* const supported_media_codecs[] = { |
| -#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| - "avc1", |
| - "mp4a", |
| -#endif |
| +static const char* const common_media_codecs[] = { |
| #if defined(ENABLE_MEDIA_CODEC_THEORA) |
| "theora", |
| #endif |
| @@ -282,6 +281,12 @@ static const char* const supported_media_codecs[] = { |
| "1" // WAVE_FORMAT_PCM. |
| }; |
| +// List of proprietary codecs only supported by Google Chrome. |
| +static const char* const proprietary_media_codecs[] = { |
| + "avc1", |
|
scherkus (not reviewing)
2012/04/11 20:15:56
de-indent by 2 spaces
ddorwin
2012/04/11 20:51:17
Done.
|
| + "mp4a" |
| +}; |
| + |
| // Note: does not include javascript types list (see supported_javascript_types) |
| static const char* const supported_non_image_types[] = { |
| "text/cache-manifest", |
| @@ -376,12 +381,20 @@ void MimeUtil::InitializeMimeTypeMaps() { |
| non_image_map_.insert(supported_non_image_types[i]); |
| for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) |
| non_image_map_.insert(supported_javascript_types[i]); |
| - for (size_t i = 0; i < arraysize(supported_media_types); ++i) |
| - non_image_map_.insert(supported_media_types[i]); |
| + for (size_t i = 0; i < arraysize(common_media_types); ++i) |
| + non_image_map_.insert(common_media_types[i]); |
| +#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| + for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) |
| + non_image_map_.insert(proprietary_media_types[i]); |
| +#endif |
| // Initialize the supported media types. |
| - for (size_t i = 0; i < arraysize(supported_media_types); ++i) |
| - media_map_.insert(supported_media_types[i]); |
| + for (size_t i = 0; i < arraysize(common_media_types); ++i) |
| + media_map_.insert(common_media_types[i]); |
| +#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| + for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) |
| + media_map_.insert(proprietary_media_types[i]); |
| +#endif |
| for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) |
| javascript_map_.insert(supported_javascript_types[i]); |
| @@ -389,8 +402,12 @@ void MimeUtil::InitializeMimeTypeMaps() { |
| for (size_t i = 0; i < arraysize(view_source_types); ++i) |
| view_source_map_.insert(view_source_types[i]); |
| - for (size_t i = 0; i < arraysize(supported_media_codecs); ++i) |
| - codecs_map_.insert(supported_media_codecs[i]); |
| + for (size_t i = 0; i < arraysize(common_media_codecs); ++i) |
| + codecs_map_.insert(common_media_codecs[i]); |
| +#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| + for (size_t i = 0; i < arraysize(proprietary_media_codecs); ++i) |
| + codecs_map_.insert(proprietary_media_codecs[i]); |
| +#endif |
| // Initialize the strict supported media types. |
| for (size_t i = 0; i < arraysize(format_codec_mappings); ++i) { |
| @@ -748,4 +765,28 @@ void GetExtensionsForMimeType(const std::string& mime_type, |
| HashSetToVector(&unique_extensions, extensions); |
| } |
| +void GetProprietaryMediaTypes(std::vector<std::string>* types) { |
| +// Unless/until WebM files are added to the media layout tests, we need to avoid |
| +// blacklisting mp4 and H.264 when Theora is not supported (and proprietary |
| +// codecs are) so that the media tests can still run. |
| +#if defined(ENABLE_MEDIA_CODEC_THEORA) || !defined(USE_PROPRIETARY_CODECS) |
| + for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) |
| + types->push_back(proprietary_media_types[i]); |
| +#else |
| + UNREFERENCED_PARAMETER(types); |
|
scherkus (not reviewing)
2012/04/11 20:15:56
nit: instead of this, what if we did types->clear(
ddorwin
2012/04/11 20:51:17
Done.
|
| +#endif |
| +} |
| + |
| +void GetProprietaryMediaCodecs(std::vector<std::string>* codecs) { |
| +// Unless/until WebM files are added to the media layout tests, we need to avoid |
| +// blacklisting mp4 and H.264 when Theora is not supported (and proprietary |
| +// codecs are) so that the media tests can still run. |
| +#if defined(ENABLE_MEDIA_CODEC_THEORA) || !defined(USE_PROPRIETARY_CODECS) |
| + for (size_t i = 0; i < arraysize(proprietary_media_codecs); ++i) |
| + codecs->push_back(proprietary_media_codecs[i]); |
| +#else |
| + UNREFERENCED_PARAMETER(codecs); |
|
scherkus (not reviewing)
2012/04/11 20:15:56
ditto
ddorwin
2012/04/11 20:51:17
Done.
|
| +#endif |
| +} |
| + |
| } // namespace net |