public class Bus extends GstObject
Bus is an object responsible for delivering Messages in a
first-in first-out way from the streaming threads to the application.
See upstream documentation at https://gstreamer.freedesktop.org/documentation/gstreamer/gstbus.html
Since the application typically only wants to deal with delivery of these messages from one thread, the Bus will marshal the messages between different threads. This is important since the actual streaming of media is done in another thread than the application.
It is also possible to get messages from the bus without any thread
marshalling with the setSyncHandler(org.freedesktop.gstreamer.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_CHANGED
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.
|
GstObject.HandleGObject.GCallback, GObject.GInterfaceNativeObject.Initializer, NativeObject.TypeProvider, NativeObject.TypeRegistration<T extends NativeObject>| Modifier and Type | Field and Description |
|---|---|
static String |
GTYPE_NAME |
| Modifier and Type | Method and Description |
|---|---|
void |
clearSyncHandler()
Clear the synchronous handler.
|
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_CHANGED 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(String signal,
Bus.MESSAGE listener)
Add a listener for messages of type
signal posted on the Bus. |
<T> void |
connect(String signal,
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_CHANGED 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(Class<T> listenerClass,
T listener) |
void |
dispose()
Dispose this object, and potentially clear (free, unref, etc.) the
underlying native object if this object owns the reference.
|
BusSyncHandler |
getSyncHandler()
Get the current synchronous handler.
|
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)
Sets the synchronous handler (message listener) on the bus.
|
addControlBinding, getAsString, getControlBinding, getName, getParent, hasActiveControlBindings, removeControlBinding, setAsString, setControlBindingDisabled, setControlBindingsDisabled, setName, suggestNextSync, syncValues, toStringaddCallback, connect, emit, emit, get, getPropertyDefaultValue, getPropertyMaximumValue, getPropertyMinimumValue, getRefCount, getTypeName, invalidate, listPropertyNames, removeCallback, setclose, disown, equals, getPointer, getRawPointer, hashCodepublic static final String GTYPE_NAME
public 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_CHANGED listener)
listener - The listener to be called when the duration changes.public void disconnect(Bus.DURATION_CHANGED 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(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 void setSyncHandler(BusSyncHandler handler)
Only one handler may be attached to the bus at any one time. An attached
sync handler forces creation of Message objects for all messages
on the bus, so the handler should be removed if no longer required.
A single native sync handler is used at all times, with synchronous and asynchronous dispatch handled on the Java side, so the bindings do not inherit issues in clearing or replacing the sync handler with versions of GStreamer prior to 1.16.3.
handler - bus sync handler, or null to removepublic void clearSyncHandler()
This is a convenience method equivalent to setSyncHandler(null)
public BusSyncHandler getSyncHandler()
public <T> void connect(String signal, Class<T> listenerClass, T listener, com.sun.jna.Callback callback)
This differs to GObject#connect in that it hooks up Bus signals
to the sync callback, not the generic GObject signal mechanism.
public <T> void disconnect(Class<T> listenerClass, T listener)
disconnect in class GObjectpublic void dispose()
NativeObjectAfter calling this method this object should not be used.
Copyright © 2021 gstreamer-java. All rights reserved.