mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix video renderer rejoining.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=123976645
This commit is contained in:
parent
a100175b72
commit
69bd31f7c2
8 changed files with 20 additions and 21 deletions
|
|
@ -332,7 +332,7 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onReset(long positionUs) {
|
protected void onReset(long positionUs, boolean joining) {
|
||||||
inputStreamEnded = false;
|
inputStreamEnded = false;
|
||||||
outputStreamEnded = false;
|
outputStreamEnded = false;
|
||||||
renderedFirstFrame = false;
|
renderedFirstFrame = false;
|
||||||
|
|
|
||||||
|
|
@ -256,14 +256,14 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onEnabled(boolean joining) throws ExoPlaybackException {
|
protected void onEnabled(boolean joining) throws ExoPlaybackException {
|
||||||
|
super.onEnabled(joining);
|
||||||
codecCounters.reset();
|
codecCounters.reset();
|
||||||
eventDispatcher.enabled(codecCounters);
|
eventDispatcher.enabled(codecCounters);
|
||||||
super.onEnabled(joining);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onReset(long positionUs) throws ExoPlaybackException {
|
protected void onReset(long positionUs, boolean joining) throws ExoPlaybackException {
|
||||||
super.onReset(positionUs);
|
super.onReset(positionUs, joining);
|
||||||
audioTrack.reset();
|
audioTrack.reset();
|
||||||
currentPositionUs = positionUs;
|
currentPositionUs = positionUs;
|
||||||
allowPositionDiscontinuity = true;
|
allowPositionDiscontinuity = true;
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onReset(long positionUs) throws ExoPlaybackException {
|
protected void onReset(long positionUs, boolean joining) throws ExoPlaybackException {
|
||||||
inputStreamEnded = false;
|
inputStreamEnded = false;
|
||||||
outputStreamEnded = false;
|
outputStreamEnded = false;
|
||||||
if (codec != null) {
|
if (codec != null) {
|
||||||
|
|
@ -830,8 +830,8 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
|
||||||
* modified between successive calls. Hence an implementation can, for example, modify the
|
* modified between successive calls. Hence an implementation can, for example, modify the
|
||||||
* buffer's position to keep track of how much of the data it has processed.
|
* buffer's position to keep track of how much of the data it has processed.
|
||||||
* <p>
|
* <p>
|
||||||
* Note that the first call to this method following a call to {@link #reset(long)} will always
|
* Note that the first call to this method following a call to {@link #onReset(long, boolean)}
|
||||||
* receive a new {@link ByteBuffer} to be processed.
|
* will always receive a new {@link ByteBuffer} to be processed.
|
||||||
*
|
*
|
||||||
* @param positionUs The current media time in microseconds, measured at the start of the
|
* @param positionUs The current media time in microseconds, measured at the start of the
|
||||||
* current iteration of the rendering loop.
|
* current iteration of the rendering loop.
|
||||||
|
|
|
||||||
|
|
@ -208,12 +208,9 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onEnabled(boolean joining) throws ExoPlaybackException {
|
protected void onEnabled(boolean joining) throws ExoPlaybackException {
|
||||||
|
super.onEnabled(joining);
|
||||||
codecCounters.reset();
|
codecCounters.reset();
|
||||||
eventDispatcher.enabled(codecCounters);
|
eventDispatcher.enabled(codecCounters);
|
||||||
super.onEnabled(joining);
|
|
||||||
if (joining && allowedJoiningTimeMs > 0) {
|
|
||||||
joiningDeadlineMs = SystemClock.elapsedRealtime() + allowedJoiningTimeMs;
|
|
||||||
}
|
|
||||||
frameReleaseTimeHelper.enable();
|
frameReleaseTimeHelper.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,11 +233,12 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onReset(long positionUs) throws ExoPlaybackException {
|
protected void onReset(long positionUs, boolean joining) throws ExoPlaybackException {
|
||||||
super.onReset(positionUs);
|
super.onReset(positionUs, joining);
|
||||||
renderedFirstFrame = false;
|
renderedFirstFrame = false;
|
||||||
consecutiveDroppedFrameCount = 0;
|
consecutiveDroppedFrameCount = 0;
|
||||||
joiningDeadlineMs = -1;
|
joiningDeadlineMs = joining && allowedJoiningTimeMs > 0
|
||||||
|
? (SystemClock.elapsedRealtime() + allowedJoiningTimeMs) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ public abstract class TrackRenderer implements ExoPlayerComponent {
|
||||||
state = STATE_ENABLED;
|
state = STATE_ENABLED;
|
||||||
onEnabled(joining);
|
onEnabled(joining);
|
||||||
replaceTrackStream(formats, stream);
|
replaceTrackStream(formats, stream);
|
||||||
reset(positionUs);
|
onReset(positionUs, joining);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -217,13 +217,13 @@ public abstract class TrackRenderer implements ExoPlayerComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a reset is encountered, and also when the renderer is enabled.
|
* Called when a reset is encountered.
|
||||||
*
|
*
|
||||||
* @param positionUs The playback position in microseconds.
|
* @param positionUs The playback position in microseconds.
|
||||||
* @throws ExoPlaybackException If an error occurs handling the reset.
|
* @throws ExoPlaybackException If an error occurs handling the reset.
|
||||||
*/
|
*/
|
||||||
/* package */ final void reset(long positionUs) throws ExoPlaybackException {
|
/* package */ final void reset(long positionUs) throws ExoPlaybackException {
|
||||||
onReset(positionUs);
|
onReset(positionUs, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -232,9 +232,10 @@ public abstract class TrackRenderer implements ExoPlayerComponent {
|
||||||
* The default implementation is a no-op.
|
* The default implementation is a no-op.
|
||||||
*
|
*
|
||||||
* @param positionUs The playback position in microseconds.
|
* @param positionUs The playback position in microseconds.
|
||||||
|
* @param joining Whether this renderer is being enabled to join an ongoing playback.
|
||||||
* @throws ExoPlaybackException If an error occurs handling the reset.
|
* @throws ExoPlaybackException If an error occurs handling the reset.
|
||||||
*/
|
*/
|
||||||
protected void onReset(long positionUs) throws ExoPlaybackException {
|
protected void onReset(long positionUs, boolean joining) throws ExoPlaybackException {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,7 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onReset(long positionUs) {
|
protected void onReset(long positionUs, boolean joining) {
|
||||||
audioTrack.reset();
|
audioTrack.reset();
|
||||||
currentPositionUs = positionUs;
|
currentPositionUs = positionUs;
|
||||||
allowPositionDiscontinuity = true;
|
allowPositionDiscontinuity = true;
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ public final class MetadataTrackRenderer<T> extends TrackRenderer implements Cal
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onReset(long positionUs) {
|
protected void onReset(long positionUs, boolean joining) {
|
||||||
pendingMetadata = null;
|
pendingMetadata = null;
|
||||||
inputStreamEnded = false;
|
inputStreamEnded = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ public final class TextTrackRenderer extends TrackRenderer implements Callback {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onReset(long positionUs) {
|
protected void onReset(long positionUs, boolean joining) {
|
||||||
inputStreamEnded = false;
|
inputStreamEnded = false;
|
||||||
outputStreamEnded = false;
|
outputStreamEnded = false;
|
||||||
if (subtitle != null) {
|
if (subtitle != null) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue