Class MediaCodecVideoRenderer
- java.lang.Object
-
- com.google.android.exoplayer2.BaseRenderer
-
- com.google.android.exoplayer2.mediacodec.MediaCodecRenderer
-
- com.google.android.exoplayer2.video.MediaCodecVideoRenderer
-
- All Implemented Interfaces:
PlayerMessage.Target,Renderer,RendererCapabilities
@Deprecated public class MediaCodecVideoRenderer extends MediaCodecRenderer
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 video usingMediaCodec.This renderer accepts the following messages sent via
ExoPlayer.createMessage(Target)on the playback thread:- Message with type
Renderer.MSG_SET_VIDEO_OUTPUTto set the output. The message payload should be the targetSurface, or null to clear the output. Other non-null payloads have the effect of clearing the output. - Message with type
Renderer.MSG_SET_VIDEO_OUTPUT_RESOLUTIONto set the output resolution. The message payload should be the output resolution inSize. - Message with type
Renderer.MSG_SET_SCALING_MODEto set the video scaling mode. The message payload should be one of the integer scaling modes inC.VideoScalingMode. Note that the scaling mode only applies if theSurfacetargeted by this renderer is owned by aSurfaceView. - Message with type
Renderer.MSG_SET_CHANGE_FRAME_RATE_STRATEGYto set the strategy used to callSurface.setFrameRate(float, int, int). - Message with type
Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENERto set a listener for metadata associated with frames being rendered. The message payload should be theVideoFrameMetadataListener, or null.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classMediaCodecVideoRenderer.CodecMaxValuesDeprecated.-
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 MediaCodecVideoRenderer(Context context, MediaCodecAdapter.Factory codecAdapterFactory, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs, boolean enableDecoderFallback, Handler eventHandler, VideoRendererEventListener eventListener, int maxDroppedFramesToNotify)Deprecated.MediaCodecVideoRenderer(Context context, MediaCodecAdapter.Factory codecAdapterFactory, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs, boolean enableDecoderFallback, Handler eventHandler, VideoRendererEventListener eventListener, int maxDroppedFramesToNotify, float assumedMinimumCodecOperatingRate)Deprecated.Creates a new instance.MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector)Deprecated.MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs)Deprecated.MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs, boolean enableDecoderFallback, Handler eventHandler, VideoRendererEventListener eventListener, int maxDroppedFramesToNotify)Deprecated.MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs, Handler eventHandler, VideoRendererEventListener eventListener, int maxDroppedFramesToNotify)Deprecated.
-
Method Summary
All Methods Static 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.protected booleancodecNeedsSetOutputSurfaceWorkaround(String name)Deprecated.Returns whether the codec is known to implementMediaCodec.setOutputSurface(Surface)incorrectly.protected MediaCodecDecoderExceptioncreateDecoderException(Throwable cause, MediaCodecInfo codecInfo)Deprecated.protected voiddropOutputBuffer(MediaCodecAdapter codec, int index, long presentationTimeUs)Deprecated.Drops the output buffer with the specified index.protected Pair<ColorInfo,ColorInfo>experimentalGetVideoFrameProcessorColorConfiguration(ColorInfo inputColorInfo)Deprecated.static intgetCodecMaxInputSize(MediaCodecInfo codecInfo, Format format)Deprecated.Returns a maximum input size for a given codec and format.protected MediaCodecVideoRenderer.CodecMaxValuesgetCodecMaxValues(MediaCodecInfo codecInfo, Format format, Format[] streamFormats)Deprecated.ReturnsMediaCodecVideoRenderer.CodecMaxValuessuitable for configuring a codec forformatin a way that will allow possible adaptation to other compatible formats instreamFormats.protected booleangetCodecNeedsEosPropagation()Deprecated.Returns whether the codec needs the renderer to propagate the end-of-stream signal directly, rather than by using an end-of-stream buffer queued to the codec.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.protected static intgetMaxInputSize(MediaCodecInfo codecInfo, Format format)Deprecated.Returns a maximum input buffer size for a givenMediaCodecandFormat.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, MediaCodecVideoRenderer.CodecMaxValues codecMaxValues, float codecOperatingRate, boolean deviceNeedsNoPostProcessWorkaround, int tunnelingAudioSessionId)Deprecated.Returns the frameworkMediaFormatthat should be used to configure the decoder.StringgetName()Deprecated.Returns the name of this renderer, for logging and debugging purposes.protected SurfacegetSurface()Deprecated.Returns the output surface.protected voidhandleInputBufferSupplementalData(DecoderInputBuffer buffer)Deprecated.Handles supplemental data associated with an input buffer.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 booleanmaybeDropBuffersToKeyframe(long positionUs, boolean treatDroppedBuffersAsSkipped)Deprecated.Drops frames from the current output buffer to the next keyframe at or before the playback 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 voidonPositionReset(long positionUs, boolean joining)Deprecated.Called when the position is reset.protected voidonProcessedOutputBuffer(long presentationTimeUs)Deprecated.Called when an output buffer is successfully processed.protected voidonProcessedStreamChange()Deprecated.Called after the last output buffer before a stream change has been processed.protected voidonProcessedTunneledBuffer(long presentationTimeUs)Deprecated.Called when a buffer was processed in tunneling mode.protected voidonQueueInputBuffer(DecoderInputBuffer buffer)Deprecated.Called immediately before an input buffer is queued into the codec.protected voidonReadyToInitializeCodec(Format format)Deprecated.Called when ready to initialize theMediaCodecAdapter.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.voidrender(long positionUs, long elapsedRealtimeUs)Deprecated.Incrementally renders theSampleStream.protected voidrenderOutputBuffer(MediaCodecAdapter codec, int index, long presentationTimeUs)Deprecated.Renders the output buffer with the specified index.protected voidrenderOutputBufferV21(MediaCodecAdapter codec, int index, long presentationTimeUs, long releaseTimeNs)Deprecated.Renders the output buffer with the specified index.protected voidresetCodecStateForFlush()Deprecated.Resets the renderer internal state after a codec flush.protected voidsetOutputSurfaceV23(MediaCodecAdapter codec, Surface surface)Deprecated.voidsetPlaybackSpeed(float currentPlaybackSpeed, float targetPlaybackSpeed)Deprecated.Indicates the playback speed to this renderer.protected booleanshouldDropBuffersToKeyframe(long earlyUs, long elapsedRealtimeUs, boolean isLastBuffer)Deprecated.Returns whether to drop all buffers from the buffer being processed to the keyframe at or after the current playback position, if possible.protected booleanshouldDropOutputBuffer(long earlyUs, long elapsedRealtimeUs, boolean isLastBuffer)Deprecated.Returns whether the buffer being processed should be dropped.protected booleanshouldForceRenderOutputBuffer(long earlyUs, long elapsedSinceLastRenderUs)Deprecated.Returns whether to force rendering an output buffer.protected booleanshouldInitCodec(MediaCodecInfo codecInfo)Deprecated.protected voidskipOutputBuffer(MediaCodecAdapter codec, int index, long presentationTimeUs)Deprecated.Skips the output buffer with the specified index.protected @com.google.android.exoplayer2.RendererCapabilities.Capabilities intsupportsFormat(MediaCodecSelector mediaCodecSelector, Format format)Deprecated.Returns theRendererCapabilities.Capabilitiesfor the givenFormat.protected voidupdateDroppedBufferCounters(int droppedInputBufferCount, int droppedDecoderBufferCount)Deprecated.Updates local counters andMediaCodecRenderer.decoderCountersto reflect that buffers were dropped.protected voidupdateVideoFrameProcessingOffsetCounters(long processingOffsetUs)Deprecated.Updates local counters andDecoderCounterswith a new video frame processing offset.-
Methods inherited from class com.google.android.exoplayer2.mediacodec.MediaCodecRenderer
flushOrReinitializeCodec, flushOrReleaseCodec, getCodec, getCodecInfo, getCodecOperatingRate, getCodecOutputMediaFormat, getOutputStreamOffsetUs, getPlaybackSpeed, isBypassPossible, maybeInitCodecOrBypass, onOutputStreamOffsetUsChanged, onStreamChanged, releaseCodec, renderToEndOfStream, resetCodecStateForRelease, setPendingOutputEndOfStream, setPendingPlaybackException, setRenderTimeLimitMs, shouldReinitCodec, shouldUseBypass, supportsFormat, supportsFormatDrm, supportsMixedMimeTypeAdaptation, updateCodecOperatingRate, updateOutputFormatForTime
-
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, hasReadStreamToEnd, init, isCurrentStreamFinal, isSourceReady, maybeThrowStreamError, onRelease, onRendererCapabilitiesChanged, readSource, release, replaceStream, reset, resetPosition, setCurrentStreamFinal, setListener, skipSource, start, stop
-
-
-
-
Constructor Detail
-
MediaCodecVideoRenderer
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector)
Deprecated.- Parameters:
context- A context.mediaCodecSelector- A decoder selector.
-
MediaCodecVideoRenderer
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs)
Deprecated.- Parameters:
context- A context.mediaCodecSelector- A decoder selector.allowedJoiningTimeMs- The maximum duration in milliseconds for which this video renderer can attempt to seamlessly join an ongoing playback.
-
MediaCodecVideoRenderer
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs, @Nullable Handler eventHandler, @Nullable VideoRendererEventListener eventListener, int maxDroppedFramesToNotify)
Deprecated.- Parameters:
context- A context.mediaCodecSelector- A decoder selector.allowedJoiningTimeMs- The maximum duration in milliseconds for which this video renderer can attempt to seamlessly join an ongoing playback.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.maxDroppedFramesToNotify- The maximum number of frames that can be dropped between invocations ofVideoRendererEventListener.onDroppedFrames(int, long).
-
MediaCodecVideoRenderer
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs, boolean enableDecoderFallback, @Nullable Handler eventHandler, @Nullable VideoRendererEventListener eventListener, int maxDroppedFramesToNotify)
Deprecated.- Parameters:
context- A context.mediaCodecSelector- A decoder selector.allowedJoiningTimeMs- The maximum duration in milliseconds for which this video renderer can attempt to seamlessly join an ongoing playback.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.maxDroppedFramesToNotify- The maximum number of frames that can be dropped between invocations ofVideoRendererEventListener.onDroppedFrames(int, long).
-
MediaCodecVideoRenderer
public MediaCodecVideoRenderer(Context context, MediaCodecAdapter.Factory codecAdapterFactory, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs, boolean enableDecoderFallback, @Nullable Handler eventHandler, @Nullable VideoRendererEventListener eventListener, int maxDroppedFramesToNotify)
Deprecated.- Parameters:
context- A context.codecAdapterFactory- TheMediaCodecAdapter.Factoryused to createMediaCodecAdapterinstances.mediaCodecSelector- A decoder selector.allowedJoiningTimeMs- The maximum duration in milliseconds for which this video renderer can attempt to seamlessly join an ongoing playback.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.maxDroppedFramesToNotify- The maximum number of frames that can be dropped between invocations ofVideoRendererEventListener.onDroppedFrames(int, long).
-
MediaCodecVideoRenderer
public MediaCodecVideoRenderer(Context context, MediaCodecAdapter.Factory codecAdapterFactory, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs, boolean enableDecoderFallback, @Nullable Handler eventHandler, @Nullable VideoRendererEventListener eventListener, int maxDroppedFramesToNotify, float assumedMinimumCodecOperatingRate)
Deprecated.Creates a new instance.- Parameters:
context- A context.codecAdapterFactory- TheMediaCodecAdapter.Factoryused to createMediaCodecAdapterinstances.mediaCodecSelector- A decoder selector.allowedJoiningTimeMs- The maximum duration in milliseconds for which this video renderer can attempt to seamlessly join an ongoing playback.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.maxDroppedFramesToNotify- The maximum number of frames that can be dropped between invocations ofVideoRendererEventListener.onDroppedFrames(int, long).assumedMinimumCodecOperatingRate- A codec operating rate that all codecs instantiated by this renderer are assumed to meet implicitly (i.e. without the operating rate being set explicitly usingMediaFormat.KEY_OPERATING_RATE).
-
-
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.- Returns:
- The name of this renderer.
-
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.
-
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.
-
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.
-
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
-
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.
-
shouldInitCodec
protected boolean shouldInitCodec(MediaCodecInfo codecInfo)
Deprecated.- Overrides:
shouldInitCodecin classMediaCodecRenderer
-
getCodecNeedsEosPropagation
protected boolean getCodecNeedsEosPropagation()
Deprecated.Description copied from class:MediaCodecRendererReturns whether the codec needs the renderer to propagate the end-of-stream signal directly, rather than by using an end-of-stream buffer queued to the codec.- Overrides:
getCodecNeedsEosPropagationin classMediaCodecRenderer
-
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.
-
render
@CallSuper 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- Overrides:
renderin 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.- Throws:
ExoPlaybackException- If an error occurs.
-
resetCodecStateForFlush
@CallSuper protected void resetCodecStateForFlush()
Deprecated.Description copied from class:MediaCodecRendererResets the renderer internal state after a codec flush.- Overrides:
resetCodecStateForFlushin classMediaCodecRenderer
-
setPlaybackSpeed
public void setPlaybackSpeed(float currentPlaybackSpeed, float targetPlaybackSpeed) throws ExoPlaybackExceptionDeprecated.Description copied from interface:RendererIndicates the playback speed to this renderer.The default implementation is a no-op.
- Specified by:
setPlaybackSpeedin interfaceRenderer- Overrides:
setPlaybackSpeedin classMediaCodecRenderer- Parameters:
currentPlaybackSpeed- The factor by which playback is currently sped up.targetPlaybackSpeed- The target factor by which playback should be sped up. This may be different fromcurrentPlaybackSpeed, for example, if the speed is temporarily adjusted for live playback.- Throws:
ExoPlaybackException- If an error occurs handling the playback speed.
-
getCodecMaxInputSize
public static int getCodecMaxInputSize(MediaCodecInfo codecInfo, Format format)
Deprecated.Returns a maximum input size for a given codec and format.- Parameters:
codecInfo- Information about theMediaCodecbeing configured.format- The format.- Returns:
- A maximum input size in bytes, or
Format.NO_VALUEif a maximum could not be determined.
-
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.
-
onReadyToInitializeCodec
@CallSuper protected void onReadyToInitializeCodec(Format format) throws ExoPlaybackException
Deprecated.Description copied from class:MediaCodecRendererCalled when ready to initialize theMediaCodecAdapter.This method is called just before the renderer obtains the configuration for the
MediaCodecAdapterand creates the adapter via the passed inMediaCodecAdapter.Factory.The default implementation is a no-op.
- Overrides:
onReadyToInitializeCodecin classMediaCodecRenderer- Parameters:
format- TheFormatfor which the codec is being configured.- Throws:
ExoPlaybackException- If an error occurs preparing for initializing the codec.
-
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.
-
onQueueInputBuffer
@CallSuper protected void onQueueInputBuffer(DecoderInputBuffer buffer) throws ExoPlaybackException
Deprecated.Called immediately before an input buffer is queued into the codec.In tunneling mode for pre Marshmallow, the buffer is treated as if immediately output.
- Overrides:
onQueueInputBufferin classMediaCodecRenderer- Parameters:
buffer- The buffer to be queued.- Throws:
ExoPlaybackException- Thrown if an error occurs handling the input buffer.
-
onOutputFormatChanged
protected void onOutputFormatChanged(Format format, @Nullable MediaFormat mediaFormat)
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.
-
handleInputBufferSupplementalData
protected void handleInputBufferSupplementalData(DecoderInputBuffer buffer) throws ExoPlaybackException
Deprecated.Description copied from class:MediaCodecRendererHandles supplemental data associated with an input buffer.The default implementation is a no-op.
- Overrides:
handleInputBufferSupplementalDatain classMediaCodecRenderer- Parameters:
buffer- The input buffer that is about to be queued.- Throws:
ExoPlaybackException- Thrown if an error occurs handling supplemental data.
-
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.
-
onProcessedTunneledBuffer
protected void onProcessedTunneledBuffer(long presentationTimeUs) throws ExoPlaybackExceptionDeprecated.Called when a buffer was processed in tunneling mode.- Throws:
ExoPlaybackException
-
onProcessedOutputBuffer
@CallSuper protected void onProcessedOutputBuffer(long presentationTimeUs)
Deprecated.Description copied from class:MediaCodecRendererCalled when an output buffer is successfully processed.- Overrides:
onProcessedOutputBufferin classMediaCodecRenderer- Parameters:
presentationTimeUs- The timestamp associated with the output buffer.
-
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
-
shouldDropOutputBuffer
protected boolean shouldDropOutputBuffer(long earlyUs, long elapsedRealtimeUs, boolean isLastBuffer)Deprecated.Returns whether the buffer being processed should be dropped.- Parameters:
earlyUs- The time until the buffer should be presented in microseconds. A negative value indicates that the buffer is late.elapsedRealtimeUs-SystemClock.elapsedRealtime()in microseconds, measured at the start of the current iteration of the rendering loop.isLastBuffer- Whether the buffer is the last buffer in the current stream.
-
shouldDropBuffersToKeyframe
protected boolean shouldDropBuffersToKeyframe(long earlyUs, long elapsedRealtimeUs, boolean isLastBuffer)Deprecated.Returns whether to drop all buffers from the buffer being processed to the keyframe at or after the current playback position, if possible.- Parameters:
earlyUs- The time until the current buffer should be presented in microseconds. A negative value indicates that the buffer is late.elapsedRealtimeUs-SystemClock.elapsedRealtime()in microseconds, measured at the start of the current iteration of the rendering loop.isLastBuffer- Whether the buffer is the last buffer in the current stream.
-
shouldForceRenderOutputBuffer
protected boolean shouldForceRenderOutputBuffer(long earlyUs, long elapsedSinceLastRenderUs)Deprecated.Returns whether to force rendering an output buffer.- Parameters:
earlyUs- The time until the current buffer should be presented in microseconds. A negative value indicates that the buffer is late.elapsedSinceLastRenderUs- The elapsed time since the last output buffer was rendered, in microseconds.- Returns:
- Returns whether to force rendering an output buffer.
-
skipOutputBuffer
protected void skipOutputBuffer(MediaCodecAdapter codec, int index, long presentationTimeUs)
Deprecated.Skips the output buffer with the specified index.- Parameters:
codec- The codec that owns the output buffer.index- The index of the output buffer to skip.presentationTimeUs- The presentation time of the output buffer, in microseconds.
-
dropOutputBuffer
protected void dropOutputBuffer(MediaCodecAdapter codec, int index, long presentationTimeUs)
Deprecated.Drops the output buffer with the specified index.- Parameters:
codec- The codec that owns the output buffer.index- The index of the output buffer to drop.presentationTimeUs- The presentation time of the output buffer, in microseconds.
-
maybeDropBuffersToKeyframe
protected boolean maybeDropBuffersToKeyframe(long positionUs, boolean treatDroppedBuffersAsSkipped) throws ExoPlaybackExceptionDeprecated.Drops frames from the current output buffer to the next keyframe at or before the playback position. If no such keyframe exists, as the playback position is inside the same group of pictures as the buffer being processed, returnsfalse. Returnstrueotherwise.- Parameters:
positionUs- The current playback position, in microseconds.treatDroppedBuffersAsSkipped- Whether dropped buffers should be treated as intentionally skipped.- Returns:
- Whether any buffers were dropped.
- Throws:
ExoPlaybackException- If an error occurs flushing the codec.
-
updateDroppedBufferCounters
protected void updateDroppedBufferCounters(int droppedInputBufferCount, int droppedDecoderBufferCount)Deprecated.Updates local counters andMediaCodecRenderer.decoderCountersto reflect that buffers were dropped.- Parameters:
droppedInputBufferCount- The number of buffers dropped from the source before being passed to the decoder.droppedDecoderBufferCount- The number of buffers dropped after being passed to the decoder.
-
updateVideoFrameProcessingOffsetCounters
protected void updateVideoFrameProcessingOffsetCounters(long processingOffsetUs)
Deprecated.Updates local counters andDecoderCounterswith a new video frame processing offset.- Parameters:
processingOffsetUs- The video frame processing offset.
-
experimentalGetVideoFrameProcessorColorConfiguration
protected Pair<ColorInfo,ColorInfo> experimentalGetVideoFrameProcessorColorConfiguration(@Nullable ColorInfo inputColorInfo)
Deprecated.
-
renderOutputBuffer
protected void renderOutputBuffer(MediaCodecAdapter codec, int index, long presentationTimeUs)
Deprecated.Renders the output buffer with the specified index. This method is only called if the platform API version of the device is less than 21.When video frame processing is MediaCodecVideoRenderer.VideoFrameProcessorManager.isEnabled() enabled}, this method renders to
MediaCodecVideoRenderer.VideoFrameProcessorManager's input surface.- Parameters:
codec- The codec that owns the output buffer.index- The index of the output buffer to drop.presentationTimeUs- The presentation time of the output buffer, in microseconds.
-
renderOutputBufferV21
@RequiresApi(21) protected void renderOutputBufferV21(MediaCodecAdapter codec, int index, long presentationTimeUs, long releaseTimeNs)
Deprecated.Renders the output buffer with the specified index. This method is only called if the platform API version of the device is 21 or later.When video frame processing is MediaCodecVideoRenderer.VideoFrameProcessorManager.isEnabled() enabled}, this method renders to
MediaCodecVideoRenderer.VideoFrameProcessorManager's input surface.- Parameters:
codec- The codec that owns the output buffer.index- The index of the output buffer to drop.presentationTimeUs- The presentation time of the output buffer, in microseconds.releaseTimeNs- The wallclock time at which the frame should be displayed, in nanoseconds.
-
setOutputSurfaceV23
@RequiresApi(23) protected void setOutputSurfaceV23(MediaCodecAdapter codec, Surface surface)
Deprecated.
-
getMediaFormat
protected MediaFormat getMediaFormat(Format format, String codecMimeType, MediaCodecVideoRenderer.CodecMaxValues codecMaxValues, float codecOperatingRate, boolean deviceNeedsNoPostProcessWorkaround, int tunnelingAudioSessionId)
Deprecated.Returns the frameworkMediaFormatthat should be used to configure the decoder.- Parameters:
format- TheFormatof media.codecMimeType- The MIME type handled by the codec.codecMaxValues- Codec max values that should be used when configuring the decoder.codecOperatingRate- The codec operating rate, orMediaCodecRenderer.CODEC_OPERATING_RATE_UNSETif no codec operating rate should be set.deviceNeedsNoPostProcessWorkaround- Whether the device is known to do post processing by default that isn't compatible with ExoPlayer.tunnelingAudioSessionId- The audio session id to use for tunneling, orC.AUDIO_SESSION_ID_UNSETif tunneling should not be enabled.- Returns:
- The framework
MediaFormatthat should be used to configure the decoder.
-
getCodecMaxValues
protected MediaCodecVideoRenderer.CodecMaxValues getCodecMaxValues(MediaCodecInfo codecInfo, Format format, Format[] streamFormats)
Deprecated.ReturnsMediaCodecVideoRenderer.CodecMaxValuessuitable for configuring a codec forformatin a way that will allow possible adaptation to other compatible formats instreamFormats.- Parameters:
codecInfo- Information about theMediaCodecbeing configured.format- TheFormatfor which the codec is being configured.streamFormats- The possible stream formats.- Returns:
- Suitable
MediaCodecVideoRenderer.CodecMaxValues.
-
createDecoderException
protected MediaCodecDecoderException createDecoderException(Throwable cause, @Nullable MediaCodecInfo codecInfo)
Deprecated.- Overrides:
createDecoderExceptionin classMediaCodecRenderer
-
getMaxInputSize
protected static int getMaxInputSize(MediaCodecInfo codecInfo, Format format)
Deprecated.Returns a maximum input buffer size for a givenMediaCodecandFormat.- Parameters:
codecInfo- Information about theMediaCodecbeing configured.format- The format.- Returns:
- A maximum input buffer size in bytes, or
Format.NO_VALUEif a maximum could not be determined.
-
codecNeedsSetOutputSurfaceWorkaround
protected boolean codecNeedsSetOutputSurfaceWorkaround(String name)
Deprecated.Returns whether the codec is known to implementMediaCodec.setOutputSurface(Surface)incorrectly.If true is returned then we fall back to releasing and re-instantiating the codec instead.
- Parameters:
name- The name of the codec.- Returns:
- True if the device is known to implement
MediaCodec.setOutputSurface(Surface)incorrectly.
-
getSurface
@Nullable protected Surface getSurface()
Deprecated.Returns the output surface.
-
-