Bus

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.

Constructors

this
this()

Creates a new #GstBus instance.

Members

Functions

addSignalWatch
void addSignalWatch()

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.main_context.MainContext.pushThreadDefault (before one had to create a bus watch source and attach it to the desired main context 'manually').

addSignalWatchFull
void addSignalWatchFull(int 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.main_context.MainContext.pushThreadDefault (before one had to create a bus watch source and attach it to the desired main context 'manually').

addWatch
uint addWatch(int priority, gst.types.BusFunc func)

Adds a bus 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.main_context.MainContext.pushThreadDefault (before one had to create a bus watch source and attach it to the desired main context 'manually').

asyncSignalFunc
bool asyncSignalFunc(gst.message.Message message, void* data)

A helper #GstBusFunc that can be used to convert all asynchronous messages into signals.

connectMessage
ulong connectMessage(string detail, T callback, Flag!"After" after)

Connect to Message signal.

connectSyncMessage
ulong connectSyncMessage(string detail, T callback, Flag!"After" after)

Connect to SyncMessage signal.

createWatch
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.

disableSyncMessageEmission
void disableSyncMessageEmission()

Instructs GStreamer to stop emitting the "sync-message" signal for this bus. See gst.bus.Bus.enableSyncMessageEmission for more information.

enableSyncMessageEmission
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 to affect what the bin's sync handler is.

getPollfd
void getPollfd(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 file descriptors. Whenever a message is available, the POLLIN / glib.types.IOCondition.In event is set.

havePending
bool havePending()

Checks if there are pending messages on the bus that should be handled.

peek
gst.message.Message peek()

Peeks the message on the top of the bus' queue. The message will remain on the bus' message queue.

poll
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 indefinitely.

pop
gst.message.Message pop()

Gets a message from the bus.

popFiltered
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 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.

post
bool post(gst.message.Message message)

Posts a message on the given bus. Ownership of the message is taken by the bus.

removeSignalWatch
void removeSignalWatch()

Removes a signal watch previously added with gst.bus.Bus.addSignalWatch.

removeWatch
bool removeWatch()

Removes an installed bus watch from bus.

setFlushing
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 false.

setSyncHandler
void setSyncHandler(gst.types.BusSyncHandler func)

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.

syncSignalHandler
gst.types.BusSyncReply syncSignalHandler(gst.message.Message message, void* data)

A helper #GstBusSyncHandler that can be used to convert all synchronous messages into signals.

timedPop
gst.message.Message timedPop(gst.types.ClockTime timeout)

Gets a message from the bus, waiting up to the specified timeout.

timedPopFiltered
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).

Inherited Members

From ObjectGst

checkUniqueness
bool checkUniqueness(gst.object.ObjectGst[] list, string name)

Checks to see if there is any object named name in list. This function does not do any locking of any kind. You might want to protect the provided list with the lock of the owner of the list. This function will lock each #GstObject in the list to compare the name, so be careful when passing a list with a locked object.

defaultDeepNotify
void defaultDeepNotify(gobject.object.ObjectG object, gst.object.ObjectGst orig, gobject.param_spec.ParamSpec pspec, string[] excludedProps)

A default deep_notify signal callback for an object. The user data should contain a pointer to an array of strings that should be excluded from the notify. The default handler will print the new value of the property using g_print.

replace
bool replace(gst.object.ObjectGst oldobj, gst.object.ObjectGst newobj)

Atomically modifies a pointer to point to a new object. The reference count of oldobj is decreased and the reference count of newobj is increased.

addControlBinding
bool addControlBinding(gst.control_binding.ControlBinding binding)

Attach the #GstControlBinding to the object. If there already was a #GstControlBinding for this property it will be replaced.

defaultError
void defaultError(glib.error.ErrorG error, string debug_)

A default error function that uses glib.global.printerr to display the error message and the optional debug string..

getControlBinding
gst.control_binding.ControlBinding getControlBinding(string propertyName)

Gets the corresponding #GstControlBinding for the property. This should be unreferenced again after use.

getControlRate
gst.types.ClockTime getControlRate()

Obtain the control-rate for this object. Audio processing #GstElement objects will use this rate to sub-divide their processing loop and call gst.object.ObjectGst.syncValues in between. The length of the processing segment should be up to control-rate nanoseconds.

getGValueArray
bool getGValueArray(string propertyName, gst.types.ClockTime timestamp, gst.types.ClockTime interval, gobject.value.Value[] values)

Gets a number of #GValues for the given controlled property starting at the requested time. The array values need to hold enough space for n_values of #GValue.

getName
string getName()

Returns a copy of the name of object. Caller should glib.global.gfree the return value after usage. For a nameless object, this returns null, which you can safely glib.global.gfree as well.

getParent
gst.object.ObjectGst getParent()

Returns the parent of object. This function increases the refcount of the parent object so you should gst.object.ObjectGst.unref it after usage.

getPathString
string getPathString()

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

getValue
gobject.value.Value getValue(string propertyName, gst.types.ClockTime timestamp)

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

hasActiveControlBindings
bool hasActiveControlBindings()

Check if the object has active controlled properties.

hasAncestor
bool hasAncestor(gst.object.ObjectGst ancestor)

Check if object has an ancestor ancestor somewhere up in the hierarchy. One can e.g. check if a #GstElement is inside a #GstPipeline.

hasAsAncestor
bool hasAsAncestor(gst.object.ObjectGst ancestor)

Check if object has an ancestor ancestor somewhere up in the hierarchy. One can e.g. check if a #GstElement is inside a #GstPipeline.

hasAsParent
bool hasAsParent(gst.object.ObjectGst parent)

Check if parent is the parent of object. E.g. a #GstElement can check if it owns a given #GstPad.

removeControlBinding
bool removeControlBinding(gst.control_binding.ControlBinding binding)

Removes the corresponding #GstControlBinding. If it was the last ref of the binding, it will be disposed.

setControlBindingDisabled
void setControlBindingDisabled(string propertyName, bool disabled)

This function is used to disable the control bindings on a property for some time, i.e. gst.object.ObjectGst.syncValues will do nothing for the property.

setControlBindingsDisabled
void setControlBindingsDisabled(bool disabled)

This function is used to disable all controlled properties of the object for some time, i.e. gst.object.ObjectGst.syncValues will do nothing.

setControlRate
void setControlRate(gst.types.ClockTime controlRate)

Change the control-rate for this object. Audio processing #GstElement objects will use this rate to sub-divide their processing loop and call gst.object.ObjectGst.syncValues in between. The length of the processing segment should be up to control-rate nanoseconds.

setName
bool setName(string name)

Sets the name of object, or gives object a guaranteed unique name (if name is null). This function makes a copy of the provided name, so the caller retains ownership of the name it sent.

setParent
bool setParent(gst.object.ObjectGst parent)

Sets the parent of object to parent. The object's reference count will be incremented, and any floating reference will be removed (see gst.object.ObjectGst.refSink).

suggestNextSync
gst.types.ClockTime suggestNextSync()

Returns a suggestion for timestamps where buffers should be split to get best controller results.

syncValues
bool syncValues(gst.types.ClockTime timestamp)

Sets the properties of the object, according to the #GstControlSources that (maybe) handle them and for the given timestamp.

unparent
void unparent()

Clear the parent of object, removing the associated reference. This function decreases the refcount of object.

connectDeepNotify
ulong connectDeepNotify(string detail, T callback, Flag!"After" after)

Connect to DeepNotify signal.