diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 75a2f8aae4..e25fc94949 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -211,6 +211,8 @@ `DefaultHttpDataSource.Factory` instead. * Remove `DashMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS`. Use `DashMediaSource.DEFAULT_FALLBACK_TARGET_LIVE_OFFSET_MS` instead. + * Remove `MediaCodecInfo.isSeamlessAdaptationSupported(Format, Format, + boolean)`. Use `MediaCodecInfo.canReuseCodec(Format, Format)` instead. ## 1.4 diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java index a4696e30d7..1f10039a09 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java @@ -50,7 +50,6 @@ import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import androidx.media3.exoplayer.DecoderReuseEvaluation; import androidx.media3.exoplayer.DecoderReuseEvaluation.DecoderDiscardReasons; -import androidx.media3.exoplayer.DecoderReuseEvaluation.DecoderReuseResult; /** Information about a {@link MediaCodec} for a given MIME type. */ @SuppressWarnings("InlinedApi") @@ -357,8 +356,7 @@ public final class MediaCodecInfo { * format when the codec is configured to play media in the specified {@code format}. * *
For adaptation to succeed, the codec must also be configured with appropriate maximum values - * and {@link #isSeamlessAdaptationSupported(Format, Format, boolean)} must return {@code true} - * for the old/new formats. + * and {@link #canReuseCodec(Format, Format)} must return {@code true} for the old/new formats. * * @param format The format of media for which the decoder will be configured. * @return Whether adaptation may be possible @@ -372,32 +370,6 @@ public final class MediaCodecInfo { } } - /** - * Returns whether it is possible to adapt an instance of this decoder seamlessly from {@code - * oldFormat} to {@code newFormat}. If {@code newFormat} may not be completely populated, pass - * {@code false} for {@code isNewFormatComplete}. - * - *
For adaptation to succeed, the codec must also be configured with maximum values that are - * compatible with the new format. - * - * @param oldFormat The format being decoded. - * @param newFormat The new format. - * @param isNewFormatComplete Whether {@code newFormat} is populated with format-specific - * metadata. - * @return Whether it is possible to adapt the decoder seamlessly. - * @deprecated Use {@link #canReuseCodec}. - */ - @Deprecated - public boolean isSeamlessAdaptationSupported( - Format oldFormat, Format newFormat, boolean isNewFormatComplete) { - if (!isNewFormatComplete && oldFormat.colorInfo != null && newFormat.colorInfo == null) { - newFormat = newFormat.buildUpon().setColorInfo(oldFormat.colorInfo).build(); - } - @DecoderReuseResult int reuseResult = canReuseCodec(oldFormat, newFormat).result; - return reuseResult == REUSE_RESULT_YES_WITH_RECONFIGURATION - || reuseResult == REUSE_RESULT_YES_WITHOUT_RECONFIGURATION; - } - /** * Evaluates whether it's possible to reuse an instance of this decoder that's currently decoding * {@code oldFormat} to decode {@code newFormat} instead. diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfoTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfoTest.java index 2f0b9ca564..c4e3f53565 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfoTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfoTest.java @@ -299,162 +299,6 @@ public final class MediaCodecInfoTest { DISCARD_REASON_INITIALIZATION_DATA_CHANGED)); } - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_withDifferentMimeType_returnsFalse() { - MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */ true); - - Format hdAv1Format = FORMAT_H264_HD.buildUpon().setSampleMimeType(VIDEO_AV1).build(); - assertThat( - codecInfo.isSeamlessAdaptationSupported( - FORMAT_H264_HD, hdAv1Format, /* isNewFormatComplete= */ true)) - .isFalse(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_withRotation_returnsFalse() { - MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */ true); - - Format hdRotatedFormat = FORMAT_H264_HD.buildUpon().setRotationDegrees(90).build(); - assertThat( - codecInfo.isSeamlessAdaptationSupported( - FORMAT_H264_HD, hdRotatedFormat, /* isNewFormatComplete= */ true)) - .isFalse(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_withResolutionChange_adaptiveCodec_returnsTrue() { - MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */ true); - - assertThat( - codecInfo.isSeamlessAdaptationSupported( - FORMAT_H264_HD, FORMAT_H264_4K, /* isNewFormatComplete= */ true)) - .isTrue(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_withResolutionChange_nonAdaptiveCodec_returnsFalse() { - MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */ false); - - assertThat( - codecInfo.isSeamlessAdaptationSupported( - FORMAT_H264_HD, FORMAT_H264_4K, /* isNewFormatComplete= */ true)) - .isFalse(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_noResolutionChange_nonAdaptiveCodec_returnsTrue() { - MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */ false); - - Format hdVariantFormat = - FORMAT_H264_HD.buildUpon().setInitializationData(ImmutableList.of(new byte[] {0})).build(); - assertThat( - codecInfo.isSeamlessAdaptationSupported( - FORMAT_H264_HD, hdVariantFormat, /* isNewFormatComplete= */ true)) - .isTrue(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_colorInfoOmittedFromCompleteNewFormat_returnsFalse() { - MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */ false); - - Format hdrVariantFormat = - FORMAT_H264_4K.buildUpon().setColorInfo(buildHdrColorInfo(C.COLOR_SPACE_BT601)).build(); - assertThat( - codecInfo.isSeamlessAdaptationSupported( - hdrVariantFormat, FORMAT_H264_4K, /* isNewFormatComplete= */ true)) - .isFalse(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_colorInfoOmittedFromIncompleteNewFormat_returnsTrue() { - MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */ false); - - Format hdrVariantFormat = - FORMAT_H264_4K.buildUpon().setColorInfo(buildHdrColorInfo(C.COLOR_SPACE_BT601)).build(); - assertThat( - codecInfo.isSeamlessAdaptationSupported( - hdrVariantFormat, FORMAT_H264_4K, /* isNewFormatComplete= */ false)) - .isTrue(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_colorInfoOmittedFromOldFormat_returnsFalse() { - MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */ false); - - Format hdrVariantFormat = - FORMAT_H264_4K.buildUpon().setColorInfo(buildHdrColorInfo(C.COLOR_SPACE_BT601)).build(); - assertThat( - codecInfo.isSeamlessAdaptationSupported( - FORMAT_H264_4K, hdrVariantFormat, /* isNewFormatComplete= */ true)) - .isFalse(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_colorInfoChange_returnsFalse() { - MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */ false); - - Format hdrVariantFormat1 = - FORMAT_H264_4K.buildUpon().setColorInfo(buildHdrColorInfo(C.COLOR_SPACE_BT601)).build(); - Format hdrVariantFormat2 = - FORMAT_H264_4K.buildUpon().setColorInfo(buildHdrColorInfo(C.COLOR_SPACE_BT709)).build(); - assertThat( - codecInfo.isSeamlessAdaptationSupported( - hdrVariantFormat1, hdrVariantFormat2, /* isNewFormatComplete= */ true)) - .isFalse(); - assertThat( - codecInfo.isSeamlessAdaptationSupported( - hdrVariantFormat1, hdrVariantFormat2, /* isNewFormatComplete= */ false)) - .isFalse(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_audioWithDifferentChannelCounts_returnsFalse() { - MediaCodecInfo codecInfo = buildAacCodecInfo(); - - assertThat( - codecInfo.isSeamlessAdaptationSupported( - FORMAT_AAC_STEREO, FORMAT_AAC_SURROUND, /* isNewFormatComplete= */ true)) - .isFalse(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_audioWithSameChannelCounts_returnsFalse() { - MediaCodecInfo codecInfo = buildAacCodecInfo(); - - Format stereoVariantFormat = FORMAT_AAC_STEREO.buildUpon().setAverageBitrate(100).build(); - assertThat( - codecInfo.isSeamlessAdaptationSupported( - FORMAT_AAC_STEREO, stereoVariantFormat, /* isNewFormatComplete= */ true)) - .isFalse(); - } - - @Test - @SuppressWarnings("deprecation") - public void isSeamlessAdaptationSupported_audioWithDifferentInitializationData_returnsFalse() { - MediaCodecInfo codecInfo = buildAacCodecInfo(); - - Format stereoVariantFormat = - FORMAT_AAC_STEREO - .buildUpon() - .setInitializationData(ImmutableList.of(new byte[] {0})) - .build(); - assertThat( - codecInfo.isSeamlessAdaptationSupported( - FORMAT_AAC_STEREO, stereoVariantFormat, /* isNewFormatComplete= */ true)) - .isFalse(); - } - private static MediaCodecInfo buildH264CodecInfo(boolean adaptive) { return new MediaCodecInfo( "h264",