Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.conference
Class AudioMixingPushBufferStream

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.control.AbstractControls
      extended by net.java.sip.communicator.impl.neomedia.control.ControlsAdapter
          extended by net.java.sip.communicator.impl.neomedia.conference.AudioMixingPushBufferStream
All Implemented Interfaces:
javax.media.Controls, javax.media.protocol.PushBufferStream, javax.media.protocol.SourceStream

public class AudioMixingPushBufferStream
extends ControlsAdapter
implements javax.media.protocol.PushBufferStream

Represents a PushBufferStream containing the result of the audio mixing of DataSources.

Author:
Lyubomir Marinov

Field Summary
 
Fields inherited from class net.java.sip.communicator.impl.neomedia.control.ControlsAdapter
EMPTY_CONTROLS
 
Fields inherited from interface javax.media.protocol.SourceStream
LENGTH_UNKNOWN
 
Constructor Summary
AudioMixingPushBufferStream(AudioMixerPushBufferStream audioMixerStream, AudioMixingPushBufferDataSource dataSource)
          Initializes a new AudioMixingPushBufferStream mixing the input data of a specific AudioMixerPushBufferStream and excluding from the mix the audio contributions of a specific AudioMixingPushBufferDataSource.
 
Method Summary
 boolean endOfStream()
          Implements SourceStream.endOfStream().
 javax.media.protocol.ContentDescriptor getContentDescriptor()
          Implements SourceStream.getContentDescriptor().
 long getContentLength()
          Implements SourceStream.getContentLength().
 AudioMixingPushBufferDataSource getDataSource()
          Gets the AudioMixingPushBufferDataSource which created and owns this instance and defines the input data which is to not be mixed in the output of this PushBufferStream.
 javax.media.format.AudioFormat getFormat()
          Implements PushBufferStream.getFormat().
 void read(javax.media.Buffer buffer)
          Implements PushBufferStream.read(Buffer).
(package private)  void setInputSamples(int[][] inputSamples, int maxInputSampleCount, long timeStamp)
          Sets the collection of audio sample sets to be mixed in the sense of audio mixing by this stream when data is read from it.
 void setTransferHandler(javax.media.protocol.BufferTransferHandler transferHandler)
          Implements PushBufferStream.setTransferHandler(BufferTransferHandler).
(package private)  void start()
          Starts the pushing of data out of this stream.
(package private)  void stop()
          Stops the pushing of data out of this stream.
 
Methods inherited from class net.java.sip.communicator.impl.neomedia.control.ControlsAdapter
getControls
 
Methods inherited from class net.java.sip.communicator.impl.neomedia.control.AbstractControls
getControl, getControl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.media.Controls
getControl, getControls
 

Constructor Detail

AudioMixingPushBufferStream

AudioMixingPushBufferStream(AudioMixerPushBufferStream audioMixerStream,
                            AudioMixingPushBufferDataSource dataSource)
Initializes a new AudioMixingPushBufferStream mixing the input data of a specific AudioMixerPushBufferStream and excluding from the mix the audio contributions of a specific AudioMixingPushBufferDataSource.

Parameters:
audioMixerStream - the AudioMixerPushBufferStream reading data from input DataSources and to push it to the new AudioMixingPushBufferStream
dataSource - the AudioMixingPushBufferDataSource which has requested the initialization of the new instance and which defines the input data to not be mixed in the output of the new instance
Method Detail

endOfStream

public boolean endOfStream()
Implements SourceStream.endOfStream(). Delegates to the wrapped AudioMixerPushBufferStream because this instance is just a facet to it.

Specified by:
endOfStream in interface javax.media.protocol.SourceStream
Returns:
true if this SourceStream has reached the end of the media it makes available; otherwise, false

getContentDescriptor

public javax.media.protocol.ContentDescriptor getContentDescriptor()
Implements SourceStream.getContentDescriptor(). Delegates to the wrapped AudioMixerPushBufferStream because this instance is just a facet to it.

Specified by:
getContentDescriptor in interface javax.media.protocol.SourceStream
Returns:
a ContentDescriptor which describes the content being made available by this SourceStream

getContentLength

public long getContentLength()
Implements SourceStream.getContentLength(). Delegates to the wrapped AudioMixerPushBufferStream because this instance is just a facet to it.

Specified by:
getContentLength in interface javax.media.protocol.SourceStream
Returns:
the length of the media being made available by this SourceStream

getDataSource

public AudioMixingPushBufferDataSource getDataSource()
Gets the AudioMixingPushBufferDataSource which created and owns this instance and defines the input data which is to not be mixed in the output of this PushBufferStream.

Returns:
the AudioMixingPushBufferDataSource which created and owns this instance and defines the input data which is to not be mixed in the output of this PushBufferStream

getFormat

public javax.media.format.AudioFormat getFormat()
Implements PushBufferStream.getFormat(). Delegates to the wrapped AudioMixerPushBufferStream because this instance is just a facet to it.

Specified by:
getFormat in interface javax.media.protocol.PushBufferStream
Returns:
the Format of the audio being made available by this PushBufferStream

read

public void read(javax.media.Buffer buffer)
          throws IOException
Implements PushBufferStream.read(Buffer). If inputSamples are available, mixes them and writes the mix to the specified Buffer performing the necessary data type conversions.

Specified by:
read in interface javax.media.protocol.PushBufferStream
Parameters:
buffer - the Buffer to receive the data read from this instance
Throws:
IOException - if anything wrong happens while reading from this instance

setInputSamples

void setInputSamples(int[][] inputSamples,
                     int maxInputSampleCount,
                     long timeStamp)
Sets the collection of audio sample sets to be mixed in the sense of audio mixing by this stream when data is read from it. Triggers a push to the clients of this stream.

Parameters:
inputSamples - the collection of audio sample sets to be mixed by this stream when data is read from it
maxInputSampleCount - the maximum number of per-stream audio samples available through inputSamples
timeStamp - the time stamp of inputSamples to be reported in the specified Buffer when data is read from this instance

setTransferHandler

public void setTransferHandler(javax.media.protocol.BufferTransferHandler transferHandler)
Implements PushBufferStream.setTransferHandler(BufferTransferHandler). Sets the BufferTransferHandler which is to be notified by this instance when it has media available for reading.

Specified by:
setTransferHandler in interface javax.media.protocol.PushBufferStream
Parameters:
transferHandler - the BufferTransferHandler to be notified by this instance when it has media available for reading

start

void start()
     throws IOException
Starts the pushing of data out of this stream.

Throws:
IOException - if starting the pushing of data out of this stream fails

stop

void stop()
    throws IOException
Stops the pushing of data out of this stream.

Throws:
IOException - if stopping the pushing of data out of this stream fails

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.