Class FakeRenderer
- java.lang.Object
-
- com.google.android.exoplayer2.BaseRenderer
-
- com.google.android.exoplayer2.testutil.FakeRenderer
-
- All Implemented Interfaces:
PlayerMessage.Target,Renderer,RendererCapabilities
- Direct Known Subclasses:
FakeAudioRenderer,FakeMediaClockRenderer,FakeVideoRenderer
public class FakeRenderer extends BaseRenderer
FakeRendererthat supports any format with the matching track type.The renderer verifies that all the formats it reads have the provided track type.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.Renderer
Renderer.MessageType, Renderer.State, Renderer.WakeupListener
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.RendererCapabilities
RendererCapabilities.AdaptiveSupport, RendererCapabilities.Capabilities, RendererCapabilities.DecoderSupport, RendererCapabilities.FormatSupport, RendererCapabilities.HardwareAccelerationSupport, RendererCapabilities.Listener, RendererCapabilities.TunnelingSupport
-
-
Field Summary
Fields Modifier and Type Field Description intenabledCountbooleanisEndedintpositionResetCountintresetCountintsampleBufferReadCount-
Fields inherited from interface com.google.android.exoplayer2.Renderer
MSG_CUSTOM_BASE, MSG_SET_AUDIO_ATTRIBUTES, MSG_SET_AUDIO_SESSION_ID, MSG_SET_AUX_EFFECT_INFO, MSG_SET_CAMERA_MOTION_LISTENER, MSG_SET_CHANGE_FRAME_RATE_STRATEGY, MSG_SET_PREFERRED_AUDIO_DEVICE, MSG_SET_SCALING_MODE, MSG_SET_SKIP_SILENCE_ENABLED, MSG_SET_VIDEO_EFFECTS, MSG_SET_VIDEO_FRAME_METADATA_LISTENER, MSG_SET_VIDEO_OUTPUT, MSG_SET_VIDEO_OUTPUT_RESOLUTION, MSG_SET_VOLUME, MSG_SET_WAKEUP_LISTENER, STATE_DISABLED, STATE_ENABLED, STATE_STARTED
-
Fields inherited from interface com.google.android.exoplayer2.RendererCapabilities
ADAPTIVE_NOT_SEAMLESS, ADAPTIVE_NOT_SUPPORTED, ADAPTIVE_SEAMLESS, ADAPTIVE_SUPPORT_MASK, DECODER_SUPPORT_FALLBACK, DECODER_SUPPORT_FALLBACK_MIMETYPE, DECODER_SUPPORT_PRIMARY, FORMAT_EXCEEDS_CAPABILITIES, FORMAT_HANDLED, FORMAT_SUPPORT_MASK, FORMAT_UNSUPPORTED_DRM, FORMAT_UNSUPPORTED_SUBTYPE, FORMAT_UNSUPPORTED_TYPE, HARDWARE_ACCELERATION_NOT_SUPPORTED, HARDWARE_ACCELERATION_SUPPORT_MASK, HARDWARE_ACCELERATION_SUPPORTED, MODE_SUPPORT_MASK, TUNNELING_NOT_SUPPORTED, TUNNELING_SUPPORT_MASK, TUNNELING_SUPPORTED
-
-
Constructor Summary
Constructors Constructor Description FakeRenderer(@com.google.android.exoplayer2.C.TrackType int trackType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Format>getFormatsRead()Returns the list of formats read by the renderer.StringgetName()Returns the name of this renderer, for logging and debugging purposes.booleanisEnded()Whether the renderer is ready for theExoPlayerinstance to transition toPlayer.STATE_ENDED.booleanisReady()Whether the renderer is able to immediately render media from the current position.protected voidonDisabled()Called when the renderer is disabled.protected voidonEnabled(boolean joining, boolean mayRenderStartOfStream)Called when the renderer is enabled.protected voidonFormatChanged(Format format)Called when the renderer reads a new format.protected voidonPositionReset(long positionUs, boolean joining)Called when the position is reset.protected voidonReset()Called when the renderer is reset.voidrender(long positionUs, long elapsedRealtimeUs)Incrementally renders theSampleStream.protected booleanshouldProcessBuffer(long bufferTimeUs, long playbackPositionUs)Called before the renderer processes a buffer.@com.google.android.exoplayer2.RendererCapabilities.Capabilities intsupportsFormat(Format format)Returns the extent to which theRenderersupports a given format.-
Methods inherited from class com.google.android.exoplayer2.BaseRenderer
clearListener, createRendererException, createRendererException, disable, enable, getCapabilities, getConfiguration, getFormatHolder, getIndex, getLastResetPositionUs, getMediaClock, getPlayerId, getReadingPositionUs, getState, getStream, getStreamFormats, getTrackType, handleMessage, hasReadStreamToEnd, init, isCurrentStreamFinal, isSourceReady, maybeThrowStreamError, onRelease, onRendererCapabilitiesChanged, onStarted, onStopped, onStreamChanged, readSource, release, replaceStream, reset, resetPosition, setCurrentStreamFinal, setListener, skipSource, start, stop, supportsMixedMimeTypeAdaptation
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.android.exoplayer2.Renderer
setPlaybackSpeed
-
-
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:RendererReturns the name of this renderer, for logging and debugging purposes. Should typically be the renderer's (un-obfuscated) class name.- Returns:
- The name of this renderer.
-
onPositionReset
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackExceptionDescription copied from class:BaseRendererCalled when the position is reset. This occurs when the renderer is enabled afterBaseRenderer.onStreamChanged(Format[], long, long)has been called, and also when a position discontinuity is encountered.After a position reset, the renderer's
SampleStreamis guaranteed to provide samples starting from a key frame.The default implementation is a no-op.
- Overrides:
onPositionResetin classBaseRenderer- Parameters:
positionUs- The new playback position in microseconds.joining- Whether this renderer is being enabled to join an ongoing playback.- Throws:
ExoPlaybackException- If an error occurs.
-
render
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackExceptionDescription copied from interface:RendererIncrementally renders theSampleStream.If the renderer is in the
Renderer.STATE_ENABLEDstate then each call to this method will do work toward being ready to render theSampleStreamwhen the renderer is started. If the renderer is in theRenderer.STATE_STARTEDstate then calls to this method will render theSampleStreamin sync with the specified media positions.The renderer may also render the very start of the media at the current position (e.g. the first frame of a video stream) while still in the
Renderer.STATE_ENABLEDstate, unless it's the initial start of the media after callingRenderer.enable(RendererConfiguration, Format[], SampleStream, long, boolean, boolean, long, long)withmayRenderStartOfStreamset tofalse.This method should return quickly, and should not block if the renderer is unable to make useful progress.
This method may be called when the renderer is in the following states:
Renderer.STATE_ENABLED,Renderer.STATE_STARTED.- Parameters:
positionUs- The current media time in microseconds, measured at the start of the current iteration of the rendering loop.elapsedRealtimeUs-SystemClock.elapsedRealtime()in microseconds, measured at the start of the current iteration of the rendering loop.- Throws:
ExoPlaybackException- If an error occurs.
-
onEnabled
protected void onEnabled(boolean joining, boolean mayRenderStartOfStream) throws ExoPlaybackExceptionDescription copied from class:BaseRendererCalled when the renderer is enabled.The default implementation is a no-op.
- Overrides:
onEnabledin classBaseRenderer- Parameters:
joining- Whether this renderer is being enabled to join an ongoing playback.mayRenderStartOfStream- Whether this renderer is allowed to render the start of the stream even if the state is notRenderer.STATE_STARTEDyet.- Throws:
ExoPlaybackException- If an error occurs.
-
onReset
protected void onReset()
Description copied from class:BaseRendererCalled when the renderer is reset.The default implementation is a no-op.
- Overrides:
onResetin classBaseRenderer
-
isReady
public boolean isReady()
Description copied from interface:RendererWhether the renderer is able to immediately render media from the current position.If the renderer is in the
Renderer.STATE_STARTEDstate 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_ENABLEDstate 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.- Returns:
- Whether the renderer is ready to render media.
-
isEnded
public boolean isEnded()
Description copied from interface:RendererWhether the renderer is ready for theExoPlayerinstance to transition toPlayer.STATE_ENDED. The player will make this transition as soon astrueis 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.- Returns:
- Whether the renderer is ready for the player to transition to the ended state.
-
supportsFormat
public @com.google.android.exoplayer2.RendererCapabilities.Capabilities int supportsFormat(Format format) throws ExoPlaybackException
Description copied from interface:RendererCapabilitiesReturns the extent to which theRenderersupports a given format.- Parameters:
format- The format.- Returns:
- The
RendererCapabilities.Capabilitiesfor this format. - Throws:
ExoPlaybackException- If an error occurs.
-
onDisabled
protected void onDisabled()
Description copied from class:BaseRendererCalled when the renderer is disabled.The default implementation is a no-op.
- Overrides:
onDisabledin classBaseRenderer
-
onFormatChanged
protected void onFormatChanged(Format format)
Called when the renderer reads a new format.
-
getFormatsRead
public List<Format> getFormatsRead()
Returns the list of formats read by the renderer.
-
shouldProcessBuffer
protected boolean shouldProcessBuffer(long bufferTimeUs, long playbackPositionUs)Called before the renderer processes a buffer.- Parameters:
bufferTimeUs- The buffer timestamp, in microseconds.playbackPositionUs- The playback position, in microseconds- Returns:
- Whether the buffer should be processed.
-
-