public final class TuSdkMediaCodecImpl extends java.lang.Object implements TuSdkMediaCodec
限定符和类型 | 方法和说明 |
---|---|
boolean |
configure(android.media.MediaFormat format,
android.view.Surface surface,
int flags,
android.media.MediaDescrambler descrambler)
Configure a component to be used with a descrambler.
|
boolean |
configure(android.media.MediaFormat format,
android.view.Surface surface,
android.media.MediaCrypto crypto,
int flags)
Configures a component.
|
java.lang.Exception |
configureError()
配置错误信息
|
static TuSdkMediaCodec |
createByCodecName(java.lang.String name)
If you know the exact name of the component you want to instantiate
use this method to instantiate it.
|
static TuSdkMediaCodec |
createDecoderByType(java.lang.String type)
Instantiate the preferred decoder supporting input data of the given mime type.
|
static TuSdkMediaCodec |
createEncoderByType(java.lang.String type)
Instantiate the preferred encoder supporting output data of the given mime type.
|
android.view.Surface |
createInputSurface()
Requests a Surface to use as the input to an encoder, in place of input buffers.
|
static android.view.Surface |
createPersistentInputSurface()
Create a persistent input surface that can be used with codecs that normally have an input
surface, such as video encoders.
|
int |
dequeueInputBuffer(long timeoutUs)
Returns the index of an input buffer to be filled with valid data
or -1 if no such buffer is currently available.
|
int |
dequeueOutputBuffer(android.media.MediaCodec.BufferInfo info,
long timeoutUs)
Dequeue an output buffer, block at most "timeoutUs" microseconds.
|
boolean |
flush()
Flush both input and output ports of the component.
|
android.media.MediaCodecInfo |
getCodecInfo()
Get the codec info.
|
java.nio.ByteBuffer |
getInputBuffer(int index)
Returns a
cleared , writable ByteBuffer
object for a dequeued input buffer index to contain the input data. |
java.nio.ByteBuffer[] |
getInputBuffers()
已过时。
Use the new
getInputBuffer(int) method instead
each time an input buffer is dequeued.
Note: As of API 21, dequeued input buffers are
automatically Do not use this method if using an input surface. |
android.media.MediaFormat |
getInputFormat()
Call this after
configure(android.media.MediaFormat, android.view.Surface, android.media.MediaCrypto, int) returns successfully to
get the input format accepted by the codec. |
android.media.Image |
getInputImage(int index)
Returns a writable Image object for a dequeued input buffer
index to contain the raw input video frame.
|
android.os.PersistableBundle |
getMetrics()
Return Metrics data about the current codec instance.
|
java.lang.String |
getName()
Get the component name.
|
java.nio.ByteBuffer |
getOutputBuffer(int index)
Returns a read-only ByteBuffer for a dequeued output buffer
index.
|
java.nio.ByteBuffer[] |
getOutputBuffers()
已过时。
Use the new
getOutputBuffer(int) method instead
each time an output buffer is dequeued. This method is not
supported if codec is configured in asynchronous mode.
Note: As of API 21, the position and limit of output buffers that are dequeued will be set to the valid data range. Do not use this method if using an output surface. |
android.media.MediaFormat |
getOutputFormat()
Call this after dequeueOutputBuffer signals a format change by returning
|
android.media.MediaFormat |
getOutputFormat(int index)
Returns the output format for a specific output buffer.
|
android.media.Image |
getOutputImage(int index)
Returns a read-only Image object for a dequeued output buffer
index that contains the raw video frame.
|
boolean |
isReleased()
是否已释放编解码器
|
boolean |
isStarted()
是否已启动编解码器
|
boolean |
queueInputBuffer(int index,
int offset,
int size,
long presentationTimeUs,
int flags)
After filling a range of the input buffer at the specified index
submit it to the component.
|
boolean |
queueSecureInputBuffer(int index,
int offset,
android.media.MediaCodec.CryptoInfo info,
long presentationTimeUs,
int flags)
Similar to
queueInputBuffer but submits a buffer that is
potentially encrypted. |
boolean |
release()
Free up resources used by the codec instance.
|
boolean |
releaseOutputBuffer(int index,
boolean render)
If you are done with a buffer, use this call to return the buffer to the codec
or to render it on the output surface.
|
boolean |
releaseOutputBuffer(int index,
long renderTimestampNs)
If you are done with a buffer, use this call to update its surface timestamp
and return it to the codec to render it on the output surface.
|
boolean |
reset()
Returns the codec to its initial (Uninitialized) state.
|
boolean |
setCallback(android.media.MediaCodec.Callback cb)
Sets an asynchronous callback for actionable MediaCodec events on the default
looper.
|
boolean |
setCallback(android.media.MediaCodec.Callback cb,
android.os.Handler handler)
Sets an asynchronous callback for actionable MediaCodec events.
|
boolean |
setInputSurface(android.view.Surface surface)
Configures the codec (e.g. encoder) to use a persistent input surface in place of input
buffers.
|
boolean |
setOnFrameRenderedListener(android.media.MediaCodec.OnFrameRenderedListener listener,
android.os.Handler handler)
Registers a callback to be invoked when an output frame is rendered on the output surface.
|
boolean |
setOutputSurface(android.view.Surface surface)
Dynamically sets the output surface of a codec.
|
boolean |
setParameters(android.os.Bundle params)
Communicate additional parameter changes to the component instance.
|
boolean |
setVideoScalingMode(int mode)
If a surface has been specified in a previous call to
configure(android.media.MediaFormat, android.view.Surface, android.media.MediaCrypto, int)
specifies the scaling mode to use. |
boolean |
signalEndOfInputStream()
Signals end-of-stream on input.
|
boolean |
start()
After successfully configuring the component, call
start . |
boolean |
stop()
Finish the decode/encode session, note that the codec instance
remains active and ready to be
start() ed again. |
public static TuSdkMediaCodec createDecoderByType(java.lang.String type)
The following is a partial list of defined mime types and their semantics:
Note: It is preferred to use MediaCodecList.findDecoderForFormat(android.media.MediaFormat)
and createByCodecName(java.lang.String)
to ensure that the resulting codec can handle a
given format.
type
- The mime type of the input data.public static TuSdkMediaCodec createEncoderByType(java.lang.String type)
Note: It is preferred to use MediaCodecList.findEncoderForFormat(android.media.MediaFormat)
and createByCodecName(java.lang.String)
to ensure that the resulting codec can handle a
given format.
type
- The desired mime type of the output data.public static TuSdkMediaCodec createByCodecName(java.lang.String name)
MediaCodecList
name
- The name of the codec to be instantiated.public static android.view.Surface createPersistentInputSurface()
MediaCodec
or MediaRecorder instances, but can only be used by at
most one codec or recorder instance concurrently.
The application is responsible for calling release() on the Surface when done.
setInputSurface(android.view.Surface)
.public boolean isStarted()
isStarted
在接口中 TuSdkMediaCodec
public boolean isReleased()
isReleased
在接口中 TuSdkMediaCodec
public java.lang.Exception configureError()
configureError
在接口中 TuSdkMediaCodec
public final boolean reset()
Call this if an unrecoverable
error has occured to reset the codec to its initial state after creation.
reset
在接口中 TuSdkMediaCodec
MediaCodec.CodecException
- if an unrecoverable error has occured and the codec
could not be reset.java.lang.IllegalStateException
- if in the Released state.public final boolean release()
Make sure you call this when you're done to free up any opened component instance instead of relying on the garbage collector to do this for you at some point in the future.
release
在接口中 TuSdkMediaCodec
public boolean configure(android.media.MediaFormat format, android.view.Surface surface, android.media.MediaCrypto crypto, int flags)
configure
在接口中 TuSdkMediaCodec
format
- The format of the input data (decoder) or the desired
format of the output data (encoder). Passing null
as format
is equivalent to passing an
an empty mediaformat
.surface
- Specify a surface on which to render the output of this
decoder. Pass null
as surface
if the
codec does not generate raw video output (e.g. not a video
decoder) and/or if you want to configure the codec for
ByteBuffer
output.crypto
- Specify a crypto object to facilitate secure decryption
of the media data. Pass null
as crypto
for
non-secure codecs.flags
- Specify CONFIGURE_FLAG_ENCODE to configure the
component as an encoder.java.lang.IllegalArgumentException
- if the surface has been released (or is invalid),
or the format is unacceptable (e.g. missing a mandatory key),
or the flags are not set properly
(e.g. missing CONFIGURE_FLAG_ENCODE for an encoder).java.lang.IllegalStateException
- if not in the Uninitialized state.MediaCodec.CryptoException
- upon DRM error.MediaCodec.CodecException
- upon codec error.public boolean configure(android.media.MediaFormat format, android.view.Surface surface, int flags, android.media.MediaDescrambler descrambler)
configure
在接口中 TuSdkMediaCodec
format
- The format of the input data (decoder) or the desired
format of the output data (encoder). Passing null
as format
is equivalent to passing an
an empty mediaformat
.surface
- Specify a surface on which to render the output of this
decoder. Pass null
as surface
if the
codec does not generate raw video output (e.g. not a video
decoder) and/or if you want to configure the codec for
ByteBuffer
output.flags
- Specify CONFIGURE_FLAG_ENCODE to configure the
component as an encoder.descrambler
- Specify a descrambler object to facilitate secure
descrambling of the media data, or null for non-secure codecs.java.lang.IllegalArgumentException
- if the surface has been released (or is invalid),
or the format is unacceptable (e.g. missing a mandatory key),
or the flags are not set properly
(e.g. missing CONFIGURE_FLAG_ENCODE for an encoder).java.lang.IllegalStateException
- if not in the Uninitialized state.MediaCodec.CryptoException
- upon DRM error.MediaCodec.CodecException
- upon codec error.public boolean setOutputSurface(android.view.Surface surface)
This can only be used if the codec was configured with an output surface. The new output surface should have a compatible usage type to the original output surface. E.g. codecs may not support switching from a SurfaceTexture (GPU readable) output to ImageReader (software readable) output.
setOutputSurface
在接口中 TuSdkMediaCodec
surface
- the output surface to use. It must not be null
.java.lang.IllegalStateException
- if the codec does not support setting the output
surface in the current state.java.lang.IllegalArgumentException
- if the new surface is not of a suitable type for the codec.public boolean setInputSurface(android.view.Surface surface)
configure(android.media.MediaFormat, android.view.Surface, android.media.MediaCrypto, int)
and before start()
, in
lieu of createInputSurface()
.setInputSurface
在接口中 TuSdkMediaCodec
surface
- a persistent input surface created by createPersistentInputSurface()
java.lang.IllegalStateException
- if not in the Configured state or does not require an input
surface.java.lang.IllegalArgumentException
- if the surface was not created by
createPersistentInputSurface()
.public final android.view.Surface createInputSurface()
configure(android.media.MediaFormat, android.view.Surface, android.media.MediaCrypto, int)
and before start()
.
The application is responsible for calling release() on the Surface when done.
The Surface must be rendered with a hardware-accelerated API, such as OpenGL ES.
Surface.lockCanvas(android.graphics.Rect)
may fail or produce
unexpected results.
createInputSurface
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if not in the Configured state.public final boolean start()
start
.
Call start
also if the codec is configured in asynchronous mode,
and it has just been flushed, to resume requesting input buffers.
start
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if not in the Configured state
or just after flush()
for a codec that is configured
in asynchronous mode.MediaCodec.CodecException
- upon codec error. Note that some codec errors
for start may be attributed to future method calls.public final boolean stop()
start()
ed again.
To ensure that it is available to other client call release()
and don't just rely on garbage collection to eventually do this for you.stop
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if in the Released state.public final boolean flush()
Upon return, all indices previously returned in calls to dequeueInputBuffer
and dequeueOutputBuffer
— or obtained
via Callback#onInputBufferAvailable onInputBufferAvailable or
Callback#onOutputBufferAvailable onOutputBufferAvailable callbacks — become
invalid, and all buffers are owned by the codec.
If the codec is configured in asynchronous mode, call start()
after flush
has returned to resume codec operations. The codec
will not request input buffers until this has happened.
Note, however, that there may still be outstanding onOutputBufferAvailable
callbacks that were not handled prior to calling flush
.
The indices returned via these callbacks also become invalid upon calling flush
and
should be discarded.
If the codec is configured in synchronous mode, codec will resume
automatically if it is configured with an input surface. Otherwise, it
will resume when dequeueInputBuffer
is called.
flush
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if not in the Executing state.MediaCodec.CodecException
- upon codec error.public final boolean queueInputBuffer(int index, int offset, int size, long presentationTimeUs, int flags)
getInputBuffer(int)
in response to a dequeueInputBuffer(long)
return value or a Callback#onInputBufferAvailable
callback.
Many decoders require the actual compressed data stream to be
preceded by "codec specific data", i.e. setup data used to initialize
the codec such as PPS/SPS in the case of AVC video or code tables
in the case of vorbis audio.
The class MediaExtractor
provides codec
specific data as part of
the returned track format in entries named "csd-0", "csd-1" ...
These buffers can be submitted directly after start()
or
flush()
by specifying the flag BUFFER_FLAG_CODEC_CONFIG
. However, if you configure the
codec with a MediaFormat
containing these keys, they
will be automatically submitted by MediaCodec directly after
start. Therefore, the use of BUFFER_FLAG_CODEC_CONFIG
flag is discouraged and is
recommended only for advanced users.
To indicate that this is the final piece of input data (or rather that no more input data follows unless the decoder is subsequently flushed) specify the flag BUFFER_FLAG_END_OF_STREAM.
Note: Prior to Build.VERSION_CODES.M
,
presentationTimeUs
was not propagated to the frame timestamp of (rendered)
Surface output buffers, and the resulting frame timestamp was undefined.
Use releaseOutputBuffer(int, long)
to ensure a specific frame timestamp is set.
Similarly, since frame timestamps can be used by the destination surface for rendering
synchronization, care must be taken to normalize presentationTimeUs so as to not be
mistaken for a system time. (See SurfaceView specifics).
queueInputBuffer
在接口中 TuSdkMediaCodec
index
- The index of a client-owned input buffer previously returned
in a call to dequeueInputBuffer(long)
.offset
- The byte offset into the input buffer at which the data starts.size
- The number of bytes of valid input data.presentationTimeUs
- The presentation timestamp in microseconds for this
buffer. This is normally the media time at which this
buffer should be presented (rendered). When using an output
surface, this will be propagated as the SurfaceTexture#getTimestamp
timestamp for the frame (after
conversion to nanoseconds).flags
- A bitmask of flags
BUFFER_FLAG_CODEC_CONFIG and BUFFER_FLAG_END_OF_STREAM.
While not prohibited, most codecs do not use the
BUFFER_FLAG_KEY_FRAME flag for input buffers.java.lang.IllegalStateException
- if not in the Executing state.MediaCodec.CodecException
- upon codec error.public final boolean queueSecureInputBuffer(int index, int offset, android.media.MediaCodec.CryptoInfo info, long presentationTimeUs, int flags)
queueInputBuffer
but submits a buffer that is
potentially encrypted.
Check out further notes at queueInputBuffer
.queueSecureInputBuffer
在接口中 TuSdkMediaCodec
index
- The index of a client-owned input buffer previously returned
in a call to dequeueInputBuffer(long)
.offset
- The byte offset into the input buffer at which the data starts.info
- Metadata required to facilitate decryption, the object can be
reused immediately after this call returns.presentationTimeUs
- The presentation timestamp in microseconds for this
buffer. This is normally the media time at which this
buffer should be presented (rendered).flags
- A bitmask of flags
BUFFER_FLAG_CODEC_CONFIG and BUFFER_FLAG_END_OF_STREAM.
While not prohibited, most codecs do not use the
BUFFER_FLAG_KEY_FRAME flag for input buffers.public final int dequeueInputBuffer(long timeoutUs)
dequeueInputBuffer
在接口中 TuSdkMediaCodec
timeoutUs
- The timeout in microseconds, a negative timeout indicates "infinite".java.lang.IllegalStateException
- if not in the Executing state,
or codec is configured in asynchronous mode.MediaCodec.CodecException
- upon codec error.public final int dequeueOutputBuffer(android.media.MediaCodec.BufferInfo info, long timeoutUs)
dequeueOutputBuffer
在接口中 TuSdkMediaCodec
info
- Will be filled with buffer meta data.timeoutUs
- The timeout in microseconds, a negative timeout indicates "infinite".java.lang.IllegalStateException
- if not in the Executing state,
or codec is configured in asynchronous mode.MediaCodec.CodecException
- upon codec error.public final boolean releaseOutputBuffer(int index, boolean render)
render
to true
will first send the buffer
to that output surface. The surface will release the buffer back to the codec once
it is no longer used/displayed.
Once an output buffer is released to the codec, it MUST NOT
be used until it is later retrieved by getOutputBuffer(int)
in response
to a dequeueOutputBuffer(android.media.MediaCodec.BufferInfo, long)
return value or a
Callback#onOutputBufferAvailable callback.
releaseOutputBuffer
在接口中 TuSdkMediaCodec
index
- The index of a client-owned output buffer previously returned
from a call to dequeueOutputBuffer(android.media.MediaCodec.BufferInfo, long)
.render
- If a valid surface was specified when configuring the codec,
passing true renders this output buffer to the surface.java.lang.IllegalStateException
- if not in the Executing state.MediaCodec.CodecException
- upon codec error.public final boolean releaseOutputBuffer(int index, long renderTimestampNs)
The timestamp may have special meaning depending on the destination surface.
SurfaceView specifics |
---|
If you render your buffer on a SurfaceView ,
you can use the timestamp to render the buffer at a specific time (at the
VSYNC at or after the buffer timestamp). For this to work, the timestamp
needs to be reasonably close to the current System.nanoTime() .
Currently, this is set as within one (1) second. A few notes:
|
Once an output buffer is released to the codec, it MUST NOT
be used until it is later retrieved by getOutputBuffer(int)
in response
to a dequeueOutputBuffer(android.media.MediaCodec.BufferInfo, long)
return value or a
Callback#onOutputBufferAvailable callback.
releaseOutputBuffer
在接口中 TuSdkMediaCodec
index
- The index of a client-owned output buffer previously returned
from a call to dequeueOutputBuffer(android.media.MediaCodec.BufferInfo, long)
.renderTimestampNs
- The timestamp to associate with this buffer when
it is sent to the Surface.java.lang.IllegalStateException
- if not in the Executing state.MediaCodec.CodecException
- upon codec error.public final boolean signalEndOfInputStream()
signalEndOfInputStream
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if not in the Executing state.MediaCodec.CodecException
- upon codec error.public final android.media.MediaFormat getOutputFormat()
getOutputFormat
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if not in the Executing or
Configured state.MediaCodec.CodecException
- upon codec error.public final android.media.MediaFormat getInputFormat()
configure(android.media.MediaFormat, android.view.Surface, android.media.MediaCrypto, int)
returns successfully to
get the input format accepted by the codec. Do this to
determine what optional configuration parameters were
supported by the codec.getInputFormat
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if not in the Executing or
Configured state.MediaCodec.CodecException
- upon codec error.public final android.media.MediaFormat getOutputFormat(int index)
getOutputFormat
在接口中 TuSdkMediaCodec
index
- The index of a client-owned input buffer previously
returned from a call to dequeueInputBuffer(long)
.public java.nio.ByteBuffer[] getInputBuffers()
getInputBuffer(int)
method instead
each time an input buffer is dequeued.
Note: As of API 21, dequeued input buffers are
automatically cleared
.
Do not use this method if using an input surface.
getInputBuffers
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if not in the Executing state,
or codec is configured in asynchronous mode.MediaCodec.CodecException
- upon codec error.public java.nio.ByteBuffer[] getOutputBuffers()
getOutputBuffer(int)
method instead
each time an output buffer is dequeued. This method is not
supported if codec is configured in asynchronous mode.
Note: As of API 21, the position and limit of output buffers that are dequeued will be set to the valid data range.
Do not use this method if using an output surface.
getOutputBuffers
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if not in the Executing state,
or codec is configured in asynchronous mode.MediaCodec.CodecException
- upon codec error.public java.nio.ByteBuffer getInputBuffer(int index)
cleared
, writable ByteBuffer
object for a dequeued input buffer index to contain the input data.
After calling this method any ByteBuffer or Image object previously returned for the same input index MUST no longer be used.
getInputBuffer
在接口中 TuSdkMediaCodec
index
- The index of a client-owned input buffer previously
returned from a call to dequeueInputBuffer(long)
,
or received via an onInputBufferAvailable callback.java.lang.IllegalStateException
- if not in the Executing state.MediaCodec.CodecException
- upon codec error.public android.media.Image getInputImage(int index)
After calling this method any ByteBuffer or Image object previously returned for the same input index MUST no longer be used.
getInputImage
在接口中 TuSdkMediaCodec
index
- The index of a client-owned input buffer previously
returned from a call to dequeueInputBuffer(long)
,
or received via an onInputBufferAvailable callback.java.lang.IllegalStateException
- if not in the Executing state.MediaCodec.CodecException
- upon codec error.public java.nio.ByteBuffer getOutputBuffer(int index)
After calling this method, any ByteBuffer or Image object previously returned for the same output index MUST no longer be used.
getOutputBuffer
在接口中 TuSdkMediaCodec
index
- The index of a client-owned output buffer previously
returned from a call to dequeueOutputBuffer(android.media.MediaCodec.BufferInfo, long)
,
or received via an onOutputBufferAvailable callback.java.lang.IllegalStateException
- if not in the Executing state.MediaCodec.CodecException
- upon codec error.public android.media.Image getOutputImage(int index)
After calling this method, any ByteBuffer or Image object previously returned for the same output index MUST no longer be used.
getOutputImage
在接口中 TuSdkMediaCodec
index
- The index of a client-owned output buffer previously
returned from a call to dequeueOutputBuffer(android.media.MediaCodec.BufferInfo, long)
,
or received via an onOutputBufferAvailable callback.java.lang.IllegalStateException
- if not in the Executing state.MediaCodec.CodecException
- upon codec error.public final boolean setVideoScalingMode(int mode)
configure(android.media.MediaFormat, android.view.Surface, android.media.MediaCrypto, int)
specifies the scaling mode to use. The default is "scale to fit".
The scaling mode may be reset to the default each time an INFO_OUTPUT_BUFFERS_CHANGED event is received from the codec; therefore, the client must call this method after every buffer change event (and before the first output buffer is released for rendering) to ensure consistent scaling mode.
Since the INFO_OUTPUT_BUFFERS_CHANGED event is deprecated, this can also be done after each INFO_OUTPUT_FORMAT_CHANGED event.
setVideoScalingMode
在接口中 TuSdkMediaCodec
java.lang.IllegalArgumentException
- if mode is not recognized.java.lang.IllegalStateException
- if in the Released state.public final java.lang.String getName()
getName
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if in the Released state.public android.os.PersistableBundle getMetrics()
getMetrics
在接口中 TuSdkMediaCodec
Additional vendor-specific fields may also be present in the return value.
public final boolean setParameters(android.os.Bundle params)
setParameters
在接口中 TuSdkMediaCodec
params
- The bundle of parameters to set.java.lang.IllegalStateException
- if in the Released state.public boolean setCallback(android.media.MediaCodec.Callback cb, android.os.Handler handler)
If the client intends to use the component in asynchronous mode,
a valid callback should be provided before configure(android.media.MediaFormat, android.view.Surface, android.media.MediaCrypto, int)
is called.
When asynchronous callback is enabled, the client should not call
getInputBuffers()
, getOutputBuffers()
,
dequeueInputBuffer(long)
or dequeueOutputBuffer(BufferInfo, long).
Also, flush()
behaves differently in asynchronous mode. After calling
flush
, you must call start()
to "resume" receiving input buffers,
even if an input surface was created.
setCallback
在接口中 TuSdkMediaCodec
cb
- The callback that will run. Use null
to clear a previously
set callback (before configure
is called and run
in synchronous mode).handler
- Callbacks will happen on the handler's thread. If null
,
callbacks are done on the default thread (the caller's thread or the
main thread.)public boolean setCallback(android.media.MediaCodec.Callback cb)
Same as setCallback(Callback, Handler) with handler set to null.
setCallback
在接口中 TuSdkMediaCodec
cb
- The callback that will run. Use null
to clear a previously
set callback (before configure
is called and run
in synchronous mode).public boolean setOnFrameRenderedListener(android.media.MediaCodec.OnFrameRenderedListener listener, android.os.Handler handler)
This method can be called in any codec state, but will only have an effect in the Executing state for codecs that render buffers to the output surface.
Note: This callback is for informational purposes only: to get precise render timing samples, and can be significantly delayed and batched. Some frames may have been rendered even if there was no callback generated.
setOnFrameRenderedListener
在接口中 TuSdkMediaCodec
listener
- the callback that will be runhandler
- the callback will be run on the handler's thread. If null
,
the callback will be run on the default thread, which is the looper
from which the codec was created, or a new thread if there was none.public android.media.MediaCodecInfo getCodecInfo()
getCodecInfo
在接口中 TuSdkMediaCodec
java.lang.IllegalStateException
- if in the Released state.