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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 case MimeUtil::H264: | 193 case MimeUtil::H264: |
194 return kCodecH264; | 194 return kCodecH264; |
195 case MimeUtil::HEVC: | 195 case MimeUtil::HEVC: |
196 return kCodecHEVC; | 196 return kCodecHEVC; |
197 case MimeUtil::VP8: | 197 case MimeUtil::VP8: |
198 return kCodecVP8; | 198 return kCodecVP8; |
199 case MimeUtil::VP9: | 199 case MimeUtil::VP9: |
200 return kCodecVP9; | 200 return kCodecVP9; |
201 case MimeUtil::THEORA: | 201 case MimeUtil::THEORA: |
202 return kCodecTheora; | 202 return kCodecTheora; |
203 case MimeUtil::DolbyVision: | |
204 return kCodecDolbyVision; | |
203 default: | 205 default: |
204 break; | 206 break; |
205 } | 207 } |
206 return kUnknownVideoCodec; | 208 return kUnknownVideoCodec; |
207 } | 209 } |
208 | 210 |
209 SupportsType MimeUtil::AreSupportedCodecs( | 211 SupportsType MimeUtil::AreSupportedCodecs( |
210 const CodecSet& supported_codecs, | 212 const CodecSet& supported_codecs, |
211 const std::vector<std::string>& codecs, | 213 const std::vector<std::string>& codecs, |
212 const std::string& mime_type_lower_case, | 214 const std::string& mime_type_lower_case, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 #endif // BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 312 #endif // BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
311 | 313 |
312 CodecSet mp4_video_codecs; | 314 CodecSet mp4_video_codecs; |
313 mp4_video_codecs.insert(H264); | 315 mp4_video_codecs.insert(H264); |
314 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 316 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
315 mp4_video_codecs.insert(HEVC); | 317 mp4_video_codecs.insert(HEVC); |
316 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING) | 318 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING) |
317 // Only VP9 with valid codec string vp09.xx.xx.xx.xx.xx.xx.xx is supported. | 319 // Only VP9 with valid codec string vp09.xx.xx.xx.xx.xx.xx.xx is supported. |
318 // See ParseVp9CodecID for details. | 320 // See ParseVp9CodecID for details. |
319 mp4_video_codecs.insert(VP9); | 321 mp4_video_codecs.insert(VP9); |
322 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) | |
323 mp4_video_codecs.insert(DolbyVision); | |
324 #endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) | |
320 CodecSet mp4_codecs(mp4_audio_codecs); | 325 CodecSet mp4_codecs(mp4_audio_codecs); |
321 mp4_codecs.insert(mp4_video_codecs.begin(), mp4_video_codecs.end()); | 326 mp4_codecs.insert(mp4_video_codecs.begin(), mp4_video_codecs.end()); |
322 #endif // defined(USE_PROPRIETARY_CODECS) | 327 #endif // defined(USE_PROPRIETARY_CODECS) |
323 | 328 |
324 AddContainerWithCodecs("audio/wav", wav_codecs, false); | 329 AddContainerWithCodecs("audio/wav", wav_codecs, false); |
325 AddContainerWithCodecs("audio/x-wav", wav_codecs, false); | 330 AddContainerWithCodecs("audio/x-wav", wav_codecs, false); |
326 AddContainerWithCodecs("audio/webm", webm_audio_codecs, false); | 331 AddContainerWithCodecs("audio/webm", webm_audio_codecs, false); |
327 DCHECK(!webm_video_codecs.empty()); | 332 DCHECK(!webm_video_codecs.empty()); |
328 AddContainerWithCodecs("video/webm", webm_codecs, false); | 333 AddContainerWithCodecs("video/webm", webm_codecs, false); |
329 AddContainerWithCodecs("audio/ogg", ogg_audio_codecs, false); | 334 AddContainerWithCodecs("audio/ogg", ogg_audio_codecs, false); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
574 | 579 |
575 if (!platform_info.has_platform_vp9_decoder) | 580 if (!platform_info.has_platform_vp9_decoder) |
576 return false; | 581 return false; |
577 | 582 |
578 // Encrypted content is demuxed so the container is irrelevant. | 583 // Encrypted content is demuxed so the container is irrelevant. |
579 if (is_encrypted) | 584 if (is_encrypted) |
580 return true; | 585 return true; |
581 | 586 |
582 // MediaPlayer only supports VP9 in WebM. | 587 // MediaPlayer only supports VP9 in WebM. |
583 return mime_type_lower_case == "video/webm"; | 588 return mime_type_lower_case == "video/webm"; |
584 } | 589 } |
wolenetz
2017/01/25 23:42:41
code formatting seems inconsistent here.
The VP9 c
erickung1
2017/02/03 18:18:31
Done.
| |
590 | |
591 return false; | |
wolenetz
2017/01/25 23:42:40
l.588 returns already. this line should never be r
erickung1
2017/02/03 18:18:31
Done.
| |
592 | |
593 case DolbyVision: | |
594 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) && !defined(OS_ANDROID) | |
595 if (platform_info.is_unified_media_pipeline_enabled && | |
596 !platform_info.has_platform_decoders) { | |
597 return false; | |
598 } | |
599 return true; | |
600 #else | |
601 return false; | |
602 #endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) && !defined(OS_ANDROID) | |
585 } | 603 } |
586 | 604 |
587 return false; | 605 return false; |
588 } | 606 } |
589 | 607 |
590 bool MimeUtil::StringToCodec(const std::string& mime_type_lower_case, | 608 bool MimeUtil::StringToCodec(const std::string& mime_type_lower_case, |
591 const std::string& codec_id, | 609 const std::string& codec_id, |
592 Codec* codec, | 610 Codec* codec, |
593 bool* is_ambiguous, | 611 bool* is_ambiguous, |
594 VideoCodecProfile* out_profile, | 612 VideoCodecProfile* out_profile, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 } | 674 } |
657 | 675 |
658 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 676 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
659 if (ParseHEVCCodecId(codec_id, out_profile, out_level)) { | 677 if (ParseHEVCCodecId(codec_id, out_profile, out_level)) { |
660 *codec = MimeUtil::HEVC; | 678 *codec = MimeUtil::HEVC; |
661 *is_ambiguous = false; | 679 *is_ambiguous = false; |
662 return true; | 680 return true; |
663 } | 681 } |
664 #endif | 682 #endif |
665 | 683 |
684 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) | |
685 if (ParseDolbyVisionCodecId(codec_id, out_profile, out_level)) { | |
686 *codec = MimeUtil::DolbyVision; | |
687 *is_ambiguous = false; | |
688 return true; | |
689 } | |
690 #endif | |
691 | |
666 DVLOG(4) << __func__ << ": Unrecognized codec id " << codec_id; | 692 DVLOG(4) << __func__ << ": Unrecognized codec id " << codec_id; |
667 return false; | 693 return false; |
668 } | 694 } |
669 | 695 |
670 bool MimeUtil::IsCodecSupported(Codec codec, | 696 bool MimeUtil::IsCodecSupported(Codec codec, |
671 const std::string& mime_type_lower_case, | 697 const std::string& mime_type_lower_case, |
672 bool is_encrypted) const { | 698 bool is_encrypted) const { |
673 DCHECK_NE(codec, INVALID_CODEC); | 699 DCHECK_NE(codec, INVALID_CODEC); |
674 | 700 |
675 #if defined(OS_ANDROID) | 701 #if defined(OS_ANDROID) |
676 if (!IsCodecSupportedOnPlatform(codec, mime_type_lower_case, is_encrypted, | 702 if (!IsCodecSupportedOnPlatform(codec, mime_type_lower_case, is_encrypted, |
677 platform_info_)) { | 703 platform_info_)) { |
678 return false; | 704 return false; |
679 } | 705 } |
680 #endif | 706 #endif |
681 | 707 |
682 return allow_proprietary_codecs_ || !IsCodecProprietary(codec); | 708 return allow_proprietary_codecs_ || !IsCodecProprietary(codec); |
683 } | 709 } |
684 | 710 |
685 bool MimeUtil::IsCodecProprietary(Codec codec) const { | 711 bool MimeUtil::IsCodecProprietary(Codec codec) const { |
686 switch (codec) { | 712 switch (codec) { |
687 case INVALID_CODEC: | 713 case INVALID_CODEC: |
688 case AC3: | 714 case AC3: |
689 case EAC3: | 715 case EAC3: |
690 case MP3: | 716 case MP3: |
691 case MPEG2_AAC: | 717 case MPEG2_AAC: |
692 case MPEG4_AAC: | 718 case MPEG4_AAC: |
693 case H264: | 719 case H264: |
694 case HEVC: | 720 case HEVC: |
721 case DolbyVision: | |
695 return true; | 722 return true; |
696 | 723 |
697 case PCM: | 724 case PCM: |
698 case VORBIS: | 725 case VORBIS: |
699 case OPUS: | 726 case OPUS: |
700 case FLAC: | 727 case FLAC: |
701 case VP8: | 728 case VP8: |
702 case VP9: | 729 case VP9: |
703 case THEORA: | 730 case THEORA: |
704 return false; | 731 return false; |
(...skipping 28 matching lines...) Expand all Loading... | |
733 const std::string& mime_type_lower_case, | 760 const std::string& mime_type_lower_case, |
734 bool is_encrypted) const { | 761 bool is_encrypted) const { |
735 Codec default_codec = Codec::INVALID_CODEC; | 762 Codec default_codec = Codec::INVALID_CODEC; |
736 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) | 763 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) |
737 return false; | 764 return false; |
738 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); | 765 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); |
739 } | 766 } |
740 | 767 |
741 } // namespace internal | 768 } // namespace internal |
742 } // namespace media | 769 } // namespace media |
OLD | NEW |