Class AudioMixer
- java.lang.Object
-
- org.jitsi.impl.neomedia.conference.AudioMixer
-
public class AudioMixer extends Object
Represents an audio mixer which manages the mixing of multiple audio streams i.e. it is able to output a single audio stream which contains the audio of multiple input audio streams.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.- Author:
- Lyubomir Marinov
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.media.protocol.CaptureDevicecaptureDeviceThe CaptureDevice capabilities provided by the AudioMixingPushBufferDataSources created by this AudioMixer.
-
Constructor Summary
Constructors Constructor Description AudioMixer(javax.media.protocol.CaptureDevice captureDevice)Initializes a new AudioMixer instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInDataSource(javax.media.protocol.DataSource inDataSource)Adds a new input DataSource to the collection of input DataSources from which this instance reads audio.protected voidconnect(javax.media.protocol.DataSource dataSource, javax.media.protocol.DataSource inDataSource)Connects to a specific DataSource which this AudioMixer will read audio from.AudioMixingPushBufferDataSourcecreateOutDataSource()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.AudioMixingPushBufferDataSourcegetLocalOutDataSource()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.TranscodingDataSourcegetTranscodingDataSource(javax.media.protocol.DataSource inDataSource)Searches this object's inDataSources for one that matches inDataSource, and returns it's associated TranscodingDataSource.protected voidread(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.voidremoveInDataSources(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.
-
-
-
Field Detail
-
captureDevice
protected final javax.media.protocol.CaptureDevice captureDevice
The CaptureDevice capabilities provided by the AudioMixingPushBufferDataSources created by this AudioMixer. JMF's Manager.createMergingDataSource(DataSource[]) requires the interface implementation for audio if it is implemented for video and it is indeed the case for our use case of AudioMixingPushBufferDataSource.
-
-
Constructor Detail
-
AudioMixer
public AudioMixer(javax.media.protocol.CaptureDevice captureDevice)
Initializes a new AudioMixer instance. Because JMF's Manager.createMergingDataSource(DataSource[]) requires the implementation of CaptureDevice for audio if it is implemented for video and it is indeed the cause for our use case of AudioMixingPushBufferDataSource, the new AudioMixer instance provides specified CaptureDevice capabilities to the AudioMixingPushBufferDataSources it creates. The specified CaptureDevice is also added as the first input DataSource of the new instance.- Parameters:
captureDevice- the CaptureDevice capabilities to be provided to the AudioMixingPushBufferDataSources created by the new instance and its first input DataSource
-
-
Method Detail
-
addInDataSource
public void addInDataSource(javax.media.protocol.DataSource inDataSource)
Adds a new input DataSource to the collection of input DataSources from which this instance reads audio. If the specified DataSource indeed provides audio, the respective contributions to the mix are always included.- Parameters:
inDataSource- a new DataSource to input audio to this instance
-
connect
protected void connect(javax.media.protocol.DataSource dataSource, javax.media.protocol.DataSource inDataSource) throws IOExceptionConnects to a specific DataSource which this AudioMixer will read audio from. The specified DataSource is known to exist because of a specific DataSource added as an input to this instance i.e. it may be an actual input DataSource added to this instance or a DataSource transcoding an input DataSource added to this instance.- Parameters:
dataSource- the DataSource to connect toinDataSource- the DataSource which is the cause for dataSource to exist in this AudioMixer- Throws:
IOException- if anything wrong happens while connecting to dataSource
-
createOutDataSource
public 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. The returned AudioMixingPushBufferDataSource can also be used to include new input DataSources in this AudioMixer but have their contributions not included in the mix available through the returned AudioMixingPushBufferDataSource.- Returns:
- 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
-
getLocalOutDataSource
public 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.- Returns:
- 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
-
getTranscodingDataSource
public TranscodingDataSource getTranscodingDataSource(javax.media.protocol.DataSource inDataSource)
Searches this object's inDataSources for one that matches inDataSource, and returns it's associated TranscodingDataSource. Currently this is only used when the MediaStream needs access to the codec chain used to playback one of it's ReceiveStreams.- Parameters:
inDataSource- the DataSource to search for.- Returns:
- The TranscodingDataSource associated with inDataSource, if we can find one, null otherwise.
-
read
protected void read(javax.media.protocol.PushBufferStream stream, javax.media.Buffer buffer, javax.media.protocol.DataSource dataSource) throws IOExceptionReads media from a specific PushBufferStream which belongs to a specific DataSource into a specific output Buffer. Allows extenders to tap into the reading and monitor and customize it.- Parameters:
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 originated- Throws:
IOException- if anything wrong happens while reading from the specified stream
-
removeInDataSources
public 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.- Parameters:
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 mixed
-
-