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 "media/base/mime_util_internal.h" | 5 #include "media/base/mime_util_internal.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 // mp4a.40.2 - MPEG-4 AAC LC | 38 // mp4a.40.2 - MPEG-4 AAC LC |
| 39 // mp4a.40.02 - MPEG-4 AAC LC (leading 0 in aud-oti for compatibility) | 39 // mp4a.40.02 - MPEG-4 AAC LC (leading 0 in aud-oti for compatibility) |
| 40 // mp4a.40.5 - MPEG-4 HE-AAC v1 (AAC LC + SBR) | 40 // mp4a.40.5 - MPEG-4 HE-AAC v1 (AAC LC + SBR) |
| 41 // mp4a.40.05 - MPEG-4 HE-AAC v1 (AAC LC + SBR) (leading 0 in aud-oti for | 41 // mp4a.40.05 - MPEG-4 HE-AAC v1 (AAC LC + SBR) (leading 0 in aud-oti for |
| 42 // compatibility) | 42 // compatibility) |
| 43 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS) | 43 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS) |
| 44 // | 44 // |
| 45 // avc1.42E0xx - H.264 Baseline | 45 // avc1.42E0xx - H.264 Baseline |
| 46 // avc1.4D40xx - H.264 Main | 46 // avc1.4D40xx - H.264 Main |
| 47 // avc1.6400xx - H.264 High | 47 // avc1.6400xx - H.264 High |
| 48 // vp09.... - VP9 | |
| 48 static const char kMP4AudioCodecsExpression[] = | 49 static const char kMP4AudioCodecsExpression[] = |
| 49 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," | 50 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," |
| 50 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 51 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 51 // Only one variant each of ac3 and eac3 codec string is sufficient here, | 52 // Only one variant each of ac3 and eac3 codec string is sufficient here, |
| 52 // since these strings are parsed and mapped to MimeUtil::Codec enum values. | 53 // since these strings are parsed and mapped to MimeUtil::Codec enum values. |
| 53 "ac-3,ec-3," | 54 "ac-3,ec-3," |
| 54 #endif | 55 #endif |
| 55 "mp4a.40.05,mp4a.40.29"; | 56 "mp4a.40.05,mp4a.40.29"; |
| 56 static const char kMP4VideoCodecsExpression[] = | 57 static const char kMP4VideoCodecsExpression[] = |
| 57 // This is not a complete list of supported avc1 codecs. It is simply used | 58 // This is not a complete list of supported avc1 codecs. It is simply used |
| 58 // to register support for the corresponding Codec enum. Instead of using | 59 // to register support for the corresponding Codec enum. Instead of using |
| 59 // strings in these three arrays, we should use the Codec enum values. | 60 // strings in these three arrays, we should use the Codec enum values. |
| 60 // This will avoid confusion and unnecessary parsing at runtime. | 61 // This will avoid confusion and unnecessary parsing at runtime. |
| 61 // kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only | 62 // kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only |
| 62 // mapping from strings to codecs. See crbug.com/461009. | 63 // mapping from strings to codecs. See crbug.com/461009. |
| 63 "avc1.42E00A,avc1.4D400A,avc1.64000A," | 64 "avc1.42E00A,avc1.4D400A,avc1.64000A," |
| 64 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 65 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 65 // Any valid unambiguous HEVC codec id will work here, since these strings | 66 // Any valid unambiguous HEVC codec id will work here, since these strings |
| 66 // are parsed and mapped to MimeUtil::Codec enum values. | 67 // are parsed and mapped to MimeUtil::Codec enum values. |
| 67 "hev1.1.6.L93.B0," | 68 "hev1.1.6.L93.B0," |
| 68 #endif | 69 #endif |
| 70 #if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING) | |
| 71 // This is not a complete list of supported vp9 codecs. Similar to avc1 | |
| 72 // comments above. | |
| 73 "vp09.00.00.08.00.01.00.00," | |
| 74 #endif | |
| 69 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," | 75 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," |
| 70 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 76 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 71 // Only one variant each of ac3 and eac3 codec string is sufficient here, | 77 // Only one variant each of ac3 and eac3 codec string is sufficient here, |
| 72 // since these strings are parsed and mapped to MimeUtil::Codec enum values. | 78 // since these strings are parsed and mapped to MimeUtil::Codec enum values. |
| 73 "ac-3,ec-3," | 79 "ac-3,ec-3," |
| 74 #endif | 80 #endif |
| 75 "mp4a.40.05,mp4a.40.29"; | 81 "mp4a.40.05,mp4a.40.29"; |
| 76 #endif // USE_PROPRIETARY_CODECS | 82 #endif // USE_PROPRIETARY_CODECS |
| 77 | 83 |
| 78 // A list of media types (https://en.wikipedia.org/wiki/Media_type) and | 84 // A list of media types (https://en.wikipedia.org/wiki/Media_type) and |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 }; | 126 }; |
| 121 | 127 |
| 122 // List of codec IDs that provide enough information to determine the | 128 // List of codec IDs that provide enough information to determine the |
| 123 // codec and profile being requested. | 129 // codec and profile being requested. |
| 124 // | 130 // |
| 125 // The "mp4a" strings come from RFC 6381. | 131 // The "mp4a" strings come from RFC 6381. |
| 126 static const CodecIDMappings kUnambiguousCodecStringMap[] = { | 132 static const CodecIDMappings kUnambiguousCodecStringMap[] = { |
| 127 {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous. | 133 {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous. |
| 128 // avc1/avc3.XXXXXX may be unambiguous; handled by ParseAVCCodecId(). | 134 // avc1/avc3.XXXXXX may be unambiguous; handled by ParseAVCCodecId(). |
| 129 // hev1/hvc1.XXXXXX may be unambiguous; handled by ParseHEVCCodecID(). | 135 // hev1/hvc1.XXXXXX may be unambiguous; handled by ParseHEVCCodecID(). |
| 136 // vp9, vp9.0, vp09.xx.xx.xx.xx.xx.xx.xx may be unambiguous; handled by | |
| 137 // ParseVp9CodecID(). | |
| 130 {"mp3", MimeUtil::MP3}, | 138 {"mp3", MimeUtil::MP3}, |
| 131 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN}, | 139 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN}, |
| 132 {"mp4a.67", MimeUtil::MPEG2_AAC_LC}, | 140 {"mp4a.67", MimeUtil::MPEG2_AAC_LC}, |
| 133 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR}, | 141 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR}, |
| 134 {"mp4a.69", MimeUtil::MP3}, | 142 {"mp4a.69", MimeUtil::MP3}, |
| 135 {"mp4a.6B", MimeUtil::MP3}, | 143 {"mp4a.6B", MimeUtil::MP3}, |
| 136 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC}, | 144 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC}, |
| 137 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC}, | 145 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC}, |
| 138 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1}, | 146 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1}, |
| 139 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1}, | 147 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1}, |
| 140 {"mp4a.40.29", MimeUtil::MPEG4_AAC_SBR_PS_v2}, | 148 {"mp4a.40.29", MimeUtil::MPEG4_AAC_SBR_PS_v2}, |
| 141 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 149 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 142 // TODO(servolk): Strictly speaking only mp4a.A5 and mp4a.A6 codec ids are | 150 // TODO(servolk): Strictly speaking only mp4a.A5 and mp4a.A6 codec ids are |
| 143 // valid according to RFC 6381 section 3.3, 3.4. Lower-case oti (mp4a.a5 and | 151 // valid according to RFC 6381 section 3.3, 3.4. Lower-case oti (mp4a.a5 and |
| 144 // mp4a.a6) should be rejected. But we used to allow those in older versions | 152 // mp4a.a6) should be rejected. But we used to allow those in older versions |
| 145 // of Chromecast firmware and some apps (notably MPL) depend on those codec | 153 // of Chromecast firmware and some apps (notably MPL) depend on those codec |
| 146 // types being supported, so they should be allowed for now | 154 // types being supported, so they should be allowed for now |
| 147 // (crbug.com/564960). | 155 // (crbug.com/564960). |
| 148 {"ac-3", MimeUtil::AC3}, | 156 {"ac-3", MimeUtil::AC3}, |
| 149 {"mp4a.a5", MimeUtil::AC3}, | 157 {"mp4a.a5", MimeUtil::AC3}, |
| 150 {"mp4a.A5", MimeUtil::AC3}, | 158 {"mp4a.A5", MimeUtil::AC3}, |
| 151 {"ec-3", MimeUtil::EAC3}, | 159 {"ec-3", MimeUtil::EAC3}, |
| 152 {"mp4a.a6", MimeUtil::EAC3}, | 160 {"mp4a.a6", MimeUtil::EAC3}, |
| 153 {"mp4a.A6", MimeUtil::EAC3}, | 161 {"mp4a.A6", MimeUtil::EAC3}, |
| 154 #endif | 162 #endif |
| 155 {"vorbis", MimeUtil::VORBIS}, | 163 {"vorbis", MimeUtil::VORBIS}, |
| 156 {"opus", MimeUtil::OPUS}, | 164 {"opus", MimeUtil::OPUS}, |
| 157 {"vp8", MimeUtil::VP8}, | 165 {"vp8", MimeUtil::VP8}, |
| 158 {"vp8.0", MimeUtil::VP8}, | 166 {"vp8.0", MimeUtil::VP8}, |
| 159 {"vp9", MimeUtil::VP9}, | |
| 160 {"vp9.0", MimeUtil::VP9}, | |
| 161 {"theora", MimeUtil::THEORA}}; | 167 {"theora", MimeUtil::THEORA}}; |
| 162 | 168 |
| 163 // List of codec IDs that are ambiguous and don't provide | 169 // List of codec IDs that are ambiguous and don't provide |
| 164 // enough information to determine the codec and profile. | 170 // enough information to determine the codec and profile. |
| 165 // The codec in these entries indicate the codec and profile | 171 // The codec in these entries indicate the codec and profile |
| 166 // we assume the user is trying to indicate. | 172 // we assume the user is trying to indicate. |
| 167 static const CodecIDMappings kAmbiguousCodecStringMap[] = { | 173 static const CodecIDMappings kAmbiguousCodecStringMap[] = { |
| 168 {"mp4a.40", MimeUtil::MPEG4_AAC_LC}, | 174 {"mp4a.40", MimeUtil::MPEG4_AAC_LC}, |
| 169 {"avc1", MimeUtil::H264}, | 175 {"avc1", MimeUtil::H264}, |
| 170 {"avc3", MimeUtil::H264}, | 176 {"avc3", MimeUtil::H264}, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 *is_ambiguous = false; | 266 *is_ambiguous = false; |
| 261 } | 267 } |
| 262 | 268 |
| 263 return true; | 269 return true; |
| 264 } | 270 } |
| 265 | 271 |
| 266 return false; | 272 return false; |
| 267 } | 273 } |
| 268 #endif | 274 #endif |
| 269 | 275 |
| 276 // Handle parsing of vp9 codec IDs. | |
| 277 static bool ParseVp9CodecID(const std::string& mime_type, | |
| 278 const std::string& codec_id, | |
| 279 MimeUtil::Codec* codec) { | |
| 280 if (mime_type == "video/webm") { | |
|
ddorwin
2016/03/02 00:58:21
I believe we can reach this code with "audio/*". W
kqyang
2016/03/10 01:16:27
I am not sure if it is a good idea, but sure. Done
| |
| 281 if (codec_id == "vp9" || codec_id == "vp9.0") { | |
| 282 *codec = MimeUtil::VP9; | |
| 283 return true; | |
| 284 } | |
| 285 // TODO(kqyang): Should we support new codec string in WebM? | |
| 286 return false; | |
| 287 } | |
| 288 | |
| 289 #if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING) | |
| 290 std::vector<std::string> fields = base::SplitString( | |
| 291 codec_id, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); | |
| 292 if (fields.size() < 1) | |
| 293 return false; | |
| 294 | |
| 295 if (fields[0] == "vp09") { | |
| 296 *codec = MimeUtil::VP9; | |
| 297 } else { | |
| 298 return false; | |
| 299 } | |
| 300 | |
| 301 if (fields.size() > 8) | |
| 302 return false; | |
| 303 | |
| 304 std::vector<int> values; | |
| 305 for (size_t i = 1; i < fields.size(); ++i) { | |
| 306 // Missing value is not allowed. | |
| 307 if (fields[i] == "") | |
| 308 return false; | |
| 309 int value; | |
| 310 if (!base::StringToInt(fields[i], &value)) | |
| 311 return false; | |
| 312 if (value < 0) | |
| 313 return false; | |
| 314 values.push_back(value); | |
| 315 } | |
| 316 | |
| 317 // The spec specifies 8 fields (7 values excluding the first codec field). | |
| 318 // We do not allow missing fields. | |
| 319 if (values.size() < 7) | |
| 320 return false; | |
| 321 | |
| 322 const int profile = values[0]; | |
| 323 if (profile > 3) | |
| 324 return false; | |
| 325 | |
| 326 const int bit_depth = values[2]; | |
| 327 if (bit_depth != 8 && bit_depth != 10 && bit_depth != 12) | |
| 328 return false; | |
| 329 | |
| 330 const int color_space = values[3]; | |
| 331 if (color_space > 7) | |
| 332 return false; | |
| 333 | |
| 334 const int chroma_subsampling = values[4]; | |
| 335 if (chroma_subsampling > 3) | |
| 336 return false; | |
| 337 | |
| 338 const int transfer_function = values[5]; | |
| 339 if (transfer_function > 1) | |
| 340 return false; | |
| 341 | |
| 342 const int video_full_range_flag = values[6]; | |
| 343 if (video_full_range_flag > 1) | |
| 344 return false; | |
| 345 | |
| 346 return true; | |
| 347 #else | |
| 348 return false; | |
| 349 #endif // #if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING) | |
| 350 } | |
| 351 | |
| 270 MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) { | 352 MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) { |
| 271 #if defined(OS_ANDROID) | 353 #if defined(OS_ANDROID) |
| 272 platform_info_.is_unified_media_pipeline_enabled = | 354 platform_info_.is_unified_media_pipeline_enabled = |
| 273 IsUnifiedMediaPipelineEnabled(); | 355 IsUnifiedMediaPipelineEnabled(); |
| 274 // When the unified media pipeline is enabled, we need support for both GPU | 356 // When the unified media pipeline is enabled, we need support for both GPU |
| 275 // video decoders and MediaCodec; indicated by HasPlatformDecoderSupport(). | 357 // video decoders and MediaCodec; indicated by HasPlatformDecoderSupport(). |
| 276 // When the Android pipeline is used, we only need access to MediaCodec. | 358 // When the Android pipeline is used, we only need access to MediaCodec. |
| 277 platform_info_.has_platform_decoders = | 359 platform_info_.has_platform_decoders = |
| 278 platform_info_.is_unified_media_pipeline_enabled | 360 platform_info_.is_unified_media_pipeline_enabled |
| 279 ? HasPlatformDecoderSupport() | 361 ? HasPlatformDecoderSupport() |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 294 const std::vector<std::string>& codecs, | 376 const std::vector<std::string>& codecs, |
| 295 const std::string& mime_type_lower_case, | 377 const std::string& mime_type_lower_case, |
| 296 bool is_encrypted) const { | 378 bool is_encrypted) const { |
| 297 DCHECK(!supported_codecs.empty()); | 379 DCHECK(!supported_codecs.empty()); |
| 298 DCHECK(!codecs.empty()); | 380 DCHECK(!codecs.empty()); |
| 299 | 381 |
| 300 SupportsType result = IsSupported; | 382 SupportsType result = IsSupported; |
| 301 for (size_t i = 0; i < codecs.size(); ++i) { | 383 for (size_t i = 0; i < codecs.size(); ++i) { |
| 302 bool is_ambiguous = true; | 384 bool is_ambiguous = true; |
| 303 Codec codec = INVALID_CODEC; | 385 Codec codec = INVALID_CODEC; |
| 304 if (!StringToCodec(codecs[i], &codec, &is_ambiguous)) | 386 if (!StringToCodec(mime_type_lower_case, codecs[i], &codec, &is_ambiguous)) |
| 305 return IsNotSupported; | 387 return IsNotSupported; |
| 306 | 388 |
| 307 if (!IsCodecSupported(codec, mime_type_lower_case, is_encrypted) || | 389 if (!IsCodecSupported(codec, mime_type_lower_case, is_encrypted) || |
| 308 supported_codecs.find(codec) == supported_codecs.end()) { | 390 supported_codecs.find(codec) == supported_codecs.end()) { |
| 309 return IsNotSupported; | 391 return IsNotSupported; |
| 310 } | 392 } |
| 311 | 393 |
| 312 if (is_ambiguous) | 394 if (is_ambiguous) |
| 313 result = MayBeSupported; | 395 result = MayBeSupported; |
| 314 } | 396 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 335 // Initialize the supported media formats. | 417 // Initialize the supported media formats. |
| 336 for (size_t i = 0; i < arraysize(kFormatCodecMappings); ++i) { | 418 for (size_t i = 0; i < arraysize(kFormatCodecMappings); ++i) { |
| 337 std::vector<std::string> mime_type_codecs; | 419 std::vector<std::string> mime_type_codecs; |
| 338 ParseCodecString(kFormatCodecMappings[i].codecs_list, &mime_type_codecs, | 420 ParseCodecString(kFormatCodecMappings[i].codecs_list, &mime_type_codecs, |
| 339 false); | 421 false); |
| 340 | 422 |
| 341 CodecSet codecs; | 423 CodecSet codecs; |
| 342 for (size_t j = 0; j < mime_type_codecs.size(); ++j) { | 424 for (size_t j = 0; j < mime_type_codecs.size(); ++j) { |
| 343 Codec codec = INVALID_CODEC; | 425 Codec codec = INVALID_CODEC; |
| 344 bool is_ambiguous = true; | 426 bool is_ambiguous = true; |
| 345 CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous)); | 427 CHECK(StringToCodec(kFormatCodecMappings[i].mime_type, |
| 428 mime_type_codecs[j], &codec, &is_ambiguous)); | |
| 346 DCHECK(!is_ambiguous); | 429 DCHECK(!is_ambiguous); |
| 347 codecs.insert(codec); | 430 codecs.insert(codec); |
| 348 } | 431 } |
| 349 | 432 |
| 350 media_format_map_[kFormatCodecMappings[i].mime_type] = codecs; | 433 media_format_map_[kFormatCodecMappings[i].mime_type] = codecs; |
| 351 } | 434 } |
| 352 } | 435 } |
| 353 | 436 |
| 354 bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const { | 437 bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const { |
| 355 return media_format_map_.find(base::ToLowerASCII(mime_type)) != | 438 return media_format_map_.find(base::ToLowerASCII(mime_type)) != |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 | 620 |
| 538 // MediaPlayer can always play VP8. Note: This is incorrect for MSE, but | 621 // MediaPlayer can always play VP8. Note: This is incorrect for MSE, but |
| 539 // MSE does not use this code. http://crbug.com/587303. | 622 // MSE does not use this code. http://crbug.com/587303. |
| 540 return true; | 623 return true; |
| 541 | 624 |
| 542 case VP9: { | 625 case VP9: { |
| 543 // If clear, the unified pipeline can always decode VP9 in software. | 626 // If clear, the unified pipeline can always decode VP9 in software. |
| 544 if (!is_encrypted && platform_info.is_unified_media_pipeline_enabled) | 627 if (!is_encrypted && platform_info.is_unified_media_pipeline_enabled) |
| 545 return true; | 628 return true; |
| 546 | 629 |
| 547 // Otherwise, platform support is required. | 630 // Otherwise, platform support is required. |
|
ddorwin
2016/03/02 00:58:21
I think we should check that the container is "vid
kqyang
2016/03/10 01:16:27
Done.
| |
| 548 return platform_info.supports_vp9; | 631 return platform_info.supports_vp9; |
| 549 } | 632 } |
| 550 } | 633 } |
| 551 | 634 |
| 552 return false; | 635 return false; |
| 553 } | 636 } |
| 554 | 637 |
| 555 bool MimeUtil::StringToCodec(const std::string& codec_id, | 638 bool MimeUtil::StringToCodec(const std::string& mime_type, |
| 639 const std::string& codec_id, | |
| 556 Codec* codec, | 640 Codec* codec, |
| 557 bool* is_ambiguous) const { | 641 bool* is_ambiguous) const { |
| 558 StringToCodecMappings::const_iterator itr = | 642 StringToCodecMappings::const_iterator itr = |
| 559 string_to_codec_map_.find(codec_id); | 643 string_to_codec_map_.find(codec_id); |
| 560 if (itr != string_to_codec_map_.end()) { | 644 if (itr != string_to_codec_map_.end()) { |
| 561 *codec = itr->second.codec; | 645 *codec = itr->second.codec; |
| 562 *is_ambiguous = itr->second.is_ambiguous; | 646 *is_ambiguous = itr->second.is_ambiguous; |
| 563 return true; | 647 return true; |
| 564 } | 648 } |
| 565 | 649 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 577 uint8_t level_idc = 0; | 661 uint8_t level_idc = 0; |
| 578 if (ParseAVCCodecId(codec_id, &profile, &level_idc)) { | 662 if (ParseAVCCodecId(codec_id, &profile, &level_idc)) { |
| 579 *codec = MimeUtil::H264; | 663 *codec = MimeUtil::H264; |
| 580 *is_ambiguous = | 664 *is_ambiguous = |
| 581 (profile != H264PROFILE_BASELINE && profile != H264PROFILE_MAIN && | 665 (profile != H264PROFILE_BASELINE && profile != H264PROFILE_MAIN && |
| 582 profile != H264PROFILE_HIGH) || | 666 profile != H264PROFILE_HIGH) || |
| 583 !IsValidH264Level(level_idc); | 667 !IsValidH264Level(level_idc); |
| 584 return true; | 668 return true; |
| 585 } | 669 } |
| 586 | 670 |
| 671 if (ParseVp9CodecID(mime_type, codec_id, codec)) { | |
| 672 *is_ambiguous = false; | |
| 673 return true; | |
| 674 } | |
| 675 | |
| 587 DVLOG(4) << __FUNCTION__ << ": Unrecognized codec id " << codec_id; | 676 DVLOG(4) << __FUNCTION__ << ": Unrecognized codec id " << codec_id; |
| 588 return false; | 677 return false; |
| 589 } | 678 } |
| 590 | 679 |
| 591 bool MimeUtil::IsCodecSupported(Codec codec, | 680 bool MimeUtil::IsCodecSupported(Codec codec, |
| 592 const std::string& mime_type_lower_case, | 681 const std::string& mime_type_lower_case, |
| 593 bool is_encrypted) const { | 682 bool is_encrypted) const { |
| 594 DCHECK_NE(codec, INVALID_CODEC); | 683 DCHECK_NE(codec, INVALID_CODEC); |
| 595 | 684 |
| 596 #if defined(OS_ANDROID) | 685 #if defined(OS_ANDROID) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 652 const std::string& mime_type_lower_case, | 741 const std::string& mime_type_lower_case, |
| 653 bool is_encrypted) const { | 742 bool is_encrypted) const { |
| 654 Codec default_codec = Codec::INVALID_CODEC; | 743 Codec default_codec = Codec::INVALID_CODEC; |
| 655 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) | 744 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) |
| 656 return false; | 745 return false; |
| 657 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); | 746 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); |
| 658 } | 747 } |
| 659 | 748 |
| 660 } // namespace internal | 749 } // namespace internal |
| 661 } // namespace media | 750 } // namespace media |
| OLD | NEW |