Struct gstreamer_base::BaseSink [−]
pub struct BaseSink(_, _);
BaseSink is the base class for sink elements in GStreamer, such as
xvimagesink or filesink. It is a layer on top of gst::Element that provides a
simplified interface to plugin writers. BaseSink 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 gst::Element or to set functions on pads, because the
BaseSink infrastructure should be sufficient.
BaseSink provides support for exactly one sink pad, which should be
named "sink". A sink implementation (subclass of BaseSink) 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>");
}
BaseSink will handle the prerolling correctly. This means that it will
return gst::StateChangeReturn::Async from a state change to PAUSED until the first
buffer arrives in this element. The base class will call the
BaseSinkClass.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, BaseSink will synchronise on the
clock using the times returned from BaseSinkClass.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
BaseSink:sync property to false.
After synchronisation the virtual method BaseSinkClass.render() will be
called. Subclasses should minimally implement this method.
Subclasses that synchronise on the clock in the BaseSinkClass.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 BaseSinkExt::wait_preroll to perform the
blocking wait.
Upon receiving the EOS event in the PLAYING state, BaseSink will wait
for the clock to reach the time indicated by the stop time of the last
BaseSinkClass.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.
BaseSink will internally use the gst::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.
BaseSink 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 BaseSinkClass.set_caps() function will be called when the subclass
should configure itself to process a specific media type.
The BaseSinkClass.start() and BaseSinkClass.stop() virtual methods
will be called when resources should be allocated. Any
BaseSinkClass.preroll(), BaseSinkClass.render() and
BaseSinkClass.set_caps() function will be called between the
BaseSinkClass.start() and BaseSinkClass.stop() calls.
The BaseSinkClass.event() virtual method will be called when an event is
received by BaseSink. Normally this method should only be overridden by
very specific elements (such as file sinks) which need to handle the
newsegment event specially.
The BaseSinkClass.unlock() method is called when the elements should
unblock any blocking operations they perform in the
BaseSinkClass.render() method. This is mostly useful when the
BaseSinkClass.render() method performs a blocking write on a file
descriptor, for example.
The BaseSink: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
BaseSinkClass.get_times() method does not return a valid start time or
max-lateness is set to -1 (the default).
Subclasses can use BaseSinkExt::set_max_lateness to configure the
max-lateness value.
The BaseSink: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 BaseSink: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.
Implements
BaseSinkExt, gst::ElementExt, gst::ObjectExt, glib::object::ObjectExt
Trait Implementations
impl Clone for BaseSink
impl Clone for BaseSinkfn clone(&self) -> BaseSink
fn clone(&self) -> BaseSinkReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Hash for BaseSink
impl Hash for BaseSinkfn hash<__H: Hasher>(&self, state: &mut __H)
fn hash<__H: Hasher>(&self, state: &mut __H)Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl Ord for BaseSink
impl Ord for BaseSinkfn cmp(&self, other: &BaseSink) -> Ordering
fn cmp(&self, other: &BaseSink) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl StaticType for BaseSink
impl StaticType for BaseSinkfn static_type() -> Type
fn static_type() -> TypeReturns the type identifier of Self.
impl<T: IsA<Object>> PartialEq<T> for BaseSink
impl<T: IsA<Object>> PartialEq<T> for BaseSinkfn eq(&self, other: &T) -> bool
fn eq(&self, other: &T) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl Eq for BaseSink
impl Eq for BaseSinkimpl<T: IsA<Object>> PartialOrd<T> for BaseSink
impl<T: IsA<Object>> PartialOrd<T> for BaseSinkfn partial_cmp(&self, other: &T) -> Option<Ordering>
fn partial_cmp(&self, other: &T) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn lt(&self, other: &Rhs) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Debug for BaseSink
impl Debug for BaseSinkimpl IsA<Element> for BaseSink
impl IsA<Element> for BaseSinkimpl IsA<Object> for BaseSink
impl IsA<Object> for BaseSinkimpl IsA<Object> for BaseSink
impl IsA<Object> for BaseSinkimpl Send for BaseSink[src]
impl Send for BaseSinkimpl Sync for BaseSink[src]
impl Sync for BaseSink