Bus

Description The GstBus is an object responsible for delivering GstMessages in a first-in first-out way from the streaming threads 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 mainloop. The GSource 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 gst_bus_post() method. With the gst_bus_peek() and gst_bus_pop() methods one can look at or retrieve a previously posted message. The bus can be polled with the gst_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 _pop() the messages from the bus to handle them. Alternatively the application can register an asynchronous bus function using gst_bus_add_watch_full() or gst_bus_add_watch(). 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_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 GstPipeline has one bus. Note that a GstPipeline will set its bus into flushing state when changing from READY to NULL state. Last reviewed on 2006-03-12 (0.10.5)

class Bus : ObjectGst {}

Constructors

this
this(GstBus* gstBus)

Sets our main struct and passes it to the parent class

this
this()

Creates a new GstBus instance.

Members

Functions

addOnMessage
void addOnMessage(void delegate(Message, Bus) dlg, ConnectFlags connectFlags)

A message has been posted on the bus. This signal is emitted from a GSource added to the mainloop. this signal will only be emitted when there is a mainloop running.

addOnSyncMessage
void addOnSyncMessage(void delegate(Message, Bus) dlg, ConnectFlags connectFlags)

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 set up gst_bus_sync_signal_handler() as a sync handler if you want this gst_bus_set_sync_handler (bus, gst_bus_sync_signal_handler, yourdata); See Also GstMessage, GstElement

addSignalWatch
void addSignalWatch()

Adds a bus signal watch to the default main context with the default priority. 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 gst_bus_remove_signal_watch() as many times as this function is called. MT safe.

addSignalWatchFull
void addSignalWatchFull(int priority)

Adds a bus signal watch to the default main context with the given priority. 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 gst_bus_remove_signal_watch() as many times as this function is called. MT safe.

addWatch
uint addWatch(bool delegate(Message) dlg)

Adds a bus watch to the default main context with the default priority. This function is used to receive asynchronous messages in the main loop. The watch can be removed using g_source_remove() or by returning FALSE from func. MT safe.

addWatchFull
uint addWatchFull(int priority, GstBusFunc func, void* userData, GDestroyNotify notify)

Adds a bus watch to the default main context with the given priority. This function is used to receive asynchronous messages in the main loop. When func is called, the message belongs to the caller; if you want to keep a copy of it, call gst_message_ref() before leaving func. The watch can be removed using g_source_remove() or by returning FALSE from func.

asyncSignalFunc
int asyncSignalFunc(Message message, void* data)

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

createWatch
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_enable_sync_message_emission() for more information. In the event that multiple pieces of code have called gst_bus_enable_sync_message_emission(), the sync-message emissions will only be stopped after all calls to gst_bus_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. MT safe.

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. This function may be called multiple times. To clean up, the caller is responsible for calling gst_bus_disable_sync_message_emission() as many times as this function is called. While this function looks similar to gst_bus_add_signal_watch(), it is not exactly the same -- this function enables synchronous emission of signals when messages arrive; gst_bus_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 main loop. MT safe.

getBusStruct
GstBus* getBusStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

havePending
int havePending()

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

peek
Message peek()

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.

poll
Message poll(GstMessageType events, GstClockTimeDiff timeout)

Poll 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. All messages not in events will be popped off the bus and will be ignored. Because poll is implemented using the "message" signal enabled by gst_bus_add_signal_watch(), calling gst_bus_poll() will cause the "message" signal to be emitted for every message that poll sees. Thus a "message" signal handler will see the same messages that this function sees -- neither will steal messages from the other. This function will run a main loop from the default main context when polling.

pop
Message pop()

Get a message from the bus.

post
int post(Message message)

Post 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_add_signal_watch(). MT safe.

setFlushing
void setFlushing(int flushing)

If flushing, flush out and unref any messages queued in the bus. Releases references to the message origin objects. Will flush future messages until gst_bus_set_flushing() sets flushing to FALSE. MT safe.

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
setSyncHandler
void setSyncHandler(GstBusSyncReply delegate(Message) dlg)

Use this for making an XOverlay. 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. You cannot replace an existing sync_handler. You can pass NULL to this function, which will clear the existing handler.

syncSignalHandler
GstBusSyncReply syncSignalHandler(Message message, void* data)

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

timedPop
Message timedPop(GstClockTime timeout)

Get a message from the bus, waiting up to the specified timeout. If timeout is 0, this function behaves like gst_bus_pop(). If timeout is GST_CLOCK_TIME_NONE, this function will block forever until a message was posted on the bus.

Static functions

callBackMessage
void callBackMessage(GstBus* busStruct, GstMessage* message, Bus _bus)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackSyncMessage
void callBackSyncMessage(GstBus* busStruct, GstMessage* message, Bus _bus)
Undocumented in source. Be warned that the author may not have intended to support it.
syncHandlerCallBack
GstBusSyncReply syncHandlerCallBack(GstBus* bus, GstMessage* msg, Bus bus_d)
Undocumented in source. Be warned that the author may not have intended to support it.
watchCallBack
gboolean watchCallBack(GstBus* bus, GstMessage* msg, Bus bus_d)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

connectedSignals
int[string] connectedSignals;
gstBus
GstBus* gstBus;

the main Gtk struct

