Struct gstreamer::Bus [−]
pub struct Bus(_, _);
The Bus
is an object responsible for delivering Message
packets in
a first-in first-out way from the streaming threads (see Task
) to the
application.
Since the application typically only wants to deal with delivery of these messages from one thread, the GstBus will marshall the messages between different threads. This is important since the actual streaming of media is done in another thread than the application.
The GstBus provides support for glib::Source
based notifications. This makes it
possible to handle the delivery in the glib mainloop.
The glib::Source
callback function Bus::async_signal_func
can be used to
convert all bus messages into signal emissions.
A message is posted on the bus with the Bus::post
method. With the
Bus::peek
and Bus::pop
methods one can look at or retrieve a
previously posted message.
The bus can be polled with the Bus::poll
method. This methods blocks
up to the specified timeout value until one of the specified messages types
is posted on the bus. The application can then Bus::pop
the messages
from the bus to handle them.
Alternatively the application can register an asynchronous bus function
using Bus::add_watch_full
or Bus::add_watch
. This function will
install a glib::Source
in the default glib main loop and will deliver messages
a short while after they have been posted. Note that the main loop should
be running for the asynchronous callbacks.
It is also possible to get messages from the bus without any thread
marshalling with the Bus::set_sync_handler
method. This makes it
possible to react to a message in the same thread that posted the
message on the bus. This should only be used if the application is able
to deal with messages from different threads.
Every Pipeline
has one bus.
Note that a Pipeline
will set its bus into flushing state when changing
from READY to NULL state.
Implements
Methods
impl Bus
[src]
impl Bus
pub fn new() -> Bus
[src]
pub fn new() -> Bus
pub fn add_signal_watch(&self)
[src]
pub fn add_signal_watch(&self)
Adds a bus signal watch to the default main context with the default priority
(G_PRIORITY_DEFAULT
). It is also possible to use a non-default
main context set up using glib::MainContext::push_thread_default
(before
one had to create a bus watch source and attach it to the desired main
context 'manually').
After calling this statement, the bus will emit the "message" signal for each message posted on the bus.
This function may be called multiple times. To clean up, the caller is
responsible for calling Bus::remove_signal_watch
as many times as this
function is called.
MT safe.
pub fn disable_sync_message_emission(&self)
[src]
pub fn disable_sync_message_emission(&self)
Instructs GStreamer to stop emitting the "sync-message" signal for this bus.
See Bus::enable_sync_message_emission
for more information.
In the event that multiple pieces of code have called
Bus::enable_sync_message_emission
, the sync-message emissions will only
be stopped after all calls to Bus::enable_sync_message_emission
were
"cancelled" by calling this function. In this way the semantics are exactly
the same as GstObjectExt::ref
that which calls enable should also call
disable.
MT safe.
pub fn enable_sync_message_emission(&self)
[src]
pub fn enable_sync_message_emission(&self)
Instructs GStreamer to emit the "sync-message" signal after running the bus's sync handler. This function is here so that code can ensure that they can synchronously receive messages without having to affect what the bin's sync handler is.
This function may be called multiple times. To clean up, the caller is
responsible for calling Bus::disable_sync_message_emission
as many times
as this function is called.
While this function looks similar to Bus::add_signal_watch
, it is not
exactly the same -- this function enables <emphasis>
synchronous</emphasis>
emission of
signals when messages arrive; Bus::add_signal_watch
adds an idle callback
to pop messages off the bus <emphasis>
asynchronously</emphasis>
. The sync-message signal
comes from the thread of whatever object posted the message; the "message"
signal is marshalled to the main thread via the main loop.
MT safe.
pub fn have_pending(&self) -> bool
[src]
pub fn have_pending(&self) -> bool
Check if there are pending messages on the bus that should be handled.
Returns
true
if there are messages on the bus to be handled, false
otherwise.
MT safe.
pub fn peek(&self) -> Option<Message>
[src]
pub fn peek(&self) -> Option<Message>
Peek the message on the top of the bus' queue. The message will remain on the bus' message queue. A reference is returned, and needs to be unreffed by the caller.
Returns
the Message
that is on the
bus, or None
if the bus is empty.
MT safe.
pub fn pop(&self) -> Option<Message>
[src]
pub fn pop(&self) -> Option<Message>
Get a message from the bus.
Returns
the Message
that is on the
bus, or None
if the bus is empty. The message is taken from
the bus and needs to be unreffed with gst_message_unref
after
usage.
MT safe.
pub fn post(&self, message: &Message) -> Result<(), BoolError>
[src]
pub fn post(&self, message: &Message) -> Result<(), BoolError>
Post a message on the given bus. Ownership of the message is taken by the bus.
message
the Message
to post
Returns
true
if the message could be posted, false
if the bus is flushing.
MT safe.
pub fn remove_signal_watch(&self)
[src]
pub fn remove_signal_watch(&self)
Removes a signal watch previously added with Bus::add_signal_watch
.
MT safe.
pub fn remove_watch(&self) -> bool
[src]
pub fn remove_watch(&self) -> bool
Removes an installed bus watch from self
.
Returns
true
on success or false
if self
has no event source.
pub fn set_flushing(&self, flushing: bool)
[src]
pub fn set_flushing(&self, flushing: bool)
If flushing
, flush out and unref any messages queued in the bus. Releases
references to the message origin objects. Will flush future messages until
Bus::set_flushing
sets flushing
to false
.
MT safe.
flushing
whether or not to flush the bus
pub fn timed_pop(&self, timeout: ClockTime) -> Option<Message>
[src]
pub fn timed_pop(&self, timeout: ClockTime) -> Option<Message>
Get a message from the bus, waiting up to the specified timeout.
If timeout
is 0, this function behaves like Bus::pop
. If timeout
is
GST_CLOCK_TIME_NONE
, this function will block forever until a message was
posted on the bus.
timeout
a timeout
Returns
the Message
that is on the
bus after the specified timeout or None
if the bus is empty
after the timeout expired. The message is taken from the bus
and needs to be unreffed with gst_message_unref
after usage.
MT safe.
pub fn connect_message<F: Fn(&Bus, &Message) + Send + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
pub fn connect_message<F: Fn(&Bus, &Message) + Send + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_sync_message<F: Fn(&Bus, &Message) + Send + Sync + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
pub fn connect_sync_message<F: Fn(&Bus, &Message) + Send + Sync + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_property_enable_async_notify<F: Fn(&Bus) + Send + Sync + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
pub fn connect_property_enable_async_notify<F: Fn(&Bus) + Send + Sync + 'static>(
&self,
f: F
) -> SignalHandlerId
impl Bus
[src]
impl Bus
pub fn add_signal_watch_full(&self, priority: Priority)
[src]
pub fn add_signal_watch_full(&self, priority: Priority)
Adds a bus signal watch to the default main context with the given priority
(e.g. G_PRIORITY_DEFAULT
). It is also possible to use a non-default main
context set up using glib::MainContext::push_thread_default
(before one had to create a bus watch source and attach it to the desired
main context 'manually').
After calling this statement, the bus will emit the "message" signal for each message posted on the bus when the main loop is running.
This function may be called multiple times. To clean up, the caller is
responsible for calling Bus::remove_signal_watch
as many times as this
function is called.
There can only be a single bus watch per bus, you must remove any signal watch before you can set another type of watch.
MT safe.
priority
The priority of the watch.
pub fn create_watch<'a, N: Into<Option<&'a str>>, F>(
&self,
name: N,
priority: Priority,
func: F
) -> Source where
F: FnMut(&Bus, &Message) -> Continue + Send + 'static,
[src]
pub fn create_watch<'a, N: Into<Option<&'a str>>, F>(
&self,
name: N,
priority: Priority,
func: F
) -> Source where
F: FnMut(&Bus, &Message) -> Continue + Send + 'static,
Create watch for this bus. The GSource will be dispatched whenever a message is on the bus. After the GSource is dispatched, the message is popped off the bus and unreffed.
Returns
a glib::Source
that can be added to a mainloop.
pub fn add_watch<F>(&self, func: F) -> SourceId where
F: FnMut(&Bus, &Message) -> Continue + Send + 'static,
[src]
pub fn add_watch<F>(&self, func: F) -> SourceId where
F: FnMut(&Bus, &Message) -> Continue + Send + 'static,
pub fn set_sync_handler<F>(&self, func: F) where
F: Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static,
[src]
pub fn set_sync_handler<F>(&self, func: F) where
F: Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static,
pub fn unset_sync_handler(&self)
[src]
pub fn unset_sync_handler(&self)
Trait Implementations
impl Clone for Bus
impl Clone for Bus
fn clone(&self) -> Bus
fn clone(&self) -> Bus
Returns 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 Bus
impl Hash for Bus
fn 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 Bus
impl Ord for Bus
fn cmp(&self, other: &Bus) -> Ordering
fn cmp(&self, other: &Bus) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl StaticType for Bus
impl StaticType for Bus
fn static_type() -> Type
fn static_type() -> Type
Returns the type identifier of Self
.
impl<T: IsA<Object>> PartialEq<T> for Bus
impl<T: IsA<Object>> PartialEq<T> for Bus
fn eq(&self, other: &T) -> bool
fn eq(&self, other: &T) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Eq for Bus
impl Eq for Bus
impl<T: IsA<Object>> PartialOrd<T> for Bus
impl<T: IsA<Object>> PartialOrd<T> for Bus
fn 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) -> bool
1.0.0[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
This 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) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Debug for Bus
impl Debug for Bus
impl IsA<Object> for Bus
impl IsA<Object> for Bus
impl IsA<Object> for Bus
impl IsA<Object> for Bus
impl Default for Bus
[src]
impl Default for Bus
impl Send for Bus
[src]
impl Send for Bus
impl Sync for Bus
[src]
impl Sync for Bus
impl UnixBusExtManual for Bus
[src]
impl UnixBusExtManual for Bus
fn get_pollfd(&self) -> RawFd
[src]
fn get_pollfd(&self) -> RawFd
impl WindowsBusExtManual for Bus
[src]
impl WindowsBusExtManual for Bus
fn get_pollfd(&self) -> RawHandle
[src]
fn get_pollfd(&self) -> RawHandle