Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: media/base/mime_util_internal.cc

Issue 1837963004: Make CanPlayType return "probably" for HI10P h264 videos. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 const std::vector<std::string>& codecs, 274 const std::vector<std::string>& codecs,
275 const std::string& mime_type_lower_case, 275 const std::string& mime_type_lower_case,
276 bool is_encrypted) const { 276 bool is_encrypted) const {
277 DCHECK(!supported_codecs.empty()); 277 DCHECK(!supported_codecs.empty());
278 DCHECK(!codecs.empty()); 278 DCHECK(!codecs.empty());
279 279
280 SupportsType result = IsSupported; 280 SupportsType result = IsSupported;
281 for (size_t i = 0; i < codecs.size(); ++i) { 281 for (size_t i = 0; i < codecs.size(); ++i) {
282 bool is_ambiguous = true; 282 bool is_ambiguous = true;
283 Codec codec = INVALID_CODEC; 283 Codec codec = INVALID_CODEC;
284 if (!StringToCodec(codecs[i], &codec, &is_ambiguous)) 284 if (!StringToCodec(codecs[i], &codec, &is_ambiguous, is_encrypted))
285 return IsNotSupported; 285 return IsNotSupported;
286 286
287 if (!IsCodecSupported(codec, mime_type_lower_case, is_encrypted) || 287 if (!IsCodecSupported(codec, mime_type_lower_case, is_encrypted) ||
288 supported_codecs.find(codec) == supported_codecs.end()) { 288 supported_codecs.find(codec) == supported_codecs.end()) {
289 return IsNotSupported; 289 return IsNotSupported;
290 } 290 }
291 291
292 if (is_ambiguous) 292 if (is_ambiguous)
293 result = MayBeSupported; 293 result = MayBeSupported;
294 } 294 }
(...skipping 20 matching lines...) Expand all
315 // Initialize the supported media formats. 315 // Initialize the supported media formats.
316 for (size_t i = 0; i < arraysize(kFormatCodecMappings); ++i) { 316 for (size_t i = 0; i < arraysize(kFormatCodecMappings); ++i) {
317 std::vector<std::string> mime_type_codecs; 317 std::vector<std::string> mime_type_codecs;
318 ParseCodecString(kFormatCodecMappings[i].codecs_list, &mime_type_codecs, 318 ParseCodecString(kFormatCodecMappings[i].codecs_list, &mime_type_codecs,
319 false); 319 false);
320 320
321 CodecSet codecs; 321 CodecSet codecs;
322 for (size_t j = 0; j < mime_type_codecs.size(); ++j) { 322 for (size_t j = 0; j < mime_type_codecs.size(); ++j) {
323 Codec codec = INVALID_CODEC; 323 Codec codec = INVALID_CODEC;
324 bool is_ambiguous = true; 324 bool is_ambiguous = true;
325 CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous)); 325 CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous, false));
326 DCHECK(!is_ambiguous); 326 DCHECK(!is_ambiguous);
327 codecs.insert(codec); 327 codecs.insert(codec);
328 } 328 }
329 329
330 media_format_map_[kFormatCodecMappings[i].mime_type] = codecs; 330 media_format_map_[kFormatCodecMappings[i].mime_type] = codecs;
331 } 331 }
332 } 332 }
333 333
334 bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const { 334 bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const {
335 return media_format_map_.find(base::ToLowerASCII(mime_type)) != 335 return media_format_map_.find(base::ToLowerASCII(mime_type)) !=
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 // Otherwise, platform support is required. 524 // Otherwise, platform support is required.
525 return platform_info.supports_vp9; 525 return platform_info.supports_vp9;
526 } 526 }
527 } 527 }
528 528
529 return false; 529 return false;
530 } 530 }
531 531
532 bool MimeUtil::StringToCodec(const std::string& codec_id, 532 bool MimeUtil::StringToCodec(const std::string& codec_id,
533 Codec* codec, 533 Codec* codec,
534 bool* is_ambiguous) const { 534 bool* is_ambiguous,
535 bool is_encrypted) const {
535 StringToCodecMappings::const_iterator itr = 536 StringToCodecMappings::const_iterator itr =
536 string_to_codec_map_.find(codec_id); 537 string_to_codec_map_.find(codec_id);
537 if (itr != string_to_codec_map_.end()) { 538 if (itr != string_to_codec_map_.end()) {
538 *codec = itr->second.codec; 539 *codec = itr->second.codec;
539 *is_ambiguous = itr->second.is_ambiguous; 540 *is_ambiguous = itr->second.is_ambiguous;
540 return true; 541 return true;
541 } 542 }
542 543
543 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is 544 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is
544 // either H.264 or HEVC/H.265 codec ID because currently those are the only 545 // either H.264 or HEVC/H.265 codec ID because currently those are the only
545 // ones that are not added to the |string_to_codec_map_| and require parsing. 546 // ones that are not added to the |string_to_codec_map_| and require parsing.
546 547
547 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 548 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
548 if (ParseHEVCCodecID(codec_id, codec, is_ambiguous)) { 549 if (ParseHEVCCodecID(codec_id, codec, is_ambiguous)) {
549 return true; 550 return true;
550 } 551 }
551 #endif 552 #endif
552 553
553 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; 554 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN;
554 uint8_t level_idc = 0; 555 uint8_t level_idc = 0;
555 if (ParseAVCCodecId(codec_id, &profile, &level_idc)) { 556 if (ParseAVCCodecId(codec_id, &profile, &level_idc)) {
556 *codec = MimeUtil::H264; 557 *codec = MimeUtil::H264;
557 *is_ambiguous = 558 switch (profile) {
558 (profile != H264PROFILE_BASELINE && profile != H264PROFILE_MAIN && 559 // HIGH10PROFILE is supported through fallback to the ffmpeg decoder,
559 profile != H264PROFILE_HIGH) || 560 // which is not available on Android, or if FFMPEG is not used.
ddorwin 2016/04/01 00:36:42 nit: remove this comma now
hubbe 2016/04/04 22:01:50 Done.
560 !IsValidH264Level(level_idc); 561 #if !defined(MEDIA_DISABLE_FFMPEG) && !defined(OS_ANDROID)
562 case H264PROFILE_HIGH10PROFILE:
563 if (is_encrypted) {
564 // FFmpeg is not generally used for encrypted videos, so we do not
565 // know wheter 10-bit is supported.
ddorwin 2016/04/01 00:36:42 whether
hubbe 2016/04/04 22:01:50 Done.
566 *is_ambiguous = true;
567 break;
568 }
569 // Fall through.
570 #endif
571
572 case H264PROFILE_BASELINE:
573 case H264PROFILE_MAIN:
574 case H264PROFILE_HIGH:
575 *is_ambiguous = !IsValidH264Level(level_idc);
576 break;
577 default:
578 *is_ambiguous = true;
579 }
561 return true; 580 return true;
562 } 581 }
563 582
564 DVLOG(4) << __FUNCTION__ << ": Unrecognized codec id " << codec_id; 583 DVLOG(4) << __FUNCTION__ << ": Unrecognized codec id " << codec_id;
565 return false; 584 return false;
566 } 585 }
567 586
568 bool MimeUtil::IsCodecSupported(Codec codec, 587 bool MimeUtil::IsCodecSupported(Codec codec,
569 const std::string& mime_type_lower_case, 588 const std::string& mime_type_lower_case,
570 bool is_encrypted) const { 589 bool is_encrypted) const {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 const std::string& mime_type_lower_case, 644 const std::string& mime_type_lower_case,
626 bool is_encrypted) const { 645 bool is_encrypted) const {
627 Codec default_codec = Codec::INVALID_CODEC; 646 Codec default_codec = Codec::INVALID_CODEC;
628 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) 647 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec))
629 return false; 648 return false;
630 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); 649 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted);
631 } 650 }
632 651
633 } // namespace internal 652 } // namespace internal
634 } // namespace media 653 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698