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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 case MimeUtil::H264: | 144 case MimeUtil::H264: |
145 return kCodecH264; | 145 return kCodecH264; |
146 case MimeUtil::HEVC: | 146 case MimeUtil::HEVC: |
147 return kCodecHEVC; | 147 return kCodecHEVC; |
148 case MimeUtil::VP8: | 148 case MimeUtil::VP8: |
149 return kCodecVP8; | 149 return kCodecVP8; |
150 case MimeUtil::VP9: | 150 case MimeUtil::VP9: |
151 return kCodecVP9; | 151 return kCodecVP9; |
152 case MimeUtil::THEORA: | 152 case MimeUtil::THEORA: |
153 return kCodecTheora; | 153 return kCodecTheora; |
| 154 case MimeUtil::DolbyVision: |
| 155 return kCodecDolbyVision; |
154 default: | 156 default: |
155 break; | 157 break; |
156 } | 158 } |
157 return kUnknownVideoCodec; | 159 return kUnknownVideoCodec; |
158 } | 160 } |
159 | 161 |
160 SupportsType MimeUtil::AreSupportedCodecs( | 162 SupportsType MimeUtil::AreSupportedCodecs( |
161 const CodecSet& supported_codecs, | 163 const CodecSet& supported_codecs, |
162 const std::vector<std::string>& codecs, | 164 const std::vector<std::string>& codecs, |
163 const std::string& mime_type_lower_case, | 165 const std::string& mime_type_lower_case, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 #endif // BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 264 #endif // BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
263 | 265 |
264 CodecSet mp4_video_codecs; | 266 CodecSet mp4_video_codecs; |
265 mp4_video_codecs.insert(H264); | 267 mp4_video_codecs.insert(H264); |
266 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 268 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
267 mp4_video_codecs.insert(HEVC); | 269 mp4_video_codecs.insert(HEVC); |
268 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING) | 270 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING) |
269 // Only VP9 with valid codec string vp09.xx.xx.xx.xx.xx.xx.xx is supported. | 271 // Only VP9 with valid codec string vp09.xx.xx.xx.xx.xx.xx.xx is supported. |
270 // See ParseVp9CodecID for details. | 272 // See ParseVp9CodecID for details. |
271 mp4_video_codecs.insert(VP9); | 273 mp4_video_codecs.insert(VP9); |
| 274 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) |
| 275 mp4_video_codecs.insert(DolbyVision); |
| 276 #endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) |
272 CodecSet mp4_codecs(mp4_audio_codecs); | 277 CodecSet mp4_codecs(mp4_audio_codecs); |
273 mp4_codecs.insert(mp4_video_codecs.begin(), mp4_video_codecs.end()); | 278 mp4_codecs.insert(mp4_video_codecs.begin(), mp4_video_codecs.end()); |
274 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 279 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
275 | 280 |
276 AddContainerWithCodecs("audio/wav", wav_codecs, false); | 281 AddContainerWithCodecs("audio/wav", wav_codecs, false); |
277 AddContainerWithCodecs("audio/x-wav", wav_codecs, false); | 282 AddContainerWithCodecs("audio/x-wav", wav_codecs, false); |
278 AddContainerWithCodecs("audio/webm", webm_audio_codecs, false); | 283 AddContainerWithCodecs("audio/webm", webm_audio_codecs, false); |
279 DCHECK(!webm_video_codecs.empty()); | 284 DCHECK(!webm_video_codecs.empty()); |
280 AddContainerWithCodecs("video/webm", webm_codecs, false); | 285 AddContainerWithCodecs("video/webm", webm_codecs, false); |
281 AddContainerWithCodecs("audio/ogg", ogg_audio_codecs, false); | 286 AddContainerWithCodecs("audio/ogg", ogg_audio_codecs, false); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 if (!platform_info.has_platform_vp9_decoder) | 535 if (!platform_info.has_platform_vp9_decoder) |
531 return false; | 536 return false; |
532 | 537 |
533 // Encrypted content is demuxed so the container is irrelevant. | 538 // Encrypted content is demuxed so the container is irrelevant. |
534 if (is_encrypted) | 539 if (is_encrypted) |
535 return true; | 540 return true; |
536 | 541 |
537 // MediaPlayer only supports VP9 in WebM. | 542 // MediaPlayer only supports VP9 in WebM. |
538 return mime_type_lower_case == "video/webm"; | 543 return mime_type_lower_case == "video/webm"; |
539 } | 544 } |
| 545 |
| 546 case DolbyVision: |
| 547 // This function is only called on Android which doesn't support Dolby |
| 548 // Vision. |
| 549 return false; |
540 } | 550 } |
541 | 551 |
542 return false; | 552 return false; |
543 } | 553 } |
544 | 554 |
545 bool MimeUtil::StringToCodec(const std::string& mime_type_lower_case, | 555 bool MimeUtil::StringToCodec(const std::string& mime_type_lower_case, |
546 const std::string& codec_id, | 556 const std::string& codec_id, |
547 Codec* codec, | 557 Codec* codec, |
548 bool* is_ambiguous, | 558 bool* is_ambiguous, |
549 VideoCodecProfile* out_profile, | 559 VideoCodecProfile* out_profile, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } | 621 } |
612 | 622 |
613 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 623 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
614 if (ParseHEVCCodecId(codec_id, out_profile, out_level)) { | 624 if (ParseHEVCCodecId(codec_id, out_profile, out_level)) { |
615 *codec = MimeUtil::HEVC; | 625 *codec = MimeUtil::HEVC; |
616 *is_ambiguous = false; | 626 *is_ambiguous = false; |
617 return true; | 627 return true; |
618 } | 628 } |
619 #endif | 629 #endif |
620 | 630 |
| 631 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) |
| 632 if (ParseDolbyVisionCodecId(codec_id, out_profile, out_level)) { |
| 633 *codec = MimeUtil::DolbyVision; |
| 634 *is_ambiguous = false; |
| 635 return true; |
| 636 } |
| 637 #endif |
| 638 |
621 DVLOG(4) << __func__ << ": Unrecognized codec id " << codec_id; | 639 DVLOG(4) << __func__ << ": Unrecognized codec id " << codec_id; |
622 return false; | 640 return false; |
623 } | 641 } |
624 | 642 |
625 bool MimeUtil::IsCodecSupported(Codec codec, | 643 bool MimeUtil::IsCodecSupported(Codec codec, |
626 const std::string& mime_type_lower_case, | 644 const std::string& mime_type_lower_case, |
627 bool is_encrypted) const { | 645 bool is_encrypted) const { |
628 DCHECK_NE(codec, INVALID_CODEC); | 646 DCHECK_NE(codec, INVALID_CODEC); |
629 | 647 |
630 #if defined(OS_ANDROID) | 648 #if defined(OS_ANDROID) |
631 if (!IsCodecSupportedOnPlatform(codec, mime_type_lower_case, is_encrypted, | 649 if (!IsCodecSupportedOnPlatform(codec, mime_type_lower_case, is_encrypted, |
632 platform_info_)) { | 650 platform_info_)) { |
633 return false; | 651 return false; |
634 } | 652 } |
635 #endif | 653 #endif |
636 | 654 |
637 return allow_proprietary_codecs_ || !IsCodecProprietary(codec); | 655 return allow_proprietary_codecs_ || !IsCodecProprietary(codec); |
638 } | 656 } |
639 | 657 |
640 bool MimeUtil::IsCodecProprietary(Codec codec) const { | 658 bool MimeUtil::IsCodecProprietary(Codec codec) const { |
641 switch (codec) { | 659 switch (codec) { |
642 case INVALID_CODEC: | 660 case INVALID_CODEC: |
643 case AC3: | 661 case AC3: |
644 case EAC3: | 662 case EAC3: |
645 case MP3: | 663 case MP3: |
646 case MPEG2_AAC: | 664 case MPEG2_AAC: |
647 case MPEG4_AAC: | 665 case MPEG4_AAC: |
648 case H264: | 666 case H264: |
649 case HEVC: | 667 case HEVC: |
| 668 case DolbyVision: |
650 return true; | 669 return true; |
651 | 670 |
652 case PCM: | 671 case PCM: |
653 case VORBIS: | 672 case VORBIS: |
654 case OPUS: | 673 case OPUS: |
655 case FLAC: | 674 case FLAC: |
656 case VP8: | 675 case VP8: |
657 case VP9: | 676 case VP9: |
658 case THEORA: | 677 case THEORA: |
659 return false; | 678 return false; |
(...skipping 28 matching lines...) Expand all Loading... |
688 const std::string& mime_type_lower_case, | 707 const std::string& mime_type_lower_case, |
689 bool is_encrypted) const { | 708 bool is_encrypted) const { |
690 Codec default_codec = Codec::INVALID_CODEC; | 709 Codec default_codec = Codec::INVALID_CODEC; |
691 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) | 710 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) |
692 return false; | 711 return false; |
693 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); | 712 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); |
694 } | 713 } |
695 | 714 |
696 } // namespace internal | 715 } // namespace internal |
697 } // namespace media | 716 } // namespace media |
OLD | NEW |