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
3 // found in the LICENSE file.
7 #include "base/containers/hash_tables.h"
8 #include "base/lazy_instance.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h"
12 #include "build/build_config.h"
13 #include "media/base/mime_util.h"
15 #if defined(OS_ANDROID)
16 #include "base/android/build_info.h"
21 // Singleton utility class for mime types.
45 bool IsSupportedMediaMimeType(const std::string
& mime_type
) const;
47 bool AreSupportedMediaCodecs(const std::vector
<std::string
>& codecs
) const;
49 void ParseCodecString(const std::string
& codecs
,
50 std::vector
<std::string
>* codecs_out
,
53 bool IsStrictMediaMimeType(const std::string
& mime_type
) const;
54 SupportsType
IsSupportedStrictMediaMimeType(
55 const std::string
& mime_type
,
56 const std::vector
<std::string
>& codecs
) const;
58 void RemoveProprietaryMediaTypesAndCodecsForTests();
61 friend struct base::DefaultLazyInstanceTraits
<MimeUtil
>;
63 typedef base::hash_set
<int> CodecSet
;
64 typedef std::map
<std::string
, CodecSet
> StrictMappings
;
66 CodecEntry() : codec(INVALID_CODEC
), is_ambiguous(true) {}
67 CodecEntry(Codec c
, bool ambiguous
) : codec(c
), is_ambiguous(ambiguous
) {}
71 typedef std::map
<std::string
, CodecEntry
> StringToCodecMappings
;
75 // For faster lookup, keep hash sets.
76 void InitializeMimeTypeMaps();
78 // Returns IsSupported if all codec IDs in |codecs| are unambiguous
79 // and are supported by the platform. MayBeSupported is returned if
80 // at least one codec ID in |codecs| is ambiguous but all the codecs
81 // are supported by the platform. IsNotSupported is returned if at
82 // least one codec ID is not supported by the platform.
83 SupportsType
AreSupportedCodecs(
84 const CodecSet
& supported_codecs
,
85 const std::vector
<std::string
>& codecs
) const;
87 // Converts a codec ID into an Codec enum value and indicates
88 // whether the conversion was ambiguous.
89 // Returns true if this method was able to map |codec_id| to a specific
90 // Codec enum value. |codec| and |is_ambiguous| are only valid if true
91 // is returned. Otherwise their value is undefined after the call.
92 // |is_ambiguous| is true if |codec_id| did not have enough information to
93 // unambiguously determine the proper Codec enum value. If |is_ambiguous|
94 // is true |codec| contains the best guess for the intended Codec enum value.
95 bool StringToCodec(const std::string
& codec_id
,
97 bool* is_ambiguous
) const;
99 // Returns true if |codec| is supported by the platform.
100 // Note: This method will return false if the platform supports proprietary
101 // codecs but |allow_proprietary_codecs_| is set to false.
102 bool IsCodecSupported(Codec codec
) const;
104 // Returns true if |codec| refers to a proprietary codec.
105 bool IsCodecProprietary(Codec codec
) const;
107 // Returns true and sets |*default_codec| if |mime_type| has a default codec
108 // associated with it. Returns false otherwise and the value of
109 // |*default_codec| is undefined.
110 bool GetDefaultCodecLowerCase(const std::string
& mime_type_lower_case
,
111 Codec
* default_codec
) const;
113 // Returns true if |mime_type_lower_case| has a default codec associated with
114 // it and IsCodecSupported() returns true for that particular codec.
115 bool IsDefaultCodecSupportedLowerCase(
116 const std::string
& mime_type_lower_case
) const;
118 using MimeTypes
= base::hash_set
<std::string
>;
119 MimeTypes media_map_
;
121 // A map of mime_types and hash map of the supported codecs for the mime_type.
122 StrictMappings strict_format_map_
;
124 // Keeps track of whether proprietary codec support should be
125 // advertised to callers.
126 bool allow_proprietary_codecs_
;
128 // Lookup table for string compare based string -> Codec mappings.
129 StringToCodecMappings string_to_codec_map_
;
131 DISALLOW_COPY_AND_ASSIGN(MimeUtil
);
134 // This variable is Leaky because it is accessed from WorkerPool threads.
135 static base::LazyInstance
<MimeUtil
>::Leaky g_media_mime_util
=
136 LAZY_INSTANCE_INITIALIZER
;
139 // A list of media types: http://en.wikipedia.org/wiki/Internet_media_type
140 // A comprehensive mime type list: http://plugindoc.mozdev.org/winmime.php
141 // This set of codecs is supported by all variations of Chromium.
142 static const char* const common_media_types
[] = {
146 #if !defined(OS_ANDROID) // Android doesn't support Ogg Theora.
158 #if defined(OS_ANDROID)
160 "application/vnd.apple.mpegurl",
161 "application/x-mpegurl",
165 // List of proprietary types only supported by Google Chrome.
166 static const char* const proprietary_media_types
[] = {
181 #if defined(ENABLE_MPEG2TS_STREAM_PARSER)
187 #if defined(OS_ANDROID)
188 static bool IsCodecSupportedOnAndroid(MimeUtil::Codec codec
) {
190 case MimeUtil::INVALID_CODEC
:
195 case MimeUtil::MPEG4_AAC_LC
:
196 case MimeUtil::MPEG4_AAC_SBR_v1
:
197 case MimeUtil::MPEG4_AAC_SBR_PS_v2
:
198 case MimeUtil::H264_BASELINE
:
199 case MimeUtil::H264_MAIN
:
200 case MimeUtil::H264_HIGH
:
202 case MimeUtil::VORBIS
:
205 case MimeUtil::HEVC_MAIN
:
206 #if defined(ENABLE_HEVC_DEMUXING)
207 // HEVC/H.265 is supported in Lollipop+ (API Level 21), according to
208 // http://developer.android.com/reference/android/media/MediaFormat.html
209 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21;
214 case MimeUtil::MPEG2_AAC_LC
:
215 case MimeUtil::MPEG2_AAC_MAIN
:
216 case MimeUtil::MPEG2_AAC_SSR
:
217 // MPEG-2 variants of AAC are not supported on Android.
221 // VP9 is supported only in KitKat+ (API Level 19).
222 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19;
225 // Opus is supported only in Lollipop+ (API Level 21).
226 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21;
228 case MimeUtil::THEORA
:
236 struct MediaFormatStrict
{
237 const char* const mime_type
;
238 const char* const codecs_list
;
241 // Following is the list of RFC 6381 compliant codecs:
242 // mp4a.66 - MPEG-2 AAC MAIN
243 // mp4a.67 - MPEG-2 AAC LC
244 // mp4a.68 - MPEG-2 AAC SSR
245 // mp4a.69 - MPEG-2 extension to MPEG-1
246 // mp4a.6B - MPEG-1 audio
247 // mp4a.40.2 - MPEG-4 AAC LC
248 // mp4a.40.02 - MPEG-4 AAC LC (leading 0 in aud-oti for compatibility)
249 // mp4a.40.5 - MPEG-4 HE-AAC v1 (AAC LC + SBR)
250 // mp4a.40.05 - MPEG-4 HE-AAC v1 (AAC LC + SBR) (leading 0 in aud-oti for
252 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS)
254 // avc1.42E0xx - H.264 Baseline
255 // avc1.4D40xx - H.264 Main
256 // avc1.6400xx - H.264 High
257 static const char kMP4AudioCodecsExpression
[] =
258 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
259 "mp4a.40.05,mp4a.40.29";
260 static const char kMP4VideoCodecsExpression
[] =
261 // This is not a complete list of supported avc1 codecs. It is simply used
262 // to register support for the corresponding Codec enum. Instead of using
263 // strings in these three arrays, we should use the Codec enum values.
264 // This will avoid confusion and unnecessary parsing at runtime.
265 // kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only
266 // mapping from strings to codecs. See crbug.com/461009.
267 "avc1.42E00A,avc1.4D400A,avc1.64000A,"
268 #if defined(ENABLE_HEVC_DEMUXING)
269 // Any valid unambiguous HEVC codec id will work here, since these strings
270 // are parsed and mapped to MimeUtil::Codec enum values.
273 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
274 "mp4a.40.05,mp4a.40.29";
276 // These containers are also included in
277 // common_media_types/proprietary_media_types. See crbug.com/461012.
278 static const MediaFormatStrict format_codec_mappings
[] = {
279 {"video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0"},
280 {"audio/webm", "opus,vorbis"},
282 {"audio/x-wav", "1"},
283 // Android does not support Opus in Ogg container.
284 #if defined(OS_ANDROID)
285 {"video/ogg", "theora,vorbis"},
286 {"audio/ogg", "vorbis"},
287 {"application/ogg", "theora,vorbis"},
289 {"video/ogg", "opus,theora,vorbis"},
290 {"audio/ogg", "opus,vorbis"},
291 {"application/ogg", "opus,theora,vorbis"},
293 {"audio/mpeg", "mp3"},
297 {"audio/mp4", kMP4AudioCodecsExpression
},
298 {"audio/x-m4a", kMP4AudioCodecsExpression
},
299 {"video/mp4", kMP4VideoCodecsExpression
},
300 {"video/x-m4v", kMP4VideoCodecsExpression
},
301 {"application/x-mpegurl", kMP4VideoCodecsExpression
},
302 {"application/vnd.apple.mpegurl", kMP4VideoCodecsExpression
}};
304 struct CodecIDMappings
{
305 const char* const codec_id
;
306 MimeUtil::Codec codec
;
309 // List of codec IDs that provide enough information to determine the
310 // codec and profile being requested.
312 // The "mp4a" strings come from RFC 6381.
313 static const CodecIDMappings kUnambiguousCodecStringMap
[] = {
314 {"1", MimeUtil::PCM
}, // We only allow this for WAV so it isn't ambiguous.
315 // avc1/avc3.XXXXXX may be unambiguous; handled by ParseH264CodecID().
316 {"mp3", MimeUtil::MP3
},
317 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN
},
318 {"mp4a.67", MimeUtil::MPEG2_AAC_LC
},
319 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR
},
320 {"mp4a.69", MimeUtil::MP3
},
321 {"mp4a.6B", MimeUtil::MP3
},
322 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC
},
323 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC
},
324 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1
},
325 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1
},
326 {"mp4a.40.29", MimeUtil::MPEG4_AAC_SBR_PS_v2
},
327 {"vorbis", MimeUtil::VORBIS
},
328 {"opus", MimeUtil::OPUS
},
329 {"vp8", MimeUtil::VP8
},
330 {"vp8.0", MimeUtil::VP8
},
331 {"vp9", MimeUtil::VP9
},
332 {"vp9.0", MimeUtil::VP9
},
333 {"theora", MimeUtil::THEORA
}};
335 // List of codec IDs that are ambiguous and don't provide
336 // enough information to determine the codec and profile.
337 // The codec in these entries indicate the codec and profile
338 // we assume the user is trying to indicate.
339 static const CodecIDMappings kAmbiguousCodecStringMap
[] = {
340 {"mp4a.40", MimeUtil::MPEG4_AAC_LC
},
341 {"avc1", MimeUtil::H264_BASELINE
},
342 {"avc3", MimeUtil::H264_BASELINE
},
343 // avc1/avc3.XXXXXX may be ambiguous; handled by ParseH264CodecID().
346 MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) {
347 InitializeMimeTypeMaps();
350 SupportsType
MimeUtil::AreSupportedCodecs(
351 const CodecSet
& supported_codecs
,
352 const std::vector
<std::string
>& codecs
) const {
353 DCHECK(!supported_codecs
.empty());
354 DCHECK(!codecs
.empty());
356 SupportsType result
= IsSupported
;
357 for (size_t i
= 0; i
< codecs
.size(); ++i
) {
358 bool is_ambiguous
= true;
359 Codec codec
= INVALID_CODEC
;
360 if (!StringToCodec(codecs
[i
], &codec
, &is_ambiguous
))
361 return IsNotSupported
;
363 if (!IsCodecSupported(codec
) ||
364 supported_codecs
.find(codec
) == supported_codecs
.end()) {
365 return IsNotSupported
;
369 result
= MayBeSupported
;
375 void MimeUtil::InitializeMimeTypeMaps() {
376 // Initialize the supported media types.
377 for (size_t i
= 0; i
< arraysize(common_media_types
); ++i
)
378 media_map_
.insert(common_media_types
[i
]);
379 #if defined(USE_PROPRIETARY_CODECS)
380 allow_proprietary_codecs_
= true;
382 for (size_t i
= 0; i
< arraysize(proprietary_media_types
); ++i
)
383 media_map_
.insert(proprietary_media_types
[i
]);
386 for (size_t i
= 0; i
< arraysize(kUnambiguousCodecStringMap
); ++i
) {
387 string_to_codec_map_
[kUnambiguousCodecStringMap
[i
].codec_id
] =
388 CodecEntry(kUnambiguousCodecStringMap
[i
].codec
, false);
391 for (size_t i
= 0; i
< arraysize(kAmbiguousCodecStringMap
); ++i
) {
392 string_to_codec_map_
[kAmbiguousCodecStringMap
[i
].codec_id
] =
393 CodecEntry(kAmbiguousCodecStringMap
[i
].codec
, true);
396 // Initialize the strict supported media types.
397 for (size_t i
= 0; i
< arraysize(format_codec_mappings
); ++i
) {
398 std::vector
<std::string
> mime_type_codecs
;
399 ParseCodecString(format_codec_mappings
[i
].codecs_list
,
404 for (size_t j
= 0; j
< mime_type_codecs
.size(); ++j
) {
405 Codec codec
= INVALID_CODEC
;
406 bool is_ambiguous
= true;
407 CHECK(StringToCodec(mime_type_codecs
[j
], &codec
, &is_ambiguous
));
408 DCHECK(!is_ambiguous
);
409 codecs
.insert(codec
);
412 strict_format_map_
[format_codec_mappings
[i
].mime_type
] = codecs
;
416 bool MimeUtil::IsSupportedMediaMimeType(const std::string
& mime_type
) const {
417 return media_map_
.find(base::ToLowerASCII(mime_type
)) != media_map_
.end();
421 bool MimeUtil::AreSupportedMediaCodecs(
422 const std::vector
<std::string
>& codecs
) const {
423 for (size_t i
= 0; i
< codecs
.size(); ++i
) {
424 Codec codec
= INVALID_CODEC
;
425 bool is_ambiguous
= true;
426 if (!StringToCodec(codecs
[i
], &codec
, &is_ambiguous
) ||
427 !IsCodecSupported(codec
)) {
434 void MimeUtil::ParseCodecString(const std::string
& codecs
,
435 std::vector
<std::string
>* codecs_out
,
437 *codecs_out
= base::SplitString(
438 base::TrimString(codecs
, "\"", base::TRIM_ALL
),
439 ",", base::TRIM_WHITESPACE
, base::SPLIT_WANT_ALL
);
441 // Convert empty or all-whitespace input to 0 results.
442 if (codecs_out
->size() == 1 && (*codecs_out
)[0].empty())
448 // Strip everything past the first '.'
449 for (std::vector
<std::string
>::iterator it
= codecs_out
->begin();
450 it
!= codecs_out
->end();
452 size_t found
= it
->find_first_of('.');
453 if (found
!= std::string::npos
)
458 bool MimeUtil::IsStrictMediaMimeType(const std::string
& mime_type
) const {
459 return strict_format_map_
.find(base::ToLowerASCII(mime_type
)) !=
460 strict_format_map_
.end();
463 SupportsType
MimeUtil::IsSupportedStrictMediaMimeType(
464 const std::string
& mime_type
,
465 const std::vector
<std::string
>& codecs
) const {
466 const std::string mime_type_lower_case
= base::ToLowerASCII(mime_type
);
467 StrictMappings::const_iterator it_strict_map
=
468 strict_format_map_
.find(mime_type_lower_case
);
469 if (it_strict_map
== strict_format_map_
.end())
470 return codecs
.empty() ? MayBeSupported
: IsNotSupported
;
472 if (it_strict_map
->second
.empty()) {
473 // We get here if the mimetype does not expect a codecs parameter.
474 return (codecs
.empty() &&
475 IsDefaultCodecSupportedLowerCase(mime_type_lower_case
))
480 if (codecs
.empty()) {
481 // We get here if the mimetype expects to get a codecs parameter,
482 // but didn't get one. If |mime_type_lower_case| does not have a default
483 // codec the best we can do is say "maybe" because we don't have enough
485 Codec default_codec
= INVALID_CODEC
;
486 if (!GetDefaultCodecLowerCase(mime_type_lower_case
, &default_codec
))
487 return MayBeSupported
;
489 return IsCodecSupported(default_codec
) ? IsSupported
: IsNotSupported
;
492 return AreSupportedCodecs(it_strict_map
->second
, codecs
);
495 void MimeUtil::RemoveProprietaryMediaTypesAndCodecsForTests() {
496 for (size_t i
= 0; i
< arraysize(proprietary_media_types
); ++i
)
497 media_map_
.erase(proprietary_media_types
[i
]);
498 allow_proprietary_codecs_
= false;
501 static bool IsValidH264Level(const std::string
& level_str
) {
503 if (level_str
.size() != 2 || !base::HexStringToUInt(level_str
, &level
))
506 // Valid levels taken from Table A-1 in ISO-14496-10.
507 // Essentially |level_str| is toHex(10 * level).
508 return ((level
>= 10 && level
<= 13) ||
509 (level
>= 20 && level
<= 22) ||
510 (level
>= 30 && level
<= 32) ||
511 (level
>= 40 && level
<= 42) ||
512 (level
>= 50 && level
<= 51));
515 // Handle parsing H.264 codec IDs as outlined in RFC 6381 and ISO-14496-10.
516 // avc1.42x0yy - H.264 Baseline
517 // avc1.4Dx0yy - H.264 Main
518 // avc1.64x0yy - H.264 High
520 // avc1.xxxxxx & avc3.xxxxxx are considered ambiguous forms that are trying to
521 // signal H.264 Baseline. For example, the idc_level, profile_idc and
522 // constraint_set3_flag pieces may explicitly require decoder to conform to
523 // baseline profile at the specified level (see Annex A and constraint_set0 in
525 static bool ParseH264CodecID(const std::string
& codec_id
,
526 MimeUtil::Codec
* codec
,
527 bool* is_ambiguous
) {
528 // Make sure we have avc1.xxxxxx or avc3.xxxxxx , where xxxxxx are hex digits
529 if (!base::StartsWith(codec_id
, "avc1.", base::CompareCase::SENSITIVE
) &&
530 !base::StartsWith(codec_id
, "avc3.", base::CompareCase::SENSITIVE
)) {
533 if (codec_id
.size() != 11 ||
534 !base::IsHexDigit(codec_id
[5]) || !base::IsHexDigit(codec_id
[6]) ||
535 !base::IsHexDigit(codec_id
[7]) || !base::IsHexDigit(codec_id
[8]) ||
536 !base::IsHexDigit(codec_id
[9]) || !base::IsHexDigit(codec_id
[10])) {
540 // Validate constraint flags and reserved bits.
541 if (!base::IsHexDigit(codec_id
[7]) || codec_id
[8] != '0') {
542 *codec
= MimeUtil::H264_BASELINE
;
543 *is_ambiguous
= true;
547 // Extract the profile.
548 std::string profile
= base::ToUpperASCII(codec_id
.substr(5, 2));
549 if (profile
== "42") {
550 *codec
= MimeUtil::H264_BASELINE
;
551 } else if (profile
== "4D") {
552 *codec
= MimeUtil::H264_MAIN
;
553 } else if (profile
== "64") {
554 *codec
= MimeUtil::H264_HIGH
;
556 *codec
= MimeUtil::H264_BASELINE
;
557 *is_ambiguous
= true;
562 *is_ambiguous
= !IsValidH264Level(base::ToUpperASCII(codec_id
.substr(9)));
566 #if defined(ENABLE_HEVC_DEMUXING)
567 // ISO/IEC FDIS 14496-15 standard section E.3 describes the syntax of codec ids
568 // reserved for HEVC. According to that spec HEVC codec id must start with
569 // either "hev1." or "hvc1.". We don't yet support full parsing of HEVC codec
570 // ids, but since no other codec id starts with those string we'll just treat
571 // any string starting with "hev1." or "hvc1." as valid HEVC codec ids.
573 static bool ParseHEVCCodecID(const std::string
& codec_id
,
574 MimeUtil::Codec
* codec
,
575 bool* is_ambiguous
) {
576 if (base::StartsWith(codec_id
, "hev1.", base::CompareCase::SENSITIVE
) ||
577 base::StartsWith(codec_id
, "hvc1.", base::CompareCase::SENSITIVE
)) {
578 *codec
= MimeUtil::HEVC_MAIN
;
580 // TODO(servolk): Full HEVC codec id parsing is not implemented yet (see
581 // crbug.com/482761). So treat HEVC codec ids as ambiguous for now.
582 *is_ambiguous
= true;
584 // TODO(servolk): Most HEVC codec ids are treated as ambiguous (see above),
585 // but we need to recognize at least one valid unambiguous HEVC codec id,
586 // which is added into kMP4VideoCodecsExpression. We need it to be
587 // unambiguous to avoid DCHECK(!is_ambiguous) in InitializeMimeTypeMaps. We
588 // also use these in unit tests (see
589 // content/browser/media/media_canplaytype_browsertest.cc).
590 // Remove this workaround after crbug.com/482761 is fixed.
591 if (codec_id
== "hev1.1.6.L93.B0" || codec_id
== "hvc1.1.6.L93.B0") {
592 *is_ambiguous
= false;
602 bool MimeUtil::StringToCodec(const std::string
& codec_id
,
604 bool* is_ambiguous
) const {
605 StringToCodecMappings::const_iterator itr
=
606 string_to_codec_map_
.find(codec_id
);
607 if (itr
!= string_to_codec_map_
.end()) {
608 *codec
= itr
->second
.codec
;
609 *is_ambiguous
= itr
->second
.is_ambiguous
;
613 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is
614 // either H.264 or HEVC/H.265 codec ID because currently those are the only
615 // ones that are not added to the |string_to_codec_map_| and require parsing.
616 #if defined(ENABLE_HEVC_DEMUXING)
617 if (ParseHEVCCodecID(codec_id
, codec
, is_ambiguous
)) {
621 return ParseH264CodecID(codec_id
, codec
, is_ambiguous
);
624 bool MimeUtil::IsCodecSupported(Codec codec
) const {
625 DCHECK_NE(codec
, INVALID_CODEC
);
627 #if defined(OS_ANDROID)
628 if (!IsCodecSupportedOnAndroid(codec
))
632 return allow_proprietary_codecs_
|| !IsCodecProprietary(codec
);
635 bool MimeUtil::IsCodecProprietary(Codec codec
) const {
643 case MPEG4_AAC_SBR_v1
:
644 case MPEG4_AAC_SBR_PS_v2
:
663 bool MimeUtil::GetDefaultCodecLowerCase(const std::string
& mime_type_lower_case
,
664 Codec
* default_codec
) const {
665 if (mime_type_lower_case
== "audio/mpeg" ||
666 mime_type_lower_case
== "audio/mp3" ||
667 mime_type_lower_case
== "audio/x-mp3") {
668 *default_codec
= MimeUtil::MP3
;
672 if (mime_type_lower_case
== "audio/aac") {
673 *default_codec
= MimeUtil::MPEG4_AAC_LC
;
680 bool MimeUtil::IsDefaultCodecSupportedLowerCase(
681 const std::string
& mime_type_lower_case
) const {
682 Codec default_codec
= Codec::INVALID_CODEC
;
683 if (!GetDefaultCodecLowerCase(mime_type_lower_case
, &default_codec
))
685 return IsCodecSupported(default_codec
);
688 bool IsSupportedMediaMimeType(const std::string
& mime_type
) {
689 return g_media_mime_util
.Get().IsSupportedMediaMimeType(mime_type
);
692 bool AreSupportedMediaCodecs(const std::vector
<std::string
>& codecs
) {
693 return g_media_mime_util
.Get().AreSupportedMediaCodecs(codecs
);
696 bool IsStrictMediaMimeType(const std::string
& mime_type
) {
697 return g_media_mime_util
.Get().IsStrictMediaMimeType(mime_type
);
700 SupportsType
IsSupportedStrictMediaMimeType(
701 const std::string
& mime_type
,
702 const std::vector
<std::string
>& codecs
) {
703 return g_media_mime_util
.Get().IsSupportedStrictMediaMimeType(
707 void ParseCodecString(const std::string
& codecs
,
708 std::vector
<std::string
>* codecs_out
,
710 g_media_mime_util
.Get().ParseCodecString(codecs
, codecs_out
, strip
);
713 void RemoveProprietaryMediaTypesAndCodecsForTests() {
714 g_media_mime_util
.Get().RemoveProprietaryMediaTypesAndCodecsForTests();