Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(890)

Unified Diff: media/base/mime_util_unittest.cc

Issue 1690063002: Fix mime type mappings when the unified media pipeline is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify, test, rebase on split. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/mime_util_unittest.cc
diff --git a/media/base/mime_util_unittest.cc b/media/base/mime_util_unittest.cc
index 34a2ea3a33aff50c604ee4e62752191749566c0f..ceab4927212317d852ea71778180f926479fee00 100644
--- a/media/base/mime_util_unittest.cc
+++ b/media/base/mime_util_unittest.cc
@@ -8,11 +8,14 @@
#include "base/strings/string_split.h"
#include "build/build_config.h"
#include "media/base/mime_util.h"
+#include "media/base/mime_util_internal.h"
#include "media/media_features.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {
+const bool kTestStates[] = {true, false};
+
TEST(MimeUtilTest, CommonMediaMimeType) {
EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm"));
EXPECT_TRUE(IsSupportedMediaMimeType("video/webm"));
@@ -111,4 +114,229 @@ TEST(MimeUtilTest, ParseCodecString) {
EXPECT_EQ("mp4a.40.2", codecs_out[1]);
}
+#if defined(OS_ANDROID)
+namespace internal {
+
+TEST(MimeUtilInternalTest, EncryptedCodecsFailWithoutPlatformSupport) {
ddorwin 2016/02/17 21:18:40 These test names should include/refer to IsCodecSu
DaleCurtis 2016/02/18 03:58:10 Done.
+ MimeUtil mime_util;
+ PlatformCodecInfo info;
+ info.has_platform_decoder = false;
+
+ const bool kTestStates[] = {true, false};
ddorwin 2016/02/17 21:18:40 remove
DaleCurtis 2016/02/18 03:58:10 Done.
+ for (bool has_unified_media_pipeline : kTestStates) {
+ info.has_unified_media_pipeline = has_unified_media_pipeline;
+ for (bool has_opus : kTestStates) {
+ info.has_opus = has_opus;
+ for (bool has_vp8 : kTestStates) {
+ info.has_vp8 = has_vp8;
+ for (bool has_vp9 : kTestStates) {
+ info.has_vp9 = has_vp9;
+ mime_util.SetPlatformCodecInfoForTests(info);
+ for (int codec = MimeUtil::INVALID_CODEC;
+ codec <= MimeUtil::LAST_CODEC; ++codec) {
+ ASSERT_FALSE(mime_util.IsCodecSupportedOnAndroidForTests(
ddorwin 2016/02/17 21:18:39 EXPECT_ throughout. We want to run all cases even
DaleCurtis 2016/02/18 03:58:10 Done, but can be obnoxious in local runs if you fa
+ static_cast<MimeUtil::Codec>(codec), "", true));
ddorwin 2016/02/17 21:18:40 It's interesting that the function allows an empty
DaleCurtis 2016/02/18 03:58:10 I don't think it should since only one portion of
ddorwin 2016/02/18 20:37:44 Right, but isn't it a bug if the caller does not p
+ }
+ }
+ }
+ }
+ }
+}
+
+TEST(MimeUtilInternalTest, EncryptedCodecBehavior) {
+ MimeUtil mime_util;
+ PlatformCodecInfo info = {0};
+ info.has_platform_decoder = true; // False is tested above.
+ for (bool has_unified_media_pipeline : kTestStates) {
+ info.has_unified_media_pipeline = has_unified_media_pipeline;
+ for (bool has_opus : kTestStates) {
+ info.has_opus = has_opus;
+ for (bool has_vp8 : kTestStates) {
+ info.has_vp8 = has_vp8;
+ for (bool has_vp9 : kTestStates) {
+ info.has_vp9 = has_vp9;
+ mime_util.SetPlatformCodecInfoForTests(info);
+ for (int codec = MimeUtil::INVALID_CODEC;
+ codec <= MimeUtil::LAST_CODEC; ++codec) {
+ const MimeUtil::Codec codec_type =
ddorwin 2016/02/17 21:18:40 nit: codec type sounds like there are types of cod
DaleCurtis 2016/02/18 03:58:10 New format removes this.
+ static_cast<MimeUtil::Codec>(codec);
+ switch (codec_type) {
+ case MimeUtil::AC3:
+ case MimeUtil::EAC3:
+ case MimeUtil::INVALID_CODEC:
+ case MimeUtil::MPEG2_AAC_LC:
+ case MimeUtil::MPEG2_AAC_MAIN:
+ case MimeUtil::MPEG2_AAC_SSR:
+ case MimeUtil::THEORA:
+ ASSERT_FALSE(mime_util.IsCodecSupportedOnAndroidForTests(
ddorwin 2016/02/17 21:18:40 If one of these fails, it's going to be difficult
DaleCurtis 2016/02/18 03:58:09 Done.
+ codec_type, "", true));
+ break;
+
+ case MimeUtil::H264_BASELINE:
+ case MimeUtil::H264_MAIN:
+ case MimeUtil::H264_HIGH:
+ case MimeUtil::PCM:
+ case MimeUtil::MP3:
+ case MimeUtil::MPEG4_AAC_LC:
+ case MimeUtil::MPEG4_AAC_SBR_v1:
+ case MimeUtil::MPEG4_AAC_SBR_PS_v2:
+ case MimeUtil::VORBIS:
+ ASSERT_TRUE(mime_util.IsCodecSupportedOnAndroidForTests(
+ codec_type, "", true));
+ break;
+
+ case MimeUtil::OPUS:
+ ASSERT_EQ(info.has_opus,
+ mime_util.IsCodecSupportedOnAndroidForTests(
+ codec_type, "", true));
+ break;
+
+ case MimeUtil::VP8:
+ ASSERT_EQ(info.has_vp8,
+ mime_util.IsCodecSupportedOnAndroidForTests(
+ codec_type, "", true));
+ break;
+
+ case MimeUtil::VP9:
+ ASSERT_EQ(info.has_vp9,
+ mime_util.IsCodecSupportedOnAndroidForTests(
+ codec_type, "", true));
+ break;
+
+ case MimeUtil::HEVC_MAIN:
+ break;
ddorwin 2016/02/17 21:18:39 ? Can we check the ifdef? We should at least call
DaleCurtis 2016/02/18 03:58:10 Done.
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+TEST(MimeUtilInternalTest, ClearCodecBehaviorWithStandardPipeline) {
ddorwin 2016/02/17 21:18:40 s/Standard/Android/?
DaleCurtis 2016/02/18 03:58:09 Done.
+ MimeUtil mime_util;
+ PlatformCodecInfo info = {0};
ddorwin 2016/02/17 21:18:40 has_unified_media_pipeline is never set to false (
ddorwin 2016/02/17 21:18:40 has_platform_decoder and has_vp8 are not set. (Cur
DaleCurtis 2016/02/18 03:58:10 = {0} zero-initializes the structure, but that's r
ddorwin 2016/02/18 20:37:44 Oops, I missed that.
+ for (bool has_opus : kTestStates) {
+ info.has_opus = has_opus;
+ for (bool has_vp9 : kTestStates) {
+ info.has_vp9 = has_vp9;
+ mime_util.SetPlatformCodecInfoForTests(info);
+ for (int codec = MimeUtil::INVALID_CODEC; codec <= MimeUtil::LAST_CODEC;
+ ++codec) {
+ const MimeUtil::Codec codec_type = static_cast<MimeUtil::Codec>(codec);
+ switch (codec_type) {
+ case MimeUtil::AC3:
+ case MimeUtil::EAC3:
+ case MimeUtil::INVALID_CODEC:
+ case MimeUtil::MPEG2_AAC_LC:
+ case MimeUtil::MPEG2_AAC_MAIN:
+ case MimeUtil::MPEG2_AAC_SSR:
+ case MimeUtil::THEORA:
+ ASSERT_FALSE(mime_util.IsCodecSupportedOnAndroidForTests(
+ codec_type, "", false));
+ break;
+
+ case MimeUtil::H264_BASELINE:
+ case MimeUtil::H264_MAIN:
+ case MimeUtil::H264_HIGH:
+ case MimeUtil::PCM:
+ case MimeUtil::MP3:
+ case MimeUtil::MPEG4_AAC_LC:
+ case MimeUtil::MPEG4_AAC_SBR_v1:
+ case MimeUtil::MPEG4_AAC_SBR_PS_v2:
+ case MimeUtil::VORBIS:
+ case MimeUtil::VP8:
+ ASSERT_TRUE(mime_util.IsCodecSupportedOnAndroidForTests(codec_type,
+ "", false));
+ break;
+
+ case MimeUtil::OPUS:
+ ASSERT_EQ(info.has_opus,
+ mime_util.IsCodecSupportedOnAndroidForTests(codec_type,
+ "", false));
+ break;
+
+ case MimeUtil::VP9:
+ ASSERT_EQ(info.has_vp9, mime_util.IsCodecSupportedOnAndroidForTests(
+ codec_type, "", false));
+ break;
+
+ case MimeUtil::HEVC_MAIN:
+ break;
ddorwin 2016/02/17 21:18:40 ditto
DaleCurtis 2016/02/18 03:58:10 Done.
+ }
+ }
+ }
+ }
+}
+
+TEST(MimeUtilInternalTest, ClearCodecBehaviorWithUnifiedPipeline) {
+ MimeUtil mime_util;
+ PlatformCodecInfo info = {0};
ddorwin 2016/02/17 21:18:40 Why aren't has_<codec> looped through?
DaleCurtis 2016/02/18 03:58:09 Done.
+ info.has_unified_media_pipeline = true;
+ for (bool has_platform_decoder : kTestStates) {
+ info.has_platform_decoder = has_platform_decoder;
+ mime_util.SetPlatformCodecInfoForTests(info);
+
+ for (int codec = MimeUtil::INVALID_CODEC; codec <= MimeUtil::LAST_CODEC;
+ ++codec) {
+ const MimeUtil::Codec codec_type = static_cast<MimeUtil::Codec>(codec);
+ switch (codec_type) {
+ case MimeUtil::AC3:
+ case MimeUtil::EAC3:
+ case MimeUtil::INVALID_CODEC:
+ case MimeUtil::THEORA:
+ ASSERT_FALSE(mime_util.IsCodecSupportedOnAndroidForTests(codec_type,
+ "", false));
+ break;
+
+ case MimeUtil::PCM:
+ case MimeUtil::MPEG2_AAC_LC:
+ case MimeUtil::MPEG2_AAC_MAIN:
+ case MimeUtil::MPEG2_AAC_SSR:
+ case MimeUtil::MP3:
+ case MimeUtil::MPEG4_AAC_LC:
+ case MimeUtil::MPEG4_AAC_SBR_v1:
+ case MimeUtil::MPEG4_AAC_SBR_PS_v2:
+ case MimeUtil::OPUS:
+ case MimeUtil::VORBIS:
+ case MimeUtil::VP8:
+ case MimeUtil::VP9:
+ ASSERT_TRUE(mime_util.IsCodecSupportedOnAndroidForTests(codec_type,
+ "", false));
+ break;
+
+ case MimeUtil::H264_BASELINE:
+ case MimeUtil::H264_MAIN:
+ case MimeUtil::H264_HIGH:
+ ASSERT_EQ(info.has_platform_decoder,
+ mime_util.IsCodecSupportedOnAndroidForTests(codec_type, "",
+ false));
+ break;
+
+ case MimeUtil::HEVC_MAIN:
+ break;
ddorwin 2016/02/17 21:18:40 ditto, though this also requires has_platform_deco
DaleCurtis 2016/02/18 03:58:10 Done.
+ }
+ }
+ }
+}
+
+TEST(MimeUtilInternalTest, OpusOggSupport) {
+ MimeUtil mime_util;
+ PlatformCodecInfo info;
+ info.has_platform_decoder = false;
ddorwin 2016/02/17 21:18:40 Should this matter? Can we loop through it?
DaleCurtis 2016/02/18 03:58:10 Done.
+ info.has_opus = true;
ddorwin 2016/02/17 21:18:40 Might as well loop throught his too?
DaleCurtis 2016/02/18 03:58:10 Done.
+
+ const bool kTestStates[] = {true, false};
ddorwin 2016/02/17 21:18:40 remove
DaleCurtis 2016/02/18 03:58:09 Done.
+ for (bool has_unified_media_pipeline : kTestStates) {
+ info.has_unified_media_pipeline = has_unified_media_pipeline;
+ mime_util.SetPlatformCodecInfoForTests(info);
+ ASSERT_EQ(info.has_unified_media_pipeline,
+ mime_util.IsCodecSupportedOnAndroidForTests(MimeUtil::OPUS,
+ "audio/ogg", false));
+ }
+}
+
+} // namespace internal
+#endif
ddorwin 2016/02/17 21:18:40 This is a long block. Add // defined(OS_ANDROID)?
DaleCurtis 2016/02/18 03:58:10 Done.
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698