mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Rename TrackRenderer.reset to TrackRenderer.onReset.
This allows the TrackRenderer superclass to do things when the renderer is reset, and makes resetting consistent with other 'events' on renderers. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=123974633
This commit is contained in:
parent
ff745ac444
commit
a100175b72
8 changed files with 62 additions and 51 deletions
|
|
@ -326,7 +326,13 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void reset(long positionUs) {
|
||||
protected void onEnabled(boolean joining) throws ExoPlaybackException {
|
||||
codecCounters.reset();
|
||||
eventDispatcher.enabled(codecCounters);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReset(long positionUs) {
|
||||
inputStreamEnded = false;
|
||||
outputStreamEnded = false;
|
||||
renderedFirstFrame = false;
|
||||
|
|
@ -336,12 +342,6 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEnabled(boolean joining) throws ExoPlaybackException {
|
||||
codecCounters.reset();
|
||||
eventDispatcher.enabled(codecCounters);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStarted() {
|
||||
droppedFrameCount = 0;
|
||||
|
|
|
|||
|
|
@ -261,6 +261,14 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
|
|||
super.onEnabled(joining);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReset(long positionUs) throws ExoPlaybackException {
|
||||
super.onReset(positionUs);
|
||||
audioTrack.reset();
|
||||
currentPositionUs = positionUs;
|
||||
allowPositionDiscontinuity = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStarted() {
|
||||
super.onStarted();
|
||||
|
|
@ -305,14 +313,6 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
|
|||
return currentPositionUs;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reset(long positionUs) throws ExoPlaybackException {
|
||||
super.reset(positionUs);
|
||||
audioTrack.reset();
|
||||
currentPositionUs = positionUs;
|
||||
allowPositionDiscontinuity = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean processOutputBuffer(long positionUs, long elapsedRealtimeUs, MediaCodec codec,
|
||||
ByteBuffer buffer, int bufferIndex, int bufferFlags, long bufferPresentationTimeUs,
|
||||
|
|
|
|||
|
|
@ -340,6 +340,15 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
|
|||
return codec == null && format != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReset(long positionUs) throws ExoPlaybackException {
|
||||
inputStreamEnded = false;
|
||||
outputStreamEnded = false;
|
||||
if (codec != null) {
|
||||
flushCodec();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisabled() {
|
||||
format = null;
|
||||
|
|
@ -391,15 +400,6 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reset(long positionUs) throws ExoPlaybackException {
|
||||
inputStreamEnded = false;
|
||||
outputStreamEnded = false;
|
||||
if (codec != null) {
|
||||
flushCodec();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStarted() {
|
||||
// Do nothing. Overridden to remove throws clause.
|
||||
|
|
|
|||
|
|
@ -236,8 +236,8 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void reset(long positionUs) throws ExoPlaybackException {
|
||||
super.reset(positionUs);
|
||||
protected void onReset(long positionUs) throws ExoPlaybackException {
|
||||
super.onReset(positionUs);
|
||||
renderedFirstFrame = false;
|
||||
consecutiveDroppedFrameCount = 0;
|
||||
joiningDeadlineMs = -1;
|
||||
|
|
|
|||
|
|
@ -216,6 +216,28 @@ public abstract class TrackRenderer implements ExoPlayerComponent {
|
|||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a reset is encountered, and also when the renderer is enabled.
|
||||
*
|
||||
* @param positionUs The playback position in microseconds.
|
||||
* @throws ExoPlaybackException If an error occurs handling the reset.
|
||||
*/
|
||||
/* package */ final void reset(long positionUs) throws ExoPlaybackException {
|
||||
onReset(positionUs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a reset is encountered, and also when the renderer is enabled.
|
||||
* <p>
|
||||
* The default implementation is a no-op.
|
||||
*
|
||||
* @param positionUs The playback position in microseconds.
|
||||
* @throws ExoPlaybackException If an error occurs handling the reset.
|
||||
*/
|
||||
protected void onReset(long positionUs) throws ExoPlaybackException {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the renderer, meaning that calls to {@link #render(long, long)} will cause media to be
|
||||
* rendered.
|
||||
|
|
@ -348,17 +370,6 @@ public abstract class TrackRenderer implements ExoPlayerComponent {
|
|||
*/
|
||||
protected abstract int supportsFormat(Format format) throws ExoPlaybackException;
|
||||
|
||||
/**
|
||||
* Invoked when a reset is encountered, and also when the renderer is enabled.
|
||||
* <p>
|
||||
* This method may be called when the renderer is in the following states:
|
||||
* {@link #STATE_ENABLED}, {@link #STATE_STARTED}.
|
||||
*
|
||||
* @param positionUs The playback position in microseconds.
|
||||
* @throws ExoPlaybackException If an error occurs handling the reset.
|
||||
*/
|
||||
protected abstract void reset(long positionUs) throws ExoPlaybackException;
|
||||
|
||||
/**
|
||||
* Incrementally renders the {@link TrackStream}.
|
||||
* <p>
|
||||
|
|
|
|||
|
|
@ -277,18 +277,6 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements
|
|||
return currentPositionUs;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reset(long positionUs) {
|
||||
audioTrack.reset();
|
||||
currentPositionUs = positionUs;
|
||||
allowPositionDiscontinuity = true;
|
||||
inputStreamEnded = false;
|
||||
outputStreamEnded = false;
|
||||
if (decoder != null) {
|
||||
flushDecoder();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the audio session id becomes known. Once the id is known it will not change
|
||||
* (and hence this method will not be invoked again) unless the renderer is disabled and then
|
||||
|
|
@ -308,6 +296,18 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements
|
|||
eventDispatcher.enabled(codecCounters);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReset(long positionUs) {
|
||||
audioTrack.reset();
|
||||
currentPositionUs = positionUs;
|
||||
allowPositionDiscontinuity = true;
|
||||
inputStreamEnded = false;
|
||||
outputStreamEnded = false;
|
||||
if (decoder != null) {
|
||||
flushDecoder();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStarted() {
|
||||
audioTrack.play();
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public final class MetadataTrackRenderer<T> extends TrackRenderer implements Cal
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void reset(long positionUs) {
|
||||
protected void onReset(long positionUs) {
|
||||
pendingMetadata = null;
|
||||
inputStreamEnded = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public final class TextTrackRenderer extends TrackRenderer implements Callback {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void reset(long positionUs) {
|
||||
protected void onReset(long positionUs) {
|
||||
inputStreamEnded = false;
|
||||
outputStreamEnded = false;
|
||||
if (subtitle != null) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue