Remove deprecated MediaCodecInfo.isSeamlessAdaptationSupported(...)

Use `MediaCodecInfo.canReuseCodec(...)` instead.

PiperOrigin-RevId: 636918479
This commit is contained in:
ibaker 2024-05-24 07:56:35 -07:00 committed by Copybara-Service
parent 2ab1c75ca7
commit 7fd8a06e08
3 changed files with 3 additions and 185 deletions

View File

@ -211,6 +211,8 @@
`DefaultHttpDataSource.Factory` instead. `DefaultHttpDataSource.Factory` instead.
* Remove `DashMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS`. Use * Remove `DashMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_MS`. Use
`DashMediaSource.DEFAULT_FALLBACK_TARGET_LIVE_OFFSET_MS` instead. `DashMediaSource.DEFAULT_FALLBACK_TARGET_LIVE_OFFSET_MS` instead.
* Remove `MediaCodecInfo.isSeamlessAdaptationSupported(Format, Format,
boolean)`. Use `MediaCodecInfo.canReuseCodec(Format, Format)` instead.
## 1.4 ## 1.4

View File

@ -50,7 +50,6 @@ import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util; import androidx.media3.common.util.Util;
import androidx.media3.exoplayer.DecoderReuseEvaluation; import androidx.media3.exoplayer.DecoderReuseEvaluation;
import androidx.media3.exoplayer.DecoderReuseEvaluation.DecoderDiscardReasons; import androidx.media3.exoplayer.DecoderReuseEvaluation.DecoderDiscardReasons;
import androidx.media3.exoplayer.DecoderReuseEvaluation.DecoderReuseResult;
/** Information about a {@link MediaCodec} for a given MIME type. */ /** Information about a {@link MediaCodec} for a given MIME type. */
@SuppressWarnings("InlinedApi") @SuppressWarnings("InlinedApi")
@ -357,8 +356,7 @@ public final class MediaCodecInfo {
* format when the codec is configured to play media in the specified {@code format}. * format when the codec is configured to play media in the specified {@code format}.
* *
* <p>For adaptation to succeed, the codec must also be configured with appropriate maximum values * <p>For adaptation to succeed, the codec must also be configured with appropriate maximum values
* and {@link #isSeamlessAdaptationSupported(Format, Format, boolean)} must return {@code true} * and {@link #canReuseCodec(Format, Format)} must return {@code true} for the old/new formats.
* for the old/new formats.
* *
* @param format The format of media for which the decoder will be configured. * @param format The format of media for which the decoder will be configured.
* @return Whether adaptation may be possible * @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}.
*
* <p>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 * Evaluates whether it's possible to reuse an instance of this decoder that's currently decoding
* {@code oldFormat} to decode {@code newFormat} instead. * {@code oldFormat} to decode {@code newFormat} instead.

View File

@ -299,162 +299,6 @@ public final class MediaCodecInfoTest {
DISCARD_REASON_INITIALIZATION_DATA_CHANGED)); 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) { private static MediaCodecInfo buildH264CodecInfo(boolean adaptive) {
return new MediaCodecInfo( return new MediaCodecInfo(
"h264", "h264",