Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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

java.lang.Object
  extended by javax.media.protocol.DataSource
      extended by javax.media.protocol.PushBufferDataSource
          extended by net.java.sip.communicator.impl.neomedia.conference.AudioMixingPushBufferDataSource
All Implemented Interfaces:
javax.media.Controls, javax.media.Duration, javax.media.protocol.CaptureDevice, InbandDTMFDataSource, MuteDataSource

public class AudioMixingPushBufferDataSource
extends javax.media.protocol.PushBufferDataSource
implements javax.media.protocol.CaptureDevice, MuteDataSource, InbandDTMFDataSource

Represents a PushBufferDataSource which provides a single PushBufferStream containing the result of the audio mixing of DataSources.

Author:
Lubomir Marinov

Field Summary
 
Fields inherited from interface javax.media.Duration
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
Constructor Summary
AudioMixingPushBufferDataSource(AudioMixer audioMixer)
          Initializes a new AudioMixingPushBufferDataSource instance which gives access to the result of the audio mixing performed by a specific AudioMixer.
 
Method Summary
 void addDTMF(DTMFInbandTone tone)
          Adds a new inband DTMF tone to send.
 void addInputDataSource(javax.media.protocol.DataSource inputDataSource)
          Adds a new input DataSource to be mixed by the associated AudioMixer of this instance and to not have its audio contributions included in the mixing output represented by this DataSource.
 void connect()
          Implements DataSource.connect().
 void disconnect()
          Implements DataSource.disconnect().
 javax.media.CaptureDeviceInfo getCaptureDeviceInfo()
          Implements CaptureDevice.getCaptureDeviceInfo().
 String getContentType()
          Implements DataSource.getContentType().
 Object getControl(String controlType)
          Implements DataSource.getControl(String).
 Object[] getControls()
          Implements DataSource.getControls().
 javax.media.Time getDuration()
          Implements DataSource.getDuration().
 javax.media.control.FormatControl[] getFormatControls()
          Implements CaptureDevice.getFormatControls().
 int[] getNextToneSignal(double samplingFrequency, int sampleSizeInBits)
          Gets the next inband DTMF tone signal.
 javax.media.protocol.PushBufferStream[] getStreams()
          Implements PushBufferDataSource.getStreams().
 boolean isMute()
          Determines whether this DataSource is mute.
 boolean isSendingDTMF()
          Determines whether this DataSource sends a DTMF tone.
 void setMute(boolean mute)
          Sets the mute state of this DataSource.
 void start()
          Implements DataSource.start().
 void stop()
          Implements DataSource.stop().
 
Methods inherited from class javax.media.protocol.DataSource
getLocator, initCheck, setLocator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioMixingPushBufferDataSource

public AudioMixingPushBufferDataSource(AudioMixer audioMixer)
Initializes a new AudioMixingPushBufferDataSource instance which gives access to the result of the audio mixing performed by a specific AudioMixer.

Parameters:
audioMixer - the AudioMixer performing audio mixing, managing the input DataSources and pushing the data of the new output PushBufferDataSource
Method Detail

addInputDataSource

public void addInputDataSource(javax.media.protocol.DataSource inputDataSource)
Adds a new input DataSource to be mixed by the associated AudioMixer of this instance and to not have its audio contributions included in the mixing output represented by this DataSource.

Parameters:
inputDataSource - a DataSource to be added for mixing to the AudioMixer associate with this instance and to not have its audio contributions included in the mixing output represented by this DataSource

connect

public void connect()
             throws IOException
Implements DataSource.connect(). Lets the AudioMixer know that one of its output PushBufferDataSources has been connected and marks this DataSource as connected.

Specified by:
connect in interface javax.media.protocol.CaptureDevice
Specified by:
connect in class javax.media.protocol.DataSource
Throws:
IOException - if the AudioMixer fails to connect

disconnect

public void disconnect()
Implements DataSource.disconnect(). Marks this DataSource as disconnected and notifies the AudioMixer that one of its output PushBufferDataSources has been disconnected.

Specified by:
disconnect in interface javax.media.protocol.CaptureDevice
Specified by:
disconnect in class javax.media.protocol.DataSource

getCaptureDeviceInfo

public javax.media.CaptureDeviceInfo getCaptureDeviceInfo()
Implements CaptureDevice.getCaptureDeviceInfo(). Delegates to the associated AudioMixer because it knows which CaptureDevice is being wrapped.

