public class Bus extends GstObject
Bus
is an object responsible for delivering Message
s 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 Bus will marshall the messages between different threads. This is important since the actual streaming of media is done in another thread than the application.
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.
It is also possible to get messages from the bus without any thread
marshalling with the setSyncHandler(org.gstreamer.event.BusSyncHandler)
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.
Modifier and Type | Class and Description |
---|---|
static interface |
Bus.ASYNC_DONE
Signal emitted by elements when they complete an ASYNC state change.
|
static interface |
Bus.BUFFERING
Signal emitted when the pipeline is buffering data.
|
static interface |
Bus.DURATION
Signal sent when a new duration message is posted by an element that
know the duration of a stream in a specific format.
|
static interface |
Bus.EOS
Signal emitted when end-of-stream is reached in a pipeline.
|
static interface |
Bus.ERROR
Signal emitted when an error occurs.
|
static interface |
Bus.INFO
Signal emitted when an informational message is delivered.
|
static interface |
Bus.MESSAGE
Catch all signals emitted on the Bus.
|
static interface |
Bus.SEGMENT_DONE
Signal emitted when the pipeline has completed playback of a segment.
|
static interface |
Bus.SEGMENT_START
This message is posted by elements that start playback of a segment as a
result of a segment seek.
|
static interface |
Bus.STATE_CHANGED
Signal emitted when a state change happens.
|
static interface |
Bus.TAG
Signal emitted when a new tag is identified on the stream.
|
static interface |
Bus.WARNING
Signal emitted when a warning message is delivered.
|
GObject.GCallback
NativeObject.Initializer
defaultInit, ownsHandle
Constructor and Description |
---|
Bus(NativeObject.Initializer init)
This constructor is used internally by gstreamer-java
|
Modifier and Type | Method and Description |
---|---|
void |
connect(Bus.ASYNC_DONE listener)
Add a listener for
Bus.ASYNC_DONE messages in the Pipeline. |
void |
connect(Bus.BUFFERING listener)
Add a listener for
Bus.BUFFERING messages in the Pipeline. |
void |
connect(Bus.DURATION listener)
Add a listener for duration changes.
|
void |
connect(Bus.EOS listener)
Add a listener for end-of-stream messages.
|
void |
connect(Bus.ERROR listener)
Add a listener for error messages.
|
void |
connect(Bus.INFO listener)
Add a listener for informational messages.
|
void |
connect(Bus.MESSAGE listener)
Add a listener for all messages posted on the Bus.
|
void |
connect(Bus.SEGMENT_DONE listener)
Add a listener for
Bus.SEGMENT_DONE messages in the Pipeline. |
void |
connect(Bus.SEGMENT_START listener)
Add a listener for
Bus.SEGMENT_START messages in the Pipeline. |
void |
connect(Bus.STATE_CHANGED listener)
Add a listener for
State changes in the Pipeline. |
void |
connect(Bus.TAG listener)
Add a listener for new media tags.
|
void |
connect(Bus.WARNING listener)
Add a listener for warning messages.
|
void |
connect(java.lang.String signal,
Bus.MESSAGE listener)
Add a listener for messages of type
signal posted on the Bus. |
<T> void |
connect(java.lang.String signal,
java.lang.Class<T> listenerClass,
T listener,
com.sun.jna.Callback callback)
Connects a callback to a signal.
|
void |
disconnect(Bus.ASYNC_DONE listener)
Disconnect the listener for async-done messages.
|
void |
disconnect(Bus.BUFFERING listener)
Disconnect the listener for buffering messages.
|
void |
disconnect(Bus.DURATION listener)
Disconnect the listener for duration change messages.
|
void |
disconnect(Bus.EOS listener)
Disconnect the listener for end-of-stream messages.
|
void |
disconnect(Bus.ERROR listener)
Disconnect the listener for error messages.
|
void |
disconnect(Bus.INFO listener)
Disconnect the listener for informational messages.
|
void |
disconnect(Bus.MESSAGE listener)
Disconnect the listener for segment-done messages.
|
void |
disconnect(Bus.SEGMENT_DONE listener)
Disconnect the listener for segment-done messages.
|
void |
disconnect(Bus.SEGMENT_START listener)
Disconnect the listener for segment-start messages.
|
void |
disconnect(Bus.STATE_CHANGED listener)
Disconnect the listener for
State change messages. |
void |
disconnect(Bus.TAG listener)
Disconnect the listener for tag messages.
|
void |
disconnect(Bus.WARNING listener)
Disconnect the listener for warning messages.
|
<T> void |
disconnect(java.lang.Class<T> listenerClass,
T listener) |
BusSyncHandler |
getSyncHandler() |
boolean |
post(Message message)
Posts a
Message on this Bus. |
void |
setFlushing(boolean flushing)
Instructs the bus to flush out any queued messages.
|
void |
setSyncHandler(BusSyncHandler handler) |
addListenerProxy, getName, getParent, initializer, initializer, ref, removeListenerProxy, setName, steal, toString, unref
addCallback, connect, connect, disconnect, disposeNativeHandle, emit, emit, g_signal_connect, get, getPointer, getPropertyDefaultValue, getPropertyMaximumValue, getPropertyMinimumValue, getType, invalidate, objectForX, removeCallback, set
classFor, disown, dispose, equals, finalize, getNativeAddress, handle, hashCode, initializer, instanceFor, isDisposed, nativeValue, objectFor, objectFor, objectFor, objectFor
public Bus(NativeObject.Initializer init)
init
- internal initialization datapublic void setFlushing(boolean flushing)
setFlushing(boolean)
is called with false.flushing
- true if flushing is desired.public void connect(Bus.EOS listener)
listener
- The listener to be called when end-of-stream is encountered.public void disconnect(Bus.EOS listener)
listener
- The listener that was registered to receive the message.public void connect(Bus.ERROR listener)
listener
- The listener to be called when an error in the stream is encountered.public void disconnect(Bus.ERROR listener)
listener
- The listener that was registered to receive the message.public void connect(Bus.WARNING listener)
listener
- The listener to be called when an Element
emits a warning.public void disconnect(Bus.WARNING listener)
listener
- The listener that was registered to receive the message.public void connect(Bus.INFO listener)
listener
- The listener to be called when an Element
emits a an informational message.public void disconnect(Bus.INFO listener)
listener
- The listener that was registered to receive the message.public void connect(Bus.STATE_CHANGED listener)
State
changes in the Pipeline.listener
- The listener to be called when the Pipeline changes state.public void disconnect(Bus.STATE_CHANGED listener)
State
change messages.listener
- The listener that was registered to receive the message.public void connect(Bus.TAG listener)
listener
- The listener to be called when new media tags are found.public void disconnect(Bus.TAG listener)
listener
- The listener that was registered to receive the message.public void connect(Bus.BUFFERING listener)
Bus.BUFFERING
messages in the Pipeline.listener
- The listener to be called when the Pipeline buffers data.public void disconnect(Bus.BUFFERING listener)
listener
- The listener that was registered to receive the message.public void connect(Bus.DURATION listener)
listener
- The listener to be called when the duration changes.public void disconnect(Bus.DURATION listener)
listener
- The listener that was registered to receive the message.public void connect(Bus.SEGMENT_START listener)
Bus.SEGMENT_START
messages in the Pipeline.listener
- The listener to be called when the Pipeline has started a segment.public void disconnect(Bus.SEGMENT_START listener)
listener
- The listener that was registered to receive the message.public void connect(Bus.SEGMENT_DONE listener)
Bus.SEGMENT_DONE
messages in the Pipeline.listener
- The listener to be called when the Pipeline has finished a segment.public void disconnect(Bus.SEGMENT_DONE listener)
listener
- The listener that was registered to receive the message.public void connect(Bus.ASYNC_DONE listener)
Bus.ASYNC_DONE
messages in the Pipeline.listener
- The listener to be called when the an element has finished
an async state change.public void disconnect(Bus.ASYNC_DONE listener)
listener
- The listener that was registered to receive the message.public void connect(Bus.MESSAGE listener)
listener
- The listener to be called when a Message
is posted.public void connect(java.lang.String signal, Bus.MESSAGE listener)
signal
posted on the Bus.signal
- the signal to connect to.listener
- The listener to be called when a Message
is posted.public void disconnect(Bus.MESSAGE listener)
listener
- The listener that was registered to receive the message.public boolean post(Message message)
Message
on this Bus.message
- the message to post.public BusSyncHandler getSyncHandler()
public void setSyncHandler(BusSyncHandler handler)
public <T> void connect(java.lang.String signal, java.lang.Class<T> listenerClass, T listener, com.sun.jna.Callback callback)
This differs to GObject.connect(java.lang.Class<T>, T, com.sun.jna.Callback)
in that it hooks up Bus signals
to the sync callback, not the generic GObject signal mechanism.
public <T> void disconnect(java.lang.Class<T> listenerClass, T listener)
disconnect
in class GObject