Revert erroneous changes

This commit is contained in:
Gaëtan Muller 2024-07-15 22:17:11 +02:00 committed by Ian Baker
parent eefb37a0ba
commit b90f00c774
4 changed files with 20 additions and 8 deletions

View File

@ -237,10 +237,16 @@ import java.util.ArrayList;
}
@Override
protected void renderOutputBuffer(
protected void renderOutputBuffer(MediaCodecAdapter codec, int index, long presentationTimeUs) {
skipToPositionBeforeRenderingFirstFrame = false;
super.renderOutputBuffer(codec, index, presentationTimeUs);
}
@Override
protected void renderOutputBufferV21(
MediaCodecAdapter codec, int index, long presentationTimeUs, long releaseTimeNs) {
skipToPositionBeforeRenderingFirstFrame = false;
super.renderOutputBuffer(codec, index, presentationTimeUs, releaseTimeNs);
super.renderOutputBufferV21(codec, index, presentationTimeUs, releaseTimeNs);
}
@Override

View File

@ -35,6 +35,7 @@ import androidx.media3.common.Format;
import androidx.media3.common.MimeTypes;
import androidx.media3.common.util.MediaFormatUtil;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -208,7 +209,7 @@ public final class DecodeOneFrameUtil {
// Format must not include KEY_FRAME_RATE on API21.
// https://developer.android.com/reference/android/media/MediaCodecList#findDecoderForFormat(android.media.MediaFormat)
float frameRate = Format.NO_VALUE;
if (format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
if (Util.SDK_INT == 21 && format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
try {
frameRate = format.getFloat(MediaFormat.KEY_FRAME_RATE);
} catch (ClassCastException e) {
@ -220,7 +221,9 @@ public final class DecodeOneFrameUtil {
@Nullable String mediaCodecName = mediaCodecList.findDecoderForFormat(format);
MediaFormatUtil.maybeSetInteger(format, MediaFormat.KEY_FRAME_RATE, round(frameRate));
if (Util.SDK_INT == 21) {
MediaFormatUtil.maybeSetInteger(format, MediaFormat.KEY_FRAME_RATE, round(frameRate));
}
return mediaCodecName;
}

View File

@ -102,15 +102,16 @@ public final class ExoplayerEffectPlaybackSeekTest {
new MediaCodecVideoRenderer(context, MediaCodecSelector.DEFAULT) {
private int numberOfFramesRendered;
// Overriding V21 is sufficient as we don't have test running below API26.
@Override
protected void renderOutputBuffer(
protected void renderOutputBufferV21(
MediaCodecAdapter codec, int index, long presentationTimeUs, long releaseTimeNs) {
numberOfFramesRendered++;
if (numberOfFramesRendered == frameIndexToSkip) {
frameSkippedCondition.open();
return;
}
super.renderOutputBuffer(codec, index, presentationTimeUs, releaseTimeNs);
super.renderOutputBufferV21(codec, index, presentationTimeUs, releaseTimeNs);
}
};

View File

@ -313,7 +313,7 @@ public final class EncoderUtil {
// Format must not include KEY_FRAME_RATE on API21.
// https://developer.android.com/reference/android/media/MediaCodecList#findDecoderForFormat(android.media.MediaFormat)
float frameRate = Format.NO_VALUE;
if (format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
if (Util.SDK_INT == 21 && format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
try {
frameRate = format.getFloat(MediaFormat.KEY_FRAME_RATE);
} catch (ClassCastException e) {
@ -328,7 +328,9 @@ public final class EncoderUtil {
? mediaCodecList.findDecoderForFormat(format)
: mediaCodecList.findEncoderForFormat(format);
MediaFormatUtil.maybeSetInteger(format, MediaFormat.KEY_FRAME_RATE, round(frameRate));
if (Util.SDK_INT == 21) {
MediaFormatUtil.maybeSetInteger(format, MediaFormat.KEY_FRAME_RATE, round(frameRate));
}
return mediaCodecName;
}