#[repr(transparent)]pub struct Bus { /* private fields */ }
Expand description
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 GMainLoop
.
The glib::Source
callback function gst_bus_async_signal_func()
can be used to
convert all bus messages into signal emissions.
A message is posted on the bus with the post()
method. With the
peek()
and pop()
methods one can look at or retrieve a
previously posted message.
The bus can be polled with the [poll()
][Self::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 pop()
the messages
from the bus to handle them.
Alternatively the application can register an asynchronous bus function
using [add_watch_full()
][Self::add_watch_full()] or 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 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
Implementations
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()
][crate::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 remove_signal_watch()
as many times as this
function is called.
Instructs GStreamer to stop emitting the “sync-message” signal for this bus.
See enable_sync_message_emission()
for more information.
In the event that multiple pieces of code have called
enable_sync_message_emission()
, the sync-message emissions will only
be stopped after all calls to enable_sync_message_emission()
were
“cancelled” by calling this function. In this way the semantics are exactly
the same as gst_object_ref()
that which calls enable should also call
disable.
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 disable_sync_message_emission()
as many times
as this function is called.
While this function looks similar to add_signal_watch()
, it is not
exactly the same – this function enables synchronous emission of
signals when messages arrive; add_signal_watch()
adds an idle callback
to pop messages off the bus asynchronously. 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 GMainLoop
.
Removes a signal watch previously added with add_signal_watch()
.
If flushing
, flushes out and unrefs any messages queued in the bus. Releases
references to the message origin objects. Will flush future messages until
set_flushing()
sets flushing
to false
.
flushing
whether or not to flush the bus
Gets a message from the bus, waiting up to the specified timeout.
If timeout
is 0, this function behaves like 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.
pub fn connect_message<F: Fn(&Self, &Message) + Send + 'static>(
&self,
detail: Option<&str>,
f: F
) -> SignalHandlerId
pub fn connect_message<F: Fn(&Self, &Message) + Send + 'static>(
&self,
detail: Option<&str>,
f: F
) -> SignalHandlerId
A message has been posted on the bus. This signal is emitted from a
glib::Source
added to the mainloop. this signal will only be emitted when
there is a GMainLoop
running.
message
the message that has been posted asynchronously
pub fn connect_sync_message<F: Fn(&Self, &Message) + Send + Sync + 'static>(
&self,
detail: Option<&str>,
f: F
) -> SignalHandlerId
pub fn connect_sync_message<F: Fn(&Self, &Message) + Send + Sync + 'static>(
&self,
detail: Option<&str>,
f: F
) -> SignalHandlerId
A message has been posted on the bus. This signal is emitted from the thread that posted the message so one has to be careful with locking.
This signal will not be emitted by default, you have to call
enable_sync_message_emission()
before.
message
the message that has been posted synchronously
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()
][crate::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 GMainLoop
is running.
This function may be called multiple times. To clean up, the caller is
responsible for calling 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.
priority
The priority of the watch.
Create watch for this bus. The glib::Source
will be dispatched whenever
a message is on the bus. After the GSource is dispatched, the
message is popped off the bus and unreffed.
As with other watches, there can only be one watch on the bus, including
any signal watch added with gst_bus_add_signal_watch
.
Returns
a glib::Source
that can be added to a GMainLoop
.
Adds a bus 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()
][crate::glib::MainContext::push_thread_default()] (before
one had to create a bus watch source and attach it to the desired main
context ‘manually’).
This function is used to receive asynchronous messages in the main loop. There can only be a single bus watch per bus, you must remove it before you can set a new one.
The bus watch will only work if a GMainLoop
is being run.
The watch can be removed using remove_watch()
or by returning false
from func
. If the watch was added to the default main context it is also
possible to remove the watch using [glib::Source::remove()
][crate::glib::Source::remove()].
The bus watch will take its own reference to the self
, so it is safe to unref
self
using gst_object_unref()
after setting the bus watch.
func
A function to call when a message is received.
Returns
The event source id or 0 if self
already got an event source.
pub fn add_watch_local<F>(&self, func: F) -> Result<SourceId, BoolError> where
F: FnMut(&Bus, &Message) -> Continue + 'static,
pub fn set_sync_handler<F>(&self, func: F) where
F: Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static,
pub fn set_sync_handler<F>(&self, func: F) where
F: Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static,
Sets the synchronous handler on the bus. The function will be called every time a new message is posted on the bus. Note that the function will be called in the same thread context as the posting object. This function is usually only called by the creator of the bus. Applications should handle messages asynchronously using the gst_bus watch and poll functions.
Before 1.16.3 it was not possible to replace an existing handler and
clearing an existing handler with None
was not thread-safe.
func
The handler function to install
notify
called when user_data
becomes unused
pub fn iter_timed(&self, timeout: impl Into<Option<ClockTime>>) -> Iter<'_>ⓘ
pub fn iter_filtered<'a>(
&'a self,
msg_types: &'a [MessageType]
) -> impl Iterator<Item = Message> + 'a
pub fn iter_timed_filtered<'a>(
&'a self,
timeout: impl Into<Option<ClockTime>>,
msg_types: &'a [MessageType]
) -> impl Iterator<Item = Message> + 'a
Gets a message from the bus whose type matches the message type mask types
,
waiting up to the specified timeout (and discarding any messages that do not
match the mask provided).
If timeout
is 0, this function behaves like pop_filtered()
. If
timeout
is GST_CLOCK_TIME_NONE
, this function will block forever until a
matching message was posted on the bus.
timeout
a timeout in nanoseconds, or GST_CLOCK_TIME_NONE
to wait forever
types
message types to take into account, GST_MESSAGE_ANY
for any type
Returns
a Message
matching the
filter in types
, or None
if no matching message was found on
the bus until the timeout expired.
Gets a message matching type_
from the bus. Will discard all messages on
the bus that do not match type_
and that have been posted before the first
message that does match type_
. If there is no message matching type_
on
the bus, all messages will be discarded. It is not possible to use message
enums beyond GST_MESSAGE_EXTENDED
in the events
mask.
types
message types to take into account
Returns
the next Message
matching
type_
that is on the bus, or None
if the bus is empty or there
is no message matching type_
.
pub fn stream_filtered<'a>(
&self,
message_types: &'a [MessageType]
) -> impl Stream<Item = Message> + Unpin + Send + 'a
Trait Implementations
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
Returns the type identifier of Self
.
Auto Trait Implementations
Blanket Implementations
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
pub fn parent_class_init<T>(class: &mut Class<U>) where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
pub fn parent_instance_init<T>(instance: &mut InitializingObject<T>) where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
Returns true
if the object is an instance of (can be cast to) T
.
Returns the ObjectClass
of the object. Read more
Returns the class of the object in the given type T
. Read more
Returns the interface T
of the object. Read more
Similar to Self::set_property
but fails instead of panicking.
Sets the property property_name
of the object to value value
. Read more
Similar to Self::set_property
but fails instead of panicking.
Sets the property property_name
of the object to value value
. Read more
Similar to Self::set_properties
but fails instead of panicking.
Sets multiple properties of the object at once. Read more
Similar to Self::set_properties_from_value
but fails instead of panicking.
Sets multiple properties of the object at once. Read more
Similar to Self::property
but fails instead of panicking.
Gets the property property_name
of the object and cast it to the type V. Read more
Similar to Self::property_value
but fails instead of panicking.
Gets the property property_name
of the object. Read more
Check if the object has a property property_name
of the given type_
. Read more
Get the type of the property property_name
of this object. Read more
Get the ParamSpec
of the property property_name
of this object.
Return all ParamSpec
of the properties of this object.
Freeze all property notifications until the return guard object is dropped. Read more
Set arbitrary data on this object with the given key
. Read more
Return previously set arbitrary data of this object with the given key
. Read more
Retrieve previously set arbitrary data of this object with the given key
. Read more
Set arbitrary data on this object with the given key
. Read more
Return previously set arbitrary data of this object with the given key
. Read more
Retrieve previously set arbitrary data of this object with the given key
. Read more
Block a given signal handler. Read more
Unblock a given signal handler.
Stop emission of the currently emitted signal.
Stop emission of the currently emitted signal by the (possibly detailed) signal name.
Similar to Self::connect
but fails instead of panicking.
Connect to the signal signal_name
on this object. Read more
Similar to Self::connect_id
but fails instead of panicking.
Connect to the signal signal_id
on this object. Read more
Similar to Self::connect_local
but fails instead of panicking.
Connect to the signal signal_name
on this object. Read more
Similar to Self::connect_local_id
but fails instead of panicking.
Connect to the signal signal_id
on this object. Read more
Similar to Self::connect_unsafe
but fails instead of panicking.
Connect to the signal signal_name
on this object. Read more
Similar to Self::connect_unsafe_id
but fails instead of panicking.
pub fn try_connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>
pub fn try_connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>
Similar to Self::connect_closure
but fails instead of panicking.
pub fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
pub fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
Connect a closure to the signal signal_name
on this object. Read more
pub fn try_connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>
pub fn try_connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> Result<SignalHandlerId, BoolError>
Similar to Self::connect_closure_id
but fails instead of panicking.
pub fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
pub fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
Connect a closure to the signal signal_id
on this object. Read more
Limits the lifetime of closure
to the lifetime of the object. When
the object’s reference count drops to zero, the closure will be
invalidated. An invalidated closure will ignore any calls to
Closure::invoke
. Read more
Connect to the signal signal_id
on this object. Read more
Similar to Self::emit
but fails instead of panicking.
Emit signal by signal id. Read more
Similar to Self::emit_with_values
but fails instead of panicking.
Same as Self::emit
but takes Value
for the arguments.
pub fn try_emit_by_name<R>(
&self,
signal_name: &str,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
pub fn try_emit_by_name<R>(
&self,
signal_name: &str,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
Similar to Self::emit_by_name
but fails instead of panicking.
pub fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> R where
R: TryFromClosureReturnValue,
pub fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> R where
R: TryFromClosureReturnValue,
Emit signal by its name. Read more
Similar to Self::emit_by_name_with_values
but fails instead of panicking.
Emit signal by its name. Read more
pub fn try_emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
pub fn try_emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Result<R, BoolError> where
R: TryFromClosureReturnValue,
Similar to Self::emit_with_details
but fails instead of panicking.
pub fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> R where
R: TryFromClosureReturnValue,
pub fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> R where
R: TryFromClosureReturnValue,
Emit signal by signal id with details. Read more
Similar to Self::emit_with_details_and_values
but fails instead of panicking.
Emit signal by signal id with details. Read more
Disconnect a previously connected signal handler.
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
Connect to the notify
signal of the object. Read more
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
Connect to the notify
signal of the object. Read more
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
Connect to the notify
signal of the object. Read more
Notify that the given property has changed its value. Read more
Notify that the given property has changed its value. Read more
pub fn bind_property<O>(
&'a self,
source_property: &'a str,
target: &'a O,
target_property: &'a str
) -> BindingBuilder<'a> where
O: ObjectType,
pub fn bind_property<O>(
&'a self,
source_property: &'a str,
target: &'a O,
target_property: &'a str
) -> BindingBuilder<'a> where
O: ObjectType,
Bind property source_property
on this object to the target_property
on the target
object. Read more
Ensures that the type has been registered with the type system.
Returns a SendValue
clone of self
.