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

net.java.sip.communicator.impl.media.protocol.alsa
Class AlsaStream

java.lang.Object
  extended by net.java.sip.communicator.impl.media.protocol.alsa.AlsaStream
All Implemented Interfaces:
Runnable, javax.media.Controls, javax.media.protocol.PushBufferStream, javax.media.protocol.SourceStream

public class AlsaStream
extends Object
implements javax.media.protocol.PushBufferStream, Runnable

low-latency ALSA access through JNI wrapper

Author:
Jean Lorchat

Field Summary
protected  javax.media.format.AudioFormat audioFormat
           
protected  javax.media.protocol.ContentDescriptor cd
           
protected  javax.media.Control[] controls
           
protected  int maxDataLength
           
(package private)  int seqNo
           
protected  boolean started
           
protected  Thread thread
           
protected  javax.media.protocol.BufferTransferHandler transferHandler
           
 
Fields inherited from interface javax.media.protocol.SourceStream
LENGTH_UNKNOWN
 
Constructor Summary
AlsaStream()
          We only provide 8 kbps access to the device for now In addition, datablock size is fixed to 160 samples (320 bytes) This turns out to be 20ms worth of samples at 8kbps Very convenient for ilbc 20ms mode...
 
Method Summary
 boolean endOfStream()
          The stream of happiness never ends, somehow.
 javax.media.protocol.ContentDescriptor getContentDescriptor()
          We are providing access to raw data
 long getContentLength()
          Come on, we are streaming.
 Object getControl(String controlType)
          Return required control from the Control[] array if exists, that is
 Object[] getControls()
          Gives control information to the caller
 javax.media.Format getFormat()
          Tell whoever has interest how we are going to send the data
 void read(javax.media.Buffer buffer)
          Reads sample data using native call
 void run()
          Transfer Buffer information through current thread then sleep until next data slice is ready.
 void setTransferHandler(javax.media.protocol.BufferTransferHandler transferHandler)
          Dunno about that piece yet...
(package private)  void start(boolean started)
          Starts a new thread for the stream operation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cd

protected javax.media.protocol.ContentDescriptor cd

maxDataLength

protected int maxDataLength

audioFormat

protected javax.media.format.AudioFormat audioFormat

started

protected boolean started

thread

protected Thread thread

transferHandler

protected javax.media.protocol.BufferTransferHandler transferHandler

controls

protected javax.media.Control[] controls

seqNo

int seqNo
Constructor Detail

AlsaStream

public AlsaStream()
We only provide 8 kbps access to the device for now In addition, datablock size is fixed to 160 samples (320 bytes) This turns out to be 20ms worth of samples at 8kbps Very convenient for ilbc 20ms mode...

Method Detail

getContentDescriptor

public javax.media.protocol.ContentDescriptor getContentDescriptor()
We are providing access to raw data

Specified by:
getContentDescriptor in interface javax.media.protocol.SourceStream

getContentLength

public long getContentLength()
Come on, we are streaming. Can't guess when the user wants to stop...

Specified by:
getContentLength in interface javax.media.protocol.SourceStream

endOfStream

public boolean endOfStream()
The stream of happiness never ends, somehow.

Specified by:
endOfStream in interface javax.media.protocol.SourceStream

getFormat

public javax.media.Format getFormat()
Tell whoever has interest how we are going to send the data

Specified by:
getFormat in interface javax.media.protocol.PushBufferStream

read

public void read(javax.media.Buffer buffer)
          throws IOException
Reads sample data using native call

Specified by:
read in interface javax.media.protocol.PushBufferStream
Parameters:
buffer - A Buffer with byte array as data, large enough to be filled with sample data. If this is not the case, we are going to allocate it ourselves anyway and replace the current data.
Throws:
IOException - Native method might throw an exception. Well actually that would surprise me because it is not implemented, but we love to be future-proof, isn't it ?

setTransferHandler

public void setTransferHandler(javax.media.protocol.BufferTransferHandler transferHandler)
Dunno about that piece yet...

Specified by:
setTransferHandler in interface javax.media.protocol.PushBufferStream

start

void start(boolean started)
Starts a new thread for the stream operation


run

public void run()
Transfer Buffer information through current thread then sleep until next data slice is ready.

Specified by:
run in interface Runnable

getControls

public Object[] getControls()
Gives control information to the caller

Specified by:
getControls in interface javax.media.Controls

getControl

public Object getControl(String controlType)
Return required control from the Control[] array if exists, that is

Specified by:
getControl in interface javax.media.Controls

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

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