org.gstreamer
Class Bus

java.lang.Object
  extended by org.gstreamer.lowlevel.NativeValue
      extended by org.gstreamer.lowlevel.Handle
          extended by org.gstreamer.lowlevel.NativeObject
              extended by org.gstreamer.lowlevel.RefCountedObject
                  extended by org.gstreamer.GObject
                      extended by org.gstreamer.GstObject
                          extended by org.gstreamer.Bus

public class Bus
extends GstObject

The Bus is an object responsible for delivering Messages 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.


Nested Class Summary
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.
 
Nested classes/interfaces inherited from class org.gstreamer.GObject
GObject.GCallback
 
Nested classes/interfaces inherited from class org.gstreamer.lowlevel.NativeObject
NativeObject.Initializer
 
Field Summary
 
Fields inherited from class org.gstreamer.lowlevel.NativeObject
defaultInit, ownsHandle
 
Constructor Summary
Bus(NativeObject.Initializer init)
          This constructor is used internally by gstreamer-java
 
Method Summary
 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)
           
 
Methods inherited from class org.gstreamer.GstObject
addListenerProxy, getName, getParent, initializer, initializer, ref, removeListenerProxy, setName, steal, toString, unref
 
Methods inherited from class org.gstreamer.GObject
addCallback, connect, connect, disconnect, disposeNativeHandle, emit, emit, g_signal_connect, get, getPointer, getPropertyDefaultValue, getPropertyMaximumValue, getPropertyMinimumValue, getType, invalidate, objectFor, removeCallback, set
 
Methods inherited from class org.gstreamer.lowlevel.NativeObject
classFor, disown, dispose, equals, finalize, getNativeAddress, handle, hashCode, initializer, instanceFor, isDisposed, nativeValue, objectFor, objectFor, objectFor
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bus

public Bus(NativeObject.Initializer init)
This constructor is used internally by gstreamer-java

Parameters:
init - internal initialization data
Method Detail

setFlushing

public void setFlushing(boolean flushing)
Instructs the bus to flush out any queued messages. If flushing, flush out any messages queued in the bus. Will flush future messages until setFlushing(boolean) is called with false.

Parameters:
flushing - true if flushing is desired.

connect

public void connect(Bus.EOS listener)
Add a listener for end-of-stream messages.

Parameters:
listener - The listener to be called when end-of-stream is encountered.

disconnect

public void disconnect(Bus.EOS listener)
Disconnect the listener for end-of-stream messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.ERROR listener)
Add a listener for error messages.

Parameters:
listener - The listener to be called when an error in the stream is encountered.

disconnect

public void disconnect(Bus.ERROR listener)
Disconnect the listener for error messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.WARNING listener)
Add a listener for warning messages.

Parameters:
listener - The listener to be called when an Element emits a warning.

disconnect

public void disconnect(Bus.WARNING listener)
Disconnect the listener for warning messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.INFO listener)
Add a listener for informational messages.

Parameters:
listener - The listener to be called when an Element emits a an informational message.

disconnect

public void disconnect(Bus.INFO listener)
Disconnect the listener for informational messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.STATE_CHANGED listener)
Add a listener for State changes in the Pipeline.

Parameters:
listener - The listener to be called when the Pipeline changes state.

disconnect

public void disconnect(Bus.STATE_CHANGED listener)
Disconnect the listener for State change messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.TAG listener)
Add a listener for new media tags.

Parameters:
listener - The listener to be called when new media tags are found.

disconnect

public void disconnect(Bus.TAG listener)
Disconnect the listener for tag messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.BUFFERING listener)
Add a listener for Bus.BUFFERING messages in the Pipeline.

Parameters:
listener - The listener to be called when the Pipeline buffers data.

disconnect

public void disconnect(Bus.BUFFERING listener)
Disconnect the listener for buffering messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.DURATION listener)
Add a listener for duration changes.

Parameters:
listener - The listener to be called when the duration changes.

disconnect

public void disconnect(Bus.DURATION listener)
Disconnect the listener for duration change messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.SEGMENT_START listener)
Add a listener for Bus.SEGMENT_START messages in the Pipeline.

Parameters:
listener - The listener to be called when the Pipeline has started a segment.

disconnect

public void disconnect(Bus.SEGMENT_START listener)
Disconnect the listener for segment-start messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.SEGMENT_DONE listener)
Add a listener for Bus.SEGMENT_DONE messages in the Pipeline.

Parameters:
listener - The listener to be called when the Pipeline has finished a segment.

disconnect

public void disconnect(Bus.SEGMENT_DONE listener)
Disconnect the listener for segment-done messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.ASYNC_DONE listener)
Add a listener for Bus.ASYNC_DONE messages in the Pipeline.

Parameters:
listener - The listener to be called when the an element has finished an async state change.

disconnect

public void disconnect(Bus.ASYNC_DONE listener)
Disconnect the listener for async-done messages.

Parameters:
listener - The listener that was registered to receive the message.

connect

public void connect(Bus.MESSAGE listener)
Add a listener for all messages posted on the Bus.

Parameters:
listener - The listener to be called when a Message is posted.

connect

public void connect(java.lang.String signal,
                    Bus.MESSAGE listener)
Add a listener for messages of type signal posted on the Bus.

Parameters:
signal - the signal to connect to.
listener - The listener to be called when a Message is posted.

disconnect

public void disconnect(Bus.MESSAGE listener)
Disconnect the listener for segment-done messages.

Parameters:
listener - The listener that was registered to receive the message.

post

public boolean post(Message message)
Posts a Message on this Bus.

Parameters:
message - the message to post.
Returns:
true if the message could be posted, false if the bus is flushing.

getSyncHandler

public BusSyncHandler getSyncHandler()

setSyncHandler

public void setSyncHandler(BusSyncHandler handler)

connect

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

This differs to GObject.connect(java.lang.Class, T, com.sun.jna.Callback) in that it hooks up Bus signals to the sync callback, not the generic GObject signal mechanism.

Overrides:
connect in class GObject
Parameters:
signal - the name of the signal to connect to.
listenerClass - the class of the listener
listener - the listener to associate with the callback
callback - the callback to call when the signal is emitted.

disconnect

public <T> void disconnect(java.lang.Class<T> listenerClass,
                           T listener)
Overrides:
disconnect in class GObject