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

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: 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 const std::vector<std::string>& codecs, 276 const std::vector<std::string>& codecs,
277 const std::string& mime_type_lower_case, 277 const std::string& mime_type_lower_case,
278 bool is_encrypted) const { 278 bool is_encrypted) const {
279 DCHECK(!supported_codecs.empty()); 279 DCHECK(!supported_codecs.empty());
280 DCHECK(!codecs.empty()); 280 DCHECK(!codecs.empty());
281 281
282 SupportsType result = IsSupported; 282 SupportsType result = IsSupported;
283 for (size_t i = 0; i < codecs.size(); ++i) { 283 for (size_t i = 0; i < codecs.size(); ++i) {
284 bool is_ambiguous = true; 284 bool is_ambiguous = true;
285 Codec codec = INVALID_CODEC; 285 Codec codec = INVALID_CODEC;
286 if (!StringToCodec(codecs[i], &codec, &is_ambiguous)) 286 if (!StringToCodec(codecs[i], &codec, &is_ambiguous, is_encrypted))
287 return IsNotSupported; 287 return IsNotSupported;
288 288
289 if (!IsCodecSupported(codec, mime_type_lower_case, is_encrypted) || 289 if (!IsCodecSupported(codec, mime_type_lower_case, is_encrypted) ||
290 supported_codecs.find(codec) == supported_codecs.end()) { 290 supported_codecs.find(codec) == supported_codecs.end()) {
291 return IsNotSupported; 291 return IsNotSupported;
292 } 292 }
293 293
294 if (is_ambiguous) 294 if (is_ambiguous)
295 result = MayBeSupported; 295 result = MayBeSupported;
296 } 296 }
(...skipping 20 matching lines...) Expand all
317 // Initialize the supported media formats. 317 // Initialize the supported media formats.
318 for (size_t i = 0; i < arraysize(kFormatCodecMappings); ++i) { 318 for (size_t i = 0; i < arraysize(kFormatCodecMappings); ++i) {
319 std::vector<std::string> mime_type_codecs; 319 std::vector<std::string> mime_type_codecs;
320 ParseCodecString(kFormatCodecMappings[i].codecs_list, &mime_type_codecs, 320 ParseCodecString(kFormatCodecMappings[i].codecs_list, &mime_type_codecs,
321 false); 321 false);
322 322
323 CodecSet codecs; 323 CodecSet codecs;
324 for (size_t j = 0; j < mime_type_codecs.size(); ++j) { 324 for (size_t j = 0; j < mime_type_codecs.size(); ++j) {
325 Codec codec = INVALID_CODEC; 325 Codec codec = INVALID_CODEC;
326 bool is_ambiguous = true; 326 bool is_ambiguous = true;
327 CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous)); 327 CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous, false));
328 DCHECK(!is_ambiguous); 328 DCHECK(!is_ambiguous);
329 codecs.insert(codec); 329 codecs.insert(codec);
330 } 330 }
331 331
332 media_format_map_[kFormatCodecMappings[i].mime_type] = codecs; 332 media_format_map_[kFormatCodecMappings[i].mime_type] = codecs;
333 } 333 }
334 } 334 }
335 335
336 bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const { 336 bool MimeUtil::IsSupportedMediaMimeType(const std::string& mime_type) const {
337 return media_format_map_.find(base::ToLowerASCII(mime_type)) != 337 return media_format_map_.find(base::ToLowerASCII(mime_type)) !=
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 // Otherwise, platform support is required. 526 // Otherwise, platform support is required.
527 return platform_info.supports_vp9; 527 return platform_info.supports_vp9;
528 } 528 }
529 } 529 }
530 530
531 return false; 531 return false;
532 } 532 }
533 533
534 bool MimeUtil::StringToCodec(const std::string& codec_id, 534 bool MimeUtil::StringToCodec(const std::string& codec_id,
535 Codec* codec, 535 Codec* codec,
536 bool* is_ambiguous) const { 536 bool* is_ambiguous,
537 bool is_encrypted) const {
537 StringToCodecMappings::const_iterator itr = 538 StringToCodecMappings::const_iterator itr =
538 string_to_codec_map_.find(codec_id); 539 string_to_codec_map_.find(codec_id);
539 if (itr != string_to_codec_map_.end()) { 540 if (itr != string_to_codec_map_.end()) {
540 *codec = itr->second.codec; 541 *codec = itr->second.codec;
541 *is_ambiguous = itr->second.is_ambiguous; 542 *is_ambiguous = itr->second.is_ambiguous;
542 return true; 543 return true;
543 } 544 }
544 545
545 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is 546 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is
546 // either H.264 or HEVC/H.265 codec ID because currently those are the only 547 // either H.264 or HEVC/H.265 codec ID because currently those are the only
547 // ones that are not added to the |string_to_codec_map_| and require parsing. 548 // ones that are not added to the |string_to_codec_map_| and require parsing.
548 549
549 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 550 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
550 if (ParseHEVCCodecID(codec_id, codec, is_ambiguous)) { 551 if (ParseHEVCCodecID(codec_id, codec, is_ambiguous)) {
551 return true; 552 return true;
552 } 553 }
553 #endif 554 #endif
554 555
555 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; 556 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN;
556 uint8_t level_idc = 0; 557 uint8_t level_idc = 0;
557 if (ParseAVCCodecId(codec_id, &profile, &level_idc)) { 558 if (ParseAVCCodecId(codec_id, &profile, &level_idc)) {
558 *codec = MimeUtil::H264; 559 *codec = MimeUtil::H264;
559 *is_ambiguous = 560 switch (profile) {
560 (profile != H264PROFILE_BASELINE && profile != H264PROFILE_MAIN && 561 case H264PROFILE_BASELINE:
561 profile != H264PROFILE_HIGH) || 562 case H264PROFILE_MAIN:
562 !IsValidH264Level(level_idc); 563 case H264PROFILE_HIGH:
564 #if !defined(OS_ANDROID)
ddorwin 2016/03/31 05:58:44 This means that Chromecast (and other platforms th
hubbe 2016/03/31 21:53:48 Hmm, after reading a bunch of config files, I *thi
565 // HIGH10PROFILE is supported through fallback to
566 // ffmpeg decoder, which is not available on android.
567 case H264PROFILE_HIGH10PROFILE:
568 if (is_encrypted) {
ddorwin 2016/03/31 05:44:05 All of the above profiles fall through to here. Th
hubbe 2016/03/31 21:53:48 Oops, fixed.
569 // Currently we do not support EME on 10-bit videos.
ddorwin 2016/03/31 05:44:05 Should we return false instead?
hubbe 2016/03/31 21:53:48 We don't do that for any of the other profiles we
570 *is_ambiguous = true;
571 break;
572 }
573 #endif
574
575 *is_ambiguous = !IsValidH264Level(level_idc);
576 break;
577 default:
578 *is_ambiguous = true;
579 }
563 return true; 580 return true;
564 } 581 }
565 582
566 DVLOG(4) << __FUNCTION__ << ": Unrecognized codec id " << codec_id; 583 DVLOG(4) << __FUNCTION__ << ": Unrecognized codec id " << codec_id;
567 return false; 584 return false;
568 } 585 }
569 586
570 bool MimeUtil::IsCodecSupported(Codec codec, 587 bool MimeUtil::IsCodecSupported(Codec codec,
571 const std::string& mime_type_lower_case, 588 const std::string& mime_type_lower_case,
572 bool is_encrypted) const { 589 bool is_encrypted) const {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 const std::string& mime_type_lower_case, 644 const std::string& mime_type_lower_case,
628 bool is_encrypted) const { 645 bool is_encrypted) const {
629 Codec default_codec = Codec::INVALID_CODEC; 646 Codec default_codec = Codec::INVALID_CODEC;
630 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) 647 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec))
631 return false; 648 return false;
632 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); 649 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted);
633 } 650 }
634 651
635 } // namespace internal 652 } // namespace internal
636 } // namespace media 653 } // namespace media
OLDNEW
« content/browser/media/media_canplaytype_browsertest.cc ('K') | « media/base/mime_util_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698