| 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 <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 case MimeUtil::H264: | 133 case MimeUtil::H264: |
| 134 return kCodecH264; | 134 return kCodecH264; |
| 135 case MimeUtil::HEVC: | 135 case MimeUtil::HEVC: |
| 136 return kCodecHEVC; | 136 return kCodecHEVC; |
| 137 case MimeUtil::VP8: | 137 case MimeUtil::VP8: |
| 138 return kCodecVP8; | 138 return kCodecVP8; |
| 139 case MimeUtil::VP9: | 139 case MimeUtil::VP9: |
| 140 return kCodecVP9; | 140 return kCodecVP9; |
| 141 case MimeUtil::THEORA: | 141 case MimeUtil::THEORA: |
| 142 return kCodecTheora; | 142 return kCodecTheora; |
| 143 case MimeUtil::DOLBY_VISION: |
| 144 return kCodecDolbyVision; |
| 143 default: | 145 default: |
| 144 break; | 146 break; |
| 145 } | 147 } |
| 146 return kUnknownVideoCodec; | 148 return kUnknownVideoCodec; |
| 147 } | 149 } |
| 148 | 150 |
| 149 SupportsType MimeUtil::AreSupportedCodecs( | 151 SupportsType MimeUtil::AreSupportedCodecs( |
| 150 const CodecSet& supported_codecs, | 152 const CodecSet& supported_codecs, |
| 151 const std::vector<std::string>& codecs, | 153 const std::vector<std::string>& codecs, |
| 152 const std::string& mime_type_lower_case, | 154 const std::string& mime_type_lower_case, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 #endif // BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 263 #endif // BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 262 | 264 |
| 263 CodecSet mp4_video_codecs; | 265 CodecSet mp4_video_codecs; |
| 264 mp4_video_codecs.insert(H264); | 266 mp4_video_codecs.insert(H264); |
| 265 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 267 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 266 mp4_video_codecs.insert(HEVC); | 268 mp4_video_codecs.insert(HEVC); |
| 267 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING) | 269 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 268 // Only VP9 with valid codec string vp09.xx.xx.xx.xx.xx.xx.xx is supported. | 270 // Only VP9 with valid codec string vp09.xx.xx.xx.xx.xx.xx.xx is supported. |
| 269 // See ParseVp9CodecID for details. | 271 // See ParseVp9CodecID for details. |
| 270 mp4_video_codecs.insert(VP9); | 272 mp4_video_codecs.insert(VP9); |
| 273 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) |
| 274 mp4_video_codecs.insert(DOLBY_VISION); |
| 275 #endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) |
| 271 CodecSet mp4_codecs(mp4_audio_codecs); | 276 CodecSet mp4_codecs(mp4_audio_codecs); |
| 272 mp4_codecs.insert(mp4_video_codecs.begin(), mp4_video_codecs.end()); | 277 mp4_codecs.insert(mp4_video_codecs.begin(), mp4_video_codecs.end()); |
| 273 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 278 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 274 | 279 |
| 275 AddContainerWithCodecs("audio/wav", wav_codecs, false); | 280 AddContainerWithCodecs("audio/wav", wav_codecs, false); |
| 276 AddContainerWithCodecs("audio/x-wav", wav_codecs, false); | 281 AddContainerWithCodecs("audio/x-wav", wav_codecs, false); |
| 277 AddContainerWithCodecs("audio/webm", webm_audio_codecs, false); | 282 AddContainerWithCodecs("audio/webm", webm_audio_codecs, false); |
| 278 DCHECK(!webm_video_codecs.empty()); | 283 DCHECK(!webm_video_codecs.empty()); |
| 279 AddContainerWithCodecs("video/webm", webm_codecs, false); | 284 AddContainerWithCodecs("video/webm", webm_codecs, false); |
| 280 AddContainerWithCodecs("audio/ogg", ogg_audio_codecs, false); | 285 AddContainerWithCodecs("audio/ogg", ogg_audio_codecs, false); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 if (!platform_info.has_platform_vp9_decoder) | 534 if (!platform_info.has_platform_vp9_decoder) |
| 530 return false; | 535 return false; |
| 531 | 536 |
| 532 // Encrypted content is demuxed so the container is irrelevant. | 537 // Encrypted content is demuxed so the container is irrelevant. |
| 533 if (is_encrypted) | 538 if (is_encrypted) |
| 534 return true; | 539 return true; |
| 535 | 540 |
| 536 // MediaPlayer only supports VP9 in WebM. | 541 // MediaPlayer only supports VP9 in WebM. |
| 537 return mime_type_lower_case == "video/webm"; | 542 return mime_type_lower_case == "video/webm"; |
| 538 } | 543 } |
| 544 |
| 545 case DOLBY_VISION: |
| 546 // This function is only called on Android which doesn't support Dolby |
| 547 // Vision. |
| 548 return false; |
| 539 } | 549 } |
| 540 | 550 |
| 541 return false; | 551 return false; |
| 542 } | 552 } |
| 543 | 553 |
| 544 bool MimeUtil::ParseCodecString(const std::string& mime_type_lower_case, | 554 bool MimeUtil::ParseCodecString(const std::string& mime_type_lower_case, |
| 545 const std::string& codec_id, | 555 const std::string& codec_id, |
| 546 Codec* codec, | 556 Codec* codec, |
| 547 bool* ambiguous_codec_string, | 557 bool* ambiguous_codec_string, |
| 548 VideoCodecProfile* out_profile, | 558 VideoCodecProfile* out_profile, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 return true; | 605 return true; |
| 596 } | 606 } |
| 597 | 607 |
| 598 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 608 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 599 if (ParseHEVCCodecId(codec_id, out_profile, out_level)) { | 609 if (ParseHEVCCodecId(codec_id, out_profile, out_level)) { |
| 600 *codec = MimeUtil::HEVC; | 610 *codec = MimeUtil::HEVC; |
| 601 return true; | 611 return true; |
| 602 } | 612 } |
| 603 #endif | 613 #endif |
| 604 | 614 |
| 615 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) |
| 616 if (ParseDolbyVisionCodecId(codec_id, out_profile, out_level)) { |
| 617 *codec = MimeUtil::DOLBY_VISION; |
| 618 return true; |
| 619 } |
| 620 #endif |
| 621 |
| 605 DVLOG(2) << __func__ << ": Unrecognized codec id " << codec_id; | 622 DVLOG(2) << __func__ << ": Unrecognized codec id " << codec_id; |
| 606 return false; | 623 return false; |
| 607 } | 624 } |
| 608 | 625 |
| 609 SupportsType MimeUtil::IsSimpleCodecSupported( | 626 SupportsType MimeUtil::IsSimpleCodecSupported( |
| 610 const std::string& mime_type_lower_case, | 627 const std::string& mime_type_lower_case, |
| 611 Codec codec, | 628 Codec codec, |
| 612 bool is_encrypted) const { | 629 bool is_encrypted) const { |
| 613 // Video codecs are not "simple" because they require a profile and level to | 630 // Video codecs are not "simple" because they require a profile and level to |
| 614 // be specified. There is no "default" video codec for a given container. | 631 // be specified. There is no "default" video codec for a given container. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 bool MimeUtil::IsCodecProprietary(Codec codec) const { | 713 bool MimeUtil::IsCodecProprietary(Codec codec) const { |
| 697 switch (codec) { | 714 switch (codec) { |
| 698 case INVALID_CODEC: | 715 case INVALID_CODEC: |
| 699 case AC3: | 716 case AC3: |
| 700 case EAC3: | 717 case EAC3: |
| 701 case MP3: | 718 case MP3: |
| 702 case MPEG2_AAC: | 719 case MPEG2_AAC: |
| 703 case MPEG4_AAC: | 720 case MPEG4_AAC: |
| 704 case H264: | 721 case H264: |
| 705 case HEVC: | 722 case HEVC: |
| 723 case DOLBY_VISION: |
| 706 return true; | 724 return true; |
| 707 | 725 |
| 708 case PCM: | 726 case PCM: |
| 709 case VORBIS: | 727 case VORBIS: |
| 710 case OPUS: | 728 case OPUS: |
| 711 case FLAC: | 729 case FLAC: |
| 712 case VP8: | 730 case VP8: |
| 713 case VP9: | 731 case VP9: |
| 714 case THEORA: | 732 case THEORA: |
| 715 return false; | 733 return false; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 742 SupportsType MimeUtil::IsDefaultCodecSupported(const std::string& mime_type, | 760 SupportsType MimeUtil::IsDefaultCodecSupported(const std::string& mime_type, |
| 743 bool is_encrypted) const { | 761 bool is_encrypted) const { |
| 744 Codec default_codec = Codec::INVALID_CODEC; | 762 Codec default_codec = Codec::INVALID_CODEC; |
| 745 if (!GetDefaultCodec(mime_type, &default_codec)) | 763 if (!GetDefaultCodec(mime_type, &default_codec)) |
| 746 return IsNotSupported; | 764 return IsNotSupported; |
| 747 return IsSimpleCodecSupported(mime_type, default_codec, is_encrypted); | 765 return IsSimpleCodecSupported(mime_type, default_codec, is_encrypted); |
| 748 } | 766 } |
| 749 | 767 |
| 750 } // namespace internal | 768 } // namespace internal |
| 751 } // namespace media | 769 } // namespace media |
| OLD | NEW |