Chromium Code Reviews| Index: net/base/mime_util.cc |
| diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc |
| index 3d34428b8e503fa0a3f2ac5d8c0c4e58dc9e3100..63f5130d6febddf548649fcff53d1238b0620928 100644 |
| --- a/net/base/mime_util.cc |
| +++ b/net/base/mime_util.cc |
| @@ -7,6 +7,9 @@ |
| #include <map> |
| #include <string> |
| +#if defined(OS_ANDROID) |
| +#include "base/android/build_info.h" |
|
scherkus (not reviewing)
2013/11/09 00:20:05
typically #if #includes are put after the first bl
vignesh
2013/11/11 19:55:34
Done.
|
| +#endif |
| #include "base/containers/hash_tables.h" |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| @@ -293,23 +296,36 @@ static const char* const proprietary_media_types[] = { |
| "audio/mpeg", |
| }; |
| +struct CommonMediaCodec { |
| + const char* codec; |
| +#if defined(OS_ANDROID) |
| + const int min_api_level; |
| +#endif |
| +}; |
| + |
| // List of supported codecs when passed in with <source type="...">. |
| // This set of codecs is supported by all variations of Chromium. |
| +// For android this also lists the minimum API level from which the codec is |
| +// supported. |
| // |
| // 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 common_media_codecs[] = { |
| -#if !defined(OS_ANDROID) // Android doesn't support Ogg Theora. |
| - "theora", |
| - "vp9", // TODO(tomfinegan): Move vp9 back down with vp8 once VP9 is supported |
| - // on Android. https://crbug.com/285016 |
| +static const CommonMediaCodec common_media_codecs[] = { |
| +#if !defined(OS_ANDROID) |
| + { "theora" }, |
| + { "vorbis" }, |
| + { "vp8" }, |
| + { "vp9" }, |
| + { "1" } // WAVE_FORMAT_PCM. |
| +#else |
| + { "vorbis", 0 }, |
| + { "vp8", 0 }, |
| + { "vp9", 19 }, // VP9 supported only in Kitkat+. |
|
scherkus (not reviewing)
2013/11/09 00:20:05
it seems unfortunate to duplicate both lists and m
vignesh
2013/11/11 16:07:10
if duplication is your only concern, then how abou
vignesh
2013/11/11 19:55:34
Hardcoding this as discussed on other comments.
|
| + { "1", 0 } // WAVE_FORMAT_PCM. |
| #endif |
| - "vorbis", |
| - "vp8", |
| - "1" // WAVE_FORMAT_PCM. |
| }; |
| // List of proprietary codecs only supported by Google Chrome. |
| @@ -412,18 +428,21 @@ static const char* const supported_javascript_types[] = { |
| struct MediaFormatStrict { |
| const char* mime_type; |
| const char* codecs_list; |
| +#if defined(OS_ANDROID) |
| + const int* min_api_levels; |
| +#endif |
| }; |
| static const MediaFormatStrict format_codec_mappings[] = { |
| - // TODO(tomfinegan): Remove this if/else when VP9 is supported on Android. |
| - // https://crbug.com/285016 |
| #if !defined(OS_ANDROID) |
| { "video/webm", "vorbis,vp8,vp8.0,vp9,vp9.0" }, |
| -#else |
| - { "video/webm", "vorbis,vp8,vp8.0" }, |
| -#endif |
| { "audio/webm", "vorbis" }, |
| { "audio/wav", "1" } |
| +#else |
| + { "video/webm", "vorbis,vp8,vp8.0,vp9,vp9.0", (int[]) { 0, 0, 0, 19, 19 } }, |
| + { "audio/webm", "vorbis", (int[]) { 0 } }, |
| + { "audio/wav", "1", (int[]) { 0 } } |
| +#endif |
| }; |
| MimeUtil::MimeUtil() { |
| @@ -472,7 +491,11 @@ void MimeUtil::InitializeMimeTypeMaps() { |
| javascript_map_.insert(supported_javascript_types[i]); |
| for (size_t i = 0; i < arraysize(common_media_codecs); ++i) |
|
scherkus (not reviewing)
2013/11/09 00:31:00
we'll also need { }s for this for loop and one bel
vignesh
2013/11/11 19:55:34
Done.
|
| - codecs_map_.insert(common_media_codecs[i]); |
| +#if defined(OS_ANDROID) |
| + if (base::android::BuildInfo::GetInstance()->sdk_int() >= |
| + common_media_codecs[i].min_api_level) |
| +#endif |
| + codecs_map_.insert(common_media_codecs[i].codec); |
| #if defined(USE_PROPRIETARY_CODECS) |
| for (size_t i = 0; i < arraysize(proprietary_media_codecs); ++i) |
| codecs_map_.insert(proprietary_media_codecs[i]); |
| @@ -487,6 +510,10 @@ void MimeUtil::InitializeMimeTypeMaps() { |
| MimeMappings codecs; |
| for (size_t j = 0; j < mime_type_codecs.size(); ++j) |
| +#if defined(OS_ANDROID) |
| + if (base::android::BuildInfo::GetInstance()->sdk_int() >= |
| + format_codec_mappings[i].min_api_levels[j]) |
| +#endif |
| codecs.insert(mime_type_codecs[j]); |
| strict_format_map_[format_codec_mappings[i].mime_type] = codecs; |
| } |