## GstVideoDecoder GstVideoDecoder — Base class for video decoders |

## Functions

#define | GST_VIDEO_DECODER_ERROR()
#define | GST_VIDEO_DECODER_SINK_PAD()
#define | GST_VIDEO_DECODER_SRC_PAD()
#define | GST_VIDEO_DECODER_STREAM_LOCK()
#define | GST_VIDEO_DECODER_STREAM_UNLOCK()
#define | GST_VIDEO_DECODER_INPUT_SEGMENT()
#define | GST_VIDEO_DECODER_OUTPUT_SEGMENT()
void | gst_video_decoder_add_to_frame ()
GstBuffer * | gst_video_decoder_allocate_output_buffer ()
GstFlowReturn | gst_video_decoder_allocate_output_frame ()
GstFlowReturn | gst_video_decoder_allocate_output_frame_with_params ()
void | gst_video_decoder_get_allocator ()
GstBufferPool * | gst_video_decoder_get_buffer_pool ()
GstFlowReturn | gst_video_decoder_drop_frame ()
GstFlowReturn | gst_video_decoder_finish_frame ()
void | gst_video_decoder_release_frame ()
gboolean | gst_video_decoder_negotiate ()
GstVideoCodecFrame * | gst_video_decoder_get_frame ()
GList * | gst_video_decoder_get_frames ()
GstClockTimeDiff | gst_video_decoder_get_max_decode_time ()
gint | gst_video_decoder_get_max_errors ()
GstVideoCodecFrame * | gst_video_decoder_get_oldest_frame ()
gboolean | gst_video_decoder_get_packetized ()
gsize | gst_video_decoder_get_pending_frame_size ()
gdouble | gst_video_decoder_get_qos_proportion ()
GstFlowReturn | gst_video_decoder_have_frame ()
void | gst_video_decoder_get_latency ()
void | gst_video_decoder_set_latency ()
gint | gst_video_decoder_get_estimate_rate ()
GstVideoCodecState * | gst_video_decoder_get_output_state ()
void | gst_video_decoder_set_estimate_rate ()
GstVideoCodecState * | gst_video_decoder_set_output_state ()
GstVideoCodecState * | gst_video_decoder_set_interlaced_output_state ()
void | gst_video_decoder_set_max_errors ()
void | gst_video_decoder_set_packetized ()
gboolean | gst_video_decoder_get_needs_format ()
void | gst_video_decoder_set_needs_format ()
void | gst_video_decoder_merge_tags ()
GstCaps * | gst_video_decoder_proxy_getcaps ()
void | gst_video_decoder_set_use_default_pad_acceptcaps ()

## Types and Values

#define | GST_VIDEO_DECODER_FLOW_NEED_DATA
#define | GST_VIDEO_DECODER_MAX_ERRORS
#define | GST_VIDEO_DECODER_SINK_NAME
#define | GST_VIDEO_DECODER_SRC_NAME
struct | GstVideoDecoder
struct | GstVideoDecoderClass

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GstObject
                ╰── GstElement
                    ╰── GstVideoDecoder

## Includes

    #include <gst/video/video.h>

## Description

This base class is for video decoders turning encoded data into raw video frames.

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 `set_format` 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' `handle_frame` callback. The ownership of the frame is given to the `handle_frame` callback.

  - If codec processing results in decoded data, the subclass should call `gst_video_decoder_finish_frame` to have decoded data pushed. downstream. Otherwise, the subclass must call `gst_video_decoder_drop_frame` , 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 ouptput caps, when they are known. This may be when the base class calls the subclass' `set_format` function, though it might be during decoding, before calling `gst_video_decoder_finish_frame` . This is done via `gst_video_decoder_set_output_state`

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 `gst_video_decoder_set_estimate_rate` 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 `gst_video_decoder_set_output_state`

- Parse input data, if it is not considered packetized from upstream Data will be provided to `parse` which should invoke `gst_video_decoder_add_to_frame` and `gst_video_decoder_have_frame` to separate the data belonging to each video frame.

- Accept data in `handle_frame` and provide decoded results to `gst_video_decoder_finish_frame` , or call `gst_video_decoder_drop_frame` .

## Functions

### GST_VIDEO_DECODER_ERROR()

    #define             GST_VIDEO_DECODER_ERROR(el, w, domain, code, text, debug, ret)

Utility function that video decoder elements can use in case they encountered a data processing error that may be fatal for the current "data unit" but need not prevent subsequent decoding. Such errors are counted and if there are too many, as configured in the context's max_errors, the pipeline will post an error message and the application will be requested to stop further media processing. Otherwise, it is considered a "glitch" and only a warning is logged. In either case, `ret` is set to the proper value to return to upstream/caller (indicating either GST_FLOW_ERROR or GST_FLOW_OK).

#### Parameters

el | the base video decoder element that generates the error |
w | element defined weight of the error, added to error count |
domain | like CORE, LIBRARY, RESOURCE or STREAM (see gstreamer-GstGError) |
code | error code defined for that domain (see gstreamer-GstGError) |
text | the message to display (format string and args enclosed in parentheses) |
debug | debugging information for the message (format string and args enclosed in parentheses) |
ret | variable to receive return value |

### GST_VIDEO_DECODER_SINK_PAD()

    #define GST_VIDEO_DECODER_SINK_PAD(obj)        (((GstVideoDecoder *) (obj))->sinkpad)

Gives the pointer to the sink GstPad object of the element.

#### Parameters

obj | a GstVideoDecoder |

### GST_VIDEO_DECODER_SRC_PAD()

    #define GST_VIDEO_DECODER_SRC_PAD(obj)         (((GstVideoDecoder *) (obj))->srcpad)

Gives the pointer to the source GstPad object of the element.

#### Parameters

obj | a GstVideoDecoder |

### GST_VIDEO_DECODER_STREAM_LOCK()

    #define GST_VIDEO_DECODER_STREAM_LOCK(decoder) g_rec_mutex_lock (&GST_VIDEO_DECODER (decoder)->stream_lock)

Obtain a lock to protect the decoder function from concurrent access.

#### Parameters

decoder | video decoder instance |

### GST_VIDEO_DECODER_STREAM_UNLOCK()

    #define GST_VIDEO_DECODER_STREAM_UNLOCK(decoder) g_rec_mutex_unlock (&GST_VIDEO_DECODER (decoder)->stream_lock)

Release the lock that protects the decoder function from concurrent access.

#### Parameters

decoder | video decoder instance |

### GST_VIDEO_DECODER_INPUT_SEGMENT()

    #define GST_VIDEO_DECODER_INPUT_SEGMENT(obj)     (GST_VIDEO_DECODER_CAST (obj)->input_segment)

Gives the segment of the element.

#### Parameters

obj | base decoder instance |

### GST_VIDEO_DECODER_OUTPUT_SEGMENT()

    #define GST_VIDEO_DECODER_OUTPUT_SEGMENT(obj)     (GST_VIDEO_DECODER_CAST (obj)->output_segment)

Gives the segment of the element.

#### Parameters

obj | base decoder instance |

### gst_video_decoder_add_to_frame ()

    void
    gst_video_decoder_add_to_frame (GstVideoDecoder *decoder,
                                    int n_bytes);

Removes next `n_bytes` of input data and adds it to currently parsed frame.

#### Parameters

decoder | a GstVideoDecoder |
n_bytes | the number of bytes to add |

### gst_video_decoder_allocate_output_buffer ()

    GstBuffer *
    gst_video_decoder_allocate_output_buffer
                                   (GstVideoDecoder *decoder);

Helper function that allocates a buffer to hold a video frame for `decoder` 's current GstVideoCodecState.

You should use `gst_video_decoder_allocate_output_frame()` instead of this function, if possible at all.

#### Parameters

decoder | a GstVideoDecoder |

#### Returns

allocated buffer, or NULL if no buffer could be allocated (e.g. when downstream is flushing or shutting down).

[transfer full]

### gst_video_decoder_allocate_output_frame ()

    GstFlowReturn
    gst_video_decoder_allocate_output_frame
                                   (GstVideoDecoder *decoder,
                                    GstVideoCodecFrame *frame);

Helper function that allocates a buffer to hold a video frame for `decoder` 's current GstVideoCodecState. 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

decoder | a GstVideoDecoder |
frame | a GstVideoCodecFrame |

#### Returns

`GST_FLOW_OK` if an output buffer could be allocated

### gst_video_decoder_allocate_output_frame_with_params ()

    GstFlowReturn
    gst_video_decoder_allocate_output_frame_with_params
                                   (GstVideoDecoder *decoder,
                                    GstVideoCodecFrame *frame,
                                    GstBufferPoolAcquireParams *params);

Same as gst_video_decoder_allocate_output_frame except it allows passing GstBufferPoolAcquireParams to the sub call gst_buffer_pool_acquire_buffer.

#### Parameters

decoder | a GstVideoDecoder |
frame | a GstVideoCodecFrame |
params | a GstBufferPoolAcquireParams |

#### Returns

`GST_FLOW_OK` if an output buffer could be allocated

Since: 1.12

### gst_video_decoder_get_allocator ()

    void
    gst_video_decoder_get_allocator (GstVideoDecoder *decoder,
                                     GstAllocator **allocator,
                                     GstAllocationParams *params);

Lets GstVideoDecoder sub-classes to know the memory `allocator` used by the base class and its `params` .

Unref the `allocator` after use it.

#### Parameters

decoder | a GstVideoDecoder |
allocator | the GstAllocator used. | [out][allow-none][transfer full]
params | the GstAllocationParams of `allocator` . | [out][allow-none][transfer full]

### gst_video_decoder_get_buffer_pool ()

    GstBufferPool *
    gst_video_decoder_get_buffer_pool (GstVideoDecoder *decoder);

#### Parameters

decoder | a GstVideoDecoder |

#### Returns

the instance of the GstBufferPool used by the decoder; free it after use it.

[transfer full]

### gst_video_decoder_drop_frame ()

    GstFlowReturn
    gst_video_decoder_drop_frame (GstVideoDecoder *dec,
                                  GstVideoCodecFrame *frame);

Similar to `gst_video_decoder_finish_frame()`, but drops `frame` 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

dec | a GstVideoDecoder |
frame | the GstVideoCodecFrame to drop. | [transfer full]

#### Returns

a GstFlowReturn, usually GST_FLOW_OK.

### gst_video_decoder_finish_frame ()

    GstFlowReturn
    gst_video_decoder_finish_frame (GstVideoDecoder *decoder,
                                    GstVideoCodecFrame *frame);

`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

decoder | a GstVideoDecoder |
frame | a decoded GstVideoCodecFrame. | [transfer full]

#### Returns

a GstFlowReturn resulting from sending data downstream

### gst_video_decoder_release_frame ()

    void
    gst_video_decoder_release_frame (GstVideoDecoder *dec,
                                     GstVideoCodecFrame *frame);

Similar to `gst_video_decoder_drop_frame()`, but simply releases `frame` without any processing other than removing it from list of pending frames, after which it is considered finished and released.

#### Parameters

dec | a GstVideoDecoder |
frame | the GstVideoCodecFrame to release. | [transfer full]

Since: 1.2.2

### gst_video_decoder_negotiate ()

    gboolean
    gst_video_decoder_negotiate (GstVideoDecoder *decoder);

Negotiate with downstream elements to currently configured GstVideoCodecState. Unmark GST_PAD_FLAG_NEED_RECONFIGURE in any case. But mark it again if negotiate fails.

#### Parameters

decoder | a GstVideoDecoder |

#### Returns

`TRUE` if the negotiation succeeded, else `FALSE`.

### gst_video_decoder_get_frame ()

    GstVideoCodecFrame *
    gst_video_decoder_get_frame (GstVideoDecoder *decoder,
                                 int frame_number);

Get a pending unfinished GstVideoCodecFrame

#### Parameters

decoder | a GstVideoDecoder |
frame_number | system_frame_number of a frame |

#### Returns

pending unfinished GstVideoCodecFrame identified by `frame_number` .

[transfer full]

### gst_video_decoder_get_frames ()

    GList *
    gst_video_decoder_get_frames (GstVideoDecoder *decoder);

Get all pending unfinished GstVideoCodecFrame

#### Parameters

decoder | a GstVideoDecoder |

#### Returns

pending unfinished GstVideoCodecFrame.

[transfer full][element-type GstVideoCodecFrame]

### gst_video_decoder_get_max_decode_time ()

    GstClockTimeDiff
    gst_video_decoder_get_max_decode_time (GstVideoDecoder *decoder,
                                           GstVideoCodecFrame *frame);

Determines maximum possible decoding time for `frame` 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

decoder | a GstVideoDecoder |
frame | a GstVideoCodecFrame |

#### Returns

max decoding time.

### gst_video_decoder_get_max_errors ()

    gint
    gst_video_decoder_get_max_errors (GstVideoDecoder *dec);

#### Parameters

dec | a GstVideoDecoder |

#### Returns

currently configured decoder tolerated error count.

### gst_video_decoder_get_oldest_frame ()

    GstVideoCodecFrame *
    gst_video_decoder_get_oldest_frame (GstVideoDecoder *decoder);

Get the oldest pending unfinished GstVideoCodecFrame

#### Parameters

decoder | a GstVideoDecoder |

#### Returns

oldest pending unfinished GstVideoCodecFrame.

[transfer full]

### gst_video_decoder_get_packetized ()

    gboolean
    gst_video_decoder_get_packetized (GstVideoDecoder *decoder);

Queries whether input data is considered packetized or not by the base class.

#### Parameters

decoder | a GstVideoDecoder |

#### Returns

TRUE if input data is considered packetized.

### gst_video_decoder_get_pending_frame_size ()

    gsize
    gst_video_decoder_get_pending_frame_size
                                   (GstVideoDecoder *decoder);

Returns the number of bytes previously added to the current frame by calling `gst_video_decoder_add_to_frame()`.

#### Parameters

decoder | a GstVideoDecoder |

#### Returns

The number of bytes pending for the current frame

Since: 1.4

### gst_video_decoder_get_qos_proportion ()

    gdouble
    gst_video_decoder_get_qos_proportion (GstVideoDecoder *decoder);

#### Parameters

decoder | a GstVideoDecoder current QoS proportion, or `NULL` |

#### Returns

The current QoS proportion.

Since: 1.0.3

### gst_video_decoder_have_frame ()

    GstFlowReturn
    gst_video_decoder_have_frame (GstVideoDecoder *decoder);

Gathers all data collected for currently parsed frame, gathers corresponding metadata and passes it along for further processing, i.e. `handle_frame` .

#### Parameters

decoder | a GstVideoDecoder |

#### Returns

a GstFlowReturn

### gst_video_decoder_get_latency ()

    void
    gst_video_decoder_get_latency (GstVideoDecoder *decoder,
                                   GstClockTime *min_latency,
                                   GstClockTime *max_latency);

Query the configured decoder latency. Results will be returned via `min_latency` and `max_latency` .

#### Parameters

decoder | a GstVideoDecoder |
min_latency | address of variable in which to store the configured minimum latency, or `NULL`. | [out][allow-none]
max_latency | address of variable in which to store the configured mximum latency, or `NULL`. | [out][allow-none]

### gst_video_decoder_set_latency ()

    void
    gst_video_decoder_set_latency (GstVideoDecoder *decoder,
                                   GstClockTime min_latency,
                                   GstClockTime max_latency);

Lets GstVideoDecoder sub-classes tell the baseclass what the decoder latency is. Will also post a LATENCY message on the bus so the pipeline can reconfigure its global latency.

#### Parameters

decoder | a GstVideoDecoder |
min_latency | minimum latency |
max_latency | maximum latency |

### gst_video_decoder_get_estimate_rate ()

    gint
    gst_video_decoder_get_estimate_rate (GstVideoDecoder *dec);

#### Parameters

dec | a GstVideoDecoder |

#### Returns

currently configured byte to time conversion setting

### gst_video_decoder_get_output_state ()

    GstVideoCodecState *
    gst_video_decoder_get_output_state (GstVideoDecoder *decoder);

Get the GstVideoCodecState currently describing the output stream.

#### Parameters

decoder | a GstVideoDecoder |

#### Returns

GstVideoCodecState describing format of video data.

[transfer full]

### gst_video_decoder_set_estimate_rate ()

    void
    gst_video_decoder_set_estimate_rate (GstVideoDecoder *dec,
                                         gboolean enabled);

Allows baseclass to perform byte to time estimated conversion.

#### Parameters

dec | a GstVideoDecoder |
enabled | whether to enable byte to time conversion |

### gst_video_decoder_set_output_state ()

    GstVideoCodecState *
    gst_video_decoder_set_output_state (GstVideoDecoder *decoder,
                                        GstVideoFormat fmt,
                                        guint width,
                                        guint height,
                                        GstVideoCodecState *reference);

Creates a new GstVideoCodecState with the specified `fmt` , `width` and `height` as the output state for the decoder. Any previously set output state on `decoder` 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 a `reference` .

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

decoder | a GstVideoDecoder |
fmt | a GstVideoFormat |
width | The width in pixels |
height | The height in pixels |
reference | An optional reference GstVideoCodecState. | [allow-none][transfer none]

#### Returns

the newly configured output state.

[transfer full]

### gst_video_decoder_set_interlaced_output_state ()

    GstVideoCodecState *
    gst_video_decoder_set_interlaced_output_state
                                   (GstVideoDecoder *decoder,
                                    GstVideoFormat fmt,
                                    GstVideoInterlaceMode mode,
                                    guint width,
                                    guint height,
                                    GstVideoCodecState *reference);

Same as `gst_video_decoder_set_output_state()` but also allows you to also set the interlacing mode.

#### Parameters

decoder | a GstVideoDecoder |
fmt | a GstVideoFormat |
width | The width in pixels |
height | The height in pixels |
mode | A GstVideoInterlaceMode |
reference | An optional reference GstVideoCodecState. | [allow-none][transfer none]

#### Returns

the newly configured output state.

[transfer full]

Since: 1.16.

### gst_video_decoder_set_max_errors ()

    void
    gst_video_decoder_set_max_errors (GstVideoDecoder *dec,
                                      gint 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

dec | a GstVideoDecoder |
num | max tolerated errors |

### gst_video_decoder_set_packetized ()

    void
    gst_video_decoder_set_packetized (GstVideoDecoder *decoder,
                                      gboolean packetized);

Allows baseclass to consider input data as packetized or not. If the input is packetized, then the `parse` method will not be called.

#### Parameters

decoder | a GstVideoDecoder |
packetized | whether the input data should be considered as packetized. |

### gst_video_decoder_get_needs_format ()

    gboolean
    gst_video_decoder_get_needs_format (GstVideoDecoder *dec);

Queries decoder required format handling.

#### Parameters

dec | a GstVideoDecoder |

#### Returns

`TRUE` if required format handling is enabled.

Since: 1.4

### gst_video_decoder_set_needs_format ()

    void
    gst_video_decoder_set_needs_format (GstVideoDecoder *dec,
                                        gboolean 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

dec | a GstVideoDecoder |
enabled | new state |

Since: 1.4

### gst_video_decoder_merge_tags ()

    void
    gst_video_decoder_merge_tags (GstVideoDecoder *decoder,
                                  const GstTagList *tags,
                                  GstTagMergeMode mode);

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

decoder | a GstVideoDecoder |
tags | a GstTagList to merge, or NULL to unset previously-set tags. | [allow-none]
mode | the GstTagMergeMode to use, usually GST_TAG_MERGE_REPLACE |

### gst_video_decoder_proxy_getcaps ()

    GstCaps *
    gst_video_decoder_proxy_getcaps (GstVideoDecoder *decoder,
                                     GstCaps *caps,
                                     GstCaps *filter);

Returns caps that express `caps` (or sink template caps if `caps` == NULL) restricted to resolution/format/... combinations supported by downstream elements.

#### Parameters

decoder | a GstVideoDecoder |
caps | initial caps. | [allow-none]
filter | filter caps. | [allow-none]

#### Returns

a GstCaps owned by caller.

[transfer full]

Since: 1.6

### gst_video_decoder_set_use_default_pad_acceptcaps ()

    void
    gst_video_decoder_set_use_default_pad_acceptcaps
                                   (GstVideoDecoder *decoder,
                                    gboolean use);

Lets GstVideoDecoder 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` and `GST_PAD_SET_ACCEPT_TEMPLATE`

#### Parameters

decoder | a GstVideoDecoder |
use | if the default pad accept-caps query handling should be used |

Since: 1.6

## Types and Values

### GST_VIDEO_DECODER_FLOW_NEED_DATA

    #define GST_VIDEO_DECODER_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS

Returned while parsing to indicate more data is needed.

### GST_VIDEO_DECODER_MAX_ERRORS

    #define GST_VIDEO_DECODER_MAX_ERRORS     10

Default maximum number of errors tolerated before signaling error.

### GST_VIDEO_DECODER_SINK_NAME

    #define GST_VIDEO_DECODER_SINK_NAME    "sink"

The name of the templates for the sink pad.

### GST_VIDEO_DECODER_SRC_NAME

    #define GST_VIDEO_DECODER_SRC_NAME     "src"

The name of the templates for the source pad.

### struct GstVideoDecoder

    struct GstVideoDecoder;

The opaque GstVideoDecoder data structure.

### struct GstVideoDecoderClass

    struct GstVideoDecoderClass {
      gboolean      (*open)           (GstVideoDecoder *decoder);

      gboolean      (*close)          (GstVideoDecoder *decoder);

      gboolean      (*start)          (GstVideoDecoder *decoder);

      gboolean      (*stop)           (GstVideoDecoder *decoder);

      GstFlowReturn (*parse)          (GstVideoDecoder *decoder,
    				   GstVideoCodecFrame *frame,
    				   GstAdapter *adapter,
    				   gboolean at_eos);

      gboolean      (*set_format)     (GstVideoDecoder *decoder,
    				   GstVideoCodecState * state);

      gboolean      (*reset)          (GstVideoDecoder *decoder,
    				   gboolean hard);

      GstFlowReturn (*finish)         (GstVideoDecoder *decoder);

      GstFlowReturn (*handle_frame)   (GstVideoDecoder *decoder,
    				   GstVideoCodecFrame *frame);

      gboolean      (*sink_event)     (GstVideoDecoder *decoder,
    				   GstEvent *event);

      gboolean      (*src_event)      (GstVideoDecoder *decoder,
    				   GstEvent *event);

      gboolean      (*negotiate)      (GstVideoDecoder *decoder);

      gboolean      (*decide_allocation)  (GstVideoDecoder *decoder, GstQuery *query);

      gboolean      (*propose_allocation) (GstVideoDecoder *decoder, GstQuery * query);

      gboolean      (*flush)              (GstVideoDecoder *decoder);

      gboolean      (*sink_query)     (GstVideoDecoder *decoder,
    				   GstQuery *query);

      gboolean      (*src_query)      (GstVideoDecoder *decoder,
    				   GstQuery *query);

      GstCaps*      (*getcaps)        (GstVideoDecoder *decoder,
                                       GstCaps *filter);

      GstFlowReturn (*drain)          (GstVideoDecoder *decoder);

      gboolean      (*transform_meta) (GstVideoDecoder *decoder,
                                       GstVideoCodecFrame *frame,
                                       GstMeta * meta);
    };

Subclasses can override any of the available virtual methods or not, as needed. At minimum `handle_frame` needs to be overridden, and `set_format` and likely as well. If non-packetized input is supported or expected, `parse` needs to be overridden as well.

#### Members

`open` () | Optional. Called when the element changes to GST_STATE_READY. Allows opening external resources. |
`close` () | Optional. Called when the element changes to GST_STATE_NULL. Allows closing external resources. |
`start` () | Optional. Called when the element starts processing. Allows opening external resources. |
`stop` () | Optional. Called when the element stops processing. Allows closing external resources. |
`parse` () | Required for non-packetized input. Allows chopping incoming data into manageable units (frames) for subsequent decoding. |
`set_format` () | Notifies subclass of incoming data format (caps). |
`reset` () | Optional. Allows subclass (decoder) to perform post-seek semantics reset. Deprecated. |
`finish` () | Optional. Called to request subclass to dispatch any pending remaining data at EOS. Sub-classes can refuse to decode new data after. |
`handle_frame` () | Provides input data frame to subclass. |
`sink_event` () | 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. |
`src_event` () | 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. |
`negotiate` () | Optional. Negotiate with downstream and configure buffer pools, etc. Subclasses should chain up to the parent implementation to invoke the default handler. |
`decide_allocation` () | 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. |
`propose_allocation` () | Optional. Propose buffer allocation parameters for upstream elements. Subclasses should chain up to the parent implementation to invoke the default handler. |
`flush` () | Optional. Flush all remaining data from the decoder without pushing it downstream. Since: 1.2 |
`sink_query` () | 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 |
`src_query` () | 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 |
`getcaps` () | Optional. Allows for a custom sink getcaps implementation. If not implemented, default returns gst_video_decoder_proxy_getcaps applied to sink template caps. |
`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 |
`transform_meta` () | 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 return `TRUE` if the metadata is to be copied. Since: 1.6 |