gstbase.base_sink
Module for [BaseSink] class
Types 3
#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:
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.types.StateChangeReturn.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.types.CLOCK_TIME_NONE] for the start time, no synchronisation will be done. Synchronisation can be disabled entirely by setting the object #GstBaseSink: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 [gstbase.base_sink.BaseSink.waitPreroll] 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.types.EventType.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.types.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 #GstBaseSink: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 [gstbase.base_sink.BaseSink.setMaxLateness] to configure the max-lateness value.
The #GstBaseSink: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 #GstBaseSink: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.
BaseSinkGidBuilder builder()Get builder for [gstbase.base_sink.BaseSink] Returns: New builder objectbool async() @propertyGet `async` property. Returns: 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 de...void async(bool propval) @propertySet `async` property. Params: propval = 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 optio...uint blocksize() @propertyGet `blocksize` property. Returns: The amount of bytes to pull when operating in pull mode.void blocksize(uint propval) @propertySet `blocksize` property. Params: propval = The amount of bytes to pull when operating in pull mode.bool enableLastSample() @propertyGet `enableLastSample` property. Returns: 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....void enableLastSample(bool propval) @propertySet `enableLastSample` property. Params: propval = 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...gst.sample.Sample lastSample() @propertyGet `lastSample` property. Returns: 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 w...ulong maxBitrate() @propertyGet `maxBitrate` property. Returns: 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 buf...void maxBitrate(ulong propval) @propertySet `maxBitrate` property. Params: propval = 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 o...long maxLateness() @propertyvoid maxLateness(long propval) @propertyulong processingDeadline() @propertyGet `processingDeadline` property. Returns: Maximum amount of time (in nanoseconds) that the pipeline can take for processing the buffer. This is added to the latency of live pipelines.void processingDeadline(ulong propval) @propertySet `processingDeadline` property. Params: propval = Maximum amount of time (in nanoseconds) that the pipeline can take for processing the buffer. This is added to the latency of live pipelines.bool qos() @propertyvoid qos(bool propval) @propertyulong renderDelay() @propertyGet `renderDelay` property. Returns: 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 s...void renderDelay(ulong propval) @propertySet `renderDelay` property. Params: propval = The additional delay between synchronisation and actual rendering of the media. This property will add additional latency to the device in order to mak...gst.structure.Structure stats() @propertyGet `stats` property. Returns: Various #GstBaseSink statistics. This property returns a #GstStructure with name `application/x-gst-base-sink-stats` with the following fields:bool sync() @propertyvoid sync(bool propval) @propertyulong throttleTime() @propertyGet `throttleTime` property. Returns: 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 b...void throttleTime(ulong propval) @propertySet `throttleTime` property. Params: propval = 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 ...long tsOffset() @propertyGet `tsOffset` property. Returns: 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 synchr...void tsOffset(long propval) @propertySet `tsOffset` property. Params: propval = Controls the final synchronisation, a negative value will render the buffer earlier while a positive value delays playback. This property can be used to f...gst.types.FlowReturn doPreroll(gst.mini_object.MiniObject 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...uint getBlocksize()Get the number of bytes that the sink will pull when it is operating in pull mode. Returns: the number of bytes sink will pull in pull mode.bool getDropOutOfSegment()Checks if sink is currently configured to drop buffers which are outside the current segment Returns: true if the sink is configured to drop buffers outside the current segment.gst.sample.Sample getLastSample()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.gst.types.ClockTime getLatency()Get the currently configured latency. Returns: The configured latency.ulong getMaxBitrate()Get the maximum amount of bits per second that the sink will render. Returns: the maximum number of bits per second sink will render.long getMaxLateness()Gets the max lateness value. See [gstbase.base_sink.BaseSink.setMaxLateness] for more details. Returns: The maximum time in nanoseconds that a buffer can be late before it is dropped and not render...gst.types.ClockTime getProcessingDeadline()Get the processing deadline of sink. see [gstbase.base_sink.BaseSink.setProcessingDeadline] for more information about the processing deadline. Returns: the processing deadlinegst.types.ClockTime getRenderDelay()Get the render delay of sink. see [gstbase.base_sink.BaseSink.setRenderDelay] for more information about the render delay. Returns: the render delay of sink.gst.structure.Structure getStats()Return various #GstBaseSink statistics. This function returns a #GstStructure with name `application/x-gst-base-sink-stats` with the following fields:bool getSync()Checks if sink is currently configured to synchronize against the clock. Returns: true if the sink is configured to synchronize against the clock.ulong getThrottleTime()Get the time that will be inserted between frames to control the maximum buffers per second. Returns: the number of nanoseconds sink will put between frames.gst.types.ClockTimeDiff getTsOffset()Get the synchronisation offset of sink. Returns: The synchronisation offset.bool isAsyncEnabled()Checks if sink is currently configured to perform asynchronous state changes to PAUSED. Returns: true if the sink is configured to perform asynchronous state changes.bool isLastSampleEnabled()Checks if sink is currently configured to store the last received sample in the last-sample property. Returns: true if the sink is configured to store the last received sample.bool isQosEnabled()Checks if sink is currently configured to send Quality-of-Service events upstream. Returns: true if the sink is configured to perform Quality-of-Service.bool queryLatency(out bool live, out bool upstreamLive, out gst.types.ClockTime minLatency, out gst.types.ClockTime maxLatency)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 tr...void setAsyncEnabled(bool 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 si...void setBlocksize(uint blocksize)Set the number of bytes that the sink will pull when it is operating in pull mode.void setDropOutOfSegment(bool dropOutOfSegment)Configure sink to drop buffers which are outside the current segmentvoid setLastSampleEnabled(bool enabled)Configures sink to store the last received sample in the last-sample property.void setMaxBitrate(ulong maxBitrate)Set the maximum amount of bits per second that the sink will render.void setMaxLateness(long maxLateness)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 u...void setProcessingDeadline(gst.types.ClockTime processingDeadline)Maximum amount of time (in nanoseconds) that the pipeline can take for processing the buffer. This is added to the latency of live pipelines.void setQosEnabled(bool enabled)Configures sink to send Quality-of-Service events upstream.void setRenderDelay(gst.types.ClockTime 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 compensa...void setSync(bool 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 ...void setThrottleTime(ulong 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.void setTsOffset(gst.types.ClockTimeDiff 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 o...gst.types.FlowReturn wait(gst.types.ClockTime time, out gst.types.ClockTimeDiff 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 synchr...gst.types.ClockReturn waitClock(gst.types.ClockTime time, out gst.types.ClockTimeDiff jitter)This function will block until time is reached. It is usually called by subclasses that use their own internal synchronisation.gst.types.FlowReturn waitPreroll()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 rend...T async(bool propval)Set `async` property. Params: propval = 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 optio...T blocksize(uint propval)Set `blocksize` property. Params: propval = The amount of bytes to pull when operating in pull mode. Returns: Builder instance for fluent chainingT enableLastSample(bool propval)Set `enableLastSample` property. Params: propval = 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...T maxBitrate(ulong propval)Set `maxBitrate` property. Params: propval = 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 o...T maxLateness(long propval)T processingDeadline(ulong propval)Set `processingDeadline` property. Params: propval = Maximum amount of time (in nanoseconds) that the pipeline can take for processing the buffer. This is added to the latency of live pipelines. Re...T qos(bool propval)T renderDelay(ulong propval)Set `renderDelay` property. Params: propval = The additional delay between synchronisation and actual rendering of the media. This property will add additional latency to the device in order to mak...T sync(bool propval)T throttleTime(ulong propval)Set `throttleTime` property. Params: propval = 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 ...T tsOffset(long propval)Set `tsOffset` property. Params: propval = Controls the final synchronisation, a negative value will render the buffer earlier while a positive value delays playback. This property can be used to f...