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 SignalSource based notifications. This makes it possible to handle the
delivery in the glib MainLoop.
The SignalSource callback function 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 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 or gst_bus_add_watch. This
function will install a SignalSource 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.
Gets the file descriptor from the bus which can be used to get
notified about messages being available with functions like poll, and allows integration into other event
loops based on file descriptors.
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).