Struct gst::Bin [−][src]
pub struct Bin { /* fields omitted */ }
GstBin is an element that can contain other GstElement, allowing them to be managed as a group. Pads from the child elements can be ghosted to the bin, see GstGhostPad. This makes the bin look like any other elements and enables creation of higher-level abstraction elements.
A new GstBin is created with gst_bin_new(). Use a GstPipeline instead if you want to create a toplevel bin because a normal bin doesn't have a bus or handle clock distribution of its own.
After the bin has been created you will typically add elements to it with gst_bin_add(). You can remove elements with gst_bin_remove().
An element can be retrieved from a bin with gst_bin_get_by_name(), using the elements name. gst_bin_get_by_name_recurse_up() is mainly used for internal purposes and will query the parent bins when the element is not found in the current bin.
An iterator of elements in a bin can be retrieved with gst_bin_iterate_elements(). Various other iterators exist to retrieve the elements in a bin.
gst_object_unref() is used to drop your reference to the bin.
The “element-added” signal is fired whenever a new element is added to the bin. Likewise the “element-removed” signal is fired whenever an element is removed from the bin. Notes
A GstBin internally intercepts every GstMessage posted by its children and implements the following default behaviour for each of them:
GST_MESSAGE_EOS
This message is only posted by sinks in the PLAYING state. If all sinks posted the EOS message, this bin will post and EOS message upwards.
GST_MESSAGE_SEGMENT_START
just collected and never forwarded upwards. The messages are used to decide when all elements have completed playback of their segment.
GST_MESSAGE_SEGMENT_DONE
Is posted by GstBin when all elements that posted a SEGMENT_START have posted a SEGMENT_DONE.
GST_MESSAGE_DURATION_CHANGED
Is posted by an element that detected a change in the stream duration. The default bin behaviour is to clear any cached duration values so that the next duration query will perform a full duration recalculation. The duration change is posted to the application so that it can refetch the new duration with a duration query. Note that these messages can be posted before the bin is prerolled, in which case the duration query might fail.
GST_MESSAGE_CLOCK_LOST
This message is posted by an element when it can no longer provide a clock. The default bin behaviour is to check if the lost clock was the one provided by the bin. If so and the bin is currently in the PLAYING state, the message is forwarded to the bin parent. This message is also generated when a clock provider is removed from the bin. If this message is received by the application, it should PAUSE the pipeline and set it back to PLAYING to force a new clock distribution.
GST_MESSAGE_CLOCK_PROVIDE
This message is generated when an element can provide a clock. This mostly happens when a new clock provider is added to the bin. The default behaviour of the bin is to mark the currently selected clock as dirty, which will perform a clock recalculation the next time the bin is asked to provide a clock. This message is never sent tot the application but is forwarded to the parent of the bin.
OTHERS
posted upwards.
A GstBin implements the following default behaviour for answering to a GstQuery:
GST_QUERY_DURATION
If the query has been asked before with the same format and the bin is a toplevel bin (ie. has no parent), use the cached previous value. If no previous value was cached, the query is sent to all sink elements in the bin and the MAXIMUM of all values is returned. If the bin is a toplevel bin the value is cached. If no sinks are available in the bin, the query fails.
GST_QUERY_POSITION
The query is sent to all sink elements in the bin and the MAXIMUM of all values is returned. If no sinks are available in the bin, the query fails.
OTHERS
the query is forwarded to all sink elements, the result of the first sink that answers the query successfully is returned. If no sink is in the bin, the query fails.
A GstBin will by default forward any event sent to it to all sink elements. If all the sinks return TRUE, the bin will also return TRUE, else FALSE is returned. If no sinks are in the bin, the event handler will return TRUE.
Methods
impl Bin
[src]
impl Bin
pub fn new(name: &str) -> Option<Bin>
[src]
pub fn new(name: &str) -> Option<Bin>
Creates a new bin with the given name.
pub unsafe fn new_from_gst_bin(element: *mut GstBin) -> Option<Bin>
[src]
pub unsafe fn new_from_gst_bin(element: *mut GstBin) -> Option<Bin>
Creates a new bin from an already existing raw pointer to a GstBin. The passed element has to be fully referenced
pub fn add<E: Into<Element>>(&mut self, element: E) -> bool
[src]
pub fn add<E: Into<Element>>(&mut self, element: E) -> bool
Adds the given element to the bin. Sets the element's parent, and thus adds a reference.
If the element's pads are linked to other pads, the pads will be unlinked before the element is added to the bin.
When you add an element to an already-running pipeline, you will have to take care to set the state of the newly-added element to the desired state (usually PLAYING or PAUSED, same you set the pipeline to originally) with Element::set_state(), or use gst_element_sync_state_with_parent(). The bin or pipeline will not take care of this for you.
pub fn add_and_link<E: Into<Element>>(&mut self, src: E, sink: E) -> bool
[src]
pub fn add_and_link<E: Into<Element>>(&mut self, src: E, sink: E) -> bool
pub fn add_many(&mut self, elements: Vec<Element>) -> bool
[src]
pub fn add_many(&mut self, elements: Vec<Element>) -> bool
pub fn add_and_link_many(&mut self, elements: Vec<Element>) -> bool
[src]
pub fn add_and_link_many(&mut self, elements: Vec<Element>) -> bool
pub fn remove(&mut self, element: &Element) -> bool
[src]
pub fn remove(&mut self, element: &Element) -> bool
Remove the element from its associated bin.
If the element's pads are linked to other pads, the pads will be unlinked before the element is removed from the bin.
pub fn get_by_name(&self, name: &str) -> Option<Element>
[src]
pub fn get_by_name(&self, name: &str) -> Option<Element>
Get the element with the given name from this bin.
Returns None if no element with the given name is found in the bin.
pub fn get_by_name_recurse_up(&self, name: &str) -> Option<Element>
[src]
pub fn get_by_name_recurse_up(&self, name: &str) -> Option<Element>
Gets the element with the given name from this bin. If the element is not found, a recursion is performed on the parent bin.
Returns None if no element with the given name is found in the bin.
ⓘImportant traits for Iter<I>pub fn iter(&self) -> Iter<Element>
[src]
pub fn iter(&self) -> Iter<Element>
ⓘImportant traits for Iter<I>pub fn iter_recurse(&self) -> Iter<Element>
[src]
pub fn iter_recurse(&self) -> Iter<Element>
pub fn recalculate_latency(&mut self) -> bool
[src]
pub fn recalculate_latency(&mut self) -> bool
Query bin for the current latency using and reconfigures this latency to all the elements with a LATENCY event.
This method is typically called on the pipeline when a GST_MESSAGE_LATENCY is posted on the bus.
This function simply emits the 'do-latency' signal so any custom latency calculations will be performed.
pub fn set_async_handling(&mut self, async: bool)
[src]
pub fn set_async_handling(&mut self, async: bool)
If set to true, the bin will handle asynchronous state changes. This should be used only if the bin subclass is modifying the state of its children on its own
pub fn set_message_forward(&mut self, forward: bool)
[src]
pub fn set_message_forward(&mut self, forward: bool)
Forward all children messages, even those that would normally be filtered by the bin. This can be interesting when one wants to be notified of the EOS state of individual elements, for example.
The messages are converted to an ELEMENT message with the bin as the source. The structure of the message is named 'GstBinForwarded' and contains a field named 'message' of type GST_TYPE_MESSAGE that contains the original forwarded message.
pub unsafe fn gst_bin(&self) -> *const GstBin
[src]
pub unsafe fn gst_bin(&self) -> *const GstBin
Returns a const raw pointer to the internal GstElement
pub unsafe fn gst_bin_mut(&mut self) -> *mut GstBin
[src]
pub unsafe fn gst_bin_mut(&mut self) -> *mut GstBin
Returns a mut raw pointer to the internal GstElement
Methods from Deref<Target = Element>
pub fn link(&mut self, dst: &mut Element) -> bool
[src]
pub fn link(&mut self, dst: &mut Element) -> bool
Links this element to dest . The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. Such pads need to be released manually when unlinking. If multiple links are possible, only one is established.
Make sure you have added your elements to a bin or pipeline with Bin::add() before trying to link them.
returns true if the elements could be linked, false otherwise.
pub fn link_filtered(&mut self, dst: &mut Element, filter: &Caps) -> bool
[src]
pub fn link_filtered(&mut self, dst: &mut Element, filter: &Caps) -> bool
Links src to dest using the given caps as filtercaps. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. If multiple links are possible, only one is established.
Make sure you have added your elements to a bin or pipeline with Bin::add() before trying to link them.
pub fn unlink(&mut self, dst: &mut Element)
[src]
pub fn unlink(&mut self, dst: &mut Element)
Unlinks all source pads of the this element with all sink pads of the sink element to which they are linked.
If the link has been made using Element::link(), it could have created a requestpad, which has to be released using gst_element_release_request_pad().
pub fn bus(&self) -> Option<Bus>
[src]
pub fn bus(&self) -> Option<Bus>
Returns the bus of the element. Note that only a Pipeline will provide a bus for the application.
pub fn set_name(&mut self, name: &str)
[src]
pub fn set_name(&mut self, name: &str)
Sets the name of the element
pub fn set_state(&mut self, state: GstState) -> GstStateChangeReturn
[src]
pub fn set_state(&mut self, state: GstState) -> GstStateChangeReturn
Sets the state of the element. This function will try to set the requested state by going through all the intermediary states and calling the class's state change function for each.
This function can return GST_STATE_CHANGE_ASYNC, in which case the element will perform the remainder of the state change asynchronously in another thread. An application can use get_state() to wait for the completion of the state change or it can wait for a GST_MESSAGE_ASYNC_DONE or GST_MESSAGE_STATE_CHANGED on the bus.
State changes to GST_STATE_READY or GST_STATE_NULL never return GST_STATE_CHANGE_ASYNC.
pub fn get_state(
&self,
timeout: GstClockTime
) -> (GstState, GstState, GstStateChangeReturn)
[src]
pub fn get_state(
&self,
timeout: GstClockTime
) -> (GstState, GstState, GstStateChangeReturn)
Gets the state of the element.
For elements that performed an ASYNC state change, as reported by set_state(), this function will block up to the specified timeout value for the state change to complete. If the element completes the state change or goes into an error, this function returns immediately with a return value of GST_STATE_CHANGE_SUCCESS or GST_STATE_CHANGE_FAILURE respectively.
For elements that did not return GST_STATE_CHANGE_ASYNC, this function returns the current and pending state immediately.
This function returns GST_STATE_CHANGE_NO_PREROLL if the element successfully changed its state but is not able to provide data yet. This mostly happens for live sources that only produce data in GST_STATE_PLAYING. While the state change return is equivalent to GST_STATE_CHANGE_SUCCESS, it is returned to the application to signal that some sink elements might not be able to complete their state change because an element is not producing data to complete the preroll. When setting the element to playing, the preroll will complete and playback will start. Returns
GST_STATE_CHANGE_SUCCESS if the element has no more pending state and the last state change succeeded, GST_STATE_CHANGE_ASYNC if the element is still performing a state change or GST_STATE_CHANGE_FAILURE if the last state change failed.
pub unsafe fn send_event(&mut self, event: *mut GstEvent) -> bool
[src]
pub unsafe fn send_event(&mut self, event: *mut GstEvent) -> bool
Sends an event to an element. If the element doesn't implement an event handler, the event will be pushed on a random linked sink pad for downstream events or a random linked source pad for upstream events.
This function takes ownership of the provided event so you should gst_event_ref() it if you want to reuse the event after this call.
pub fn seek_simple(
&mut self,
format: GstFormat,
flags: GstSeekFlags,
pos: i64
) -> bool
[src]
pub fn seek_simple(
&mut self,
format: GstFormat,
flags: GstSeekFlags,
pos: i64
) -> bool
Simple API to perform a seek on the given element, meaning it just seeks to the given position relative to the start of the stream. For more complex operations like segment seeks (e.g. for looping) or changing the playback rate or seeking relative to the last configured playback segment you should use gst_element_seek().
In a completely prerolled PAUSED or PLAYING pipeline, seeking is always guaranteed to return TRUE on a seekable media type or FALSE when the media type is certainly not seekable (such as a live stream).
Some elements allow for seeking in the READY state, in this case they will store the seek event and execute it when they are put to PAUSED. If the element supports seek in READY, it will always return true when it receives the event in the READY state.
pub fn seek(
&mut self,
rate: f64,
format: GstFormat,
flags: GstSeekFlags,
start_type: GstSeekType,
start: i64,
stop_type: GstSeekType,
stop: i64
) -> bool
[src]
pub fn seek(
&mut self,
rate: f64,
format: GstFormat,
flags: GstSeekFlags,
start_type: GstSeekType,
start: i64,
stop_type: GstSeekType,
stop: i64
) -> bool
Sends a seek event to an element. See gst_event_new_seek() for the details of the parameters. The seek event is sent to the element using send_event().
pub fn query_duration(&self, format: GstFormat) -> Option<i64>
[src]
pub fn query_duration(&self, format: GstFormat) -> Option<i64>
Queries an element (usually top-level pipeline or playbin element) for the total stream duration in nanoseconds. This query will only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application will receive an ASYNC_DONE message on the pipeline bus when that is the case.
If the duration changes for some reason, you will get a DURATION_CHANGED message on the pipeline bus, in which case you should re-query the duration using this function.
pub fn query_position(&self, format: GstFormat) -> Option<i64>
[src]
pub fn query_position(&self, format: GstFormat) -> Option<i64>
Queries an element (usually top-level pipeline or playbin element) for the stream position in nanoseconds. This will be a value between 0 and the stream duration (if the stream duration is known). This query will usually only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application will receive an ASYNC_DONE message on the pipeline bus when that is the case.
pub fn duration_ns(&self) -> Option<i64>
[src]
pub fn duration_ns(&self) -> Option<i64>
Shortcut for query_duration with format == TIME
pub fn duration_s(&self) -> Option<f64>
[src]
pub fn duration_s(&self) -> Option<f64>
Shortcut for query_duration with format == TIME and conversion to seconds
pub fn position_ns(&self) -> Option<i64>
[src]
pub fn position_ns(&self) -> Option<i64>
Shortcut for query_position with format == TIME
pub fn position_pct(&self) -> Option<f64>
[src]
pub fn position_pct(&self) -> Option<f64>
Shortcut for query_position with format == TIME and conversion to pct as 0..1
pub fn position_s(&self) -> Option<f64>
[src]
pub fn position_s(&self) -> Option<f64>
Shortcut for query_position with format == TIME and conversion to seconds
pub fn set_position_ns(&mut self, ns: i64) -> bool
[src]
pub fn set_position_ns(&mut self, ns: i64) -> bool
Shortcut for seek to a ceratin position in ns
pub fn set_position_s(&mut self, s: f64) -> bool
[src]
pub fn set_position_s(&mut self, s: f64) -> bool
Shortcut for seek to a ceratin position in secs
pub fn set_position_pct(&mut self, pct: f64) -> bool
[src]
pub fn set_position_pct(&mut self, pct: f64) -> bool
Shortcut for seek to a ceratin position in pcs as 0..1
pub fn set_speed(&mut self, speed: f64) -> bool
[src]
pub fn set_speed(&mut self, speed: f64) -> bool
Shortcut for seek to the current position but change in playback rate
pub fn set_null_state(&mut self) -> GstStateChangeReturn
[src]
pub fn set_null_state(&mut self) -> GstStateChangeReturn
shortcut to set_state with state == NULL
pub fn set_ready_state(&mut self) -> GstStateChangeReturn
[src]
pub fn set_ready_state(&mut self) -> GstStateChangeReturn
shortcut to set_state with state == READY
pub fn pause(&mut self) -> GstStateChangeReturn
[src]
pub fn pause(&mut self) -> GstStateChangeReturn
shortcut to set_state with state == PAUSED
pub fn play(&mut self) -> GstStateChangeReturn
[src]
pub fn play(&mut self) -> GstStateChangeReturn
shortcut to set_state with state == PLAYING
pub fn is_paused(&self) -> bool
[src]
pub fn is_paused(&self) -> bool
shortcut to query the state and returns state == PAUSED
pub fn is_playing(&self) -> bool
[src]
pub fn is_playing(&self) -> bool
shortcut to query the state and returns state == PLAYING
pub fn is_null_state(&self) -> bool
[src]
pub fn is_null_state(&self) -> bool
shortcut to query the state and returns state == NULL
pub fn is_ready_state(&self) -> bool
[src]
pub fn is_ready_state(&self) -> bool
shortcut to query the state and returns state == READY
pub fn static_pad(&mut self, name: &str) -> Option<Pad>
[src]
pub fn static_pad(&mut self, name: &str) -> Option<Pad>
pub unsafe fn gst_element(&self) -> *const GstElement
[src]
pub unsafe fn gst_element(&self) -> *const GstElement
Returns a const raw pointer to the internal GstElement
pub unsafe fn gst_element_mut(&mut self) -> *mut GstElement
[src]
pub unsafe fn gst_element_mut(&mut self) -> *mut GstElement
Returns a mutable raw pointer to the internal GstElement
Trait Implementations
impl Sync for Bin
[src]
impl Sync for Bin
impl Send for Bin
[src]
impl Send for Bin
impl AsRef<Element> for Bin
[src]
impl AsRef<Element> for Bin
impl AsMut<Element> for Bin
[src]
impl AsMut<Element> for Bin
impl From<Bin> for Element
[src]
impl From<Bin> for Element
impl Deref for Bin
[src]
impl Deref for Bin
type Target = Element
The resulting type after dereferencing.
fn deref(&self) -> &Element
[src]
fn deref(&self) -> &Element
Dereferences the value.
impl DerefMut for Bin
[src]
impl DerefMut for Bin
impl Transfer for Bin
[src]
impl Transfer for Bin
unsafe fn transfer(self) -> *mut GstElement
[src]
unsafe fn transfer(self) -> *mut GstElement
Consumes the current object and transfers ownership of the raw pointer Used to transfer ownership to ffi functions, should be used when an ffi function expects full transfer of an object to avoid the original object to be unreferenced in the process Read more
impl Reference for Bin
[src]
impl Reference for Bin
impl AsRef<Bin> for Pipeline
[src]
impl AsRef<Bin> for Pipeline
impl AsMut<Bin> for Pipeline
[src]
impl AsMut<Bin> for Pipeline
impl From<Pipeline> for Bin
[src]
impl From<Pipeline> for Bin