Adding platform specific variables for MediaCanPlayTypeTest

Vp9 codec is supported after KitKat (API level 19)
Expectation values are modifed in the test case based on the Android sdk version

HLS mime types are supported after Ice-cream sandwich (API level 14)
A check for identifying android version is added which decides whether the mime type should be added in the media_map_ or not.

Theora is not supported on Android. This check is also added in the "IsCodecSupportedOnAndroid".

MediaCanPlayType test are re-enabled on android.

BUG=357665

Review URL: https://codereview.chromium.org/230413003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269748 0039d316-1c4b-4281-b951-d872f2087c98
parent c6fb725b
......@@ -413,6 +413,10 @@ static const char* const supported_javascript_types[] = {
#if defined(OS_ANDROID)
static bool IsCodecSupportedOnAndroid(const std::string& codec) {
// Theora is not supported in Android
if (!codec.compare("theora"))
return false;
// VP9 is supported only in KitKat+ (API Level 19).
if ((!codec.compare("vp9") || !codec.compare("vp9.0")) &&
base::android::BuildInfo::GetInstance()->sdk_int() < 19) {
......@@ -426,6 +430,16 @@ static bool IsCodecSupportedOnAndroid(const std::string& codec) {
}
return true;
}
static bool IsMimeTypeSupportedOnAndroid(const std::string& mimeType) {
// HLS codecs are supported in ICS and above (API level 14)
if ((!mimeType.compare("application/vnd.apple.mpegurl") ||
!mimeType.compare("application/x-mpegurl")) &&
base::android::BuildInfo::GetInstance()->sdk_int() < 14) {
return false;
}
return true;
}
#endif
struct MediaFormatStrict {
......@@ -476,16 +490,26 @@ void MimeUtil::InitializeMimeTypeMaps() {
unsupported_text_map_.insert(unsupported_text_types[i]);
for (size_t i = 0; i < arraysize(supported_javascript_types); ++i)
non_image_map_.insert(supported_javascript_types[i]);
for (size_t i = 0; i < arraysize(common_media_types); ++i)
for (size_t i = 0; i < arraysize(common_media_types); ++i) {
#if defined(OS_ANDROID)
if (!IsMimeTypeSupportedOnAndroid(common_media_types[i]))
continue;
#endif
non_image_map_.insert(common_media_types[i]);
}
#if defined(USE_PROPRIETARY_CODECS)
for (size_t i = 0; i < arraysize(proprietary_media_types); ++i)
non_image_map_.insert(proprietary_media_types[i]);
#endif
// Initialize the supported media types.
for (size_t i = 0; i < arraysize(common_media_types); ++i)
for (size_t i = 0; i < arraysize(common_media_types); ++i) {
#if defined(OS_ANDROID)
if (!IsMimeTypeSupportedOnAndroid(common_media_types[i]))
continue;
#endif
media_map_.insert(common_media_types[i]);
}
#if defined(USE_PROPRIETARY_CODECS)
for (size_t i = 0; i < arraysize(proprietary_media_types); ++i)
media_map_.insert(proprietary_media_types[i]);
......
......@@ -8,6 +8,10 @@
#include "net/base/mime_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
#endif
namespace net {
TEST(MimeUtilTest, ExtensionTest) {
......@@ -189,6 +193,60 @@ TEST(MimeUtilTest, MatchesMimeType) {
EXPECT_TRUE(MatchesMimeType("ab/*cd", "ab/xxxcd"));
}
TEST(MimeUtilTest, CommonMediaMimeType) {
#if defined(OS_ANDROID)
bool HLSSupported;
if (base::android::BuildInfo::GetInstance()->sdk_int() < 14)
HLSSupported = false;
else
HLSSupported = true;
#endif
EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm"));
EXPECT_TRUE(IsSupportedMediaMimeType("video/webm"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/wav"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-wav"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg"));
EXPECT_TRUE(IsSupportedMediaMimeType("application/ogg"));
#if defined(OS_ANDROID)
EXPECT_FALSE(IsSupportedMediaMimeType("video/ogg"));
EXPECT_EQ(HLSSupported, IsSupportedMediaMimeType("application/x-mpegurl"));
EXPECT_EQ(HLSSupported,
IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
#else
EXPECT_TRUE(IsSupportedMediaMimeType("video/ogg"));
EXPECT_FALSE(IsSupportedMediaMimeType("application/x-mpegurl"));
EXPECT_FALSE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
#endif // OS_ANDROID
#if defined(USE_PROPRIETARY_CODECS)
EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp4"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-m4a"));
EXPECT_TRUE(IsSupportedMediaMimeType("video/mp4"));
EXPECT_TRUE(IsSupportedMediaMimeType("video/x-m4v"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp3"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-mp3"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/mpeg"));
#else
EXPECT_FALSE(IsSupportedMediaMimeType("audio/mp4"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/x-m4a"));
EXPECT_FALSE(IsSupportedMediaMimeType("video/mp4"));
EXPECT_FALSE(IsSupportedMediaMimeType("video/x-m4v"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/mp3"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/x-mp3"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/mpeg"));
#endif // USE_PROPRIETARY_CODECS
EXPECT_FALSE(IsSupportedMediaMimeType("video/mp3"));
EXPECT_FALSE(IsSupportedMediaMimeType("video/unknown"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/unknown"));
EXPECT_FALSE(IsSupportedMediaMimeType("unknown/unknown"));
}
// Note: codecs should only be a list of 2 or fewer; hence the restriction of
// results' length to 2.
TEST(MimeUtilTest, ParseCodecString) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment