Index: media/base/mime_util.cc |
diff --git a/media/base/mime_util.cc b/media/base/mime_util.cc |
index ff1d3369e1d6017a2274a0aeef4ef2d90f50d18f..9529734cee5c6a38577b55ea9efe979c50ee8229 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" |
@@ -163,11 +164,12 @@ static bool IsCodecSupportedOnAndroid(MimeUtil::Codec codec) { |
case MimeUtil::MPEG2_AAC_MAIN: |
case MimeUtil::MPEG2_AAC_SSR: |
// MPEG-2 variants of AAC are not supported on Android. |
- return false; |
+ return IsUnifiedMediaPipelineEnabled(); |
ddorwin
2016/02/12 18:45:12
As mentioned previously, we need to know that it c
DaleCurtis
2016/02/13 02:01:43
We'll either be using MediaPlayer or the unified m
|
case MimeUtil::OPUS: |
// Opus is supported only in Lollipop+ (API Level 21). |
- return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; |
+ return base::android::BuildInfo::GetInstance()->sdk_int() >= 21 || |
+ IsUnifiedMediaPipelineEnabled(); |
case MimeUtil::HEVC_MAIN: |
#if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
@@ -180,7 +182,8 @@ static bool IsCodecSupportedOnAndroid(MimeUtil::Codec codec) { |
case MimeUtil::VP9: |
// VP9 is supported only in KitKat+ (API Level 19). |
- return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; |
+ return base::android::BuildInfo::GetInstance()->sdk_int() >= 19 || |
+ IsUnifiedMediaPipelineEnabled(); |
ddorwin
2016/02/12 18:45:12
This one may not be affected by the blacklist (bas
DaleCurtis
2016/02/13 02:01:43
The blacklist doesn't matter here (currently), so
|
case MimeUtil::THEORA: |
return false; |
@@ -188,6 +191,19 @@ static bool IsCodecSupportedOnAndroid(MimeUtil::Codec codec) { |
return false; |
} |
+ |
+static bool IsMimeTypeAndCodecSupportedOnAndroid(const std::string& mime_type, |
+ MimeUtil::Codec codec) { |
+ // Opus in ogg is not allowed on Android unless the unified media pipeline is |
+ // available. |
+ if (base::EndsWith(mime_type, "ogg", base::CompareCase::INSENSITIVE_ASCII) && |
ddorwin
2016/02/12 18:45:12
Minor: Since this comes from our code, the check c
DaleCurtis
2016/02/13 02:01:43
Done.
|
+ codec == MimeUtil::OPUS) { |
+ return IsUnifiedMediaPipelineEnabled(); |
ddorwin
2016/02/12 18:45:12
Ditto on the blacklist.
(As long as we support WM
DaleCurtis
2016/02/13 02:01:43
Blacklist doesn't matter here since either the pip
|
+ } |
+ |
+ return true; |
ddorwin
2016/02/12 18:45:12
As mentioned below, we might want to call IsCodecS
DaleCurtis
2016/02/13 02:01:43
Done.
|
+} |
+ |
#endif |
enum MediaFormatType { COMMON, PROPRIETARY }; |
@@ -254,16 +270,13 @@ static const MediaFormat kFormatCodecMappings[] = { |
{"audio/webm", COMMON, "opus,vorbis"}, |
{"audio/wav", COMMON, "1"}, |
{"audio/x-wav", COMMON, "1"}, |
-#if defined(OS_ANDROID) |
- // Android does not support Opus in Ogg container. |
- // Android does not support Theora and thus video/ogg. |
- {"audio/ogg", COMMON, "vorbis"}, |
- {"application/ogg", COMMON, "vorbis"}, |
-#else |
+#if !defined(OS_ANDROID) |
ddorwin
2016/02/12 18:45:12
Should we retain this comment?
// Android does not
DaleCurtis
2016/02/13 02:01:43
Done.
|
{"video/ogg", COMMON, "opus,theora,vorbis"}, |
+#endif |
{"audio/ogg", COMMON, "opus,vorbis"}, |
+ // Note: Theora is not supported on Android and will be rejected during the |
+ // call to IsCodecSupportedOnAndroid(). |
{"application/ogg", COMMON, "opus,theora,vorbis"}, |
-#endif |
#if defined(USE_PROPRIETARY_CODECS) |
{"audio/mpeg", PROPRIETARY, "mp3"}, |
{"audio/mp3", PROPRIETARY, ""}, |
@@ -447,6 +460,16 @@ void MimeUtil::InitializeMimeTypeMaps() { |
bool is_ambiguous = true; |
CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous)); |
DCHECK(!is_ambiguous); |
+ |
+#if defined(OS_ANDROID) |
+ // Android has container retrictions on codecs which may vary at runtime, |
+ // filter out container and codec combinations which are disallowed. |
+ if (!IsMimeTypeAndCodecSupportedOnAndroid( |
+ kFormatCodecMappings[i].mime_type, codec)) { |
+ continue; |
+ } |
+#endif |
+ |
codecs.insert(codec); |
} |