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

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

Issue 2572573007: Use passthrough decoder for (E)AC3 formats (Closed)
Patch Set: Use BitReader to unpack header fileds Created 4 years 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/flac")); 135 EXPECT_TRUE(IsSupportedMediaMimeType("audio/flac"));
128 136
129 EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg")); 137 EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg"));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 test_states.has_platform_decoders = true; 255 test_states.has_platform_decoders = true;
248 256
249 RunCodecSupportTest( 257 RunCodecSupportTest(
250 states_to_vary, test_states, 258 states_to_vary, test_states,
251 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) { 259 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) {
252 const bool result = MimeUtil::IsCodecSupportedOnPlatform( 260 const bool result = MimeUtil::IsCodecSupportedOnPlatform(
253 codec, kTestMimeType, true, info); 261 codec, kTestMimeType, true, info);
254 switch (codec) { 262 switch (codec) {
255 // These codecs are never supported by the Android platform. 263 // These codecs are never supported by the Android platform.
256 case MimeUtil::INVALID_CODEC: 264 case MimeUtil::INVALID_CODEC:
257 case MimeUtil::AC3:
258 case MimeUtil::EAC3:
259 case MimeUtil::MPEG2_AAC: 265 case MimeUtil::MPEG2_AAC:
260 case MimeUtil::THEORA: 266 case MimeUtil::THEORA:
261 EXPECT_FALSE(result); 267 EXPECT_FALSE(result);
262 break; 268 break;
263 269
264 // These codecs are always available with platform decoder support. 270 // These codecs are always available with platform decoder support.
265 case MimeUtil::PCM: 271 case MimeUtil::PCM:
266 case MimeUtil::MP3: 272 case MimeUtil::MP3:
267 case MimeUtil::MPEG4_AAC: 273 case MimeUtil::MPEG4_AAC:
268 case MimeUtil::VORBIS: 274 case MimeUtil::VORBIS:
(...skipping 12 matching lines...) Expand all
281 EXPECT_EQ(info.has_platform_vp8_decoder, result); 287 EXPECT_EQ(info.has_platform_vp8_decoder, result);
282 break; 288 break;
283 289
284 case MimeUtil::VP9: 290 case MimeUtil::VP9:
285 EXPECT_EQ(info.has_platform_vp9_decoder, result); 291 EXPECT_EQ(info.has_platform_vp9_decoder, result);
286 break; 292 break;
287 293
288 case MimeUtil::HEVC: 294 case MimeUtil::HEVC:
289 EXPECT_EQ(HasHevcSupport(), result); 295 EXPECT_EQ(HasHevcSupport(), result);
290 break; 296 break;
297
298 case MimeUtil::AC3:
299 case MimeUtil::EAC3:
300 EXPECT_EQ(HasEac3Support(), result);
301 break;
291 } 302 }
292 }); 303 });
293 } 304 }
294 305
295 TEST(IsCodecSupportedOnPlatformTest, ClearCodecBehaviorWithAndroidPipeline) { 306 TEST(IsCodecSupportedOnPlatformTest, ClearCodecBehaviorWithAndroidPipeline) {
296 // Vary all parameters except |is_unified_media_pipeline_enabled|. 307 // Vary all parameters except |is_unified_media_pipeline_enabled|.
297 MimeUtil::PlatformInfo states_to_vary = VaryAllFields(); 308 MimeUtil::PlatformInfo states_to_vary = VaryAllFields();
298 states_to_vary.is_unified_media_pipeline_enabled = false; 309 states_to_vary.is_unified_media_pipeline_enabled = false;
299 310
300 // Disable the unified pipeline. 311 // Disable the unified pipeline.
301 MimeUtil::PlatformInfo test_states; 312 MimeUtil::PlatformInfo test_states;
302 test_states.is_unified_media_pipeline_enabled = false; 313 test_states.is_unified_media_pipeline_enabled = false;
303 314
304 RunCodecSupportTest( 315 RunCodecSupportTest(
305 states_to_vary, test_states, 316 states_to_vary, test_states,
306 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) { 317 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) {
307 const bool result = MimeUtil::IsCodecSupportedOnPlatform( 318 const bool result = MimeUtil::IsCodecSupportedOnPlatform(
308 codec, kTestMimeType, false, info); 319 codec, kTestMimeType, false, info);
309 switch (codec) { 320 switch (codec) {
310 // These codecs are never supported by the Android platform. 321 // These codecs are never supported by the Android platform.
311 case MimeUtil::INVALID_CODEC: 322 case MimeUtil::INVALID_CODEC:
312 case MimeUtil::AC3:
313 case MimeUtil::EAC3:
314 case MimeUtil::MPEG2_AAC: 323 case MimeUtil::MPEG2_AAC:
315 case MimeUtil::THEORA: 324 case MimeUtil::THEORA:
316 EXPECT_FALSE(result); 325 EXPECT_FALSE(result);
317 break; 326 break;
318 327
319 // These codecs are always available via MediaPlayer. 328 // These codecs are always available via MediaPlayer.
320 case MimeUtil::FLAC: 329 case MimeUtil::FLAC:
321 case MimeUtil::PCM: 330 case MimeUtil::PCM:
322 case MimeUtil::MP3: 331 case MimeUtil::MP3:
323 case MimeUtil::MPEG4_AAC: 332 case MimeUtil::MPEG4_AAC:
324 case MimeUtil::VORBIS: 333 case MimeUtil::VORBIS:
325 case MimeUtil::H264: 334 case MimeUtil::H264:
326 case MimeUtil::VP8: 335 case MimeUtil::VP8:
327 EXPECT_TRUE(result); 336 EXPECT_TRUE(result);
328 break; 337 break;
329 338
330 // The remaining codecs depend on the platform version. 339 // The remaining codecs depend on the platform version.
331 case MimeUtil::OPUS: 340 case MimeUtil::OPUS:
332 EXPECT_EQ(info.supports_opus, result); 341 EXPECT_EQ(info.supports_opus, result);
333 break; 342 break;
334 343
335 case MimeUtil::VP9: 344 case MimeUtil::VP9:
336 // MediaPlayer only supports VP9 in WebM. 345 // MediaPlayer only supports VP9 in WebM.
337 EXPECT_FALSE(result); 346 EXPECT_FALSE(result);
338 break; 347 break;
339 348
340 case MimeUtil::HEVC: 349 case MimeUtil::HEVC:
341 EXPECT_EQ(HasHevcSupport(), result); 350 EXPECT_EQ(HasHevcSupport(), result);
342 break; 351 break;
352
353 case MimeUtil::AC3:
354 case MimeUtil::EAC3:
355 EXPECT_EQ(HasEac3Support(), result);
356 break;
343 } 357 }
344 }); 358 });
345 359
346 // Verify vp9 support in WebM. 360 // Verify vp9 support in WebM.
347 RunCodecSupportTest( 361 RunCodecSupportTest(
348 states_to_vary, test_states, 362 states_to_vary, test_states,
349 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) { 363 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) {
350 const bool result = MimeUtil::IsCodecSupportedOnPlatform( 364 const bool result = MimeUtil::IsCodecSupportedOnPlatform(
351 codec, "video/webm", true, info); 365 codec, "video/webm", true, info);
352 if (codec == MimeUtil::VP9) 366 if (codec == MimeUtil::VP9)
(...skipping 11 matching lines...) Expand all
364 test_states.is_unified_media_pipeline_enabled = true; 378 test_states.is_unified_media_pipeline_enabled = true;
365 379
366 RunCodecSupportTest( 380 RunCodecSupportTest(
367 states_to_vary, test_states, 381 states_to_vary, test_states,
368 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) { 382 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) {
369 const bool result = MimeUtil::IsCodecSupportedOnPlatform( 383 const bool result = MimeUtil::IsCodecSupportedOnPlatform(
370 codec, kTestMimeType, false, info); 384 codec, kTestMimeType, false, info);
371 switch (codec) { 385 switch (codec) {
372 // These codecs are never supported by the Android platform. 386 // These codecs are never supported by the Android platform.
373 case MimeUtil::INVALID_CODEC: 387 case MimeUtil::INVALID_CODEC:
374 case MimeUtil::AC3:
375 case MimeUtil::EAC3:
376 case MimeUtil::THEORA: 388 case MimeUtil::THEORA:
377 EXPECT_FALSE(result); 389 EXPECT_FALSE(result);
378 break; 390 break;
379 391
380 // These codecs are always supported with the unified pipeline. 392 // These codecs are always supported with the unified pipeline.
381 case MimeUtil::FLAC: 393 case MimeUtil::FLAC:
382 case MimeUtil::PCM: 394 case MimeUtil::PCM:
383 case MimeUtil::MPEG2_AAC: 395 case MimeUtil::MPEG2_AAC:
384 case MimeUtil::MP3: 396 case MimeUtil::MP3:
385 case MimeUtil::MPEG4_AAC: 397 case MimeUtil::MPEG4_AAC:
386 case MimeUtil::OPUS: 398 case MimeUtil::OPUS:
387 case MimeUtil::VORBIS: 399 case MimeUtil::VORBIS:
388 case MimeUtil::VP8: 400 case MimeUtil::VP8:
389 case MimeUtil::VP9: 401 case MimeUtil::VP9:
390 EXPECT_TRUE(result); 402 EXPECT_TRUE(result);
391 break; 403 break;
392 404
393 // These codecs are only supported if platform decoders are supported. 405 // These codecs are only supported if platform decoders are supported.
394 case MimeUtil::H264: 406 case MimeUtil::H264:
395 EXPECT_EQ(info.has_platform_decoders, result); 407 EXPECT_EQ(info.has_platform_decoders, result);
396 break; 408 break;
397 409
398 case MimeUtil::HEVC: 410 case MimeUtil::HEVC:
399 EXPECT_EQ(HasHevcSupport() && info.has_platform_decoders, result); 411 EXPECT_EQ(HasHevcSupport() && info.has_platform_decoders, result);
400 break; 412 break;
413
414 case MimeUtil::AC3:
415 case MimeUtil::EAC3:
416 EXPECT_EQ(HasEac3Support(), result);
417 break;
401 } 418 }
402 }); 419 });
403 } 420 }
404 421
405 TEST(IsCodecSupportedOnPlatformTest, OpusOggSupport) { 422 TEST(IsCodecSupportedOnPlatformTest, OpusOggSupport) {
406 // Vary all parameters; thus use default initial state. 423 // Vary all parameters; thus use default initial state.
407 MimeUtil::PlatformInfo states_to_vary = VaryAllFields(); 424 MimeUtil::PlatformInfo states_to_vary = VaryAllFields();
408 MimeUtil::PlatformInfo test_states; 425 MimeUtil::PlatformInfo test_states;
409 426
410 RunCodecSupportTest( 427 RunCodecSupportTest(
(...skipping 15 matching lines...) Expand all
426 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) { 443 [](const MimeUtil::PlatformInfo& info, MimeUtil::Codec codec) {
427 EXPECT_FALSE(MimeUtil::IsCodecSupportedOnPlatform( 444 EXPECT_FALSE(MimeUtil::IsCodecSupportedOnPlatform(
428 MimeUtil::MPEG2_AAC, "application/x-mpegurl", false, info)); 445 MimeUtil::MPEG2_AAC, "application/x-mpegurl", false, info));
429 EXPECT_FALSE(MimeUtil::IsCodecSupportedOnPlatform( 446 EXPECT_FALSE(MimeUtil::IsCodecSupportedOnPlatform(
430 MimeUtil::MPEG2_AAC, "application/vnd.apple.mpegurl", false, info)); 447 MimeUtil::MPEG2_AAC, "application/vnd.apple.mpegurl", false, info));
431 }); 448 });
432 } 449 }
433 450
434 } // namespace internal 451 } // namespace internal
435 } // namespace media 452 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698