Chromium Code Reviews| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 AddContainerWithCodecs("audio/webm", webm_audio_codecs, false); | 401 AddContainerWithCodecs("audio/webm", webm_audio_codecs, false); |
| 402 DCHECK(!webm_video_codecs.empty()); | 402 DCHECK(!webm_video_codecs.empty()); |
| 403 AddContainerWithCodecs("video/webm", webm_codecs, false); | 403 AddContainerWithCodecs("video/webm", webm_codecs, false); |
| 404 AddContainerWithCodecs("audio/ogg", ogg_audio_codecs, false); | 404 AddContainerWithCodecs("audio/ogg", ogg_audio_codecs, false); |
| 405 // video/ogg is only supported if an appropriate video codec is supported. | 405 // video/ogg is only supported if an appropriate video codec is supported. |
| 406 // Note: This assumes such codecs cannot be later excluded. | 406 // Note: This assumes such codecs cannot be later excluded. |
| 407 if (!ogg_video_codecs.empty()) | 407 if (!ogg_video_codecs.empty()) |
| 408 AddContainerWithCodecs("video/ogg", ogg_codecs, false); | 408 AddContainerWithCodecs("video/ogg", ogg_codecs, false); |
| 409 // TODO(ddorwin): Should the application type support Opus? | 409 // TODO(ddorwin): Should the application type support Opus? |
| 410 AddContainerWithCodecs("application/ogg", ogg_codecs, false); | 410 AddContainerWithCodecs("application/ogg", ogg_codecs, false); |
| 411 AddContainerWithCodecs("audio/flac", implicit_codec, false); | |
| 411 | 412 |
| 412 #if defined(USE_PROPRIETARY_CODECS) | 413 #if defined(USE_PROPRIETARY_CODECS) |
| 413 AddContainerWithCodecs("audio/mpeg", mp3_codecs, true); // Allow "mp3". | 414 AddContainerWithCodecs("audio/mpeg", mp3_codecs, true); // Allow "mp3". |
| 414 AddContainerWithCodecs("audio/mp3", implicit_codec, true); | 415 AddContainerWithCodecs("audio/mp3", implicit_codec, true); |
| 415 AddContainerWithCodecs("audio/x-mp3", implicit_codec, true); | 416 AddContainerWithCodecs("audio/x-mp3", implicit_codec, true); |
| 416 AddContainerWithCodecs("audio/aac", implicit_codec, true); // AAC / ADTS. | 417 AddContainerWithCodecs("audio/aac", implicit_codec, true); // AAC / ADTS. |
| 417 AddContainerWithCodecs("audio/mp4", mp4_audio_codecs, true); | 418 AddContainerWithCodecs("audio/mp4", mp4_audio_codecs, true); |
| 418 DCHECK(!mp4_video_codecs.empty()); | 419 DCHECK(!mp4_video_codecs.empty()); |
| 419 AddContainerWithCodecs("video/mp4", mp4_codecs, true); | 420 AddContainerWithCodecs("video/mp4", mp4_codecs, true); |
| 420 // These strings are supported for backwards compatibility only and thus only | 421 // These strings are supported for backwards compatibility only and thus only |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 case INVALID_CODEC: | 556 case INVALID_CODEC: |
| 556 case AC3: | 557 case AC3: |
| 557 case EAC3: | 558 case EAC3: |
| 558 case THEORA: | 559 case THEORA: |
| 559 return false; | 560 return false; |
| 560 | 561 |
| 561 // ---------------------------------------------------------------------- | 562 // ---------------------------------------------------------------------- |
| 562 // The remaining codecs may be supported depending on platform abilities. | 563 // The remaining codecs may be supported depending on platform abilities. |
| 563 // ---------------------------------------------------------------------- | 564 // ---------------------------------------------------------------------- |
| 564 | 565 |
| 566 case FLAC: | |
|
ddorwin
2016/11/18 00:11:21
Pedantic: This should be after MPEG4_AAC. The othe
DaleCurtis
2016/11/18 00:39:26
Done.
| |
| 565 case PCM: | 567 case PCM: |
| 566 case MP3: | 568 case MP3: |
| 567 case MPEG4_AAC: | 569 case MPEG4_AAC: |
| 568 case VORBIS: | 570 case VORBIS: |
| 569 // These codecs are always supported; via a platform decoder (when used | 571 // These codecs are always supported; via a platform decoder (when used |
| 570 // with MSE/EME), a software decoder (the unified pipeline), or with | 572 // with MSE/EME), a software decoder (the unified pipeline), or with |
| 571 // MediaPlayer. | 573 // MediaPlayer. |
| 572 DCHECK(!is_encrypted || platform_info.has_platform_decoders); | 574 DCHECK(!is_encrypted || platform_info.has_platform_decoders); |
| 573 return true; | 575 return true; |
| 574 | 576 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 759 case INVALID_CODEC: | 761 case INVALID_CODEC: |
| 760 case AC3: | 762 case AC3: |
| 761 case EAC3: | 763 case EAC3: |
| 762 case MP3: | 764 case MP3: |
| 763 case MPEG2_AAC: | 765 case MPEG2_AAC: |
| 764 case MPEG4_AAC: | 766 case MPEG4_AAC: |
| 765 case H264: | 767 case H264: |
| 766 case HEVC: | 768 case HEVC: |
| 767 return true; | 769 return true; |
| 768 | 770 |
| 771 case FLAC: | |
|
ddorwin
2016/11/18 00:11:21
Pedantic: This should be after OPUS.
DaleCurtis
2016/11/18 00:39:26
Done.
| |
| 769 case PCM: | 772 case PCM: |
| 770 case VORBIS: | 773 case VORBIS: |
| 771 case OPUS: | 774 case OPUS: |
| 772 case VP8: | 775 case VP8: |
| 773 case VP9: | 776 case VP9: |
| 774 case THEORA: | 777 case THEORA: |
| 775 return false; | 778 return false; |
| 776 } | 779 } |
| 777 | 780 |
| 778 return true; | 781 return true; |
|
ddorwin
2016/11/18 00:11:21
Should we have a NOTREACHED() here?
Can be a separ
| |
| 779 } | 782 } |
| 780 | 783 |
| 781 bool MimeUtil::GetDefaultCodecLowerCase(const std::string& mime_type_lower_case, | 784 bool MimeUtil::GetDefaultCodecLowerCase(const std::string& mime_type_lower_case, |
| 782 Codec* default_codec) const { | 785 Codec* default_codec) const { |
| 783 if (mime_type_lower_case == "audio/mpeg" || | 786 if (mime_type_lower_case == "audio/mpeg" || |
| 784 mime_type_lower_case == "audio/mp3" || | 787 mime_type_lower_case == "audio/mp3" || |
| 785 mime_type_lower_case == "audio/x-mp3") { | 788 mime_type_lower_case == "audio/x-mp3") { |
| 786 *default_codec = MimeUtil::MP3; | 789 *default_codec = MimeUtil::MP3; |
| 787 return true; | 790 return true; |
| 788 } | 791 } |
| 789 | 792 |
| 790 if (mime_type_lower_case == "audio/aac") { | 793 if (mime_type_lower_case == "audio/aac") { |
| 791 *default_codec = MimeUtil::MPEG4_AAC; | 794 *default_codec = MimeUtil::MPEG4_AAC; |
| 792 return true; | 795 return true; |
| 793 } | 796 } |
| 794 | 797 |
| 798 if (mime_type_lower_case == "audio/flac") { | |
| 799 *default_codec = MimeUtil::FLAC; | |
| 800 return true; | |
| 801 } | |
| 802 | |
| 795 return false; | 803 return false; |
| 796 } | 804 } |
| 797 | 805 |
| 798 bool MimeUtil::IsDefaultCodecSupportedLowerCase( | 806 bool MimeUtil::IsDefaultCodecSupportedLowerCase( |
| 799 const std::string& mime_type_lower_case, | 807 const std::string& mime_type_lower_case, |
| 800 bool is_encrypted) const { | 808 bool is_encrypted) const { |
| 801 Codec default_codec = Codec::INVALID_CODEC; | 809 Codec default_codec = Codec::INVALID_CODEC; |
| 802 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) | 810 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) |
| 803 return false; | 811 return false; |
| 804 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); | 812 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); |
| 805 } | 813 } |
| 806 | 814 |
| 807 } // namespace internal | 815 } // namespace internal |
| 808 } // namespace media | 816 } // namespace media |
| OLD | NEW |