mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add a software decoder check to MediaFormat change GTS test.
PiperOrigin-RevId: 327620772
This commit is contained in:
parent
a673eec845
commit
7abece9a39
1 changed files with 16 additions and 8 deletions
|
|
@ -24,6 +24,7 @@ import android.media.MediaFormat;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
|
|
@ -84,13 +85,14 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
private final long[] timestampsList;
|
private final long[] timestampsList;
|
||||||
private final ArrayDeque<Long> inputFormatChangeTimesUs;
|
private final ArrayDeque<Long> inputFormatChangeTimesUs;
|
||||||
private final boolean enableMediaFormatChangeTimeCheck;
|
|
||||||
|
private boolean skipToPositionBeforeRenderingFirstFrame;
|
||||||
|
private boolean shouldMediaFormatChangeTimesBeChecked;
|
||||||
|
|
||||||
private int startIndex;
|
private int startIndex;
|
||||||
private int queueSize;
|
private int queueSize;
|
||||||
private int bufferCount;
|
private int bufferCount;
|
||||||
private int minimumInsertIndex;
|
private int minimumInsertIndex;
|
||||||
private boolean skipToPositionBeforeRenderingFirstFrame;
|
|
||||||
private boolean inputFormatChanged;
|
private boolean inputFormatChanged;
|
||||||
private boolean outputMediaFormatChanged;
|
private boolean outputMediaFormatChanged;
|
||||||
|
|
||||||
|
|
@ -112,10 +114,6 @@ import java.util.ArrayList;
|
||||||
maxDroppedFrameCountToNotify);
|
maxDroppedFrameCountToNotify);
|
||||||
timestampsList = new long[ARRAY_SIZE];
|
timestampsList = new long[ARRAY_SIZE];
|
||||||
inputFormatChangeTimesUs = new ArrayDeque<>();
|
inputFormatChangeTimesUs = new ArrayDeque<>();
|
||||||
|
|
||||||
// As per [Internal ref: b/149818050, b/149751672], MediaFormat changes can occur early for
|
|
||||||
// SDK 29 and 30. Should be fixed for SDK 31 onwards.
|
|
||||||
enableMediaFormatChangeTimeCheck = Util.SDK_INT < 29 || Util.SDK_INT >= 31;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -137,6 +135,14 @@ import java.util.ArrayList;
|
||||||
// frames up to the current playback position [Internal: b/66494991].
|
// frames up to the current playback position [Internal: b/66494991].
|
||||||
skipToPositionBeforeRenderingFirstFrame = getState() == Renderer.STATE_STARTED;
|
skipToPositionBeforeRenderingFirstFrame = getState() == Renderer.STATE_STARTED;
|
||||||
super.configureCodec(codecInfo, codecAdapter, format, crypto, operatingRate);
|
super.configureCodec(codecInfo, codecAdapter, format, crypto, operatingRate);
|
||||||
|
|
||||||
|
// Two separate issues affect whether MediaFormat changes occur at the correct time.
|
||||||
|
// As per [Internal ref: b/149818050, b/149751672], MediaFormat changes can occur early for
|
||||||
|
// SDK 29 and 30. Should be fixed for SDK 31 onwards.
|
||||||
|
// [Internal ref: b/165786766] When using OMX Software decoders, MediaFormat change timestamp
|
||||||
|
// appears to occur early.
|
||||||
|
shouldMediaFormatChangeTimesBeChecked =
|
||||||
|
(Util.SDK_INT < 29 || Util.SDK_INT > 30) && !codecInfo.name.startsWith("OMX.google");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -247,10 +253,12 @@ import java.util.ArrayList;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputMediaFormatChanged) {
|
if (outputMediaFormatChanged) {
|
||||||
long inputFormatChangeTimeUs = inputFormatChangeTimesUs.remove();
|
long inputFormatChangeTimeUs =
|
||||||
|
inputFormatChangeTimesUs.isEmpty() ? C.TIME_UNSET : inputFormatChangeTimesUs.remove();
|
||||||
outputMediaFormatChanged = false;
|
outputMediaFormatChanged = false;
|
||||||
|
|
||||||
if (enableMediaFormatChangeTimeCheck && presentationTimeUs != inputFormatChangeTimeUs) {
|
if (shouldMediaFormatChangeTimesBeChecked
|
||||||
|
&& presentationTimeUs != inputFormatChangeTimeUs) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Expected output MediaFormat change timestamp ("
|
"Expected output MediaFormat change timestamp ("
|
||||||
+ presentationTimeUs
|
+ presentationTimeUs
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue