Class VideoDecoder
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
VideoDecoder.VideoDecoderImpl
The GstVideoDecoder base class and derived subclasses should cooperate as follows:
Configuration
- Initially, GstVideoDecoder calls
start
when the decoder element is activated, which allows the subclass to perform any global setup.
- GstVideoDecoder calls
setFormat
to inform the subclass of caps describing input video data that it is about to receive, including possibly configuration data. While unlikely, it might be called more than once, if changing input parameters require reconfiguration.
- Incoming data buffers are processed as needed, described in Data Processing below.
- GstVideoDecoder calls
stop
at end of all processing.
Data processing
- The base class gathers input data, and optionally allows subclass to parse this into subsequently manageable chunks, typically corresponding to and referred to as 'frames'.
- Each input frame is provided in turn to the subclass'
handleFrame
callback. - When the subclass enables the subframe mode with
gst_video_decoder_set_subframe_mode
, the base class will provide to the subclass the same input frame with different input buffers to the subclasshandleFrame
callback. During this call, the subclass needs to take ownership of the input_buffer asGstVideoCodecFrame
.input_buffer will have been changed before the next subframe buffer is received. The subclass will callgst_video_decoder_have_last_subframe
when a new input frame can be created by the base class. Every subframe will share the sameGstVideoCodecFrame
.output_buffer to write the decoding result. The subclass is responsible to protect its access.
- If codec processing results in decoded data, the subclass should call
gstVideoDecoderFinishFrame
to have decoded data pushed downstream. In subframe mode the subclass should callgstVideoDecoderFinishSubframe
until the last subframe where it should callgstVideoDecoderFinishFrame
. The subclass can detect the last subframe using GST_VIDEO_BUFFER_FLAG_MARKER on buffers or using its own logic to collect the subframes. In case of decoding failure, the subclass must callgstVideoDecoderDropFrame
orgstVideoDecoderDropSubframe
, to allow the base class to do timestamp and offset tracking, and possibly to requeue the frame for a later attempt in the case of reverse playback.
Shutdown phase
- The GstVideoDecoder class calls
stop
to inform the subclass that data parsing will be stopped.
Additional Notes
- Seeking/Flushing
- When the pipeline is seeked or otherwise flushed, the subclass is
informed via a call to its
reset
callback, with the hard parameter set to true. This indicates the subclass should drop any internal data queues and timestamps and prepare for a fresh set of buffers to arrive for parsing and decoding.
- End Of Stream
- At end-of-stream, the subclass
parse
function may be called some final times with the at_eos parameter set to true, indicating that the element should not expect any more data to be arriving, and it should parse and remaining frames and call gst_video_decoder_have_frame() if possible.
The subclass is responsible for providing pad template caps for
source and sink pads. The pads need to be named "sink" and "src". It also
needs to provide information about the output caps, when they are known.
This may be when the base class calls the subclass' setFormat
function,
though it might be during decoding, before calling
gstVideoDecoderFinishFrame
. This is done via
gstVideoDecoderSetOutputState
The subclass is also responsible for providing (presentation) timestamps (likely based on corresponding input ones). If that is not applicable or possible, the base class provides limited framerate based interpolation.
Similarly, the base class provides some limited (legacy) seeking support
if specifically requested by the subclass, as full-fledged support
should rather be left to upstream demuxer, parser or alike. This simple
approach caters for seeking and duration reporting using estimated input
bitrates. To enable it, a subclass should call
gstVideoDecoderSetEstimateRate
to enable handling of incoming
byte-streams.
The base class provides some support for reverse playback, in particular in case incoming data is not packetized or upstream does not provide fragments on keyframe boundaries. However, the subclass should then be prepared for the parsing and frame processing stage to occur separately (in normal forward processing, the latter immediately follows the former), The subclass also needs to ensure the parsing stage properly marks keyframes, unless it knows the upstream elements will do so properly for incoming data.
The bare minimum that a functional subclass needs to implement is:
- Provide pad templates
- Inform the base class of output caps via
gstVideoDecoderSetOutputState
- Parse input data, if it is not considered packetized from upstream
Data will be provided to
parse
which should invokegstVideoDecoderAddToFrame
andgstVideoDecoderHaveFrame
to separate the data belonging to each video frame.
- Accept data in
handleFrame
and provide decoded results togstVideoDecoderFinishFrame
, or callgstVideoDecoderDropFrame
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
VideoDecoder.Builder<B extends VideoDecoder.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Subclasses can override any of the available virtual methods or not, as needed.static class
The VideoDecoderImpl type represents a native instance of the abstract VideoDecoder class.Nested classes/interfaces inherited from class org.freedesktop.gstreamer.gst.Element
Element.ElementClass, Element.ElementImpl, Element.NoMorePadsCallback, Element.PadAddedCallback, Element.PadRemovedCallback
Nested classes/interfaces inherited from class org.freedesktop.gstreamer.gst.GstObject
GstObject.DeepNotifyCallback, GstObject.ObjectClass, GstObject.ObjectImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback
-
Constructor Summary
ConstructorDescriptionVideoDecoder
(MemorySegment address) Create a VideoDecoder proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToFrame
(int nBytes) Removes nextnBytes
of input data and adds it to currently parsed frame.Helper function that allocates a buffer to hold a video frame for this VideoDecoder's currentGstVideoCodecState
.Helper function that allocates a buffer to hold a video frame for this VideoDecoder's currentGstVideoCodecState
.allocateOutputFrameWithParams
(VideoCodecFrame frame, BufferPoolAcquireParams params) Same asgst_video_decoder_allocate_output_frame
except it allows passingGstBufferPoolAcquireParams
to the sub call gst_buffer_pool_acquire_buffer.protected VideoDecoder
asParent()
Returns this instance as if it were its parent type.static VideoDecoder.Builder
<? extends VideoDecoder.Builder> builder()
AVideoDecoder.Builder
object constructs aVideoDecoder
with the specified properties.protected boolean
close()
Optional.protected boolean
decideAllocation
(Query query) Optional.protected FlowReturn
drain()
Optional.dropFrame
(VideoCodecFrame frame) Similar to gst_video_decoder_finish_frame(), but dropsframe
in any case and posts a QoS message with the frame's details on the bus.dropSubframe
(VideoCodecFrame frame) Drops input data.protected FlowReturn
finish()
Optional.finishFrame
(VideoCodecFrame frame) frame
should have a valid decoded data buffer, whose metadata fields are then appropriately set according to frame data and pushed downstream.finishSubframe
(VideoCodecFrame frame) Indicate that a subframe has been finished to be decoded by the subclass.protected boolean
flush()
Optional.void
getAllocator
(@Nullable Out<Allocator> allocator, @Nullable AllocationParams params) LetsGstVideoDecoder
sub-classes to know the memoryallocator
used by the base class and itsparams
.protected Caps
Optional.int
getFrame
(int frameNumber) Get a pending unfinishedGstVideoCodecFrame
Get all pending unfinishedGstVideoCodecFrame
int
Queries the number of the last subframe received by the decoder baseclass in theframe
.void
getLatency
(@Nullable ClockTime minLatency, @Nullable ClockTime maxLatency) Query the configured decoder latency.getMaxDecodeTime
(VideoCodecFrame frame) Determines maximum possible decoding time forframe
that will allow it to decode and arrive in time (as determined by QoS events).int
static MemoryLayout
The memory layout of the native struct.boolean
Queries decoder required format handling.boolean
Queries if the decoder requires a sync point before it starts outputting data in the beginning.Get the oldest pending unfinishedGstVideoCodecFrame
Get theGstVideoCodecState
currently describing the output stream.boolean
Queries whether input data is considered packetized or not by the base class.long
Returns the number of bytes previously added to the current frame by calling gst_video_decoder_add_to_frame().int
Queries the number of subframes in the frame processed by the decoder baseclass.double
boolean
Queries whether input data is considered as subframes or not by the base class.static Type
getType()
Get the GType of the VideoDecoder classprotected FlowReturn
handleFrame
(VideoCodecFrame frame) protected boolean
handleMissingData
(ClockTime timestamp, ClockTime duration) Gathers all data collected for currently parsed frame, gathers corresponding metadata and passes it along for further processing, i.e.haveLastSubframe
(VideoCodecFrame frame) Indicates that the last subframe has been processed by the decoder inframe
.void
mergeTags
(@Nullable TagList tags, TagMergeMode mode) Sets the audio decoder tags and how they should be merged with any upstream stream tags.boolean
Negotiate with downstream elements to currently configuredGstVideoCodecState
.protected boolean
open()
Optional.protected FlowReturn
parse
(VideoCodecFrame frame, Adapter adapter, boolean atEos) Required for non-packetized input.protected boolean
proposeAllocation
(Query query) Optional.proxyGetcaps
(@Nullable Caps caps, @Nullable Caps filter) Returns caps that expresscaps
(or sink template caps ifcaps
== NULL) restricted to resolution/format/...void
releaseFrame
(VideoCodecFrame frame) Similar to gst_video_decoder_drop_frame(), but simply releasesframe
without any processing other than removing it from list of pending frames, after which it is considered finished and released.void
requestSyncPoint
(VideoCodecFrame frame, Set<VideoDecoderRequestSyncPointFlags> flags) Allows theGstVideoDecoder
subclass to request from the base class that a new sync should be requested from upstream, and thatframe
was the frame when the subclass noticed that a new sync point is required.void
requestSyncPoint
(VideoCodecFrame frame, VideoDecoderRequestSyncPointFlags... flags) Allows theGstVideoDecoder
subclass to request from the base class that a new sync should be requested from upstream, and thatframe
was the frame when the subclass noticed that a new sync point is required.protected boolean
reset
(boolean hard) Optional.void
setEstimateRate
(boolean enabled) Allows baseclass to perform byte to time estimated conversion.protected boolean
setFormat
(VideoCodecState state) Notifies subclass of incoming data format (caps).setInterlacedOutputState
(VideoFormat fmt, VideoInterlaceMode interlaceMode, int width, int height, @Nullable VideoCodecState reference) Same asgst_video_decoder_set_output_state
() but also allows you to also set the interlacing mode.void
setLatency
(ClockTime minLatency, ClockTime maxLatency) LetsGstVideoDecoder
sub-classes tell the baseclass what the decoder latency is.void
setMaxErrors
(int num) Sets numbers of tolerated decoder errors, where a tolerated one is then only warned about, but more than tolerated will lead to fatal error.void
setNeedsFormat
(boolean enabled) Configures decoder format needs.void
setNeedsSyncPoint
(boolean enabled) Configures whether the decoder requires a sync point before it starts outputting data in the beginning.setOutputState
(VideoFormat fmt, int width, int height, @Nullable VideoCodecState reference) Creates a newGstVideoCodecState
with the specifiedfmt
,width
andheight
as the output state for the decoder.void
setPacketized
(boolean packetized) Allows baseclass to consider input data as packetized or not.void
setSubframeMode
(boolean subframeMode) If this is set to TRUE, it informs the base class that the subclass can receive the data at a granularity lower than one frame.void
setUseDefaultPadAcceptcaps
(boolean use) LetsGstVideoDecoder
sub-classes decide if they want the sink pad to use the default pad query handler to reply to accept-caps queries.protected boolean
Optional.protected boolean
Optional.protected boolean
Optional.protected boolean
Optional.protected boolean
start()
Optional.protected boolean
stop()
Optional.protected boolean
transformMeta
(VideoCodecFrame frame, Meta meta) Optional.Methods inherited from class org.freedesktop.gstreamer.gst.Element
abortState, addPad, addPropertyDeepNotifyWatch, addPropertyNotifyWatch, callAsync, changeState, continueState, createAllPads, decorateStreamId, decorateStreamIdPrintf, emitNoMorePads, emitPadAdded, emitPadRemoved, foreachPad, foreachSinkPad, foreachSrcPad, getBaseTime, getBus, getClock, getCompatiblePad, getCompatiblePadTemplate, getContext, getContexts, getContextUnlocked, getCurrentClockTime, getCurrentRunningTime, getFactory, getMetadata, getPadTemplate, getPadTemplateList, getRequestPad, getStartTime, getState, getStaticPad, isLockedState, iteratePads, iterateSinkPads, iterateSrcPads, link, linkFiltered, linkMany, linkPads, linkPadsFiltered, linkPadsFull, linkPadsFull, lostState, makeFromUri, messageFull, messageFull, messageFullWithDetails, messageFullWithDetails, noMorePads, onNoMorePads, onPadAdded, onPadRemoved, padAdded, padRemoved, postMessage, provideClock, query, queryConvert, queryDuration, queryPosition, register, releasePad, releaseRequestPad, removePad, removePropertyNotifyWatch, requestPad, requestPadSimple, seek, seek, seekSimple, seekSimple, sendEvent, setBaseTime, setBus, setClock, setContext, setLockedState, setStartTime, setState, stateChanged, stateChangeReturnGetName, stateGetName, syncStateWithParent, typeSetSkipDocumentation, unlink, unlinkMany, unlinkPads
Methods inherited from class org.freedesktop.gstreamer.gst.GstObject
addControlBinding, checkUniqueness, deepNotify, defaultDeepNotify, defaultError, emitDeepNotify, getControlBinding, getControlRate, getGValueArray, getName, getParent, getPathString, getValue, getValueArray, hasActiveControlBindings, hasAncestor, hasAsAncestor, hasAsParent, onDeepNotify, ref, refSink, removeControlBinding, replace, setControlBindingDisabled, setControlBindingsDisabled, setControlRate, setName, setParent, suggestNextSync, syncValues, unparent, unref
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
VideoDecoder
Create a VideoDecoder proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
addToFrame
public void addToFrame(int nBytes) Removes nextnBytes
of input data and adds it to currently parsed frame.- Parameters:
nBytes
- the number of bytes to add
-
allocateOutputBuffer
Helper function that allocates a buffer to hold a video frame for this VideoDecoder's currentGstVideoCodecState
.You should use gst_video_decoder_allocate_output_frame() instead of this function, if possible at all.
- Returns:
- allocated buffer, or NULL if no buffer could be allocated (e.g. when downstream is flushing or shutting down)
-
allocateOutputFrame
Helper function that allocates a buffer to hold a video frame for this VideoDecoder's currentGstVideoCodecState
. Subclass should already have configured video state and set src pad caps.The buffer allocated here is owned by the frame and you should only keep references to the frame, not the buffer.
- Parameters:
frame
- aGstVideoCodecFrame
- Returns:
FlowReturn.OK
if an output buffer could be allocated
-
allocateOutputFrameWithParams
public FlowReturn allocateOutputFrameWithParams(VideoCodecFrame frame, BufferPoolAcquireParams params) Same asgst_video_decoder_allocate_output_frame
except it allows passingGstBufferPoolAcquireParams
to the sub call gst_buffer_pool_acquire_buffer.- Parameters:
frame
- aGstVideoCodecFrame
params
- aGstBufferPoolAcquireParams
- Returns:
FlowReturn.OK
if an output buffer could be allocated
-
dropFrame
Similar to gst_video_decoder_finish_frame(), but dropsframe
in any case and posts a QoS message with the frame's details on the bus. In any case, the frame is considered finished and released.- Parameters:
frame
- theGstVideoCodecFrame
to drop- Returns:
- a
GstFlowReturn
, usually GST_FLOW_OK.
-
dropSubframe
Drops input data. The frame is not considered finished until the whole frame is finished or dropped by the subclass.- Parameters:
frame
- theGstVideoCodecFrame
- Returns:
- a
GstFlowReturn
, usually GST_FLOW_OK.
-
finishFrame
frame
should have a valid decoded data buffer, whose metadata fields are then appropriately set according to frame data and pushed downstream. If no output data is provided,frame
is considered skipped. In any case, the frame is considered finished and released.After calling this function the output buffer of the frame is to be considered read-only. This function will also change the metadata of the buffer.
- Parameters:
frame
- a decodedGstVideoCodecFrame
- Returns:
- a
GstFlowReturn
resulting from sending data downstream
-
finishSubframe
Indicate that a subframe has been finished to be decoded by the subclass. This method should be called for all subframes except the last subframe wheregstVideoDecoderFinishFrame
should be called instead.- Parameters:
frame
- theGstVideoCodecFrame
- Returns:
- a
GstFlowReturn
, usually GST_FLOW_OK.
-
getAllocator
public void getAllocator(@Nullable @Nullable Out<Allocator> allocator, @Nullable @Nullable AllocationParams params) LetsGstVideoDecoder
sub-classes to know the memoryallocator
used by the base class and itsparams
.Unref the
allocator
after use it.- Parameters:
allocator
- theGstAllocator
usedparams
- theGstAllocationParams
ofallocator
-
getBufferPool
-
getEstimateRate
public int getEstimateRate() -
getFrame
Get a pending unfinishedGstVideoCodecFrame
- Parameters:
frameNumber
- system_frame_number of a frame- Returns:
- pending unfinished
GstVideoCodecFrame
identified byframeNumber
.
-
getFrames
Get all pending unfinishedGstVideoCodecFrame
- Returns:
- pending unfinished
GstVideoCodecFrame
.
-
getInputSubframeIndex
Queries the number of the last subframe received by the decoder baseclass in theframe
.- Parameters:
frame
- theGstVideoCodecFrame
to update- Returns:
- the current subframe index received in subframe mode, 1 otherwise.
-
getLatency
public void getLatency(@Nullable @Nullable ClockTime minLatency, @Nullable @Nullable ClockTime maxLatency) Query the configured decoder latency. Results will be returned viaminLatency
andmaxLatency
.- Parameters:
minLatency
- address of variable in which to store the configured minimum latency, ornull
maxLatency
- address of variable in which to store the configured mximum latency, ornull
-
getMaxDecodeTime
Determines maximum possible decoding time forframe
that will allow it to decode and arrive in time (as determined by QoS events). In particular, a negative result means decoding in time is no longer possible and should therefore occur as soon/skippy as possible.- Parameters:
frame
- aGstVideoCodecFrame
- Returns:
- max decoding time.
-
getMaxErrors
public int getMaxErrors() -
getNeedsFormat
public boolean getNeedsFormat()Queries decoder required format handling.- Returns:
true
if required format handling is enabled.
-
getNeedsSyncPoint
public boolean getNeedsSyncPoint()Queries if the decoder requires a sync point before it starts outputting data in the beginning.- Returns:
true
if a sync point is required in the beginning.
-
getOldestFrame
Get the oldest pending unfinishedGstVideoCodecFrame
- Returns:
- oldest pending unfinished
GstVideoCodecFrame
.
-
getOutputState
Get theGstVideoCodecState
currently describing the output stream.- Returns:
GstVideoCodecState
describing format of video data.
-
getPacketized
public boolean getPacketized()Queries whether input data is considered packetized or not by the base class.- Returns:
- TRUE if input data is considered packetized.
-
getPendingFrameSize
public long getPendingFrameSize()Returns the number of bytes previously added to the current frame by calling gst_video_decoder_add_to_frame().- Returns:
- The number of bytes pending for the current frame
-
getProcessedSubframeIndex
Queries the number of subframes in the frame processed by the decoder baseclass.- Parameters:
frame
- theGstVideoCodecFrame
to update- Returns:
- the current subframe processed received in subframe mode.
-
getQosProportion
public double getQosProportion() -
getSubframeMode
public boolean getSubframeMode()Queries whether input data is considered as subframes or not by the base class. If FALSE, each input buffer will be considered as a full frame.- Returns:
- TRUE if input data is considered as sub frames.
-
haveFrame
Gathers all data collected for currently parsed frame, gathers corresponding metadata and passes it along for further processing, i.e.handleFrame
.- Returns:
- a
GstFlowReturn
-
haveLastSubframe
Indicates that the last subframe has been processed by the decoder inframe
. This will release the current frame in video decoder allowing to receive new frames from upstream elements. This method must be called in the subclasshandleFrame
callback.- Parameters:
frame
- theGstVideoCodecFrame
to update- Returns:
- a
GstFlowReturn
, usually GST_FLOW_OK.
-
mergeTags
Sets the audio decoder tags and how they should be merged with any upstream stream tags. This will override any tags previously-set with gst_audio_decoder_merge_tags().Note that this is provided for convenience, and the subclass is not required to use this and can still do tag handling on its own.
MT safe.
- Parameters:
tags
- aGstTagList
to merge, or NULL to unset previously-set tagsmode
- theGstTagMergeMode
to use, usuallyGST_TAG_MERGE_REPLACE
-
negotiate
public boolean negotiate()Negotiate with downstream elements to currently configuredGstVideoCodecState
. Unmark GST_PAD_FLAG_NEED_RECONFIGURE in any case. But mark it again if negotiate fails.- Returns:
true
if the negotiation succeeded, elsefalse
.
-
proxyGetcaps
Returns caps that expresscaps
(or sink template caps ifcaps
== NULL) restricted to resolution/format/... combinations supported by downstream elements.- Parameters:
caps
- initial capsfilter
- filter caps- Returns:
- a
GstCaps
owned by caller
-
releaseFrame
Similar to gst_video_decoder_drop_frame(), but simply releasesframe
without any processing other than removing it from list of pending frames, after which it is considered finished and released.- Parameters:
frame
- theGstVideoCodecFrame
to release
-
requestSyncPoint
Allows theGstVideoDecoder
subclass to request from the base class that a new sync should be requested from upstream, and thatframe
was the frame when the subclass noticed that a new sync point is required. A reason for the subclass to do this could be missing reference frames, for example.The base class will then request a new sync point from upstream as long as the time that passed since the last one is exceeding
GstVideoDecoder
:min-force-key-unit-interval.The subclass can signal via
flags
how the frames until the next sync point should be handled:- If
VideoDecoderRequestSyncPointFlags.DISCARD_INPUT
is selected then all following input frames until the next sync point are discarded. This can be useful if the lack of a sync point will prevent all further decoding and the decoder implementation is not very robust in handling missing references frames. - If
VideoDecoderRequestSyncPointFlags.CORRUPT_OUTPUT
is selected then all output frames followingframe
are marked as corrupted viaBufferFlags.CORRUPTED
. Corrupted frames can be automatically dropped by the base class, seeGstVideoDecoder
:discard-corrupted-frames. Subclasses can manually mark frames as corrupted viaVideoCodecFrameFlags.CORRUPTED
before calling gst_video_decoder_finish_frame().
- Parameters:
frame
- aGstVideoCodecFrame
flags
-GstVideoDecoderRequestSyncPointFlags
- If
-
requestSyncPoint
Allows theGstVideoDecoder
subclass to request from the base class that a new sync should be requested from upstream, and thatframe
was the frame when the subclass noticed that a new sync point is required. A reason for the subclass to do this could be missing reference frames, for example.The base class will then request a new sync point from upstream as long as the time that passed since the last one is exceeding
GstVideoDecoder
:min-force-key-unit-interval.The subclass can signal via
flags
how the frames until the next sync point should be handled:- If
VideoDecoderRequestSyncPointFlags.DISCARD_INPUT
is selected then all following input frames until the next sync point are discarded. This can be useful if the lack of a sync point will prevent all further decoding and the decoder implementation is not very robust in handling missing references frames. - If
VideoDecoderRequestSyncPointFlags.CORRUPT_OUTPUT
is selected then all output frames followingframe
are marked as corrupted viaBufferFlags.CORRUPTED
. Corrupted frames can be automatically dropped by the base class, seeGstVideoDecoder
:discard-corrupted-frames. Subclasses can manually mark frames as corrupted viaVideoCodecFrameFlags.CORRUPTED
before calling gst_video_decoder_finish_frame().
- Parameters:
frame
- aGstVideoCodecFrame
flags
-GstVideoDecoderRequestSyncPointFlags
- If
-
setEstimateRate
public void setEstimateRate(boolean enabled) Allows baseclass to perform byte to time estimated conversion.- Parameters:
enabled
- whether to enable byte to time conversion
-
setInterlacedOutputState
public VideoCodecState setInterlacedOutputState(VideoFormat fmt, VideoInterlaceMode interlaceMode, int width, int height, @Nullable @Nullable VideoCodecState reference) Same asgst_video_decoder_set_output_state
() but also allows you to also set the interlacing mode.- Parameters:
fmt
- aGstVideoFormat
interlaceMode
- AGstVideoInterlaceMode
width
- The width in pixelsheight
- The height in pixelsreference
- An optional referenceGstVideoCodecState
- Returns:
- the newly configured output state.
-
setLatency
LetsGstVideoDecoder
sub-classes tell the baseclass what the decoder latency is. If the provided values changed from previously provided ones, this will also post a LATENCY message on the bus so the pipeline can reconfigure its global latency.- Parameters:
minLatency
- minimum latencymaxLatency
- maximum latency
-
setMaxErrors
public void setMaxErrors(int num) Sets numbers of tolerated decoder errors, where a tolerated one is then only warned about, but more than tolerated will lead to fatal error. You can set -1 for never returning fatal errors. Default is set to GST_VIDEO_DECODER_MAX_ERRORS.The '-1' option was added in 1.4
- Parameters:
num
- max tolerated errors
-
setNeedsFormat
public void setNeedsFormat(boolean enabled) Configures decoder format needs. If enabled, subclass needs to be negotiated with format caps before it can process any data. It will then never be handed any data before it has been configured. Otherwise, it might be handed data without having been configured and is then expected being able to do so either by default or based on the input data.- Parameters:
enabled
- new state
-
setNeedsSyncPoint
public void setNeedsSyncPoint(boolean enabled) Configures whether the decoder requires a sync point before it starts outputting data in the beginning. If enabled, the base class will discard all non-sync point frames in the beginning and after a flush and does not pass it to the subclass.If the first frame is not a sync point, the base class will request a sync point via the force-key-unit event.
- Parameters:
enabled
- new state
-
setOutputState
public VideoCodecState setOutputState(VideoFormat fmt, int width, int height, @Nullable @Nullable VideoCodecState reference) Creates a newGstVideoCodecState
with the specifiedfmt
,width
andheight
as the output state for the decoder. Any previously set output state on this VideoDecoder will be replaced by the newly created one.If the subclass wishes to copy over existing fields (like pixel aspec ratio, or framerate) from an existing
GstVideoCodecState
, it can be provided as areference
.If the subclass wishes to override some fields from the output state (like pixel-aspect-ratio or framerate) it can do so on the returned
GstVideoCodecState
.The new output state will only take effect (set on pads and buffers) starting from the next call to
gst_video_decoder_finish_frame
().- Parameters:
fmt
- aGstVideoFormat
width
- The width in pixelsheight
- The height in pixelsreference
- An optional referenceGstVideoCodecState
- Returns:
- the newly configured output state.
-
setPacketized
public void setPacketized(boolean packetized) Allows baseclass to consider input data as packetized or not. If the input is packetized, then theparse
method will not be called.- Parameters:
packetized
- whether the input data should be considered as packetized.
-
setSubframeMode
public void setSubframeMode(boolean subframeMode) If this is set to TRUE, it informs the base class that the subclass can receive the data at a granularity lower than one frame.Note that in this mode, the subclass has two options. It can either require the presence of a GST_VIDEO_BUFFER_FLAG_MARKER to mark the end of a frame. Or it can operate in such a way that it will decode a single frame at a time. In this second case, every buffer that arrives to the element is considered part of the same frame until gst_video_decoder_finish_frame() is called.
In either case, the same
GstVideoCodecFrame
will be passed to the GstVideoDecoderClass:handle_frame vmethod repeatedly with a different GstVideoCodecFrame:input_buffer every time until the end of the frame has been signaled using either method. This method must be called during the decoder subclasssetFormat
call.- Parameters:
subframeMode
- whether the input data should be considered as subframes.
-
setUseDefaultPadAcceptcaps
public void setUseDefaultPadAcceptcaps(boolean use) LetsGstVideoDecoder
sub-classes decide if they want the sink pad to use the default pad query handler to reply to accept-caps queries.By setting this to true it is possible to further customize the default handler with
GST_PAD_SET_ACCEPT_INTERSECT
andGST_PAD_SET_ACCEPT_TEMPLATE
- Parameters:
use
- if the default pad accept-caps query handling should be used
-
close
protected boolean close()Optional. Called when the element changes to GST_STATE_NULL. Allows closing external resources. -
decideAllocation
Optional. Setup the allocation parameters for allocating output buffers. The passed in query contains the result of the downstream allocation query. Subclasses should chain up to the parent implementation to invoke the default handler. -
drain
Optional. Called to request subclass to decode any data it can at this point, but that more data may arrive after. (e.g. at segment end). Sub-classes should be prepared to handle new data afterward, or seamless segment processing will break. Since: 1.6 -
finish
Optional. Called to request subclass to dispatch any pending remaining data at EOS. Sub-classes can refuse to decode new data after. -
flush
protected boolean flush()Optional. Flush all remaining data from the decoder without pushing it downstream. Since: 1.2 -
getcaps
-
handleFrame
-
handleMissingData
-
open
protected boolean open()Optional. Called when the element changes to GST_STATE_READY. Allows opening external resources. -
parse
Required for non-packetized input. Allows chopping incoming data into manageable units (frames) for subsequent decoding. -
proposeAllocation
Optional. Propose buffer allocation parameters for upstream elements. Subclasses should chain up to the parent implementation to invoke the default handler. -
reset
protected boolean reset(boolean hard) Optional. Allows subclass (decoder) to perform post-seek semantics reset. Deprecated. -
setFormat
Notifies subclass of incoming data format (caps). -
sinkEvent
Optional. Event handler on the sink pad. This function should return TRUE if the event was handled and should be discarded (i.e. not unref'ed). Subclasses should chain up to the parent implementation to invoke the default handler. -
sinkQuery
Optional. Query handler on the sink pad. This function should return TRUE if the query could be performed. Subclasses should chain up to the parent implementation to invoke the default handler. Since: 1.4 -
srcEvent
Optional. Event handler on the source pad. This function should return TRUE if the event was handled and should be discarded (i.e. not unref'ed). Subclasses should chain up to the parent implementation to invoke the default handler. -
srcQuery
Optional. Query handler on the source pad. This function should return TRUE if the query could be performed. Subclasses should chain up to the parent implementation to invoke the default handler. Since: 1.4 -
start
protected boolean start()Optional. Called when the element starts processing. Allows opening external resources. -
stop
protected boolean stop()Optional. Called when the element stops processing. Allows closing external resources. -
transformMeta
Optional. Transform the metadata on the input buffer to the output buffer. By default this method is copies all meta without tags and meta with only the "video" tag. subclasses can implement this method and returntrue
if the metadata is to be copied. Since: 1.6 -
builder
AVideoDecoder.Builder
object constructs aVideoDecoder
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withVideoDecoder.Builder.build()
.
-