Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "media/base/mime_util.h" | 10 #include "media/base/mime_util.h" |
| 11 #include "media/base/mime_util_internal.h" | |
| 11 #include "media/media_features.h" | 12 #include "media/media_features.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 namespace media { | 15 namespace media { |
| 15 | 16 |
| 17 const bool kTestStates[] = {true, false}; | |
| 18 | |
| 16 TEST(MimeUtilTest, CommonMediaMimeType) { | 19 TEST(MimeUtilTest, CommonMediaMimeType) { |
| 17 EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm")); | 20 EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm")); |
| 18 EXPECT_TRUE(IsSupportedMediaMimeType("video/webm")); | 21 EXPECT_TRUE(IsSupportedMediaMimeType("video/webm")); |
| 19 | 22 |
| 20 EXPECT_TRUE(IsSupportedMediaMimeType("audio/wav")); | 23 EXPECT_TRUE(IsSupportedMediaMimeType("audio/wav")); |
| 21 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-wav")); | 24 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-wav")); |
| 22 | 25 |
| 23 EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg")); | 26 EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg")); |
| 24 EXPECT_TRUE(IsSupportedMediaMimeType("application/ogg")); | 27 EXPECT_TRUE(IsSupportedMediaMimeType("application/ogg")); |
| 25 #if defined(OS_ANDROID) | 28 #if defined(OS_ANDROID) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 } | 107 } |
| 105 | 108 |
| 106 // Test without stripping the codec type. | 109 // Test without stripping the codec type. |
| 107 std::vector<std::string> codecs_out; | 110 std::vector<std::string> codecs_out; |
| 108 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); | 111 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); |
| 109 ASSERT_EQ(2u, codecs_out.size()); | 112 ASSERT_EQ(2u, codecs_out.size()); |
| 110 EXPECT_EQ("avc1.42E01E", codecs_out[0]); | 113 EXPECT_EQ("avc1.42E01E", codecs_out[0]); |
| 111 EXPECT_EQ("mp4a.40.2", codecs_out[1]); | 114 EXPECT_EQ("mp4a.40.2", codecs_out[1]); |
| 112 } | 115 } |
| 113 | 116 |
| 117 #if defined(OS_ANDROID) | |
| 118 namespace internal { | |
| 119 | |
| 120 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.
| |
| 121 MimeUtil mime_util; | |
| 122 PlatformCodecInfo info; | |
| 123 info.has_platform_decoder = false; | |
| 124 | |
| 125 const bool kTestStates[] = {true, false}; | |
|
ddorwin
2016/02/17 21:18:40
remove
DaleCurtis
2016/02/18 03:58:10
Done.
| |
| 126 for (bool has_unified_media_pipeline : kTestStates) { | |
| 127 info.has_unified_media_pipeline = has_unified_media_pipeline; | |
| 128 for (bool has_opus : kTestStates) { | |
| 129 info.has_opus = has_opus; | |
| 130 for (bool has_vp8 : kTestStates) { | |
| 131 info.has_vp8 = has_vp8; | |
| 132 for (bool has_vp9 : kTestStates) { | |
| 133 info.has_vp9 = has_vp9; | |
| 134 mime_util.SetPlatformCodecInfoForTests(info); | |
| 135 for (int codec = MimeUtil::INVALID_CODEC; | |
| 136 codec <= MimeUtil::LAST_CODEC; ++codec) { | |
| 137 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
| |
| 138 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
| |
| 139 } | |
| 140 } | |
| 141 } | |
| 142 } | |
| 143 } | |
| 144 } | |
| 145 | |
| 146 TEST(MimeUtilInternalTest, EncryptedCodecBehavior) { | |
| 147 MimeUtil mime_util; | |
| 148 PlatformCodecInfo info = {0}; | |
| 149 info.has_platform_decoder = true; // False is tested above. | |
| 150 for (bool has_unified_media_pipeline : kTestStates) { | |
| 151 info.has_unified_media_pipeline = has_unified_media_pipeline; | |
| 152 for (bool has_opus : kTestStates) { | |
| 153 info.has_opus = has_opus; | |
| 154 for (bool has_vp8 : kTestStates) { | |
| 155 info.has_vp8 = has_vp8; | |
| 156 for (bool has_vp9 : kTestStates) { | |
| 157 info.has_vp9 = has_vp9; | |
| 158 mime_util.SetPlatformCodecInfoForTests(info); | |
| 159 for (int codec = MimeUtil::INVALID_CODEC; | |
| 160 codec <= MimeUtil::LAST_CODEC; ++codec) { | |
| 161 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.
| |
| 162 static_cast<MimeUtil::Codec>(codec); | |
| 163 switch (codec_type) { | |
| 164 case MimeUtil::AC3: | |
| 165 case MimeUtil::EAC3: | |
| 166 case MimeUtil::INVALID_CODEC: | |
| 167 case MimeUtil::MPEG2_AAC_LC: | |
| 168 case MimeUtil::MPEG2_AAC_MAIN: | |
| 169 case MimeUtil::MPEG2_AAC_SSR: | |
| 170 case MimeUtil::THEORA: | |
| 171 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.
| |
| 172 codec_type, "", true)); | |
| 173 break; | |
| 174 | |
| 175 case MimeUtil::H264_BASELINE: | |
| 176 case MimeUtil::H264_MAIN: | |
| 177 case MimeUtil::H264_HIGH: | |
| 178 case MimeUtil::PCM: | |
| 179 case MimeUtil::MP3: | |
| 180 case MimeUtil::MPEG4_AAC_LC: | |
| 181 case MimeUtil::MPEG4_AAC_SBR_v1: | |
| 182 case MimeUtil::MPEG4_AAC_SBR_PS_v2: | |
| 183 case MimeUtil::VORBIS: | |
| 184 ASSERT_TRUE(mime_util.IsCodecSupportedOnAndroidForTests( | |
| 185 codec_type, "", true)); | |
| 186 break; | |
| 187 | |
| 188 case MimeUtil::OPUS: | |
| 189 ASSERT_EQ(info.has_opus, | |
| 190 mime_util.IsCodecSupportedOnAndroidForTests( | |
| 191 codec_type, "", true)); | |
| 192 break; | |
| 193 | |
| 194 case MimeUtil::VP8: | |
| 195 ASSERT_EQ(info.has_vp8, | |
| 196 mime_util.IsCodecSupportedOnAndroidForTests( | |
| 197 codec_type, "", true)); | |
| 198 break; | |
| 199 | |
| 200 case MimeUtil::VP9: | |
| 201 ASSERT_EQ(info.has_vp9, | |
| 202 mime_util.IsCodecSupportedOnAndroidForTests( | |
| 203 codec_type, "", true)); | |
| 204 break; | |
| 205 | |
| 206 case MimeUtil::HEVC_MAIN: | |
| 207 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.
| |
| 208 } | |
| 209 } | |
| 210 } | |
| 211 } | |
| 212 } | |
| 213 } | |
| 214 } | |
| 215 | |
| 216 TEST(MimeUtilInternalTest, ClearCodecBehaviorWithStandardPipeline) { | |
|
ddorwin
2016/02/17 21:18:40
s/Standard/Android/?
DaleCurtis
2016/02/18 03:58:09
Done.
| |
| 217 MimeUtil mime_util; | |
| 218 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.
| |
| 219 for (bool has_opus : kTestStates) { | |
| 220 info.has_opus = has_opus; | |
| 221 for (bool has_vp9 : kTestStates) { | |
| 222 info.has_vp9 = has_vp9; | |
| 223 mime_util.SetPlatformCodecInfoForTests(info); | |
| 224 for (int codec = MimeUtil::INVALID_CODEC; codec <= MimeUtil::LAST_CODEC; | |
| 225 ++codec) { | |
| 226 const MimeUtil::Codec codec_type = static_cast<MimeUtil::Codec>(codec); | |
| 227 switch (codec_type) { | |
| 228 case MimeUtil::AC3: | |
| 229 case MimeUtil::EAC3: | |
| 230 case MimeUtil::INVALID_CODEC: | |
| 231 case MimeUtil::MPEG2_AAC_LC: | |
| 232 case MimeUtil::MPEG2_AAC_MAIN: | |
| 233 case MimeUtil::MPEG2_AAC_SSR: | |
| 234 case MimeUtil::THEORA: | |
| 235 ASSERT_FALSE(mime_util.IsCodecSupportedOnAndroidForTests( | |
| 236 codec_type, "", false)); | |
| 237 break; | |
| 238 | |
| 239 case MimeUtil::H264_BASELINE: | |
| 240 case MimeUtil::H264_MAIN: | |
| 241 case MimeUtil::H264_HIGH: | |
| 242 case MimeUtil::PCM: | |
| 243 case MimeUtil::MP3: | |
| 244 case MimeUtil::MPEG4_AAC_LC: | |
| 245 case MimeUtil::MPEG4_AAC_SBR_v1: | |
| 246 case MimeUtil::MPEG4_AAC_SBR_PS_v2: | |
| 247 case MimeUtil::VORBIS: | |
| 248 case MimeUtil::VP8: | |
| 249 ASSERT_TRUE(mime_util.IsCodecSupportedOnAndroidForTests(codec_type, | |
| 250 "", false)); | |
| 251 break; | |
| 252 | |
| 253 case MimeUtil::OPUS: | |
| 254 ASSERT_EQ(info.has_opus, | |
| 255 mime_util.IsCodecSupportedOnAndroidForTests(codec_type, | |
| 256 "", false)); | |
| 257 break; | |
| 258 | |
| 259 case MimeUtil::VP9: | |
| 260 ASSERT_EQ(info.has_vp9, mime_util.IsCodecSupportedOnAndroidForTests( | |
| 261 codec_type, "", false)); | |
| 262 break; | |
| 263 | |
| 264 case MimeUtil::HEVC_MAIN: | |
| 265 break; | |
|
ddorwin
2016/02/17 21:18:40
ditto
DaleCurtis
2016/02/18 03:58:10
Done.
| |
| 266 } | |
| 267 } | |
| 268 } | |
| 269 } | |
| 270 } | |
| 271 | |
| 272 TEST(MimeUtilInternalTest, ClearCodecBehaviorWithUnifiedPipeline) { | |
| 273 MimeUtil mime_util; | |
| 274 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.
| |
| 275 info.has_unified_media_pipeline = true; | |
| 276 for (bool has_platform_decoder : kTestStates) { | |
| 277 info.has_platform_decoder = has_platform_decoder; | |
| 278 mime_util.SetPlatformCodecInfoForTests(info); | |
| 279 | |
| 280 for (int codec = MimeUtil::INVALID_CODEC; codec <= MimeUtil::LAST_CODEC; | |
| 281 ++codec) { | |
| 282 const MimeUtil::Codec codec_type = static_cast<MimeUtil::Codec>(codec); | |
| 283 switch (codec_type) { | |
| 284 case MimeUtil::AC3: | |
| 285 case MimeUtil::EAC3: | |
| 286 case MimeUtil::INVALID_CODEC: | |
| 287 case MimeUtil::THEORA: | |
| 288 ASSERT_FALSE(mime_util.IsCodecSupportedOnAndroidForTests(codec_type, | |
| 289 "", false)); | |
| 290 break; | |
| 291 | |
| 292 case MimeUtil::PCM: | |
| 293 case MimeUtil::MPEG2_AAC_LC: | |
| 294 case MimeUtil::MPEG2_AAC_MAIN: | |
| 295 case MimeUtil::MPEG2_AAC_SSR: | |
| 296 case MimeUtil::MP3: | |
| 297 case MimeUtil::MPEG4_AAC_LC: | |
| 298 case MimeUtil::MPEG4_AAC_SBR_v1: | |
| 299 case MimeUtil::MPEG4_AAC_SBR_PS_v2: | |
| 300 case MimeUtil::OPUS: | |
| 301 case MimeUtil::VORBIS: | |
| 302 case MimeUtil::VP8: | |
| 303 case MimeUtil::VP9: | |
| 304 ASSERT_TRUE(mime_util.IsCodecSupportedOnAndroidForTests(codec_type, | |
| 305 "", false)); | |
| 306 break; | |
| 307 | |
| 308 case MimeUtil::H264_BASELINE: | |
| 309 case MimeUtil::H264_MAIN: | |
| 310 case MimeUtil::H264_HIGH: | |
| 311 ASSERT_EQ(info.has_platform_decoder, | |
| 312 mime_util.IsCodecSupportedOnAndroidForTests(codec_type, "", | |
| 313 false)); | |
| 314 break; | |
| 315 | |
| 316 case MimeUtil::HEVC_MAIN: | |
| 317 break; | |
|
ddorwin
2016/02/17 21:18:40
ditto, though this also requires has_platform_deco
DaleCurtis
2016/02/18 03:58:10
Done.
| |
| 318 } | |
| 319 } | |
| 320 } | |
| 321 } | |
| 322 | |
| 323 TEST(MimeUtilInternalTest, OpusOggSupport) { | |
| 324 MimeUtil mime_util; | |
| 325 PlatformCodecInfo info; | |
| 326 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.
| |
| 327 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.
| |
| 328 | |
| 329 const bool kTestStates[] = {true, false}; | |
|
ddorwin
2016/02/17 21:18:40
remove
DaleCurtis
2016/02/18 03:58:09
Done.
| |
| 330 for (bool has_unified_media_pipeline : kTestStates) { | |
| 331 info.has_unified_media_pipeline = has_unified_media_pipeline; | |
| 332 mime_util.SetPlatformCodecInfoForTests(info); | |
| 333 ASSERT_EQ(info.has_unified_media_pipeline, | |
| 334 mime_util.IsCodecSupportedOnAndroidForTests(MimeUtil::OPUS, | |
| 335 "audio/ogg", false)); | |
| 336 } | |
| 337 } | |
| 338 | |
| 339 } // namespace internal | |
| 340 #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.
| |
| 341 | |
| 114 } // namespace media | 342 } // namespace media |
| OLD | NEW |