|
16 | 16 | package androidx.media3.exoplayer.mediacodec; |
17 | 17 |
|
18 | 18 | import static androidx.media3.common.MimeTypes.AUDIO_AAC; |
| 19 | +import static androidx.media3.common.MimeTypes.AUDIO_AC4; |
| 20 | +import static androidx.media3.common.MimeTypes.AUDIO_E_AC3; |
| 21 | +import static androidx.media3.common.MimeTypes.AUDIO_E_AC3_JOC; |
19 | 22 | import static androidx.media3.common.MimeTypes.VIDEO_AV1; |
20 | 23 | import static androidx.media3.common.MimeTypes.VIDEO_H264; |
21 | 24 | import static androidx.media3.exoplayer.DecoderReuseEvaluation.DISCARD_REASON_AUDIO_CHANNEL_COUNT_CHANGED; |
@@ -74,6 +77,33 @@ public final class MediaCodecInfoTest { |
74 | 77 | .setInitializationData(ImmutableList.of(new byte[] {4, 4, 1, 0, 0})) |
75 | 78 | .build(); |
76 | 79 |
|
| 80 | + private static final Format FORMAT_EAC3 = |
| 81 | + new Format.Builder() |
| 82 | + .setSampleMimeType(AUDIO_E_AC3) |
| 83 | + .setChannelCount(6) |
| 84 | + .setSampleRate(48000) |
| 85 | + .setAverageBitrate(5000) |
| 86 | + .setInitializationData(ImmutableList.of(new byte[] {4, 4, 1, 0, 0})) |
| 87 | + .build(); |
| 88 | + |
| 89 | + private static final Format FORMAT_EAC3JOC = |
| 90 | + new Format.Builder() |
| 91 | + .setSampleMimeType(AUDIO_E_AC3_JOC) |
| 92 | + .setChannelCount(12) |
| 93 | + .setSampleRate(48000) |
| 94 | + .setAverageBitrate(5000) |
| 95 | + .setInitializationData(ImmutableList.of(new byte[] {4, 4, 1, 0, 0})) |
| 96 | + .build(); |
| 97 | + |
| 98 | + private static final Format FORMAT_AC4 = |
| 99 | + new Format.Builder() |
| 100 | + .setSampleMimeType(AUDIO_AC4) |
| 101 | + .setChannelCount(21) |
| 102 | + .setSampleRate(48000) |
| 103 | + .setAverageBitrate(5000) |
| 104 | + .setInitializationData(ImmutableList.of(new byte[] {4, 4, 1, 0, 0})) |
| 105 | + .build(); |
| 106 | + |
77 | 107 | @Test |
78 | 108 | public void canReuseCodec_withDifferentMimeType_returnsNo() { |
79 | 109 | MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */ true); |
@@ -318,6 +348,63 @@ public void canReuseCodec_differentVideoCrop_returnsNo() { |
318 | 348 | DISCARD_REASON_WORKAROUND)); |
319 | 349 | } |
320 | 350 |
|
| 351 | + @Test |
| 352 | + public void canReuseCodec_eac3_returnsYesWithoutReconfiguration() { |
| 353 | + MediaCodecInfo codecInfo = buildEac3CodecInfo(); |
| 354 | + |
| 355 | + Format variantFormat = |
| 356 | + FORMAT_EAC3 |
| 357 | + .buildUpon() |
| 358 | + .setInitializationData(ImmutableList.of(new byte[] {0})) |
| 359 | + .build(); |
| 360 | + assertThat(codecInfo.canReuseCodec(FORMAT_EAC3, variantFormat)) |
| 361 | + .isEqualTo( |
| 362 | + new DecoderReuseEvaluation( |
| 363 | + codecInfo.name, |
| 364 | + FORMAT_EAC3, |
| 365 | + variantFormat, |
| 366 | + DecoderReuseEvaluation.REUSE_RESULT_YES_WITHOUT_RECONFIGURATION, |
| 367 | + /* discardReasons= */ 0)); |
| 368 | + } |
| 369 | + |
| 370 | + @Test |
| 371 | + public void canReuseCodec_eac3joc_returnsYesWithoutReconfiguration() { |
| 372 | + MediaCodecInfo codecInfo = buildEac3JocCodecInfo(); |
| 373 | + |
| 374 | + Format variantFormat = |
| 375 | + FORMAT_EAC3JOC |
| 376 | + .buildUpon() |
| 377 | + .setInitializationData(ImmutableList.of(new byte[] {0})) |
| 378 | + .build(); |
| 379 | + assertThat(codecInfo.canReuseCodec(FORMAT_EAC3JOC, variantFormat)) |
| 380 | + .isEqualTo( |
| 381 | + new DecoderReuseEvaluation( |
| 382 | + codecInfo.name, |
| 383 | + FORMAT_EAC3JOC, |
| 384 | + variantFormat, |
| 385 | + DecoderReuseEvaluation.REUSE_RESULT_YES_WITHOUT_RECONFIGURATION, |
| 386 | + /* discardReasons= */ 0)); |
| 387 | + } |
| 388 | + |
| 389 | + @Test |
| 390 | + public void canReuseCodec_ac4_returnsYesWithoutReconfiguration() { |
| 391 | + MediaCodecInfo codecInfo = buildAc4CodecInfo(); |
| 392 | + |
| 393 | + Format variantFormat = |
| 394 | + FORMAT_AC4 |
| 395 | + .buildUpon() |
| 396 | + .setInitializationData(ImmutableList.of(new byte[] {0})) |
| 397 | + .build(); |
| 398 | + assertThat(codecInfo.canReuseCodec(FORMAT_AC4, variantFormat)) |
| 399 | + .isEqualTo( |
| 400 | + new DecoderReuseEvaluation( |
| 401 | + codecInfo.name, |
| 402 | + FORMAT_AC4, |
| 403 | + variantFormat, |
| 404 | + DecoderReuseEvaluation.REUSE_RESULT_YES_WITHOUT_RECONFIGURATION, |
| 405 | + /* discardReasons= */ 0)); |
| 406 | + } |
| 407 | + |
321 | 408 | private static MediaCodecInfo buildH264CodecInfo(boolean adaptive) { |
322 | 409 | return new MediaCodecInfo( |
323 | 410 | "h264", |
@@ -348,6 +435,51 @@ private static MediaCodecInfo buildAacCodecInfo() { |
348 | 435 | /* detachedSurfaceSupported= */ false); |
349 | 436 | } |
350 | 437 |
|
| 438 | + private static MediaCodecInfo buildEac3CodecInfo() { |
| 439 | + return new MediaCodecInfo( |
| 440 | + "eac3joc", |
| 441 | + AUDIO_E_AC3, |
| 442 | + AUDIO_E_AC3, |
| 443 | + /* capabilities= */ null, |
| 444 | + /* hardwareAccelerated= */ false, |
| 445 | + /* softwareOnly= */ true, |
| 446 | + /* vendor= */ true, |
| 447 | + /* adaptive= */ false, |
| 448 | + /* tunneling= */ false, |
| 449 | + /* secure= */ false, |
| 450 | + /* detachedSurfaceSupported= */ false); |
| 451 | + } |
| 452 | + |
| 453 | + private static MediaCodecInfo buildEac3JocCodecInfo() { |
| 454 | + return new MediaCodecInfo( |
| 455 | + "eac3joc", |
| 456 | + AUDIO_E_AC3_JOC, |
| 457 | + AUDIO_E_AC3_JOC, |
| 458 | + /* capabilities= */ null, |
| 459 | + /* hardwareAccelerated= */ false, |
| 460 | + /* softwareOnly= */ true, |
| 461 | + /* vendor= */ true, |
| 462 | + /* adaptive= */ false, |
| 463 | + /* tunneling= */ false, |
| 464 | + /* secure= */ false, |
| 465 | + /* detachedSurfaceSupported= */ false); |
| 466 | + } |
| 467 | + |
| 468 | + private static MediaCodecInfo buildAc4CodecInfo() { |
| 469 | + return new MediaCodecInfo( |
| 470 | + "ac4", |
| 471 | + AUDIO_AC4, |
| 472 | + AUDIO_AC4, |
| 473 | + /* capabilities= */ null, |
| 474 | + /* hardwareAccelerated= */ false, |
| 475 | + /* softwareOnly= */ true, |
| 476 | + /* vendor= */ true, |
| 477 | + /* adaptive= */ false, |
| 478 | + /* tunneling= */ false, |
| 479 | + /* secure= */ false, |
| 480 | + /* detachedSurfaceSupported= */ false); |
| 481 | + } |
| 482 | + |
351 | 483 | private static ColorInfo buildHdrColorInfo(@C.ColorSpace int colorSpace) { |
352 | 484 | return new ColorInfo.Builder() |
353 | 485 | .setColorSpace(colorSpace) |
|
0 commit comments