public class AudioCaptureClient
extends java.lang.Object
WASAPIStream
to simultaneously utilize multiple
IAudioCaptureClient instances (e.g. in the case of acoustic echo
cancellation in which audio is input from both the capture and the render
endpoint devices).Modifier and Type | Field and Description |
---|---|
(package private) int |
bufferSize
The size/length in bytes of the byte[] to be filled in an
invocation of
read(byte[], int, int) . |
(package private) long |
devicePeriod
The length in milliseconds of the interval between successive, periodic
processing passes by the audio engine on the data in the endpoint buffer.
|
(package private) javax.media.format.AudioFormat |
outFormat
The AudioFormat of the data output/made available by this
AudioCaptureClient.
|
Constructor and Description |
---|
AudioCaptureClient(WASAPISystem audioSystem,
javax.media.MediaLocator locator,
AudioSystem.DataFlow dataFlow,
int streamFlags,
long hnsBufferDuration,
javax.media.format.AudioFormat outFormat,
javax.media.protocol.BufferTransferHandler transferHandler)
Initializes a new AudioCaptureClient instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Releases the resources acquired by this instance throughout its lifetime
and prepares it to be garbage collected.
|
(package private) int |
getAvailableLength()
Gets the number of bytes of audio samples which have been read from the
associated IAudioCaptureClient by this instance and are
available to be read out of this instance via
read(byte[], int, int) . |
int |
read(byte[] buffer,
int offset,
int length)
Reads audio data from this instance into a specific byte array.
|
int |
read(IMediaBuffer iMediaBuffer,
int length)
Reads audio data from this instance into a specific
IMediaBuffer.
|
void |
start()
Starts the transfer of media from the IAudioCaptureClient
identified by the MediaLocator with which this instance has
been initialized.
|
void |
stop()
Stops the transfer of media from the IAudioCaptureClient
identified by the MediaLocator with which this instance has
been initialized.
|
final int bufferSize
read(byte[], int, int)
.final long devicePeriod
final javax.media.format.AudioFormat outFormat
public AudioCaptureClient(WASAPISystem audioSystem, javax.media.MediaLocator locator, AudioSystem.DataFlow dataFlow, int streamFlags, long hnsBufferDuration, javax.media.format.AudioFormat outFormat, javax.media.protocol.BufferTransferHandler transferHandler) throws java.lang.Exception
audioSystem
- the WASAPISystem instance which has
contributed locatorlocator
- a MediaLocator which identifies the audio
endpoint device to be opened and read by the new instancedataFlow
- the AudioSystem.DataFlow of the audio endpoint
device identified by locator. If
AudioSystem.DataFlow.PLAYBACK and streamFlags includes
WASAPI.AUDCLNT_STREAMFLAGS_LOOPBACK
, allows opening a render
endpoint device in loopback mode and inputing the data that is being
written on that render endpoint devicestreamFlags
- zero or more of the AUDCLNT_STREAMFLAGS_XXX
flags defined by the WASAPI classhnsBufferDuration
- the base of the duration in milliseconds of the
buffer that the audio application will share with the audio engine. If
Format.NOT_SPECIFIED
, the method uses the default interval
between periodic passes by the audio engine.outFormat
- the AudioFormat of the data to be made
available by the new instance. Eventually, the
IAudioCaptureClient to be represented by the new instance may be
initialized with a different AudioFormat in which case the new
instance will automatically transcode the data input from the
IAudioCaptureClient into the specified outFormat.transferHandler
- the BufferTransferHandler to be invoked
when the new instance has made data available to be read via
read(byte[], int, int)
java.lang.Exception
- if the initialization of the new instance failspublic void close()
int getAvailableLength()
read(byte[], int, int)
.public int read(byte[] buffer, int offset, int length) throws java.io.IOException
buffer
- the byte array into which the audio data read from
this instance is to be writtenoffset
- the offset in buffer at which the writing of the
audio data is to startlength
- the maximum number of bytes in buffer starting at
offset to be writtenjava.io.IOException
- if the reading from this instance or the writing into
the specified buffer failspublic int read(IMediaBuffer iMediaBuffer, int length) throws java.io.IOException
iMediaBuffer
- the IMediaBuffer into which the audio data
read from this instance is to be writtenlength
- the maximum number of bytes to read from this instance and
write into the specified iMediaBufferjava.io.IOException
- if the reading of audio data from this instance or
the writing into the specified iMediaBuffer failspublic void start() throws java.io.IOException
java.io.IOException
- if the starting of the transfer of media failspublic void stop() throws java.io.IOException
java.io.IOException
- if the stopping of the transfer of media fails
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.