gst.bus

Module for [Bus] class

Types 3

The #GstBus is an object responsible for delivering #GstMessage packets in a first-in first-out way from the streaming threads (see #GstTask) 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 #GSource based notifications. This makes it possible to handle the delivery in the glib #GMainLoop.

The #GSource callback function [gst.bus.Bus.asyncSignalFunc] can be used to convert all bus messages into signal emissions.

A message is posted on the bus with the [gst.bus.Bus.post] method. With the [gst.bus.Bus.peek] and [gst.bus.Bus.pop] methods one can look at or retrieve a previously posted message.

The bus can be polled with the [gst.bus.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 [gst.bus.Bus.pop] the messages from the bus to handle them. Alternatively the application can register an asynchronous bus function using [gst.bus.Bus.addWatchFull] or [gst.bus.Bus.addWatch]. This function will install a #GSource 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 [gst.bus.Bus.setSyncHandler] 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 #GstPipeline has one bus.

Note that a #GstPipeline will set its bus into flushing state when changing from READY to NULL state.

Methods
GType _gType() @property
Bus self()Returns `this`, for use in `with` statements.
BusGidBuilder builder()Get builder for [gst.bus.Bus] Returns: New builder object
void addSignalWatch()Adds a bus signal watch to the default main context with the default priority ( [glib.types.PRIORITYDEFAULT] ). It is also possible to use a non-default main context set up using [glib.maincontext....
void addSignalWatchFull(int priority)Adds a bus signal watch to the default main context with the given priority (e.g. [glib.types.PRIORITYDEFAULT]). It is also possible to use a non-default main context set up using [glib.maincontext...
uint addWatch(int priority, gst.types.BusFunc func)Adds a bus watch to the default main context with the given priority (e.g. [glib.types.PRIORITYDEFAULT]). It is also possible to use a non-default main context set up using [glib.maincontext.MainC...
bool asyncSignalFunc(gst.message.Message message, void * data = null)A helper #GstBusFunc that can be used to convert all asynchronous messages into signals.
glib.source.Source createWatch()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.
void disableSyncMessageEmission()Instructs GStreamer to stop emitting the "sync-message" signal for this bus. See [gst.bus.Bus.enableSyncMessageEmission] for more information.
void enableSyncMessageEmission()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...
void getPollfd(out glib.types.PollFD fd)Gets the file descriptor from the bus which can be used to get notified about messages being available with functions like [glib.global.poll], and allows integration into other event loops based on...
bool havePending()Checks 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.
gst.message.Message peek()Peeks the message on the top of the bus' queue. The message will remain on the bus' message queue. Returns: the #GstMessage that is on the bus, or null if the bus is empty.
gst.message.Message poll(gst.types.MessageType events, gst.types.ClockTime timeout)Polls the bus for messages. Will block while waiting for messages to come. You can specify a maximum time to poll with the timeout parameter. If timeout is negative, this function will block indefi...
gst.message.Message pop()Gets a message from the bus. Returns: the #GstMessage that is on the bus, or null if the bus is empty.
gst.message.Message popFiltered(gst.types.MessageType types)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 mess...
bool post(gst.message.Message message)Posts a message on the given bus. Ownership of the message is taken by the bus.
void removeSignalWatch()Removes a signal watch previously added with [gst.bus.Bus.addSignalWatch].
bool removeWatch()Removes an installed bus watch from bus. Returns: true on success or false if bus has no event source.
void setFlushing(bool flushing)If flushing, flushes out and unrefs any messages queued in the bus. Releases references to the message origin objects. Will flush future messages until [gst.bus.Bus.setFlushing] sets flushing to fa...
void setSyncHandler(gst.types.BusSyncHandler func = null)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 o...
gst.types.BusSyncReply syncSignalHandler(gst.message.Message message, void * data = null)A helper #GstBusSyncHandler that can be used to convert all synchronous messages into signals.
gst.message.Message timedPop(gst.types.ClockTime timeout)Gets a message from the bus, waiting up to the specified timeout.
gst.message.Message timedPopFiltered(gst.types.ClockTime timeout, gst.types.MessageType types)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).
gulong connectMessage(T)(string detail = null, T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gst.message.Message))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gst.bus.Bus))) && Parameters!T.length < 3)Connect to `Message` signal.
gulong connectSyncMessage(T)(string detail = null, T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gst.message.Message))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gst.bus.Bus))) && Parameters!T.length < 3)Connect to `SyncMessage` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new #GstBus instance. Returns: a new #GstBus instance
Methods
T enableAsync(bool propval)Set `enableAsync` property. Params: propval = Enables async message delivery support for bus watches, [gst.bus.Bus.pop] and similar API. Without this only the synchronous message handlers are called.

Fluent builder for [gst.bus.Bus]

Methods