onMessageListeners
void delegate(Message, Bus)[] onMessageListeners;
Undocumented in source.
onSyncHandlerListener
GstBusSyncReply delegate(Message) onSyncHandlerListener;
Undocumented in source.
onSyncMessageListeners
void delegate(Message, Bus)[] onSyncMessageListeners;
Undocumented in source.
onWatchListener
bool delegate(Message) onWatchListener;
Undocumented in source.

Inherited Members

From ObjectGst

gstObject
GstObject* gstObject;

the main Gtk struct

getObjectGstStruct
GstObject* getObjectGstStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
connectedSignals
int[string] connectedSignals;
onDeepNotifyListeners
void delegate(ObjectGst, ParamSpec, ObjectGst)[] onDeepNotifyListeners;
Undocumented in source.
addOnDeepNotify
void addOnDeepNotify(void delegate(ObjectGst, ParamSpec, ObjectGst) dlg, ConnectFlags connectFlags)

The deep notify signal is used to be notified of property changes. It is typically attached to the toplevel bin to receive notifications from all the elements contained in that bin.

callBackDeepNotify
void callBackDeepNotify(GstObject* gstobjectStruct, GstObject* propObject, GParamSpec* prop, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
onObjectSavedListeners
void delegate(void*, ObjectGst)[] onObjectSavedListeners;
Undocumented in source.
addOnObjectSaved
void addOnObjectSaved(void delegate(void*, ObjectGst) dlg, ConnectFlags connectFlags)

Trigered whenever a new object is saved to XML. You can connect to this signal to insert custom XML tags into the core XML.

callBackObjectSaved
void callBackObjectSaved(GstObject* gstobjectStruct, void* xmlNode, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
onParentSetListeners
void delegate(ObjectG, ObjectGst)[] onParentSetListeners;
Undocumented in source.
addOnParentSet
void addOnParentSet(void delegate(ObjectG, ObjectGst) dlg, ConnectFlags connectFlags)

Emitted when the parent of an object is set.

callBackParentSet
void callBackParentSet(GstObject* gstobjectStruct, GObject* parent, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
onParentUnsetListeners
void delegate(ObjectG, ObjectGst)[] onParentUnsetListeners;
Undocumented in source.
addOnParentUnset
void addOnParentUnset(void delegate(ObjectG, ObjectGst) dlg, ConnectFlags connectFlags)

Emitted when the parent of an object is unset.

callBackParentUnset
void callBackParentUnset(GstObject* gstobjectStruct, GObject* parent, ObjectGst _objectGst)
Undocumented in source. Be warned that the author may not have intended to support it.
setName
int 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.

getName
string getName()

Returns a copy of the name of object. Caller should g_free() the return value after usage. For a nameless object, this returns NULL, which you can safely g_free() as well.

setParent
int setParent(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_sink()). This function causes the parent-set signal to be emitted when the parent was successfully set.

getParent
ObjectGst getParent()

Returns the parent of object. This function increases the refcount of the parent object so you should gst_object_unref() it after usage.

unparent
void unparent()

Clear the parent of object, removing the associated reference. This function decreases the refcount of object. MT safe. Grabs and releases object's lock.

getNamePrefix
string getNamePrefix()

Returns a copy of the name prefix of object. Caller should g_free() the return value after usage. For a prefixless object, this returns NULL, which you can safely g_free() as well.

setNamePrefix
void setNamePrefix(string namePrefix)

Sets the name prefix of object to name_prefix. This function makes a copy of the provided name prefix, so the caller retains ownership of the name prefix it sent. MT safe. This function grabs and releases object's LOCK.

defaultDeepNotify
void defaultDeepNotify(ObjectG object, ObjectGst orig, 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. MT safe. This function grabs and releases object's LOCK for getting its path string.

defaultError
void defaultError(ErrorG error, string dbug)

A default error function. The default handler will simply print the error string using g_print.

checkUniqueness
int checkUniqueness(ListG 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 carefull when passing a list with a locked object.

hasAncestor
int hasAncestor(ObjectGst ancestor)

Check if object has an ancestor ancestor somewhere up in the hierarchy.

doref
void* doref(void* object)

Increments the refence count on object. This function does not take the lock on object because it relies on atomic refcounting. This object returns the input parameter to ease writing

unref
void unref(void* object)

Decrements the refence count on object. If reference count hits zero, destroy object. This function does not take the lock on object as it relies on atomic refcounting. The unref method should never be called with the LOCK held since this might deadlock the dispose function.

sink
void sink(void* object)

If object was floating, the GST_OBJECT_FLOATING flag is removed and object is unreffed. When object was not floating, this function does nothing. Any newly created object has a refcount of 1 and is floating. This function should be used when creating a new object to symbolically 'take ownership' of object. This done by first doing a gst_object_ref() to keep a reference to object and then gst_object_sink() to remove and unref any floating references to object. Use gst_object_set_parent() to have this done for you. MT safe. This function grabs and releases object lock.

replace
void replace(ObjectGst oldobj, ObjectGst newobj)

Unrefs the GstObject pointed to by oldobj, refs newobj and puts newobj in *oldobj. Be carefull when calling this function, it does not take any locks. You might want to lock the object owning oldobj pointer before calling this function. Make sure not to LOCK oldobj because it might be unreffed which could cause a deadlock when it is disposed.

getPathString
string getPathString()

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

Meta