| Index: media/base/mime_util.cc
|
| diff --git a/media/base/mime_util.cc b/media/base/mime_util.cc
|
| index ff1d3369e1d6017a2274a0aeef4ef2d90f50d18f..3f9bd125b9f39a1e7dbfe7886f4bdcd09acff3ea 100644
|
| --- a/media/base/mime_util.cc
|
| +++ b/media/base/mime_util.cc
|
| @@ -14,6 +14,7 @@
|
| #include "base/strings/string_split.h"
|
| #include "base/strings/string_util.h"
|
| #include "build/build_config.h"
|
| +#include "media/base/media.h"
|
| #include "media/base/mime_util.h"
|
| #include "media/media_features.h"
|
|
|
| @@ -100,6 +101,9 @@ class MimeUtil {
|
| Codec* codec,
|
| bool* is_ambiguous) const;
|
|
|
| + media::AudioCodec MediaCodecToAudioCodec(Codec codec) const;
|
| + media::VideoCodec MediaCodecToVideoCodec(Codec codec) const;
|
| +
|
| // Returns true if |codec| is supported by the platform.
|
| // Note: This method will return false if the platform supports proprietary
|
| // codecs but |allow_proprietary_codecs_| is set to false.
|
| @@ -492,6 +496,9 @@ SupportsType MimeUtil::IsSupportedMediaFormat(
|
| if (it_media_format_map == media_format_map_.end())
|
| return IsNotSupported;
|
|
|
| + // TODO: implement and use media::IsMediaContainerSupported
|
| + // similar to IsVideoCodecSupported
|
| +
|
| if (it_media_format_map->second.empty()) {
|
| // We get here if the mimetype does not expect a codecs parameter.
|
| return (codecs.empty() &&
|
| @@ -655,6 +662,77 @@ bool MimeUtil::StringToCodec(const std::string& codec_id,
|
| return ParseH264CodecID(codec_id, codec, is_ambiguous);
|
| }
|
|
|
| +media::AudioCodec MimeUtil::MediaCodecToAudioCodec(Codec codec) const {
|
| + switch (codec) {
|
| + case PCM:
|
| + return kCodecPCM_S16BE; // kCodecPCM_S24BE
|
| + case MP3:
|
| + return kCodecMP3;
|
| + case AC3:
|
| + return kCodecAC3;
|
| + case EAC3:
|
| + return kCodecEAC3;
|
| + case MPEG2_AAC_LC:
|
| + case MPEG2_AAC_MAIN:
|
| + case MPEG2_AAC_SSR:
|
| + case MPEG4_AAC_LC:
|
| + case MPEG4_AAC_SBR_v1:
|
| + case MPEG4_AAC_SBR_PS_v2:
|
| + return kCodecAAC;
|
| + case VORBIS:
|
| + return kCodecVorbis;
|
| + case OPUS:
|
| + return kCodecOpus;
|
| + /*
|
| + case ?
|
| + return kCodecFLAC;
|
| + case ?
|
| + return kCodecAMR_NB;
|
| + case ?
|
| + return kCodecAMR_WB;
|
| + case ?
|
| + return kCodecPCM_ALAW;
|
| + return kCodecPCM_MULAW;
|
| + case ?
|
| + return kCodecGSM_MS;
|
| + case ?
|
| + return kCodecALAC;;
|
| + */
|
| +
|
| + default:
|
| + DVLOG(1) << "Unknown Codec: " << codec;
|
| + }
|
| + return kUnknownAudioCodec;
|
| +}
|
| +
|
| +VideoCodec MimeUtil::MediaCodecToVideoCodec(Codec codec) const {
|
| + switch (codec) {
|
| + case H264_BASELINE:
|
| + case H264_MAIN:
|
| + case H264_HIGH:
|
| + return kCodecH264;
|
| + case HEVC_MAIN:
|
| + return kCodecHEVC;
|
| + case VP8:
|
| + return kCodecVP8;
|
| + case VP9:
|
| + return kCodecVP9;
|
| + case THEORA:
|
| + return kCodecTheora;
|
| + /*
|
| + case ?:
|
| + return kCodecVC1;
|
| + case ?:
|
| + return kCodecMPEG2;
|
| + case ?:
|
| + return kCodecMPEG4;
|
| + */
|
| + default:
|
| + DVLOG(1) << "Unknown Codec: " << codec;
|
| + }
|
| + return kUnknownVideoCodec;
|
| +}
|
| +
|
| bool MimeUtil::IsCodecSupported(Codec codec) const {
|
| DCHECK_NE(codec, INVALID_CODEC);
|
|
|
| @@ -663,7 +741,27 @@ bool MimeUtil::IsCodecSupported(Codec codec) const {
|
| return false;
|
| #endif
|
|
|
| - return allow_proprietary_codecs_ || !IsCodecProprietary(codec);
|
| + bool allow = allow_proprietary_codecs_ || !IsCodecProprietary(codec);
|
| +
|
| + // Not allowed because of build configuration.
|
| + if (!allow)
|
| + return false;
|
| +
|
| + // Check if the underlying media library actually supports the codec. Useful
|
| + // when the build configuration allows proprietary codecs but not the
|
| + // underlying media library.
|
| +
|
| + AudioCodec audio_codec = MediaCodecToAudioCodec(codec);
|
| + if (audio_codec != kUnknownAudioCodec &&
|
| + media::IsAudioCodecSupported(audio_codec))
|
| + return true;
|
| +
|
| + media::VideoCodec video_codec = MediaCodecToVideoCodec(codec);
|
| + if (video_codec != kUnknownVideoCodec &&
|
| + media::IsVideoCodecSupported(video_codec))
|
| + return true;
|
| +
|
| + return false;
|
| }
|
|
|
| bool MimeUtil::IsCodecProprietary(Codec codec) const {
|
|
|