Specified by:
getCaptureDeviceInfo in interface javax.media.protocol.CaptureDevice
Returns:
the CaptureDeviceInfo of the CaptureDevice of the AudioMixer

getContentType

public String getContentType()
Implements DataSource.getContentType(). Delegates to the associated AudioMixer because it manages the inputs and knows their characteristics.

Specified by:
getContentType in class javax.media.protocol.DataSource
Returns:
a String value which represents the type of the content being made available by this DataSource i.e. the associated AudioMixer

getControl

public Object getControl(String controlType)
Implements DataSource.getControl(String).

Specified by:
getControl in interface javax.media.Controls
Specified by:
getControl in class javax.media.protocol.DataSource
Parameters:
controlType - a String value which names the type of the control of this instance to be retrieved
Returns:
an Object which represents the control of this instance with the specified type if such a control is available; otherwise, null

getControls

public Object[] getControls()
Implements DataSource.getControls(). Gets an array of Objects which represent the controls available for this DataSource.

Specified by:
getControls in interface javax.media.Controls
Specified by:
getControls in class javax.media.protocol.DataSource
Returns:
an array of Objects which represent the controls available for this DataSource

getDuration

public javax.media.Time getDuration()
Implements DataSource.getDuration(). Delegates to the associated AudioMixer because it manages the inputs and knows their characteristics.

Specified by:
getDuration in interface javax.media.Duration
Specified by:
getDuration in class javax.media.protocol.DataSource
Returns:
a Time value which represents the duration of the media being made available through this DataSource

getFormatControls

public javax.media.control.FormatControl[] getFormatControls()
Implements CaptureDevice.getFormatControls(). Delegates to the associated AudioMixer because it knows which CaptureDevice is being wrapped.

Specified by:
getFormatControls in interface javax.media.protocol.CaptureDevice
Returns:
an array of FormatControls of the CaptureDevice of the associated AudioMixer

getStreams

public javax.media.protocol.PushBufferStream[] getStreams()
Implements PushBufferDataSource.getStreams(). Gets a PushBufferStream which reads data from the associated AudioMixer and mixes its inputs.

Specified by:
getStreams in class javax.media.protocol.PushBufferDataSource
Returns:
an array with a single PushBufferStream which reads data from the associated AudioMixer and mixes its inputs if this DataSource is connected; otherwise, an empty array

start

public void start()
           throws IOException
Implements DataSource.start(). Starts the output PushBufferStream of this DataSource (if it exists) and notifies the AudioMixer that one of its output PushBufferDataSources has been started.

Specified by:
start in interface javax.media.protocol.CaptureDevice
Specified by:
start in class javax.media.protocol.DataSource
Throws:
IOException - if anything wrong happens while starting the output PushBufferStream of this DataSource

stop

public void stop()
          throws IOException
Implements DataSource.stop(). Notifies the AudioMixer that one of its output PushBufferDataSources has been stopped and stops the output PushBufferStream of this DataSource (if it exists).

Specified by:
stop in interface javax.media.protocol.CaptureDevice
Specified by:
stop in class javax.media.protocol.DataSource
Throws:
IOException - if anything wrong happens while stopping the output PushBufferStream of this DataSource

isMute

public boolean isMute()
Determines whether this DataSource is mute.

Specified by:
isMute in interface MuteDataSource
Returns:
true if this DataSource is mute; otherwise, false

setMute

public void setMute(boolean mute)
Sets the mute state of this DataSource.

Specified by:
setMute in interface MuteDataSource
Parameters:
mute - true to mute this DataSource; otherwise, false

addDTMF

public void addDTMF(DTMFInbandTone tone)
Adds a new inband DTMF tone to send.

Specified by:
addDTMF in interface InbandDTMFDataSource
Parameters:
tone - the DTMF tone to send.

isSendingDTMF

public boolean isSendingDTMF()
Determines whether this DataSource sends a DTMF tone.

Returns:
true if this DataSource is sending a DTMF tone; otherwise, false.

getNextToneSignal

public int[] getNextToneSignal(double samplingFrequency,
                               int sampleSizeInBits)
Gets the next inband DTMF tone signal.

Parameters:
samplingFrequency - The sampling frequency (codec clock rate) in Hz of the stream which will encapsulate this signal.
sampleSizeInBits - The size of each sample (8 for a byte, 16 for a short and 32 for an int)
Returns:
The data array containing the DTMF signal.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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