mirror of
https://github.com/samsonjs/media.git
synced 2026-03-30 10:15:48 +00:00
Fix GTS playback test timestamp verifications
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143549680
This commit is contained in:
parent
b774660989
commit
9f81b72291
1 changed files with 17 additions and 7 deletions
|
|
@ -19,6 +19,7 @@ import android.annotation.TargetApi;
|
|||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.LoadControl;
|
||||
import com.google.android.exoplayer2.Renderer;
|
||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||
|
|
@ -66,16 +67,14 @@ public class DebugSimpleExoPlayer extends SimpleExoPlayer {
|
|||
private int startIndex;
|
||||
private int queueSize;
|
||||
private int bufferCount;
|
||||
private int minimumInsertIndex;
|
||||
|
||||
public DebugMediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
|
||||
long allowedJoiningTimeMs, Handler eventHandler,
|
||||
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
|
||||
VideoRendererEventListener eventListener,
|
||||
int maxDroppedFrameCountToNotify) {
|
||||
VideoRendererEventListener eventListener, int maxDroppedFrameCountToNotify) {
|
||||
super(context, mediaCodecSelector, allowedJoiningTimeMs, drmSessionManager, false,
|
||||
eventHandler, eventListener, maxDroppedFrameCountToNotify);
|
||||
startIndex = 0;
|
||||
queueSize = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -90,6 +89,14 @@ public class DebugSimpleExoPlayer extends SimpleExoPlayer {
|
|||
clearTimestamps();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException {
|
||||
super.onInputFormatChanged(newFormat);
|
||||
// Ensure timestamps of buffers queued after this format change are never inserted into the
|
||||
// queue of expected output timestamps before those of buffers that have already been queued.
|
||||
minimumInsertIndex = startIndex + queueSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onQueueInputBuffer(DecoderInputBuffer buffer) {
|
||||
insertTimestamp(buffer.timeUs);
|
||||
|
|
@ -111,10 +118,11 @@ public class DebugSimpleExoPlayer extends SimpleExoPlayer {
|
|||
startIndex = 0;
|
||||
queueSize = 0;
|
||||
bufferCount = 0;
|
||||
minimumInsertIndex = 0;
|
||||
}
|
||||
|
||||
private void insertTimestamp(long presentationTimeUs) {
|
||||
for (int i = startIndex + queueSize - 1; i >= startIndex; i--) {
|
||||
for (int i = startIndex + queueSize - 1; i >= minimumInsertIndex; i--) {
|
||||
if (presentationTimeUs >= timestampsList[i]) {
|
||||
timestampsList[i + 1] = presentationTimeUs;
|
||||
queueSize++;
|
||||
|
|
@ -122,20 +130,22 @@ public class DebugSimpleExoPlayer extends SimpleExoPlayer {
|
|||
}
|
||||
timestampsList[i + 1] = timestampsList[i];
|
||||
}
|
||||
timestampsList[startIndex] = presentationTimeUs;
|
||||
timestampsList[minimumInsertIndex] = presentationTimeUs;
|
||||
queueSize++;
|
||||
}
|
||||
|
||||
private void maybeShiftTimestampsList() {
|
||||
if (startIndex + queueSize == ARRAY_SIZE) {
|
||||
System.arraycopy(timestampsList, startIndex, timestampsList, 0, queueSize);
|
||||
minimumInsertIndex -= startIndex;
|
||||
startIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private long dequeueTimestamp() {
|
||||
startIndex++;
|
||||
queueSize--;
|
||||
startIndex++;
|
||||
minimumInsertIndex = Math.max(minimumInsertIndex, startIndex);
|
||||
return timestampsList[startIndex - 1];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue