## GstBaseSink GstBaseSink — Base class for sink elements |

## Functions

gboolean | gst_base_sink_query_latency ()
GstClockTime | gst_base_sink_get_latency ()
GstFlowReturn | gst_base_sink_do_preroll ()
GstFlowReturn | gst_base_sink_wait ()
GstFlowReturn | gst_base_sink_wait_preroll ()
GstClockReturn | gst_base_sink_wait_clock ()
void | gst_base_sink_set_sync ()
gboolean | gst_base_sink_get_sync ()
void | gst_base_sink_set_max_lateness ()
gint64 | gst_base_sink_get_max_lateness ()
void | gst_base_sink_set_qos_enabled ()
gboolean | gst_base_sink_is_qos_enabled ()
void | gst_base_sink_set_async_enabled ()
gboolean | gst_base_sink_is_async_enabled ()
void | gst_base_sink_set_ts_offset ()
GstClockTimeDiff | gst_base_sink_get_ts_offset ()
void | gst_base_sink_set_render_delay ()
GstClockTime | gst_base_sink_get_render_delay ()
GstSample * | gst_base_sink_get_last_sample ()
void | gst_base_sink_set_blocksize ()
guint | gst_base_sink_get_blocksize ()
guint64 | gst_base_sink_get_throttle_time ()
void | gst_base_sink_set_throttle_time ()
void | gst_base_sink_set_max_bitrate ()
guint64 | gst_base_sink_get_max_bitrate ()
void | gst_base_sink_set_last_sample_enabled ()
gboolean | gst_base_sink_is_last_sample_enabled ()
#define | GST_BASE_SINK_PAD()
#define | GST_BASE_SINK_GET_PREROLL_COND()
#define | GST_BASE_SINK_GET_PREROLL_LOCK()
#define | GST_BASE_SINK_PREROLL_BROADCAST()
#define | GST_BASE_SINK_PREROLL_LOCK()
#define | GST_BASE_SINK_PREROLL_SIGNAL()
#define | GST_BASE_SINK_PREROLL_TRYLOCK()
#define | GST_BASE_SINK_PREROLL_UNLOCK()
#define | GST_BASE_SINK_PREROLL_WAIT()
#define | GST_BASE_SINK_PREROLL_WAIT_UNTIL()

## Properties

gboolean | async | Read / Write
guint | blocksize | Read / Write
gboolean | enable-last-sample | Read / Write
GstSample * | last-sample | Read
guint64 | max-bitrate | Read / Write
gint64 | max-lateness | Read / Write
gboolean | qos | Read / Write
guint64 | render-delay | Read / Write
gboolean | sync | Read / Write
guint64 | throttle-time | Read / Write
gint64 | ts-offset | Read / Write

## Types and Values

struct | GstBaseSink
struct | GstBaseSinkClass

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GstObject
                ╰── GstElement
                    ╰── GstBaseSink

## Includes

    #include <gst/base/gstbasesink.h>

## Description

GstBaseSink is the base class for sink elements in GStreamer, such as xvimagesink or filesink. It is a layer on top of GstElement that provides a simplified interface to plugin writers. GstBaseSink handles many details for you, for example: preroll, clock synchronization, state changes, activation in push or pull mode, and queries.

In most cases, when writing sink elements, there is no need to implement class methods from GstElement or to set functions on pads, because the GstBaseSink infrastructure should be sufficient.

GstBaseSink provides support for exactly one sink pad, which should be named "sink". A sink implementation (subclass of GstBaseSink) should install a pad template in its class_init function, like so:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    static void
    my_element_class_init (GstMyElementClass *klass)
    {
      GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);

      // sinktemplate should be a #GstStaticPadTemplate with direction
      // %GST_PAD_SINK and name "sink"
      gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);

      gst_element_class_set_static_metadata (gstelement_class,
          "Sink name",
          "Sink",
          "My Sink element",
          "The author <my.sink@my.email>");
    }

GstBaseSink will handle the prerolling correctly. This means that it will return `GST_STATE_CHANGE_ASYNC` from a state change to PAUSED until the first buffer arrives in this element. The base class will call the `GstBaseSinkClass.preroll()` vmethod with this preroll buffer and will then commit the state change to the next asynchronously pending state.

When the element is set to PLAYING, GstBaseSink will synchronise on the clock using the times returned from `GstBaseSinkClass.get_times()`. If this function returns `GST_CLOCK_TIME_NONE` for the start time, no synchronisation will be done. Synchronisation can be disabled entirely by setting the object “sync” property to `FALSE`.

After synchronisation the virtual method `GstBaseSinkClass.render()` will be called. Subclasses should minimally implement this method.

Subclasses that synchronise on the clock in the `GstBaseSinkClass.render()` method are supported as well. These classes typically receive a buffer in the render method and can then potentially block on the clock while rendering. A typical example is an audiosink. These subclasses can use `gst_base_sink_wait_preroll()` to perform the blocking wait.

Upon receiving the EOS event in the PLAYING state, GstBaseSink will wait for the clock to reach the time indicated by the stop time of the last `GstBaseSinkClass.get_times()` call before posting an EOS message. When the element receives EOS in PAUSED, preroll completes, the event is queued and an EOS message is posted when going to PLAYING.

GstBaseSink will internally use the `GST_EVENT_SEGMENT` events to schedule synchronisation and clipping of buffers. Buffers that fall completely outside of the current segment are dropped. Buffers that fall partially in the segment are rendered (and prerolled). Subclasses should do any subbuffer clipping themselves when needed.

GstBaseSink will by default report the current playback position in `GST_FORMAT_TIME` based on the current clock time and segment information. If no clock has been set on the element, the query will be forwarded upstream.

The `GstBaseSinkClass.set_caps()` function will be called when the subclass should configure itself to process a specific media type.

The `GstBaseSinkClass.start()` and `GstBaseSinkClass.stop()` virtual methods will be called when resources should be allocated. Any `GstBaseSinkClass.preroll()`, `GstBaseSinkClass.render()` and `GstBaseSinkClass.set_caps()` function will be called between the `GstBaseSinkClass.start()` and `GstBaseSinkClass.stop()` calls.

The `GstBaseSinkClass.event()` virtual method will be called when an event is received by GstBaseSink. Normally this method should only be overridden by very specific elements (such as file sinks) which need to handle the newsegment event specially.

The `GstBaseSinkClass.unlock()` method is called when the elements should unblock any blocking operations they perform in the `GstBaseSinkClass.render()` method. This is mostly useful when the `GstBaseSinkClass.render()` method performs a blocking write on a file descriptor, for example.

The “max-lateness” property affects how the sink deals with buffers that arrive too late in the sink. A buffer arrives too late in the sink when the presentation time (as a combination of the last segment, buffer timestamp and element base_time) plus the duration is before the current time of the clock. If the frame is later than max-lateness, the sink will drop the buffer without calling the render method. This feature is disabled if sync is disabled, the `GstBaseSinkClass.get_times()` method does not return a valid start time or max-lateness is set to -1 (the default). Subclasses can use `gst_base_sink_set_max_lateness()` to configure the max-lateness value.

The “qos” property will enable the quality-of-service features of the basesink which gather statistics about the real-time performance of the clock synchronisation. For each buffer received in the sink, statistics are gathered and a QOS event is sent upstream with these numbers. This information can then be used by upstream elements to reduce their processing rate, for example.

The “async” property can be used to instruct the sink to never perform an ASYNC state change. This feature is mostly usable when dealing with non-synchronized streams or sparse streams.

## Functions

### gst_base_sink_query_latency ()

    gboolean
    gst_base_sink_query_latency (GstBaseSink *sink,
                                 gboolean *live,
                                 gboolean *upstream_live,
                                 GstClockTime *min_latency,
                                 GstClockTime *max_latency);

Query the sink for the latency parameters. The latency will be queried from the upstream elements. `live` will be `TRUE` if `sink` is configured to synchronize against the clock. `upstream_live` will be `TRUE` if an upstream element is live.

If both `live` and `upstream_live` are `TRUE`, the sink will want to compensate for the latency introduced by the upstream elements by setting the `min_latency` to a strictly positive value.

This function is mostly used by subclasses.

#### Parameters

sink | the sink |
live | if the sink is live. | [out][allow-none]
upstream_live | if an upstream element is live. | [out][allow-none]
min_latency | the min latency of the upstream elements. | [out][allow-none]
max_latency | the max latency of the upstream elements. | [out][allow-none]

#### Returns

`TRUE` if the query succeeded.

### gst_base_sink_get_latency ()

    GstClockTime
    gst_base_sink_get_latency (GstBaseSink *sink);

Get the currently configured latency.

#### Parameters

sink | the sink |

#### Returns

The configured latency.

### gst_base_sink_do_preroll ()

    GstFlowReturn
    gst_base_sink_do_preroll (GstBaseSink *sink,
                              GstMiniObject *obj);

If the `sink` spawns its own thread for pulling buffers from upstream it should call this method after it has pulled a buffer. If the element needed to preroll, this function will perform the preroll and will then block until the element state is changed.

This function should be called with the PREROLL_LOCK held.

#### Parameters

sink | the sink |
obj | the mini object that caused the preroll. | [transfer none]

#### Returns

`GST_FLOW_OK` if the preroll completed and processing can continue. Any other return value should be returned from the render vmethod.

### gst_base_sink_wait ()

    GstFlowReturn
    gst_base_sink_wait (GstBaseSink *sink,
                        GstClockTime time,
                        GstClockTimeDiff *jitter);

This function will wait for preroll to complete and will then block until `time` is reached. It is usually called by subclasses that use their own internal synchronisation but want to let some synchronization (like EOS) be handled by the base class.

This function should only be called with the PREROLL_LOCK held (like when receiving an EOS event in the ::event vmethod or when handling buffers in ::render).

The `time` argument should be the running_time of when the timeout should happen and will be adjusted with any latency and offset configured in the sink.

#### Parameters

sink | the sink |
time | the running_time to be reached |
jitter | the jitter to be filled with time diff, or `NULL`. | [out][allow-none]

#### Returns

GstFlowReturn

### gst_base_sink_wait_preroll ()

    GstFlowReturn
    gst_base_sink_wait_preroll (GstBaseSink *sink);

If the `GstBaseSinkClass.render()` method performs its own synchronisation against the clock it must unblock when going from PLAYING to the PAUSED state and call this method before continuing to render the remaining data.

If the `GstBaseSinkClass.render()` method can block on something else than the clock, it must also be ready to unblock immediately on the `GstBaseSinkClass.unlock()` method and cause the `GstBaseSinkClass.render()` method to immediately call this function. In this case, the subclass must be prepared to continue rendering where it left off if this function returns `GST_FLOW_OK`.

This function will block until a state change to PLAYING happens (in which case this function returns `GST_FLOW_OK`) or the processing must be stopped due to a state change to READY or a FLUSH event (in which case this function returns `GST_FLOW_FLUSHING`).

This function should only be called with the PREROLL_LOCK held, like in the render function.

#### Parameters

sink | the sink |

#### Returns

`GST_FLOW_OK` if the preroll completed and processing can continue. Any other return value should be returned from the render vmethod.

### gst_base_sink_wait_clock ()

    GstClockReturn
    gst_base_sink_wait_clock (GstBaseSink *sink,
                              GstClockTime time,
                              GstClockTimeDiff *jitter);

This function will block until `time` is reached. It is usually called by subclasses that use their own internal synchronisation.

If `time` is not valid, no synchronisation is done and `GST_CLOCK_BADTIME` is returned. Likewise, if synchronisation is disabled in the element or there is no clock, no synchronisation is done and `GST_CLOCK_BADTIME` is returned.

This function should only be called with the PREROLL_LOCK held, like when receiving an EOS event in the `GstBaseSinkClass.event()` vmethod or when receiving a buffer in the `GstBaseSinkClass.render()` vmethod.

The `time` argument should be the running_time of when this method should return and is not adjusted with any latency or offset configured in the sink.

#### Parameters

sink | the sink |
time | the running_time to be reached |
jitter | the jitter to be filled with time diff, or `NULL`. | [out][allow-none]

#### Returns

GstClockReturn

### gst_base_sink_set_sync ()

    void
    gst_base_sink_set_sync (GstBaseSink *sink,
                            gboolean sync);

Configures `sink` to synchronize on the clock or not. When `sync` is `FALSE`, incoming samples will be played as fast as possible. If `sync` is `TRUE`, the timestamps of the incoming buffers will be used to schedule the exact render time of its contents.

#### Parameters

sink | the sink |
sync | the new sync value. |

### gst_base_sink_get_sync ()

    gboolean
    gst_base_sink_get_sync (GstBaseSink *sink);

Checks if `sink` is currently configured to synchronize against the clock.

#### Parameters

sink | the sink |

#### Returns

`TRUE` if the sink is configured to synchronize against the clock.

### gst_base_sink_set_max_lateness ()

    void
    gst_base_sink_set_max_lateness (GstBaseSink *sink,
                                    gint64 max_lateness);

Sets the new max lateness value to `max_lateness` . This value is used to decide if a buffer should be dropped or not based on the buffer timestamp and the current clock time. A value of -1 means an unlimited time.

#### Parameters

sink | the sink |
max_lateness | the new max lateness value. |

### gst_base_sink_get_max_lateness ()

    gint64
    gst_base_sink_get_max_lateness (GstBaseSink *sink);

Gets the max lateness value. See `gst_base_sink_set_max_lateness()` for more details.

#### Parameters

sink | the sink |

#### Returns

The maximum time in nanoseconds that a buffer can be late before it is dropped and not rendered. A value of -1 means an unlimited time.

### gst_base_sink_set_qos_enabled ()

    void
    gst_base_sink_set_qos_enabled (GstBaseSink *sink,
                                   gboolean enabled);

Configures `sink` to send Quality-of-Service events upstream.

#### Parameters

sink | the sink |
enabled | the new qos value. |

### gst_base_sink_is_qos_enabled ()

    gboolean
    gst_base_sink_is_qos_enabled (GstBaseSink *sink);

Checks if `sink` is currently configured to send Quality-of-Service events upstream.

#### Parameters

sink | the sink |

#### Returns

`TRUE` if the sink is configured to perform Quality-of-Service.

### gst_base_sink_set_async_enabled ()

    void
    gst_base_sink_set_async_enabled (GstBaseSink *sink,
                                     gboolean enabled);

Configures `sink` to perform all state changes asynchronously. When async is disabled, the sink will immediately go to PAUSED instead of waiting for a preroll buffer. This feature is useful if the sink does not synchronize against the clock or when it is dealing with sparse streams.

#### Parameters

sink | the sink |
enabled | the new async value. |

### gst_base_sink_is_async_enabled ()

    gboolean
    gst_base_sink_is_async_enabled (GstBaseSink *sink);

Checks if `sink` is currently configured to perform asynchronous state changes to PAUSED.

#### Parameters

sink | the sink |

#### Returns

`TRUE` if the sink is configured to perform asynchronous state changes.

### gst_base_sink_set_ts_offset ()

    void
    gst_base_sink_set_ts_offset (GstBaseSink *sink,
                                 GstClockTimeDiff offset);

Adjust the synchronisation of `sink` with `offset` . A negative value will render buffers earlier than their timestamp. A positive value will delay rendering. This function can be used to fix playback of badly timestamped buffers.

#### Parameters

sink | the sink |
offset | the new offset |

### gst_base_sink_get_ts_offset ()

    GstClockTimeDiff
    gst_base_sink_get_ts_offset (GstBaseSink *sink);

Get the synchronisation offset of `sink` .

#### Parameters

sink | the sink |

#### Returns

The synchronisation offset.

### gst_base_sink_set_render_delay ()

    void
    gst_base_sink_set_render_delay (GstBaseSink *sink,
                                    GstClockTime delay);

Set the render delay in `sink` to `delay` . The render delay is the time between actual rendering of a buffer and its synchronisation time. Some devices might delay media rendering which can be compensated for with this function.

After calling this function, this sink will report additional latency and other sinks will adjust their latency to delay the rendering of their media.

This function is usually called by subclasses.

#### Parameters

sink | a GstBaseSink |
delay | the new delay |

### gst_base_sink_get_render_delay ()

    GstClockTime
    gst_base_sink_get_render_delay (GstBaseSink *sink);

Get the render delay of `sink` . see `gst_base_sink_set_render_delay()` for more information about the render delay.

#### Parameters

sink | a GstBaseSink |

#### Returns

the render delay of `sink` .

### gst_base_sink_get_last_sample ()

    GstSample *
    gst_base_sink_get_last_sample (GstBaseSink *sink);

Get the last sample that arrived in the sink and was used for preroll or for rendering. This property can be used to generate thumbnails.

The GstCaps on the sample can be used to determine the type of the buffer.

Free-function: gst_sample_unref

#### Parameters

sink | the sink |

#### Returns

a GstSample. `gst_sample_unref()` after usage. This function returns `NULL` when no buffer has arrived in the sink yet or when the sink is not in PAUSED or PLAYING.

[transfer full][nullable]

### gst_base_sink_set_blocksize ()

    void
    gst_base_sink_set_blocksize (GstBaseSink *sink,
                                 guint blocksize);

Set the number of bytes that the sink will pull when it is operating in pull mode.

#### Parameters

sink | a GstBaseSink |
blocksize | the blocksize in bytes |

### gst_base_sink_get_blocksize ()

    guint
    gst_base_sink_get_blocksize (GstBaseSink *sink);

Get the number of bytes that the sink will pull when it is operating in pull mode.

#### Parameters

sink | a GstBaseSink |

#### Returns

the number of bytes `sink` will pull in pull mode.

### gst_base_sink_get_throttle_time ()

    guint64
    gst_base_sink_get_throttle_time (GstBaseSink *sink);

Get the time that will be inserted between frames to control the maximum buffers per second.

#### Parameters

sink | a GstBaseSink |

#### Returns

the number of nanoseconds `sink` will put between frames.

### gst_base_sink_set_throttle_time ()

    void
    gst_base_sink_set_throttle_time (GstBaseSink *sink,
                                     guint64 throttle);

Set the time that will be inserted between rendered buffers. This can be used to control the maximum buffers per second that the sink will render.

#### Parameters

sink | a GstBaseSink |
throttle | the throttle time in nanoseconds |

### gst_base_sink_set_max_bitrate ()

    void
    gst_base_sink_set_max_bitrate (GstBaseSink *sink,
                                   guint64 max_bitrate);

Set the maximum amount of bits per second that the sink will render.

#### Parameters

sink | a GstBaseSink |
max_bitrate | the max_bitrate in bits per second |

Since: 1.2

### gst_base_sink_get_max_bitrate ()

    guint64
    gst_base_sink_get_max_bitrate (GstBaseSink *sink);

Get the maximum amount of bits per second that the sink will render.

#### Parameters

sink | a GstBaseSink |

#### Returns

the maximum number of bits per second `sink` will render.

Since: 1.2

### gst_base_sink_set_last_sample_enabled ()

    void
    gst_base_sink_set_last_sample_enabled (GstBaseSink *sink,
                                           gboolean enabled);

Configures `sink` to store the last received sample in the last-sample property.

#### Parameters

sink | the sink |
enabled | the new enable-last-sample value. |

### gst_base_sink_is_last_sample_enabled ()

    gboolean
    gst_base_sink_is_last_sample_enabled (GstBaseSink *sink);

Checks if `sink` is currently configured to store the last received sample in the last-sample property.

#### Parameters

sink | the sink |

#### Returns

`TRUE` if the sink is configured to store the last received sample.

### GST_BASE_SINK_PAD()

    #define GST_BASE_SINK_PAD(obj)          (GST_BASE_SINK_CAST (obj)->sinkpad)

Gives the pointer to the GstPad object of the element.

#### Parameters

obj | base sink instance |

### GST_BASE_SINK_GET_PREROLL_COND()

    #define GST_BASE_SINK_GET_PREROLL_COND(obj)   (&GST_BASE_SINK_CAST(obj)->preroll_cond)

### GST_BASE_SINK_GET_PREROLL_LOCK()

    #define GST_BASE_SINK_GET_PREROLL_LOCK(obj)   (&GST_BASE_SINK_CAST(obj)->preroll_lock)

### GST_BASE_SINK_PREROLL_BROADCAST()

    #define GST_BASE_SINK_PREROLL_BROADCAST(obj)  g_cond_broadcast (GST_BASE_SINK_GET_PREROLL_COND (obj));

### GST_BASE_SINK_PREROLL_LOCK()

    #define GST_BASE_SINK_PREROLL_LOCK(obj)       (g_mutex_lock(GST_BASE_SINK_GET_PREROLL_LOCK(obj)))

### GST_BASE_SINK_PREROLL_SIGNAL()

    #define GST_BASE_SINK_PREROLL_SIGNAL(obj)     g_cond_signal (GST_BASE_SINK_GET_PREROLL_COND (obj));

### GST_BASE_SINK_PREROLL_TRYLOCK()

    #define GST_BASE_SINK_PREROLL_TRYLOCK(obj)    (g_mutex_trylock(GST_BASE_SINK_GET_PREROLL_LOCK(obj)))

### GST_BASE_SINK_PREROLL_UNLOCK()

    #define GST_BASE_SINK_PREROLL_UNLOCK(obj)     (g_mutex_unlock(GST_BASE_SINK_GET_PREROLL_LOCK(obj)))

### GST_BASE_SINK_PREROLL_WAIT()

    #define             GST_BASE_SINK_PREROLL_WAIT(obj)

### GST_BASE_SINK_PREROLL_WAIT_UNTIL()

    #define             GST_BASE_SINK_PREROLL_WAIT_UNTIL(obj, end_time)

## Types and Values

### struct GstBaseSink

    struct GstBaseSink;

The opaque GstBaseSink data structure.

### struct GstBaseSinkClass

    struct GstBaseSinkClass {
      GstElementClass parent_class;

      /* get caps from subclass */
      GstCaps*      (*get_caps)     (GstBaseSink *sink, GstCaps *filter);
      /* notify subclass of new caps */
      gboolean      (*set_caps)     (GstBaseSink *sink, GstCaps *caps);

      /* fixate sink caps during pull-mode negotiation */
      GstCaps *     (*fixate)       (GstBaseSink *sink, GstCaps *caps);
      /* start or stop a pulling thread */
      gboolean      (*activate_pull)(GstBaseSink *sink, gboolean active);

      /* get the start and end times for syncing on this buffer */
      void          (*get_times)    (GstBaseSink *sink, GstBuffer *buffer,
                                     GstClockTime *start, GstClockTime *end);

      /* propose allocation parameters for upstream */
      gboolean      (*propose_allocation)   (GstBaseSink *sink, GstQuery *query);

      /* start and stop processing, ideal for opening/closing the resource */
      gboolean      (*start)        (GstBaseSink *sink);
      gboolean      (*stop)         (GstBaseSink *sink);

      /* unlock any pending access to the resource. subclasses should unlock
       * any function ASAP. */
      gboolean      (*unlock)       (GstBaseSink *sink);
      /* Clear a previously indicated unlock request not that unlocking is
       * complete. Sub-classes should clear any command queue or indicator they
       * set during unlock */
      gboolean      (*unlock_stop)  (GstBaseSink *sink);

      /* notify subclass of query */
      gboolean      (*query)        (GstBaseSink *sink, GstQuery *query);

      /* notify subclass of event */
      gboolean      (*event)        (GstBaseSink *sink, GstEvent *event);
      /* wait for eos or gap, subclasses should chain up to parent first */
      GstFlowReturn (*wait_event)   (GstBaseSink *sink, GstEvent *event);

      /* notify subclass of buffer or list before doing sync */
      GstFlowReturn (*prepare)      (GstBaseSink *sink, GstBuffer *buffer);
      GstFlowReturn (*prepare_list) (GstBaseSink *sink, GstBufferList *buffer_list);

      /* notify subclass of preroll buffer or real buffer */
      GstFlowReturn (*preroll)      (GstBaseSink *sink, GstBuffer *buffer);
      GstFlowReturn (*render)       (GstBaseSink *sink, GstBuffer *buffer);
      /* Render a BufferList */
      GstFlowReturn (*render_list)  (GstBaseSink *sink, GstBufferList *buffer_list);
    };

Subclasses can override any of the available virtual methods or not, as needed. At the minimum, the `render` method should be overridden to output/present buffers.

#### Members

`get_caps` () | Called to get sink pad caps from the subclass |
`set_caps` () | Notify subclass of changed caps |
`fixate` () | Only useful in pull mode. Implement if you have ideas about what should be the default values for the caps you support. |
`activate_pull` () | Subclasses should override this when they can provide an alternate method of spawning a thread to drive the pipeline in pull mode. Should start or stop the pulling thread, depending on the value of the "active" argument. Called after actually activating the sink pad in pull mode. The default implementation starts a task on the sink pad. |
`get_times` () | Called to get the start and end times for synchronising the passed buffer to the clock |
`propose_allocation` () | configure the allocation query |
`start` () | Start processing. Ideal for opening resources in the subclass |
`stop` () | Stop processing. Subclasses should use this to close resources. |
`unlock` () | Unlock any pending access to the resource. Subclasses should unblock any blocked function ASAP and call `gst_base_sink_wait_preroll()` |
`unlock_stop` () | Clear the previous unlock request. Subclasses should clear any state they set during `GstBaseSinkClass.unlock()`, and be ready to continue where they left off after `gst_base_sink_wait_preroll()`, `gst_base_sink_wait()` or `gst_wait_sink_wait_clock()` return or `GstBaseSinkClass.render()` is called again. |
`query` () | perform a GstQuery on the element. |
`event` () | Override this to handle events arriving on the sink pad |
`wait_event` () | Override this to implement custom logic to wait for the event time (for events like EOS and GAP). Subclasses should always first chain up to the default implementation. |
`prepare` () | Called to prepare the buffer for `render` and `preroll` . This function is called before synchronisation is performed. |
`prepare_list` () | Called to prepare the buffer list for `render_list` . This function is called before synchronisation is performed. |
`preroll` () | Called to present the preroll buffer if desired. |
`render` () | Called when a buffer should be presented or output, at the correct moment if the GstBaseSink has been set to sync to the clock. |
`render_list` () | Same as `render` but used with buffer lists instead of buffers. |

## Property Details

### The `“async”` property

      “async”                    gboolean

If set to `TRUE`, the basesink will perform asynchronous state changes. When set to `FALSE`, the sink will not signal the parent when it prerolls. Use this option when dealing with sparse streams or when synchronisation is not required.

Flags: Read / Write

Default value: TRUE

### The `“blocksize”` property

      “blocksize”                guint

The amount of bytes to pull when operating in pull mode.

Flags: Read / Write

Default value: 4096

### The `“enable-last-sample”` property

      “enable-last-sample”       gboolean

Enable the last-sample property. If `FALSE`, basesink doesn't keep a reference to the last buffer arrived and the last-sample property is always set to `NULL`. This can be useful if you need buffers to be released as soon as possible, eg. if you're using a buffer pool.

Flags: Read / Write

Default value: TRUE

### The `“last-sample”` property

      “last-sample”              GstSample *

The last buffer that arrived in the sink and was used for preroll or for rendering. This property can be used to generate thumbnails. This property can be `NULL` when the sink has not yet received a buffer.

Flags: Read

### The `“max-bitrate”` property

      “max-bitrate”              guint64

Control the maximum amount of bits that will be rendered per second. Setting this property to a value bigger than 0 will make the sink delay rendering of the buffers when it would exceed to max-bitrate.

Flags: Read / Write

Default value: 0

Since: 1.2

### The `“max-lateness”` property

      “max-lateness”             gint64

Maximum number of nanoseconds that a buffer can be late before it is dropped (-1 unlimited).

Flags: Read / Write

Allowed values: >= -1

Default value: -1

### The `“qos”` property

      “qos”                      gboolean

Generate Quality-of-Service events upstream.

Flags: Read / Write

Default value: FALSE

### The `“render-delay”` property

      “render-delay”             guint64

The additional delay between synchronisation and actual rendering of the media. This property will add additional latency to the device in order to make other sinks compensate for the delay.

Flags: Read / Write

Default value: 0

### The `“sync”` property

      “sync”                     gboolean

Sync on the clock.

Flags: Read / Write

Default value: TRUE

### The `“throttle-time”` property

      “throttle-time”            guint64

The time to insert between buffers. This property can be used to control the maximum amount of buffers per second to render. Setting this property to a value bigger than 0 will make the sink create THROTTLE QoS events.

Flags: Read / Write

Default value: 0

### The `“ts-offset”` property

      “ts-offset”                gint64

Controls the final synchronisation, a negative value will render the buffer earlier while a positive value delays playback. This property can be used to fix synchronisation in bad files.

Flags: Read / Write

Default value: 0

## See Also

GstBaseTransform, GstBaseSrc