Class MediaCodecAudioRenderer
- java.lang.Object
-
- com.google.android.exoplayer2.BaseRenderer
-
- com.google.android.exoplayer2.mediacodec.MediaCodecRenderer
-
- com.google.android.exoplayer2.audio.MediaCodecAudioRenderer
-
- All Implemented Interfaces:
PlayerMessage.Target,Renderer,RendererCapabilities,MediaClock
@Deprecated public class MediaCodecAudioRenderer extends MediaCodecRenderer 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 usingMediaCodecand anAudioSink.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 class com.google.android.exoplayer2.mediacodec.MediaCodecRenderer
MediaCodecRenderer.DecoderInitializationException
-
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 class com.google.android.exoplayer2.mediacodec.MediaCodecRenderer
CODEC_OPERATING_RATE_UNSET, decoderCounters
-
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 MediaCodecAudioRenderer(Context context, MediaCodecAdapter.Factory codecAdapterFactory, MediaCodecSelector mediaCodecSelector, boolean enableDecoderFallback, Handler eventHandler, AudioRendererEventListener eventListener, AudioSink audioSink)Deprecated.Creates a new instance.MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector)Deprecated.MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, boolean enableDecoderFallback, Handler eventHandler, AudioRendererEventListener eventListener, AudioSink audioSink)Deprecated.MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, Handler eventHandler, AudioRendererEventListener eventListener)Deprecated.MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, Handler eventHandler, AudioRendererEventListener eventListener, AudioCapabilities audioCapabilities, AudioProcessor... audioProcessors)Deprecated.MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, Handler eventHandler, AudioRendererEventListener eventListener, AudioSink audioSink)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected DecoderReuseEvaluationcanReuseCodec(MediaCodecInfo codecInfo, Format oldFormat, Format newFormat)Deprecated.Evaluates whether the existingMediaCodeccan be kept for a newFormat, and if it can whether it requires reconfiguration.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.protected intgetCodecMaxInputSize(MediaCodecInfo codecInfo, Format format, Format[] streamFormats)Deprecated.Returns a maximum input size suitable for configuring a codec forformatin a way that will allow possible adaptation to other compatible formats instreamFormats.protected floatgetCodecOperatingRateV23(float targetPlaybackSpeed, Format format, Format[] streamFormats)Deprecated.Returns theMediaFormat.KEY_OPERATING_RATEvalue for a given playback speed, currentFormatand set of possible stream formats.protected List<MediaCodecInfo>getDecoderInfos(MediaCodecSelector mediaCodecSelector, Format format, boolean requiresSecureDecoder)Deprecated.Returns a list of decoders that can decode media in the specified format, in priority order.MediaClockgetMediaClock()Deprecated.If the renderer advances its own playback position then this method returns a correspondingMediaClock.protected MediaCodecAdapter.ConfigurationgetMediaCodecConfiguration(MediaCodecInfo codecInfo, Format format, MediaCrypto crypto, float codecOperatingRate)Deprecated.Returns theMediaCodecAdapter.Configurationthat will be used to create and configure aMediaCodecto decode the givenFormatfor a playback.protected MediaFormatgetMediaFormat(Format format, String codecMimeType, int codecMaxInputSize, float codecOperatingRate)Deprecated.Returns the frameworkMediaFormatthat can be used to configure aMediaCodecfor decoding the givenFormatfor playback.StringgetName()Deprecated.Returns the name of this renderer, for logging and debugging purposes.PlaybackParametersgetPlaybackParameters()Deprecated.Returns the active playback parameters.longgetPositionUs()Deprecated.Returns the current media position in microseconds.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 voidonCodecError(Exception codecError)Deprecated.Called when a codec error has occurred.protected voidonCodecInitialized(String name, MediaCodecAdapter.Configuration configuration, long initializedTimestampMs, long initializationDurationMs)Deprecated.Called when aMediaCodechas been created and configured.protected voidonCodecReleased(String name)Deprecated.Called when aMediaCodechas been released.protected voidonDisabled()Deprecated.Called when the renderer is disabled.protected voidonEnabled(boolean joining, boolean mayRenderStartOfStream)Deprecated.Called when the renderer is enabled.protected DecoderReuseEvaluationonInputFormatChanged(FormatHolder formatHolder)Deprecated.Called when a newFormatis read from the upstreamMediaPeriod.protected voidonOutputFormatChanged(Format format, MediaFormat mediaFormat)Deprecated.Called when one of the output formats changes.protected voidonOutputStreamOffsetUsChanged(long outputStreamOffsetUs)Deprecated.Called after the output stream offset changes.protected voidonPositionDiscontinuity()Deprecated.protected voidonPositionReset(long positionUs, boolean joining)Deprecated.Called when the position is reset.protected voidonProcessedStreamChange()Deprecated.Called after the last output buffer before a stream change has been processed.protected voidonQueueInputBuffer(DecoderInputBuffer buffer)Deprecated.Called immediately before an input buffer is queued into the codec.protected voidonRelease()Deprecated.Called when the renderer is released.protected voidonReset()Deprecated.Called when the renderer is reset.protected voidonStarted()Deprecated.Called when the renderer is started.protected voidonStopped()Deprecated.Called when the renderer is stopped.protected booleanprocessOutputBuffer(long positionUs, long elapsedRealtimeUs, MediaCodecAdapter codec, ByteBuffer buffer, int bufferIndex, int bufferFlags, int sampleCount, long bufferPresentationTimeUs, boolean isDecodeOnlyBuffer, boolean isLastBuffer, Format format)Deprecated.Processes an output media buffer.protected voidrenderToEndOfStream()Deprecated.Incrementally renders any remaining output.voidsetPlaybackParameters(PlaybackParameters playbackParameters)Deprecated.Attempts to set the playback parameters.protected booleanshouldUseBypass(Format format)Deprecated.Returns whether buffers in the input format can be processed without a codec.protected @com.google.android.exoplayer2.RendererCapabilities.Capabilities intsupportsFormat(MediaCodecSelector mediaCodecSelector, Format format)Deprecated.Returns theRendererCapabilities.Capabilitiesfor the givenFormat.-
Methods inherited from class com.google.android.exoplayer2.mediacodec.MediaCodecRenderer
createDecoderException, flushOrReinitializeCodec, flushOrReleaseCodec, getCodec, getCodecInfo, getCodecNeedsEosPropagation, getCodecOperatingRate, getCodecOutputMediaFormat, getOutputStreamOffsetUs, getPlaybackSpeed, handleInputBufferSupplementalData, isBypassPossible, maybeInitCodecOrBypass, onProcessedOutputBuffer, onReadyToInitializeCodec, onStreamChanged, releaseCodec, render, resetCodecStateForFlush, resetCodecStateForRelease, setPendingOutputEndOfStream, setPendingPlaybackException, setPlaybackSpeed, setRenderTimeLimitMs, shouldInitCodec, shouldReinitCodec, supportsFormat, supportsFormatDrm, supportsMixedMimeTypeAdaptation, updateCodecOperatingRate, updateOutputFormatForTime
-
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, onRendererCapabilitiesChanged, readSource, release, replaceStream, reset, resetPosition, setCurrentStreamFinal, setListener, skipSource, start, stop
-
-
-
-
Constructor Detail
-
MediaCodecAudioRenderer
public MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector)
Deprecated.- Parameters:
context- A context.mediaCodecSelector- A decoder selector.
-
MediaCodecAudioRenderer
public MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, @Nullable Handler eventHandler, @Nullable AudioRendererEventListener eventListener)
Deprecated.- Parameters:
context- A context.mediaCodecSelector- A decoder selector.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.
-
MediaCodecAudioRenderer
public MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, @Nullable Handler eventHandler, @Nullable AudioRendererEventListener eventListener, AudioCapabilities audioCapabilities, AudioProcessor... audioProcessors)
Deprecated.- Parameters:
context- A context.mediaCodecSelector- A decoder selector.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 PCM audio before output.
-
MediaCodecAudioRenderer
public MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, @Nullable Handler eventHandler, @Nullable AudioRendererEventListener eventListener, AudioSink audioSink)
Deprecated.- Parameters:
context- A context.mediaCodecSelector- A decoder selector.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.
-
MediaCodecAudioRenderer
public MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, boolean enableDecoderFallback, @Nullable Handler eventHandler, @Nullable AudioRendererEventListener eventListener, AudioSink audioSink)
Deprecated.- Parameters:
context- A context.mediaCodecSelector- A decoder selector.enableDecoderFallback- Whether to enable fallback to lower-priority decoders if decoder initialization fails. This may result in using a decoder that is slower/less efficient than the primary decoder.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.
-
MediaCodecAudioRenderer
public MediaCodecAudioRenderer(Context context, MediaCodecAdapter.Factory codecAdapterFactory, MediaCodecSelector mediaCodecSelector, boolean enableDecoderFallback, @Nullable Handler eventHandler, @Nullable AudioRendererEventListener eventListener, AudioSink audioSink)
Deprecated.Creates a new instance.- Parameters:
context- A context.codecAdapterFactory- TheMediaCodecAdapter.Factoryused to createMediaCodecAdapterinstances.mediaCodecSelector- A decoder selector.enableDecoderFallback- Whether to enable fallback to lower-priority decoders if decoder initialization fails. This may result in using a decoder that is slower/less efficient than the primary decoder.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
-
getName
public String getName()
Deprecated.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.- Specified by:
getNamein interfaceRenderer- Specified by:
getNamein interfaceRendererCapabilities- Returns:
- The name of this renderer.
-
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.
-
supportsFormat
protected @com.google.android.exoplayer2.RendererCapabilities.Capabilities int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format) throws MediaCodecUtil.DecoderQueryException
Deprecated.Description copied from class:MediaCodecRendererReturns theRendererCapabilities.Capabilitiesfor the givenFormat.- Specified by:
supportsFormatin classMediaCodecRenderer- Parameters:
mediaCodecSelector- The decoder selector.format- TheFormat.- Returns:
- The
RendererCapabilities.Capabilitiesfor thisFormat. - Throws:
MediaCodecUtil.DecoderQueryException- If there was an error querying decoders.
-
getDecoderInfos
protected List<MediaCodecInfo> getDecoderInfos(MediaCodecSelector mediaCodecSelector, Format format, boolean requiresSecureDecoder) throws MediaCodecUtil.DecoderQueryException
Deprecated.Description copied from class:MediaCodecRendererReturns a list of decoders that can decode media in the specified format, in priority order.- Specified by:
getDecoderInfosin classMediaCodecRenderer- Parameters:
mediaCodecSelector- The decoder selector.format- TheFormatfor which a decoder is required.requiresSecureDecoder- Whether a secure decoder is required.- Returns:
- A list of
MediaCodecInfos corresponding to decoders. May be empty. - Throws:
MediaCodecUtil.DecoderQueryException- Thrown if there was an error querying decoders.
-
shouldUseBypass
protected boolean shouldUseBypass(Format format)
Deprecated.Description copied from class:MediaCodecRendererReturns whether buffers in the input format can be processed without a codec.This method is only called if the content is not DRM protected, because if the content is DRM protected use of bypass is never possible.
- Overrides:
shouldUseBypassin classMediaCodecRenderer- Parameters:
format- The inputFormat.- Returns:
- Whether playback bypassing
MediaCodecis supported.
-
getMediaCodecConfiguration
protected MediaCodecAdapter.Configuration getMediaCodecConfiguration(MediaCodecInfo codecInfo, Format format, @Nullable MediaCrypto crypto, float codecOperatingRate)
Deprecated.Description copied from class:MediaCodecRendererReturns theMediaCodecAdapter.Configurationthat will be used to create and configure aMediaCodecto decode the givenFormatfor a playback.- Specified by:
getMediaCodecConfigurationin classMediaCodecRenderer- Parameters:
codecInfo- Information about theMediaCodecbeing configured.format- TheFormatfor which the codec is being configured.crypto- For drm protected playbacks, aMediaCryptoto use for decryption.codecOperatingRate- The codec operating rate, orMediaCodecRenderer.CODEC_OPERATING_RATE_UNSETif no codec operating rate should be set.- Returns:
- The parameters needed to call
MediaCodec.configure(android.media.MediaFormat, android.view.Surface, android.media.MediaCrypto, int).
-
canReuseCodec
protected DecoderReuseEvaluation canReuseCodec(MediaCodecInfo codecInfo, Format oldFormat, Format newFormat)
Deprecated.Description copied from class:MediaCodecRendererEvaluates whether the existingMediaCodeccan be kept for a newFormat, and if it can whether it requires reconfiguration.The default implementation does not allow decoder reuse.
- Overrides:
canReuseCodecin classMediaCodecRenderer- Parameters:
codecInfo- AMediaCodecInfodescribing the decoder.oldFormat- TheFormatfor which the existing instance is configured.newFormat- The newFormat.- Returns:
- The result of the evaluation.
-
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.
-
getCodecOperatingRateV23
protected float getCodecOperatingRateV23(float targetPlaybackSpeed, Format format, Format[] streamFormats)Deprecated.Description copied from class:MediaCodecRendererReturns theMediaFormat.KEY_OPERATING_RATEvalue for a given playback speed, currentFormatand set of possible stream formats.The default implementation returns
MediaCodecRenderer.CODEC_OPERATING_RATE_UNSET.- Overrides:
getCodecOperatingRateV23in classMediaCodecRenderer- Parameters:
targetPlaybackSpeed- The target factor by which playback should be sped up. This may be different from the current playback speed, for example, if the speed is temporarily adjusted for live playback.format- TheFormatfor which the codec is being configured.streamFormats- The possible stream formats.- Returns:
- The codec operating rate, or
MediaCodecRenderer.CODEC_OPERATING_RATE_UNSETif no codec operating rate should be set.
-
onCodecInitialized
protected void onCodecInitialized(String name, MediaCodecAdapter.Configuration configuration, long initializedTimestampMs, long initializationDurationMs)
Deprecated.Description copied from class:MediaCodecRendererCalled when aMediaCodechas been created and configured.The default implementation is a no-op.
- Overrides:
onCodecInitializedin classMediaCodecRenderer- Parameters:
name- The name of the codec that was initialized.configuration- TheMediaCodecAdapter.Configurationused to configure the codec.initializedTimestampMs-SystemClock.elapsedRealtime()when initialization finished.initializationDurationMs- The time taken to initialize the codec in milliseconds.
-
onCodecReleased
protected void onCodecReleased(String name)
Deprecated.Description copied from class:MediaCodecRendererCalled when aMediaCodechas been released.The default implementation is a no-op.
- Overrides:
onCodecReleasedin classMediaCodecRenderer- Parameters:
name- The name of the codec that was released.
-
onCodecError
protected void onCodecError(Exception codecError)
Deprecated.Description copied from class:MediaCodecRendererCalled when a codec error has occurred.The default implementation is a no-op.
- Overrides:
onCodecErrorin classMediaCodecRenderer- Parameters:
codecError- The error.
-
onInputFormatChanged
@Nullable protected DecoderReuseEvaluation onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException
Deprecated.Description copied from class:MediaCodecRendererCalled when a newFormatis read from the upstreamMediaPeriod.- Overrides:
onInputFormatChangedin classMediaCodecRenderer- Parameters:
formatHolder- AFormatHolderthat holds the newFormat.- Returns:
- The result of the evaluation to determine whether the existing decoder instance can be
reused for the new format, or
nullif the renderer did not have a decoder. - Throws:
ExoPlaybackException- If an error occurs re-initializing theMediaCodec.
-
onOutputFormatChanged
protected void onOutputFormatChanged(Format format, @Nullable MediaFormat mediaFormat) throws ExoPlaybackException
Deprecated.Description copied from class:MediaCodecRendererCalled when one of the output formats changes.The default implementation is a no-op.
- Overrides:
onOutputFormatChangedin classMediaCodecRenderer- Parameters:
format- The inputFormatto which future output now corresponds. If the renderer is in bypass mode, this is also the output format.mediaFormat- The codec outputMediaFormat, ornullif the renderer is in bypass mode.- Throws:
ExoPlaybackException- Thrown if an error occurs configuring the output.
-
onPositionDiscontinuity
@CallSuper protected void onPositionDiscontinuity()
Deprecated.
-
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 classMediaCodecRenderer- 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 classMediaCodecRenderer- 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 classMediaCodecRenderer
-
onStopped
protected void onStopped()
Deprecated.Description copied from class:BaseRendererCalled when the renderer is stopped.The default implementation is a no-op.
- Overrides:
onStoppedin classMediaCodecRenderer
-
onDisabled
protected void onDisabled()
Deprecated.Description copied from class:BaseRendererCalled when the renderer is disabled.The default implementation is a no-op.
- Overrides:
onDisabledin classMediaCodecRenderer
-
onReset
protected void onReset()
Deprecated.Description copied from class:BaseRendererCalled when the renderer is reset.The default implementation is a no-op.
- Overrides:
onResetin classMediaCodecRenderer
-
onRelease
protected void onRelease()
Deprecated.Description copied from class:BaseRendererCalled when the renderer is released.The default implementation is a no-op.
- Overrides:
onReleasein classBaseRenderer
-
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.- Specified by:
isEndedin interfaceRenderer- Overrides:
isEndedin classMediaCodecRenderer- Returns:
- Whether the renderer is ready for the player to transition to the ended state.
-
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.- Specified by:
isReadyin interfaceRenderer- Overrides:
isReadyin classMediaCodecRenderer- Returns:
- Whether the renderer is ready to render media.
-
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
-
onQueueInputBuffer
protected void onQueueInputBuffer(DecoderInputBuffer buffer)
Deprecated.Description copied from class:MediaCodecRendererCalled immediately before an input buffer is queued into the codec.The default implementation is a no-op.
- Overrides:
onQueueInputBufferin classMediaCodecRenderer- Parameters:
buffer- The buffer to be queued.
-
onProcessedStreamChange
protected void onProcessedStreamChange()
Deprecated.Description copied from class:MediaCodecRendererCalled after the last output buffer before a stream change has been processed.- Overrides:
onProcessedStreamChangein classMediaCodecRenderer
-
processOutputBuffer
protected boolean processOutputBuffer(long positionUs, long elapsedRealtimeUs, @Nullable MediaCodecAdapter codec, @Nullable ByteBuffer buffer, int bufferIndex, int bufferFlags, int sampleCount, long bufferPresentationTimeUs, boolean isDecodeOnlyBuffer, boolean isLastBuffer, Format format) throws ExoPlaybackExceptionDeprecated.Description copied from class:MediaCodecRendererProcesses an output media buffer.When a new
ByteBufferis passed to this method its position and limit delineate the data to be processed. The return value indicates whether the buffer was processed in full. If true is returned then the next call to this method will receive a new buffer to be processed. If false is returned then the same buffer will be passed to the next call. An implementation of this method is free to modify the buffer and can assume that the buffer will not be externally 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.Note that the first call to this method following a call to
MediaCodecRenderer.onPositionReset(long, boolean)will always receive a newByteBufferto be processed.- Specified by:
processOutputBufferin classMediaCodecRenderer- 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.codec- TheMediaCodecAdapterinstance, or null in bypass mode were no codec is used.buffer- The output buffer to process, or null if the buffer data is not made available to the application layer (seeMediaCodec.getOutputBuffer(int)). Thisbuffercan only be null for video data. Note that the buffer data can still be rendered in this case by using thebufferIndex.bufferIndex- The index of the output buffer.bufferFlags- The flags attached to the output buffer.sampleCount- The number of samples extracted from the sample queue in the buffer. This allows handling multiple samples as a batch for efficiency.bufferPresentationTimeUs- The presentation time of the output buffer in microseconds.isDecodeOnlyBuffer- Whether the buffer was marked withC.BUFFER_FLAG_DECODE_ONLYby the source.isLastBuffer- Whether the buffer is known to contain the last sample of the current stream. This flag is set on a best effort basis, and any logic relying on it should degrade gracefully to handle cases where it's not set.format- TheFormatassociated with the buffer.- Returns:
- Whether the output buffer was fully processed (for example, rendered or skipped).
- Throws:
ExoPlaybackException- If an error occurs processing the output buffer.
-
renderToEndOfStream
protected void renderToEndOfStream() throws ExoPlaybackExceptionDeprecated.Description copied from class:MediaCodecRendererIncrementally renders any remaining output.The default implementation is a no-op.
- Overrides:
renderToEndOfStreamin classMediaCodecRenderer- Throws:
ExoPlaybackException- Thrown if an error occurs rendering remaining output.
-
onOutputStreamOffsetUsChanged
protected void onOutputStreamOffsetUsChanged(long outputStreamOffsetUs)
Deprecated.Description copied from class:MediaCodecRendererCalled after the output stream offset changes.The default implementation is a no-op.
- Overrides:
onOutputStreamOffsetUsChangedin classMediaCodecRenderer- Parameters:
outputStreamOffsetUs- The output stream offset in microseconds.
-
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.
-
getCodecMaxInputSize
protected int getCodecMaxInputSize(MediaCodecInfo codecInfo, Format format, Format[] streamFormats)
Deprecated.Returns a maximum input size suitable for configuring a codec forformatin a way that will allow possible adaptation to other compatible formats instreamFormats.- Parameters:
codecInfo- AMediaCodecInfodescribing the decoder.format- TheFormatfor which the codec is being configured.streamFormats- The possible stream formats.- Returns:
- A suitable maximum input size.
-
getMediaFormat
protected MediaFormat getMediaFormat(Format format, String codecMimeType, int codecMaxInputSize, float codecOperatingRate)
Deprecated.Returns the frameworkMediaFormatthat can be used to configure aMediaCodecfor decoding the givenFormatfor playback.- Parameters:
format- TheFormatof the media.codecMimeType- The MIME type handled by the codec.codecMaxInputSize- The maximum input size supported by the codec.codecOperatingRate- The codec operating rate, orMediaCodecRenderer.CODEC_OPERATING_RATE_UNSETif no codec operating rate should be set.- Returns:
- The framework
MediaFormat.
-
-