public class AudioMixer
extends java.lang.Object
The input audio streams are provided to the AudioMixer through
addInDataSource(DataSource)
in the form of input
DataSources giving access to one or more input
SourceStreams.
The output audio stream representing the mix of the multiple input audio
streams is provided by the AudioMixer in the form of a
AudioMixingPushBufferDataSource giving access to a
AudioMixingPushBufferStream. Such an output is obtained through
createOutDataSource()
. The AudioMixer is able to provide
multiple output audio streams at one and the same time, though, each of them
containing the mix of a subset of the input audio streams.
Modifier and Type | Field and Description |
---|---|
protected javax.media.protocol.CaptureDevice |
captureDevice
The CaptureDevice capabilities provided by the
AudioMixingPushBufferDataSources created by this
AudioMixer.
|
Constructor and Description |
---|
AudioMixer(javax.media.protocol.CaptureDevice captureDevice)
Initializes a new AudioMixer instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addInDataSource(javax.media.protocol.DataSource inDataSource)
Adds a new input DataSource to the collection of input
DataSources from which this instance reads audio.
|
(package private) void |
addInDataSource(javax.media.protocol.DataSource inDataSource,
AudioMixingPushBufferDataSource outDataSource)
Adds a new input DataSource to the collection of input
DataSources from which this instance reads audio.
|
(package private) void |
connect()
Notifies this AudioMixer that an output
AudioMixingPushBufferDataSource reading from it has been
connected.
|
protected void |
connect(javax.media.protocol.DataSource dataSource,
javax.media.protocol.DataSource inDataSource)
Connects to a specific DataSource which this AudioMixer
will read audio from.
|
(package private) void |
connected(InDataSourceDesc inDataSource)
Notifies this AudioMixer that a specific input
DataSource has finished its connecting procedure.
|
AudioMixingPushBufferDataSource |
createOutDataSource()
Creates a new AudioMixingPushBufferDataSource which gives
access to a single audio stream representing the mix of the audio streams
input into this AudioMixer through its input
DataSources.
|
(package private) void |
disconnect()
Notifies this AudioMixer that an output
AudioMixingPushBufferDataSource reading from it has been
disconnected.
|
(package private) javax.media.control.BufferControl |
getBufferControl()
Gets the BufferControl of this instance and, respectively, its
AudioMixingPushBufferDataSources.
|
(package private) javax.media.CaptureDeviceInfo |
getCaptureDeviceInfo()
Gets the CaptureDeviceInfo of the CaptureDevice
this AudioMixer provides through its output
AudioMixingPushBufferDataSources.
|
(package private) java.lang.String |
getContentType()
Gets the content type of the data output by this AudioMixer.
|
(package private) javax.media.Time |
getDuration()
Gets the duration of each one of the output streams produced by this
AudioMixer.
|
(package private) javax.media.control.FormatControl[] |
getFormatControls()
Gets an array of FormatControls for the
CaptureDevice this AudioMixer provides through
its output AudioMixingPushBufferDataSources.
|
AudioMixingPushBufferDataSource |
getLocalOutDataSource()
Gets the AudioMixingPushBufferDataSource containing the mix of
all input DataSources excluding the CaptureDevice of
this AudioMixer and is thus meant for playback on the local peer
in a call.
|
(package private) AudioMixerPushBufferStream |
getOutStream()
Gets the AudioMixerPushBufferStream, first creating it if it
does not exist already, which reads data from the input
DataSources of this AudioMixer and pushes it to
output AudioMixingPushBufferStreams for audio mixing.
|
TranscodingDataSource |
getTranscodingDataSource(javax.media.protocol.DataSource inDataSource)
Searches this object's inDataSources for one that matches
inDataSource, and returns it's associated
TranscodingDataSource.
|
protected void |
read(javax.media.protocol.PushBufferStream stream,
javax.media.Buffer buffer,
javax.media.protocol.DataSource dataSource)
Reads media from a specific PushBufferStream which belongs to
a specific DataSource into a specific output Buffer.
|
void |
removeInDataSources(DataSourceFilter dataSourceFilter)
Removes DataSources accepted by a specific
DataSourceFilter from the list of input DataSources of
this AudioMixer from which it reads audio to be mixed.
|
(package private) void |
start(AudioMixerPushBufferStream outStream,
long generation)
Starts the input DataSources of this AudioMixer.
|
(package private) void |
stop(AudioMixerPushBufferStream outStream,
long generation)
Stops the input DataSources of this AudioMixer.
|
protected final javax.media.protocol.CaptureDevice captureDevice
public AudioMixer(javax.media.protocol.CaptureDevice captureDevice)
captureDevice
- the CaptureDevice capabilities to be
provided to the AudioMixingPushBufferDataSources created by the
new instance and its first input DataSourcepublic void addInDataSource(javax.media.protocol.DataSource inDataSource)
inDataSource
- a new DataSource to input audio to this
instancevoid addInDataSource(javax.media.protocol.DataSource inDataSource, AudioMixingPushBufferDataSource outDataSource)
inDataSource
- a new DataSource to input audio to this
instanceoutDataSource
- the AudioMixingPushBufferDataSource to
not include the audio contributions of inDataSource in the
mix it outputsvoid connect() throws java.io.IOException
java.io.IOException
- if input/output error occurredprotected void connect(javax.media.protocol.DataSource dataSource, javax.media.protocol.DataSource inDataSource) throws java.io.IOException
dataSource
- the DataSource to connect toinDataSource
- the DataSource which is the cause for
dataSource to exist in this AudioMixerjava.io.IOException
- if anything wrong happens while connecting to
dataSourcevoid connected(InDataSourceDesc inDataSource) throws java.io.IOException
inDataSource
- the InDataSourceDesc of the input
DataSource which has finished its connecting procedurejava.io.IOException
- if anything wrong happens while including
inDataSource into the mixpublic AudioMixingPushBufferDataSource createOutDataSource()
void disconnect()
javax.media.control.BufferControl getBufferControl()
javax.media.CaptureDeviceInfo getCaptureDeviceInfo()
java.lang.String getContentType()
javax.media.Time getDuration()
javax.media.control.FormatControl[] getFormatControls()
public AudioMixingPushBufferDataSource getLocalOutDataSource()
AudioMixerPushBufferStream getOutStream()
public TranscodingDataSource getTranscodingDataSource(javax.media.protocol.DataSource inDataSource)
inDataSource
- the DataSource to search for.protected void read(javax.media.protocol.PushBufferStream stream, javax.media.Buffer buffer, javax.media.protocol.DataSource dataSource) throws java.io.IOException
stream
- the PushBufferStream to read media from and known
to belong to the specified DataSOurcebuffer
- the output Buffer in which the media read from the
specified stream is to be written so that it gets returned to
the callerdataSource
- the DataSource from which stream
originatedjava.io.IOException
- if anything wrong happens while reading from the
specified streampublic void removeInDataSources(DataSourceFilter dataSourceFilter)
dataSourceFilter
- the DataSourceFilter which selects the
DataSources to be removed from the list of input
DataSources of this AudioMixer from which it reads
audio to be mixedvoid start(AudioMixerPushBufferStream outStream, long generation) throws java.io.IOException
outStream
- the AudioMixerPushBufferStream which requests
this AudioMixer to start. If outStream is the current
one and only AudioMixerPushBufferStream of this
AudioMixer, this AudioMixer starts if it hasn't started
yet. Otherwise, the request is ignored.generation
- a value generated by outStream indicating the
order of the invocations of the start and stop methods
performed by outStream allowing it to execute the said methods
outside synchronized blocks for the purposes of reducing deadlock risksjava.io.IOException
- if any of the input DataSources of this
AudioMixer throws such an exception while attempting to start itvoid stop(AudioMixerPushBufferStream outStream, long generation) throws java.io.IOException
outStream
- the AudioMixerPushBufferStream which requests
this AudioMixer to stop. If outStream is the current
one and only AudioMixerPushBufferStream of this
AudioMixer, this AudioMixer stops. Otherwise, the
request is ignored.generation
- a value generated by outStream indicating the
order of the invocations of the start and stop methods
performed by outStream allowing it to execute the said methods
outside synchronized blocks for the purposes of reducing deadlock risksjava.io.IOException
- if any of the input DataSources of this
AudioMixer throws such an exception while attempting to stop it
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.