Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "media/base/media.h" | |
| 17 #include "media/base/mime_util.h" | 18 #include "media/base/mime_util.h" |
| 18 #include "media/media_features.h" | 19 #include "media/media_features.h" |
| 19 | 20 |
| 20 #if defined(OS_ANDROID) | 21 #if defined(OS_ANDROID) |
| 21 #include "base/android/build_info.h" | 22 #include "base/android/build_info.h" |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 namespace media { | 25 namespace media { |
| 25 | 26 |
| 26 // Singleton utility class for mime types. | 27 // Singleton utility class for mime types. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 | 157 |
| 157 case MimeUtil::AC3: | 158 case MimeUtil::AC3: |
| 158 case MimeUtil::EAC3: | 159 case MimeUtil::EAC3: |
| 159 // TODO(servolk): Revisit this for AC3/EAC3 support on AndroidTV | 160 // TODO(servolk): Revisit this for AC3/EAC3 support on AndroidTV |
| 160 return false; | 161 return false; |
| 161 | 162 |
| 162 case MimeUtil::MPEG2_AAC_LC: | 163 case MimeUtil::MPEG2_AAC_LC: |
| 163 case MimeUtil::MPEG2_AAC_MAIN: | 164 case MimeUtil::MPEG2_AAC_MAIN: |
| 164 case MimeUtil::MPEG2_AAC_SSR: | 165 case MimeUtil::MPEG2_AAC_SSR: |
| 165 // MPEG-2 variants of AAC are not supported on Android. | 166 // MPEG-2 variants of AAC are not supported on Android. |
| 166 return false; | 167 return false; |
|
ddorwin
2016/02/11 21:08:24
return IsUnifiedMediaPipelineEnabled()?
DaleCurtis
2016/02/11 22:04:53
Done.
| |
| 167 | 168 |
| 168 case MimeUtil::OPUS: | 169 case MimeUtil::OPUS: |
| 169 // Opus is supported only in Lollipop+ (API Level 21). | 170 // Opus is supported only in Lollipop+ (API Level 21). |
| 170 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; | 171 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21 || |
| 172 IsUnifiedMediaPipelineEnabled(); | |
| 171 | 173 |
| 172 case MimeUtil::HEVC_MAIN: | 174 case MimeUtil::HEVC_MAIN: |
| 173 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 175 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 174 // HEVC/H.265 is supported in Lollipop+ (API Level 21), according to | 176 // HEVC/H.265 is supported in Lollipop+ (API Level 21), according to |
| 175 // http://developer.android.com/reference/android/media/MediaFormat.html | 177 // http://developer.android.com/reference/android/media/MediaFormat.html |
| 176 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; | 178 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; |
| 177 #else | 179 #else |
| 178 return false; | 180 return false; |
| 179 #endif | 181 #endif |
| 180 | 182 |
| 181 case MimeUtil::VP9: | 183 case MimeUtil::VP9: |
| 182 // VP9 is supported only in KitKat+ (API Level 19). | 184 // VP9 is supported only in KitKat+ (API Level 19). |
| 183 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; | 185 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19 || |
| 186 IsUnifiedMediaPipelineEnabled(); | |
| 184 | 187 |
| 185 case MimeUtil::THEORA: | 188 case MimeUtil::THEORA: |
| 186 return false; | 189 return false; |
| 187 } | 190 } |
| 188 | 191 |
| 189 return false; | 192 return false; |
| 190 } | 193 } |
| 191 #endif | 194 #endif |
| 192 | 195 |
| 193 enum MediaFormatType { COMMON, PROPRIETARY }; | 196 enum MediaFormatType { COMMON, PROPRIETARY }; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 | 250 |
| 248 // A list of media types (https://en.wikipedia.org/wiki/Media_type) and | 251 // A list of media types (https://en.wikipedia.org/wiki/Media_type) and |
| 249 // corresponding media codecs supported by these types/containers. | 252 // corresponding media codecs supported by these types/containers. |
| 250 // Media formats marked as PROPRIETARY are not supported by Chromium, only | 253 // Media formats marked as PROPRIETARY are not supported by Chromium, only |
| 251 // Google Chrome browser supports them. | 254 // Google Chrome browser supports them. |
| 252 static const MediaFormat kFormatCodecMappings[] = { | 255 static const MediaFormat kFormatCodecMappings[] = { |
| 253 {"video/webm", COMMON, "opus,vorbis,vp8,vp8.0,vp9,vp9.0"}, | 256 {"video/webm", COMMON, "opus,vorbis,vp8,vp8.0,vp9,vp9.0"}, |
| 254 {"audio/webm", COMMON, "opus,vorbis"}, | 257 {"audio/webm", COMMON, "opus,vorbis"}, |
| 255 {"audio/wav", COMMON, "1"}, | 258 {"audio/wav", COMMON, "1"}, |
| 256 {"audio/x-wav", COMMON, "1"}, | 259 {"audio/x-wav", COMMON, "1"}, |
| 257 #if defined(OS_ANDROID) | 260 // Note: Theora is not supported on Android and will be rejected during the |
| 258 // Android does not support Opus in Ogg container. | 261 // call to IsCodecSupportedOnAndroid(). |
| 259 // Android does not support Theora and thus video/ogg. | |
| 260 {"audio/ogg", COMMON, "vorbis"}, | |
| 261 {"application/ogg", COMMON, "vorbis"}, | |
| 262 #else | |
| 263 {"video/ogg", COMMON, "opus,theora,vorbis"}, | 262 {"video/ogg", COMMON, "opus,theora,vorbis"}, |
|
ddorwin
2016/02/11 21:08:24
Previously, "VIDEO/ogg" was not supported on Andro
DaleCurtis
2016/02/11 22:04:53
Ah, yeah I missed that, it seems that restriction
| |
| 264 {"audio/ogg", COMMON, "opus,vorbis"}, | 263 {"audio/ogg", COMMON, "opus,vorbis"}, |
| 265 {"application/ogg", COMMON, "opus,theora,vorbis"}, | 264 {"application/ogg", COMMON, "opus,theora,vorbis"}, |
| 266 #endif | |
| 267 #if defined(USE_PROPRIETARY_CODECS) | 265 #if defined(USE_PROPRIETARY_CODECS) |
| 268 {"audio/mpeg", PROPRIETARY, "mp3"}, | 266 {"audio/mpeg", PROPRIETARY, "mp3"}, |
| 269 {"audio/mp3", PROPRIETARY, ""}, | 267 {"audio/mp3", PROPRIETARY, ""}, |
| 270 {"audio/x-mp3", PROPRIETARY, ""}, | 268 {"audio/x-mp3", PROPRIETARY, ""}, |
| 271 {"audio/aac", PROPRIETARY, ""}, // AAC / ADTS | 269 {"audio/aac", PROPRIETARY, ""}, // AAC / ADTS |
| 272 {"audio/mp4", PROPRIETARY, kMP4AudioCodecsExpression}, | 270 {"audio/mp4", PROPRIETARY, kMP4AudioCodecsExpression}, |
| 273 {"audio/x-m4a", PROPRIETARY, kMP4AudioCodecsExpression}, | 271 {"audio/x-m4a", PROPRIETARY, kMP4AudioCodecsExpression}, |
| 274 {"video/mp4", PROPRIETARY, kMP4VideoCodecsExpression}, | 272 {"video/mp4", PROPRIETARY, kMP4VideoCodecsExpression}, |
| 275 {"video/x-m4v", PROPRIETARY, kMP4VideoCodecsExpression}, | 273 {"video/x-m4v", PROPRIETARY, kMP4VideoCodecsExpression}, |
| 276 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 274 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 bool is_ambiguous = true; | 445 bool is_ambiguous = true; |
| 448 CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous)); | 446 CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous)); |
| 449 DCHECK(!is_ambiguous); | 447 DCHECK(!is_ambiguous); |
| 450 codecs.insert(codec); | 448 codecs.insert(codec); |
| 451 } | 449 } |
| 452 | 450 |
| 453 media_format_map_[kFormatCodecMappings[i].mime_type] = codecs; | 451 media_format_map_[kFormatCodecMappings[i].mime_type] = codecs; |
| 454 } | 452 } |
| 455 } | 453 } |
| 456 | 454 |
| 457 bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const { | 455 bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const { |
|
ddorwin
2016/02/11 21:08:24
"video/ogg" will now succeed here. This is called
DaleCurtis
2016/02/11 22:04:53
Done.
| |
| 458 return media_format_map_.find(base::ToLowerASCII(mime_type)) != | 456 return media_format_map_.find(base::ToLowerASCII(mime_type)) != |
| 459 media_format_map_.end(); | 457 media_format_map_.end(); |
| 460 } | 458 } |
| 461 | 459 |
| 462 void MimeUtil::ParseCodecString(const std::string& codecs, | 460 void MimeUtil::ParseCodecString(const std::string& codecs, |
| 463 std::vector<std::string>* codecs_out, | 461 std::vector<std::string>* codecs_out, |
| 464 bool strip) { | 462 bool strip) { |
| 465 *codecs_out = base::SplitString( | 463 *codecs_out = base::SplitString( |
| 466 base::TrimString(codecs, "\"", base::TRIM_ALL), | 464 base::TrimString(codecs, "\"", base::TRIM_ALL), |
| 467 ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 465 ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 734 std::vector<std::string>* codecs_out, | 732 std::vector<std::string>* codecs_out, |
| 735 const bool strip) { | 733 const bool strip) { |
| 736 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); | 734 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); |
| 737 } | 735 } |
| 738 | 736 |
| 739 void RemoveProprietaryMediaTypesAndCodecsForTests() { | 737 void RemoveProprietaryMediaTypesAndCodecsForTests() { |
| 740 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); | 738 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); |
| 741 } | 739 } |
| 742 | 740 |
| 743 } // namespace media | 741 } // namespace media |
| OLD | NEW |