Struct gstreamer_base::BaseSink[][src]

pub struct BaseSink(_);
Expand description

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 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, BaseSink 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 property::BaseSink::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 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 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.

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 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 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 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 property::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 GstBaseSinkClass::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 property::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 property::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.

This is an Abstract Base Class, you cannot instantiate it.

Implements

BaseSinkExt, gst::prelude::ElementExt, gst::prelude::ObjectExt, trait@glib::ObjectExt, BaseSinkExtManual

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Override the virtual methods of this class for the given subclass and do other class initialization. Read more

Instance specific initialization. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Upcasts an object to a superclass or interface T. Read more

Upcasts an object to a reference of its superclass or interface T. Read more

Tries to downcast to a subclass or interface implementor T. Read more

Tries to downcast to a reference of its subclass or interface implementor T. Read more

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Casts to T unconditionally. Read more

Casts to &T unconditionally. Read more

Abort the state change of the element. This function is used by elements that do asynchronous state changes and find out something is wrong. Read more

Adds a pad (link point) to self. pad’s parent will be set to self; see GstObjectExt::set_parent() for refcounting information. Read more

Perform transition on self. Read more

Commit the state change of the element and proceed to the next pending state if any. This function is used by elements that do asynchronous state changes. The core will normally call this method automatically when an element returned StateChangeReturn::Success from the state change function. Read more

This is supported on crate feature v1_14 only.
This is supported on crate feature v1_14 only.
This is supported on crate feature v1_14 only.
This is supported on crate feature v1_20 only.
This is supported on crate feature v1_10 only.
This is supported on crate feature v1_10 only.
This is supported on crate feature v1_10 only.
This is supported on crate feature v1_10 only.
This is supported on crate feature v1_10 only.
This is supported on crate feature v1_10 only.

Performs the conversion.

Attach the ControlBinding to the object. If there already was a ControlBinding for this property it will be replaced. Read more

A default error function that uses g_printerr() to display the error message and the optional debug string.. Read more

Gets the corresponding ControlBinding for the property. This should be unreferenced again after use. Read more

Obtain the control-rate for this self. Audio processing Element objects will use this rate to sub-divide their processing loop and call sync_values() in between. The length of the processing segment should be up to control-rate nanoseconds. Read more

Returns a copy of the name of self. Caller should g_free() the return value after usage. For a nameless object, this returns None, which you can safely g_free() as well. Read more

Returns the parent of self. This function increases the refcount of the parent object so you should gst_object_unref() it after usage. Read more

Generates a string describing the path of self in the object hierarchy. Only useful (or used) for debugging. Read more

Gets the value for the given controlled property at the requested time. Read more

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Emit signal with details by signal id.

Emit signal by it’s name.

Same as emit but takes Value for the arguments.

Same as emit_by_name but takes Value for the arguments.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.