Class DecoderAudioRenderer<T extends Decoder<DecoderInputBuffer,? extends SimpleDecoderOutputBuffer,? extends DecoderException>>
- java.lang.Object
-
- com.google.android.exoplayer2.BaseRenderer
-
- com.google.android.exoplayer2.audio.DecoderAudioRenderer<T>
-
- All Implemented Interfaces:
PlayerMessage.Target,Renderer,RendererCapabilities,MediaClock
- Direct Known Subclasses:
FfmpegAudioRenderer,LibflacAudioRenderer,LibopusAudioRenderer
@Deprecated public abstract class DecoderAudioRenderer<T extends Decoder<DecoderInputBuffer,? extends SimpleDecoderOutputBuffer,? extends DecoderException>> extends BaseRenderer implements MediaClock
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.Decodes and renders audio using aDecoder.This renderer accepts the following messages sent via
ExoPlayer.createMessage(Target)on the playback thread:- Message with type
Renderer.MSG_SET_VOLUMEto set the volume. The message payload should be aFloatwith 0 being silence and 1 being unity gain. - Message with type
Renderer.MSG_SET_AUDIO_ATTRIBUTESto set the audio attributes. The message payload should be anAudioAttributesinstance that will configure the underlying audio track. - Message with type
Renderer.MSG_SET_AUX_EFFECT_INFOto set the auxiliary effect. The message payload should be anAuxEffectInfoinstance that will configure the underlying audio track. - Message with type
Renderer.MSG_SET_SKIP_SILENCE_ENABLEDto enable or disable skipping silences. The message payload should be aBoolean. - Message with type
Renderer.MSG_SET_AUDIO_SESSION_IDto set the audio session ID. The message payload should be a session IDIntegerthat will be attached to the underlying audio track.
-
-
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 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 DecoderAudioRenderer()Deprecated.DecoderAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener, AudioCapabilities audioCapabilities, AudioProcessor... audioProcessors)Deprecated.DecoderAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener, AudioProcessor... audioProcessors)Deprecated.DecoderAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener, AudioSink audioSink)Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected DecoderReuseEvaluationcanReuseDecoder(String decoderName, Format oldFormat, Format newFormat)Deprecated.Evaluates whether the existing decoder can be reused for a newFormat.protected abstract TcreateDecoder(Format format, CryptoConfig cryptoConfig)Deprecated.Creates a decoder for the given format.voidexperimentalSetEnableKeepAudioTrackOnSeek(boolean enableKeepAudioTrackOnSeek)Deprecated.Sets whether to enable the experimental feature that keeps and flushes theAudioTrackwhen a seek occurs, as opposed to releasing and reinitialising.MediaClockgetMediaClock()Deprecated.If the renderer advances its own playback position then this method returns a correspondingMediaClock.protected abstract FormatgetOutputFormat(T decoder)Deprecated.Returns the format of audio buffers output by the decoder.PlaybackParametersgetPlaybackParameters()Deprecated.Returns the active playback parameters.longgetPositionUs()Deprecated.Returns the current media position in microseconds.protected @com.google.android.exoplayer2.audio.AudioSink.SinkFormatSupport intgetSinkFormatSupport(Format format)Deprecated.voidhandleMessage(@com.google.android.exoplayer2.Renderer.MessageType int messageType, Object message)Deprecated.Handles a message delivered to the target.booleanisEnded()Deprecated.Whether the renderer is ready for theExoPlayerinstance to transition toPlayer.STATE_ENDED.booleanisReady()Deprecated.Whether the renderer is able to immediately render media from the current position.protected voidonDisabled()Deprecated.Called when the renderer is disabled.protected voidonEnabled(boolean joining, boolean mayRenderStartOfStream)Deprecated.Called when the renderer is enabled.protected voidonPositionDiscontinuity()Deprecated.protected voidonPositionReset(long positionUs, boolean joining)Deprecated.Called when the position is reset.protected voidonQueueInputBuffer(DecoderInputBuffer buffer)Deprecated.protected voidonStarted()Deprecated.Called when the renderer is started.protected voidonStopped()Deprecated.Called when the renderer is stopped.protected voidonStreamChanged(Format[] formats, long startPositionUs, long offsetUs)Deprecated.Called when the renderer's stream has changed.voidrender(long positionUs, long elapsedRealtimeUs)Deprecated.Incrementally renders theSampleStream.voidsetPlaybackParameters(PlaybackParameters playbackParameters)Deprecated.Attempts to set the playback parameters.protected booleansinkSupportsFormat(Format format)Deprecated.@com.google.android.exoplayer2.RendererCapabilities.Capabilities intsupportsFormat(Format format)Deprecated.Returns the extent to which theRenderersupports a given format.protected abstract @com.google.android.exoplayer2.C.FormatSupport intsupportsFormatInternal(Format format)Deprecated.Returns theC.FormatSupportfor the givenFormat.-
Methods inherited from class com.google.android.exoplayer2.BaseRenderer
clearListener, createRendererException, createRendererException, disable, enable, getCapabilities, getConfiguration, getFormatHolder, getIndex, getLastResetPositionUs, getPlayerId, getReadingPositionUs, getState, getStream, getStreamFormats, getTrackType, hasReadStreamToEnd, init, isCurrentStreamFinal, isSourceReady, maybeThrowStreamError, onRelease, onRendererCapabilitiesChanged, onReset, 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
getName, setPlaybackSpeed
-
Methods inherited from interface com.google.android.exoplayer2.RendererCapabilities
getName
-
-
-
-
Constructor Detail
-
DecoderAudioRenderer
public DecoderAudioRenderer()
Deprecated.
-
DecoderAudioRenderer
public DecoderAudioRenderer(@Nullable Handler eventHandler, @Nullable AudioRendererEventListener eventListener, AudioProcessor... audioProcessors)Deprecated.- Parameters:
eventHandler- A handler to use when delivering events toeventListener. May be null if delivery of events is not required.eventListener- A listener of events. May be null if delivery of events is not required.audioProcessors- OptionalAudioProcessors that will process audio before output.
-
DecoderAudioRenderer
public DecoderAudioRenderer(@Nullable Handler eventHandler, @Nullable AudioRendererEventListener eventListener, AudioCapabilities audioCapabilities, AudioProcessor... audioProcessors)Deprecated.- Parameters:
eventHandler- A handler to use when delivering events toeventListener. May be null if delivery of events is not required.eventListener- A listener of events. May be null if delivery of events is not required.audioCapabilities- The audio capabilities for playback on this device. UseAudioCapabilities.DEFAULT_AUDIO_CAPABILITIESif default capabilities (no encoded audio passthrough support) should be assumed.audioProcessors- OptionalAudioProcessors that will process audio before output.
-
DecoderAudioRenderer
public DecoderAudioRenderer(@Nullable Handler eventHandler, @Nullable AudioRendererEventListener eventListener, AudioSink audioSink)Deprecated.- Parameters:
eventHandler- A handler to use when delivering events toeventListener. May be null if delivery of events is not required.eventListener- A listener of events. May be null if delivery of events is not required.audioSink- The sink to which audio will be output.
-
-
Method Detail
-
experimentalSetEnableKeepAudioTrackOnSeek
public void experimentalSetEnableKeepAudioTrackOnSeek(boolean enableKeepAudioTrackOnSeek)
Deprecated.Sets whether to enable the experimental feature that keeps and flushes theAudioTrackwhen a seek occurs, as opposed to releasing and reinitialising. Off by default.This method is experimental, and will be renamed or removed in a future release.
- Parameters:
enableKeepAudioTrackOnSeek- Whether to keep theAudioTrackon seek.
-
getMediaClock
@Nullable public MediaClock getMediaClock()
Deprecated.Description copied from interface:RendererIf the renderer advances its own playback position then this method returns a correspondingMediaClock. If provided, the player will use the returnedMediaClockas its source of time during playback. A player may have at most one renderer that returns aMediaClockfrom this method.- Specified by:
getMediaClockin interfaceRenderer- Overrides:
getMediaClockin classBaseRenderer- Returns:
- The
MediaClocktracking the playback position of the renderer, or null.
-
supportsFormat
public final @com.google.android.exoplayer2.RendererCapabilities.Capabilities int supportsFormat(Format format)
Deprecated.Description copied from interface:RendererCapabilitiesReturns the extent to which theRenderersupports a given format.- Specified by:
supportsFormatin interfaceRendererCapabilities- Parameters:
format- The format.- Returns:
- The
RendererCapabilities.Capabilitiesfor this format.
-
supportsFormatInternal
@ForOverride @FormatSupport protected abstract @com.google.android.exoplayer2.C.FormatSupport int supportsFormatInternal(Format format)
Deprecated.Returns theC.FormatSupportfor the givenFormat.- Parameters:
format- The format, which has an audioFormat.sampleMimeType.- Returns:
- The
C.FormatSupportfor thisFormat.
-
sinkSupportsFormat
protected final boolean sinkSupportsFormat(Format format)
Deprecated.- See Also:
AudioSink.supportsFormat(Format)
-
getSinkFormatSupport
protected final @com.google.android.exoplayer2.audio.AudioSink.SinkFormatSupport int getSinkFormatSupport(Format format)
Deprecated.- See Also:
(Format)
-
render
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackExceptionDeprecated.Description 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.- Specified by:
renderin interfaceRenderer- 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.
-
onPositionDiscontinuity
@CallSuper @ForOverride protected void onPositionDiscontinuity()
Deprecated.
-
createDecoder
@ForOverride protected abstract T createDecoder(Format format, @Nullable CryptoConfig cryptoConfig) throws DecoderException
Deprecated.Creates a decoder for the given format.- Parameters:
format- The format for which a decoder is required.cryptoConfig- TheCryptoConfigobject required for decoding encrypted content. May be null and can be ignored if decoder does not handle encrypted content.- Returns:
- The decoder.
- Throws:
DecoderException- If an error occurred creating a suitable decoder.
-
getOutputFormat
@ForOverride protected abstract Format getOutputFormat(T decoder)
Deprecated.Returns the format of audio buffers output by the decoder. Will not be called until the first output buffer has been dequeued, so the decoder may use input data to determine the format.- Parameters:
decoder- The decoder.
-
canReuseDecoder
@ForOverride protected DecoderReuseEvaluation canReuseDecoder(String decoderName, Format oldFormat, Format newFormat)
Deprecated.Evaluates whether the existing decoder can be reused for a newFormat.The default implementation does not allow decoder reuse.
- Parameters:
decoderName- The name of the decoder.oldFormat- The previous format.newFormat- The new format.- Returns:
- The result of the evaluation.
-
isEnded
public boolean isEnded()
Deprecated.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.
-
isReady
public boolean isReady()
Deprecated.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.
-
getPositionUs
public long getPositionUs()
Deprecated.Description copied from interface:MediaClockReturns the current media position in microseconds.- Specified by:
getPositionUsin interfaceMediaClock
-
setPlaybackParameters
public void setPlaybackParameters(PlaybackParameters playbackParameters)
Deprecated.Description copied from interface:MediaClockAttempts to set the playback parameters. The media clock may override the speed if changing the playback parameters is not supported.- Specified by:
setPlaybackParametersin interfaceMediaClock- Parameters:
playbackParameters- The playback parameters to attempt to set.
-
getPlaybackParameters
public PlaybackParameters getPlaybackParameters()
Deprecated.Description copied from interface:MediaClockReturns the active playback parameters.- Specified by:
getPlaybackParametersin interfaceMediaClock
-
onEnabled
protected void onEnabled(boolean joining, boolean mayRenderStartOfStream) throws ExoPlaybackExceptionDeprecated.Description 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.
-
onPositionReset
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackExceptionDeprecated.Description 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.
-
onStarted
protected void onStarted()
Deprecated.Description copied from class:BaseRendererCalled when the renderer is started.The default implementation is a no-op.
- Overrides:
onStartedin classBaseRenderer
-
onStopped
protected void onStopped()
Deprecated.Description copied from class:BaseRendererCalled when the renderer is stopped.The default implementation is a no-op.
- Overrides:
onStoppedin classBaseRenderer
-
onDisabled
protected void onDisabled()
Deprecated.Description copied from class:BaseRendererCalled when the renderer is disabled.The default implementation is a no-op.
- Overrides:
onDisabledin classBaseRenderer
-
onStreamChanged
protected void onStreamChanged(Format[] formats, long startPositionUs, long offsetUs) throws ExoPlaybackException
Deprecated.Description copied from class:BaseRendererCalled when the renderer's stream has changed. This occurs when the renderer is enabled afterBaseRenderer.onEnabled(boolean, boolean)has been called, and also when the stream has been replaced whilst the renderer is enabled or started.The default implementation is a no-op.
- Overrides:
onStreamChangedin classBaseRenderer- Parameters:
formats- The enabled formats.startPositionUs- The start position of the new stream in renderer time (microseconds).offsetUs- The offset that will be added to the timestamps of buffers read viaBaseRenderer.readSource(com.google.android.exoplayer2.FormatHolder, com.google.android.exoplayer2.decoder.DecoderInputBuffer, @com.google.android.exoplayer2.source.SampleStream.ReadFlags int)so that decoder input buffers have monotonically increasing timestamps.- Throws:
ExoPlaybackException- If an error occurs.
-
handleMessage
public void handleMessage(@com.google.android.exoplayer2.Renderer.MessageType int messageType, @Nullable Object message) throws ExoPlaybackExceptionDeprecated.Description copied from interface:PlayerMessage.TargetHandles a message delivered to the target.- Specified by:
handleMessagein interfacePlayerMessage.Target- Overrides:
handleMessagein classBaseRenderer- Parameters:
messageType- The message type.message- The message payload.- Throws:
ExoPlaybackException- If an error occurred whilst handling the message. Should only be thrown by targets that handle messages on the playback thread.
-
onQueueInputBuffer
protected void onQueueInputBuffer(DecoderInputBuffer buffer)
Deprecated.
-
-