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

Side by Side Diff: media/base/mime_util_unittest.cc

Issue 2466463005: Support (E)AC3 passthrough
Patch Set: Improve CastMediaClient::IsSupportedPassthroughAudio() Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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 "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 #if defined(OS_ANDROID) 110 #if defined(OS_ANDROID)
111 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; 111 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21;
112 #else 112 #else
113 return true; 113 return true;
114 #endif // defined(OS_ANDROID) 114 #endif // defined(OS_ANDROID)
115 #else 115 #else
116 return false; 116 return false;
117 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING) 117 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING)
118 } 118 }
119 119
120 static bool HasEac3Support() {
121 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
122 return true;
123 #else
124 return false;
125 #endif
126 }
127
120 TEST(MimeUtilTest, CommonMediaMimeType) { 128 TEST(MimeUtilTest, CommonMediaMimeType) {
121 EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm")); 129 EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm"));
122 EXPECT_TRUE(IsSupportedMediaMimeType("video/webm")); 130 EXPECT_TRUE(IsSupportedMediaMimeType("video/webm"));
123 131
124 EXPECT_TRUE(IsSupportedMediaMimeType("audio/wav")); 132 EXPECT_TRUE(IsSupportedMediaMimeType("audio/wav"));
125 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-wav")); 133 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-wav"));
126 134
127 EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg")); 135 EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg"));
128 EXPECT_TRUE(IsSupportedMediaMimeType("application/ogg")); 136 EXPECT_TRUE(IsSupportedMediaMimeType("application/ogg"));
129 #if defined(OS_ANDROID) 137 #if defined(OS_ANDROID)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 test_states.has_platform_decoders = true; 253 test_states.has_platform_decoders = true;
246 254
247 RunCodecSupportTest( 255 RunCodecSupportTest(
248 states_to_vary, test_states, 256 states_to_vary, test_states,
249 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) { 257 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) {
250 const bool result = MimeUtil::IsCodecSupportedOnPlatform( 258 const bool result = MimeUtil::IsCodecSupportedOnPlatform(
251 codec, kTestMimeType, true, info); 259 codec, kTestMimeType, true, info);
252 switch (codec) { 260 switch (codec) {
253 // These codecs are never supported by the Android platform. 261 // These codecs are never supported by the Android platform.
254 case MimeUtil::INVALID_CODEC: 262 case MimeUtil::INVALID_CODEC:
255 case MimeUtil::AC3:
256 case MimeUtil::EAC3:
257 case MimeUtil::MPEG2_AAC: 263 case MimeUtil::MPEG2_AAC:
258 case MimeUtil::THEORA: 264 case MimeUtil::THEORA:
259 EXPECT_FALSE(result); 265 EXPECT_FALSE(result);
260 break; 266 break;
261 267
262 // These codecs are always available with platform decoder support. 268 // These codecs are always available with platform decoder support.
263 case MimeUtil::PCM: 269 case MimeUtil::PCM:
264 case MimeUtil::MP3: 270 case MimeUtil::MP3:
265 case MimeUtil::MPEG4_AAC: 271 case MimeUtil::MPEG4_AAC:
266 case MimeUtil::VORBIS: 272 case MimeUtil::VORBIS:
(...skipping 11 matching lines...) Expand all
278 EXPECT_EQ(info.has_platform_vp8_decoder, result); 284 EXPECT_EQ(info.has_platform_vp8_decoder, result);
279 break; 285 break;
280 286
281 case MimeUtil::VP9: 287 case MimeUtil::VP9:
282 EXPECT_EQ(info.has_platform_vp9_decoder, result); 288 EXPECT_EQ(info.has_platform_vp9_decoder, result);
283 break; 289 break;
284 290
285 case MimeUtil::HEVC: 291 case MimeUtil::HEVC:
286 EXPECT_EQ(HasHevcSupport(), result); 292 EXPECT_EQ(HasHevcSupport(), result);
287 break; 293 break;
294
295 case MimeUtil::AC3:
296 case MimeUtil::EAC3:
297 EXPECT_EQ(HasEac3Support(), result);
298 break;
288 } 299 }
289 }); 300 });
290 } 301 }
291 302
292 TEST(IsCodecSupportedOnPlatformTest, ClearCodecBehaviorWithAndroidPipeline) { 303 TEST(IsCodecSupportedOnPlatformTest, ClearCodecBehaviorWithAndroidPipeline) {
293 // Vary all parameters except |is_unified_media_pipeline_enabled|. 304 // Vary all parameters except |is_unified_media_pipeline_enabled|.
294 MimeUtil::PlatformInfo states_to_vary = VaryAllFields(); 305 MimeUtil::PlatformInfo states_to_vary = VaryAllFields();
295 states_to_vary.is_unified_media_pipeline_enabled = false; 306 states_to_vary.is_unified_media_pipeline_enabled = false;
296 307
297 // Disable the unified pipeline. 308 // Disable the unified pipeline.
298 MimeUtil::PlatformInfo test_states; 309 MimeUtil::PlatformInfo test_states;
299 test_states.is_unified_media_pipeline_enabled = false; 310 test_states.is_unified_media_pipeline_enabled = false;
300 311
301 RunCodecSupportTest( 312 RunCodecSupportTest(
302 states_to_vary, test_states, 313 states_to_vary, test_states,
303 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) { 314 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) {
304 const bool result = MimeUtil::IsCodecSupportedOnPlatform( 315 const bool result = MimeUtil::IsCodecSupportedOnPlatform(
305 codec, kTestMimeType, false, info); 316 codec, kTestMimeType, false, info);
306 switch (codec) { 317 switch (codec) {
307 // These codecs are never supported by the Android platform. 318 // These codecs are never supported by the Android platform.
308 case MimeUtil::INVALID_CODEC: 319 case MimeUtil::INVALID_CODEC:
309 case MimeUtil::AC3:
310 case MimeUtil::EAC3:
311 case MimeUtil::MPEG2_AAC: 320 case MimeUtil::MPEG2_AAC:
312 case MimeUtil::THEORA: 321 case MimeUtil::THEORA:
313 EXPECT_FALSE(result); 322 EXPECT_FALSE(result);
314 break; 323 break;
315 324
316 // These codecs are always available via MediaPlayer. 325 // These codecs are always available via MediaPlayer.
317 case MimeUtil::PCM: 326 case MimeUtil::PCM:
318 case MimeUtil::MP3: 327 case MimeUtil::MP3:
319 case MimeUtil::MPEG4_AAC: 328 case MimeUtil::MPEG4_AAC:
320 case MimeUtil::VORBIS: 329 case MimeUtil::VORBIS:
321 case MimeUtil::H264: 330 case MimeUtil::H264:
322 case MimeUtil::VP8: 331 case MimeUtil::VP8:
323 EXPECT_TRUE(result); 332 EXPECT_TRUE(result);
324 break; 333 break;
325 334
326 // The remaining codecs depend on the platform version. 335 // The remaining codecs depend on the platform version.
327 case MimeUtil::OPUS: 336 case MimeUtil::OPUS:
328 EXPECT_EQ(info.supports_opus, result); 337 EXPECT_EQ(info.supports_opus, result);
329 break; 338 break;
330 339
331 case MimeUtil::VP9: 340 case MimeUtil::VP9:
332 // MediaPlayer only supports VP9 in WebM. 341 // MediaPlayer only supports VP9 in WebM.
333 EXPECT_FALSE(result); 342 EXPECT_FALSE(result);
334 break; 343 break;
335 344
336 case MimeUtil::HEVC: 345 case MimeUtil::HEVC:
337 EXPECT_EQ(HasHevcSupport(), result); 346 EXPECT_EQ(HasHevcSupport(), result);
338 break; 347 break;
348
349 case MimeUtil::AC3:
350 case MimeUtil::EAC3:
351 EXPECT_EQ(HasEac3Support(), result);
352 break;
339 } 353 }
340 }); 354 });
341 355
342 // Verify vp9 support in WebM. 356 // Verify vp9 support in WebM.
343 RunCodecSupportTest( 357 RunCodecSupportTest(
344 states_to_vary, test_states, 358 states_to_vary, test_states,
345 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) { 359 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) {
346 const bool result = MimeUtil::IsCodecSupportedOnPlatform( 360 const bool result = MimeUtil::IsCodecSupportedOnPlatform(
347 codec, "video/webm", true, info); 361 codec, "video/webm", true, info);
348 if (codec == MimeUtil::VP9) 362 if (codec == MimeUtil::VP9)
(...skipping 11 matching lines...) Expand all
360 test_states.is_unified_media_pipeline_enabled = true; 374 test_states.is_unified_media_pipeline_enabled = true;
361 375
362 RunCodecSupportTest( 376 RunCodecSupportTest(
363 states_to_vary, test_states, 377 states_to_vary, test_states,
364 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) { 378 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) {
365 const bool result = MimeUtil::IsCodecSupportedOnPlatform( 379 const bool result = MimeUtil::IsCodecSupportedOnPlatform(
366 codec, kTestMimeType, false, info); 380 codec, kTestMimeType, false, info);
367 switch (codec) { 381 switch (codec) {
368 // These codecs are never supported by the Android platform. 382 // These codecs are never supported by the Android platform.
369 case MimeUtil::INVALID_CODEC: 383 case MimeUtil::INVALID_CODEC:
370 case MimeUtil::AC3:
371 case MimeUtil::EAC3:
372 case MimeUtil::THEORA: 384 case MimeUtil::THEORA:
373 EXPECT_FALSE(result); 385 EXPECT_FALSE(result);
374 break; 386 break;
375 387
376 // These codecs are always supported with the unified pipeline. 388 // These codecs are always supported with the unified pipeline.
377 case MimeUtil::PCM: 389 case MimeUtil::PCM:
378 case MimeUtil::MPEG2_AAC: 390 case MimeUtil::MPEG2_AAC:
379 case MimeUtil::MP3: 391 case MimeUtil::MP3:
380 case MimeUtil::MPEG4_AAC: 392 case MimeUtil::MPEG4_AAC:
381 case MimeUtil::OPUS: 393 case MimeUtil::OPUS:
382 case MimeUtil::VORBIS: 394 case MimeUtil::VORBIS:
383 case MimeUtil::VP8: 395 case MimeUtil::VP8:
384 case MimeUtil::VP9: 396 case MimeUtil::VP9:
385 EXPECT_TRUE(result); 397 EXPECT_TRUE(result);
386 break; 398 break;
387 399
388 // These codecs are only supported if platform decoders are supported. 400 // These codecs are only supported if platform decoders are supported.
389 case MimeUtil::H264: 401 case MimeUtil::H264:
390 EXPECT_EQ(info.has_platform_decoders, result); 402 EXPECT_EQ(info.has_platform_decoders, result);
391 break; 403 break;
392 404
393 case MimeUtil::HEVC: 405 case MimeUtil::HEVC:
394 EXPECT_EQ(HasHevcSupport() && info.has_platform_decoders, result); 406 EXPECT_EQ(HasHevcSupport() && info.has_platform_decoders, result);
395 break; 407 break;
408
409 case MimeUtil::AC3:
410 case MimeUtil::EAC3:
411 EXPECT_EQ(HasEac3Support(), result);
412 break;
396 } 413 }
397 }); 414 });
398 } 415 }
399 416
400 TEST(IsCodecSupportedOnPlatformTest, OpusOggSupport) { 417 TEST(IsCodecSupportedOnPlatformTest, OpusOggSupport) {
401 // Vary all parameters; thus use default initial state. 418 // Vary all parameters; thus use default initial state.
402 MimeUtil::PlatformInfo states_to_vary = VaryAllFields(); 419 MimeUtil::PlatformInfo states_to_vary = VaryAllFields();
403 MimeUtil::PlatformInfo test_states; 420 MimeUtil::PlatformInfo test_states;
404 421
405 RunCodecSupportTest( 422 RunCodecSupportTest(
(...skipping 15 matching lines...) Expand all
421 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) { 438 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) {
422 EXPECT_FALSE(MimeUtil::IsCodecSupportedOnPlatform( 439 EXPECT_FALSE(MimeUtil::IsCodecSupportedOnPlatform(
423 MimeUtil::MPEG2_AAC, "application/x-mpegurl", false, info)); 440 MimeUtil::MPEG2_AAC, "application/x-mpegurl", false, info));
424 EXPECT_FALSE(MimeUtil::IsCodecSupportedOnPlatform( 441 EXPECT_FALSE(MimeUtil::IsCodecSupportedOnPlatform(
425 MimeUtil::MPEG2_AAC, "application/vnd.apple.mpegurl", false, info)); 442 MimeUtil::MPEG2_AAC, "application/vnd.apple.mpegurl", false, info));
426 }); 443 });
427 } 444 }
428 445
429 } // namespace internal 446 } // namespace internal
430 } // namespace media 447 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698