mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.LoadControl;
|
import com.google.android.exoplayer2.LoadControl;
|
||||||
import com.google.android.exoplayer2.Renderer;
|
import com.google.android.exoplayer2.Renderer;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
|
|
@ -66,16 +67,14 @@ public class DebugSimpleExoPlayer extends SimpleExoPlayer {
|
||||||
private int startIndex;
|
private int startIndex;
|
||||||
private int queueSize;
|
private int queueSize;
|
||||||
private int bufferCount;
|
private int bufferCount;
|
||||||
|
private int minimumInsertIndex;
|
||||||
|
|
||||||
public DebugMediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
|
public DebugMediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
|
||||||
long allowedJoiningTimeMs, Handler eventHandler,
|
long allowedJoiningTimeMs, Handler eventHandler,
|
||||||
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
|
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
|
||||||
VideoRendererEventListener eventListener,
|
VideoRendererEventListener eventListener, int maxDroppedFrameCountToNotify) {
|
||||||
int maxDroppedFrameCountToNotify) {
|
|
||||||
super(context, mediaCodecSelector, allowedJoiningTimeMs, drmSessionManager, false,
|
super(context, mediaCodecSelector, allowedJoiningTimeMs, drmSessionManager, false,
|
||||||
eventHandler, eventListener, maxDroppedFrameCountToNotify);
|
eventHandler, eventListener, maxDroppedFrameCountToNotify);
|
||||||
startIndex = 0;
|
|
||||||
queueSize = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -90,6 +89,14 @@ public class DebugSimpleExoPlayer extends SimpleExoPlayer {
|
||||||
clearTimestamps();
|
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
|
@Override
|
||||||
protected void onQueueInputBuffer(DecoderInputBuffer buffer) {
|
protected void onQueueInputBuffer(DecoderInputBuffer buffer) {
|
||||||
insertTimestamp(buffer.timeUs);
|
insertTimestamp(buffer.timeUs);
|
||||||
|
|
@ -111,10 +118,11 @@ public class DebugSimpleExoPlayer extends SimpleExoPlayer {
|
||||||
startIndex = 0;
|
startIndex = 0;
|
||||||
queueSize = 0;
|
queueSize = 0;
|
||||||
bufferCount = 0;
|
bufferCount = 0;
|
||||||
|
minimumInsertIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertTimestamp(long presentationTimeUs) {
|
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]) {
|
if (presentationTimeUs >= timestampsList[i]) {
|
||||||
timestampsList[i + 1] = presentationTimeUs;
|
timestampsList[i + 1] = presentationTimeUs;
|
||||||
queueSize++;
|
queueSize++;
|
||||||
|
|
@ -122,20 +130,22 @@ public class DebugSimpleExoPlayer extends SimpleExoPlayer {
|
||||||
}
|
}
|
||||||
timestampsList[i + 1] = timestampsList[i];
|
timestampsList[i + 1] = timestampsList[i];
|
||||||
}
|
}
|
||||||
timestampsList[startIndex] = presentationTimeUs;
|
timestampsList[minimumInsertIndex] = presentationTimeUs;
|
||||||
queueSize++;
|
queueSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeShiftTimestampsList() {
|
private void maybeShiftTimestampsList() {
|
||||||
if (startIndex + queueSize == ARRAY_SIZE) {
|
if (startIndex + queueSize == ARRAY_SIZE) {
|
||||||
System.arraycopy(timestampsList, startIndex, timestampsList, 0, queueSize);
|
System.arraycopy(timestampsList, startIndex, timestampsList, 0, queueSize);
|
||||||
|
minimumInsertIndex -= startIndex;
|
||||||
startIndex = 0;
|
startIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long dequeueTimestamp() {
|
private long dequeueTimestamp() {
|
||||||
startIndex++;
|
|
||||||
queueSize--;
|
queueSize--;
|
||||||
|
startIndex++;
|
||||||
|
minimumInsertIndex = Math.max(minimumInsertIndex, startIndex);
|
||||||
return timestampsList[startIndex - 1];
|
return timestampsList[startIndex - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue