public abstract class NoSampleRenderer extends java.lang.Object implements Renderer, RendererCapabilities
Renderer implementation whose track type is C.TRACK_TYPE_NONE and does not
consume data from its SampleStream.STATE_DISABLED, STATE_ENABLED, STATE_STARTEDADAPTIVE_NOT_SEAMLESS, ADAPTIVE_NOT_SUPPORTED, ADAPTIVE_SEAMLESS, ADAPTIVE_SUPPORT_MASK, FORMAT_EXCEEDS_CAPABILITIES, FORMAT_HANDLED, FORMAT_SUPPORT_MASK, FORMAT_UNSUPPORTED_DRM, FORMAT_UNSUPPORTED_SUBTYPE, FORMAT_UNSUPPORTED_TYPE, TUNNELING_NOT_SUPPORTED, TUNNELING_SUPPORT_MASK, TUNNELING_SUPPORTED| Constructor and Description |
|---|
NoSampleRenderer() |
| Modifier and Type | Method and Description |
|---|---|
void |
disable()
Disable the renderer, transitioning it to the
Renderer.STATE_DISABLED state. |
void |
enable(RendererConfiguration configuration,
Format[] formats,
SampleStream stream,
long positionUs,
boolean joining,
long offsetUs)
Replaces the
SampleStream that will be associated with this renderer. |
RendererCapabilities |
getCapabilities()
Returns the capabilities of the renderer.
|
protected RendererConfiguration |
getConfiguration()
Returns the configuration set when the renderer was most recently enabled.
|
protected int |
getIndex()
Returns the index of the renderer within the player.
|
MediaClock |
getMediaClock()
If the renderer advances its own playback position then this method returns a corresponding
MediaClock. |
int |
getState()
Returns the current state of the renderer.
|
SampleStream |
getStream()
Returns the
SampleStream being consumed, or null if the renderer is disabled. |
int |
getTrackType()
Returns the track type that the
Renderer handles. |
void |
handleMessage(int what,
java.lang.Object object)
Handles a message delivered to the target.
|
boolean |
hasReadStreamToEnd()
Returns whether the renderer has read the current
SampleStream to the end. |
boolean |
isCurrentStreamFinal()
Returns whether the current
SampleStream will be the final one supplied before the
renderer is next disabled or reset. |
boolean |
isEnded()
Whether the renderer is ready for the
ExoPlayer instance to transition to
Player.STATE_ENDED. |
boolean |
isReady()
Whether the renderer is able to immediately render media from the current position.
|
void |
maybeThrowStreamError()
Throws an error that's preventing the renderer from reading from its
SampleStream. |
protected void |
onDisabled()
Called when the renderer is disabled.
|
protected void |
onEnabled(boolean joining)
Called when the renderer is enabled.
|
protected void |
onPositionReset(long positionUs,
boolean joining)
Called when the position is reset.
|
protected void |
onRendererOffsetChanged(long offsetUs)
Called when the renderer's offset has been changed.
|
protected void |
onStarted()
Called when the renderer is started.
|
protected void |
onStopped()
Called when the renderer is stopped.
|
void |
replaceStream(Format[] formats,
SampleStream stream,
long offsetUs)
Replaces the
SampleStream that will be associated with this renderer. |
void |
resetPosition(long positionUs)
Signals to the renderer that a position discontinuity has occurred.
|
void |
setCurrentStreamFinal()
Signals to the renderer that the current
SampleStream will be the final one supplied
before it is next disabled or reset. |
void |
setIndex(int index)
Sets the index of this renderer within the player.
|
void |
start()
Starts the renderer, meaning that calls to
Renderer.render(long, long) will cause media to be
rendered. |
void |
stop()
Stops the renderer, transitioning it to the
Renderer.STATE_ENABLED state. |
int |
supportsFormat(Format format)
Returns the extent to which the
Renderer supports a given format. |
int |
supportsMixedMimeTypeAdaptation()
Returns the extent to which the
Renderer supports adapting between supported formats
that have different mime types. |
public final int getTrackType()
RendererRenderer handles. For example, a video renderer will
return C.TRACK_TYPE_VIDEO, an audio renderer will return C.TRACK_TYPE_AUDIO, a
text renderer will return C.TRACK_TYPE_TEXT, and so on.getTrackType in interface RenderergetTrackType in interface RendererCapabilitiesTRACK_TYPE_* constants defined in C.Renderer.getTrackType()public final RendererCapabilities getCapabilities()
RenderergetCapabilities in interface Rendererpublic final void setIndex(int index)
Rendererpublic MediaClock getMediaClock()
RendererMediaClock. If provided, the player will use the returned MediaClock as its
source of time during playback. A player may have at most one renderer that returns a
MediaClock from this method.getMediaClock in interface RendererMediaClock tracking the playback position of the renderer, or null.public final int getState()
Rendererpublic final void enable(RendererConfiguration configuration, Format[] formats, SampleStream stream, long positionUs, boolean joining, long offsetUs) throws ExoPlaybackException
SampleStream that will be associated with this renderer.
This method may be called when the renderer is in the following states:
Renderer.STATE_DISABLED.
enable in interface Rendererconfiguration - The renderer configuration.formats - The enabled formats. Should be empty.stream - The SampleStream from which the renderer should consume.positionUs - The player's current position.joining - Whether this renderer is being enabled to join an ongoing playback.offsetUs - The offset that should be subtracted from positionUs
to get the playback position with respect to the media.ExoPlaybackException - If an error occurs.public final void start()
throws ExoPlaybackException
RendererRenderer.render(long, long) will cause media to be
rendered.
This method may be called when the renderer is in the following states:
Renderer.STATE_ENABLED.
start in interface RendererExoPlaybackException - If an error occurs.public final void replaceStream(Format[] formats, SampleStream stream, long offsetUs) throws ExoPlaybackException
SampleStream that will be associated with this renderer.
This method may be called when the renderer is in the following states:
Renderer.STATE_ENABLED, Renderer.STATE_STARTED.
replaceStream in interface Rendererformats - The enabled formats. Should be empty.stream - The SampleStream to be associated with this renderer.offsetUs - The offset that should be subtracted from positionUs in
Renderer.render(long, long) to get the playback position with respect to the media.ExoPlaybackException - If an error occurs.public final SampleStream getStream()
RendererSampleStream being consumed, or null if the renderer is disabled.public final boolean hasReadStreamToEnd()
RendererSampleStream to the end.
This method may be called when the renderer is in the following states:
Renderer.STATE_ENABLED, Renderer.STATE_STARTED.
hasReadStreamToEnd in interface Rendererpublic final void setCurrentStreamFinal()
RendererSampleStream will be the final one supplied
before it is next disabled or reset.
This method may be called when the renderer is in the following states:
Renderer.STATE_ENABLED, Renderer.STATE_STARTED.
setCurrentStreamFinal in interface Rendererpublic final boolean isCurrentStreamFinal()
RendererSampleStream will be the final one supplied before the
renderer is next disabled or reset.isCurrentStreamFinal in interface Rendererpublic final void maybeThrowStreamError()
throws java.io.IOException
RendererSampleStream. Does
nothing if no such error exists.
This method may be called when the renderer is in the following states:
Renderer.STATE_ENABLED, Renderer.STATE_STARTED.
maybeThrowStreamError in interface Rendererjava.io.IOException - An error that's preventing the renderer from making progress or buffering
more data.public final void resetPosition(long positionUs)
throws ExoPlaybackException
Renderer
After a position discontinuity, the renderer's SampleStream is guaranteed to provide
samples starting from a key frame.
This method may be called when the renderer is in the following states:
Renderer.STATE_ENABLED, Renderer.STATE_STARTED.
resetPosition in interface RendererpositionUs - The new playback position in microseconds.ExoPlaybackException - If an error occurs handling the reset.public final void stop()
throws ExoPlaybackException
RendererRenderer.STATE_ENABLED state.
This method may be called when the renderer is in the following states:
Renderer.STATE_STARTED.
stop in interface RendererExoPlaybackException - If an error occurs.public final void disable()
RendererRenderer.STATE_DISABLED state.
This method may be called when the renderer is in the following states:
Renderer.STATE_ENABLED.
public boolean isReady()
Renderer
If the renderer is in the Renderer.STATE_STARTED state then returning true indicates that the
renderer has everything that it needs to continue playback. Returning false indicates that
the player should pause until the renderer is ready.
If the renderer is in the Renderer.STATE_ENABLED state then returning true indicates that the
renderer is ready for playback to be started. Returning false indicates that it is not.
This method may be called when the renderer is in the following states:
Renderer.STATE_ENABLED, Renderer.STATE_STARTED.
public boolean isEnded()
RendererExoPlayer instance to transition to
Player.STATE_ENDED. The player will make this transition as soon as true is
returned by all of its Renderers.
This method may be called when the renderer is in the following states:
Renderer.STATE_ENABLED, Renderer.STATE_STARTED.
public int supportsFormat(Format format) throws ExoPlaybackException
RendererCapabilitiesRenderer supports a given format. The returned value is
the bitwise OR of three properties:
RendererCapabilities.FORMAT_HANDLED,
RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES, RendererCapabilities.FORMAT_UNSUPPORTED_DRM,
RendererCapabilities.FORMAT_UNSUPPORTED_SUBTYPE and RendererCapabilities.FORMAT_UNSUPPORTED_TYPE.RendererCapabilities.ADAPTIVE_SEAMLESS, RendererCapabilities.ADAPTIVE_NOT_SEAMLESS and
RendererCapabilities.ADAPTIVE_NOT_SUPPORTED. Only set if the level of support for the format itself is
RendererCapabilities.FORMAT_HANDLED or RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES.RendererCapabilities.TUNNELING_SUPPORTED and
RendererCapabilities.TUNNELING_NOT_SUPPORTED. Only set if the level of support for the format itself is
RendererCapabilities.FORMAT_HANDLED or RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES.RendererCapabilities.FORMAT_SUPPORT_MASK, RendererCapabilities.ADAPTIVE_SUPPORT_MASK and
RendererCapabilities.TUNNELING_SUPPORT_MASK respectively.supportsFormat in interface RendererCapabilitiesformat - The format.ExoPlaybackException - If an error occurs.public int supportsMixedMimeTypeAdaptation()
throws ExoPlaybackException
RendererCapabilitiesRenderer supports adapting between supported formats
that have different mime types.supportsMixedMimeTypeAdaptation in interface RendererCapabilitiesRendererCapabilities.ADAPTIVE_SEAMLESS, RendererCapabilities.ADAPTIVE_NOT_SEAMLESS and
RendererCapabilities.ADAPTIVE_NOT_SUPPORTED.ExoPlaybackException - If an error occurs.public void handleMessage(int what,
java.lang.Object object)
throws ExoPlaybackException
PlayerMessage.TargethandleMessage in interface PlayerMessage.Targetwhat - The message type.object - The message payload.ExoPlaybackException - If an error occurred whilst handling the message. Should only be
thrown by targets that handle messages on the playback thread.protected void onEnabled(boolean joining)
throws ExoPlaybackException
The default implementation is a no-op.
joining - Whether this renderer is being enabled to join an ongoing playback.ExoPlaybackException - If an error occurs.protected void onRendererOffsetChanged(long offsetUs)
throws ExoPlaybackException
The default implementation is a no-op.
offsetUs - The offset that should be subtracted from positionUs in
Renderer.render(long, long) to get the playback position with respect to the media.ExoPlaybackException - If an error occurs.protected void onPositionReset(long positionUs,
boolean joining)
throws ExoPlaybackException
onRendererOffsetChanged(long) has been called, and also when a position
discontinuity is encountered.
The default implementation is a no-op.
positionUs - The new playback position in microseconds.joining - Whether this renderer is being enabled to join an ongoing playback.ExoPlaybackException - If an error occurs.protected void onStarted()
throws ExoPlaybackException
The default implementation is a no-op.
ExoPlaybackException - If an error occurs.protected void onStopped()
throws ExoPlaybackException
The default implementation is a no-op.
ExoPlaybackException - If an error occurs.protected void onDisabled()
The default implementation is a no-op.
protected final RendererConfiguration getConfiguration()
protected final int getIndex()