SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.media.protocol.portaudio.streams
Class MasterPortAudioStream

java.lang.Object
  extended by net.java.sip.communicator.impl.media.protocol.portaudio.streams.MasterPortAudioStream

public class MasterPortAudioStream
extends Object

The master audio stream which opens the PortAudio stream and reads from it. We can have multiple slave input streams that are connected to this master stream.

Author:
Damian Minkov, Lubomir Marinov

Field Summary
(package private)  int channels
           
(package private)  double sampleRate
           
 
Constructor Summary
MasterPortAudioStream(int deviceIndex, double sampleRate, int channels)
          Creates new stream.
 
Method Summary
 int getDeviceIndex()
          Returns the index of the device that we use.
 long getStream()
          Returns the pointer to the stream that we use for reading.
 byte[] read()
          Block and read a buffer from the stream.
 void setParams(OutputPortAudioStream out, boolean deNoiseEnabled, boolean echoCancelEnabled, int frameSize, int filterLength)
          Sets parameters to the underlying stream.
(package private)  void start(InputPortAudioStream slave)
          Starts the stream operation if not already started and stores the slave inputstream that starts us.
(package private)  void stop(InputPortAudioStream slave)
          Stops the PortAudio stream if requested by the last stream that uses us.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sampleRate

double sampleRate

channels

int channels
Constructor Detail

MasterPortAudioStream

public MasterPortAudioStream(int deviceIndex,
                             double sampleRate,
                             int channels)
                      throws PortAudioException
Creates new stream.

Parameters:
deviceIndex - the device to use.
channels - the channels to serve.
sampleRate - the sample rate.
Throws:
PortAudioException - if stream cannot be opened.
Method Detail

start

void start(InputPortAudioStream slave)
     throws PortAudioException
Starts the stream operation if not already started and stores the slave inputstream that starts us.

Throws:
PortAudioException

stop

void stop(InputPortAudioStream slave)
    throws PortAudioException
Stops the PortAudio stream if requested by the last stream that uses us.

Throws:
PortAudioException

getDeviceIndex

public int getDeviceIndex()
Returns the index of the device that we use.

Returns:
the deviceIndex

getStream

public long getStream()
Returns the pointer to the stream that we use for reading.

Returns:
the stream pointer.

read

public byte[] read()
            throws PortAudioException
Block and read a buffer from the stream.

Returns:
the bytes that a read from underlying stream.
Throws:
PortAudioException - if an error occurs while reading.

setParams

public void setParams(OutputPortAudioStream out,
                      boolean deNoiseEnabled,
                      boolean echoCancelEnabled,
                      int frameSize,
                      int filterLength)
Sets parameters to the underlying stream.

Parameters:
out - the connected output stream if echo cancel is enabled.
deNoiseEnabled - true if we want to enable noise reduction.
echoCancelEnabled - true to enable echo cancel.
frameSize - Number of samples to process at one time (should correspond to 10-20 ms).
filterLength - Number of samples of echo to cancel (should generally correspond to 100-500 ms)

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

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