|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectaudio.AudioInterfacePCM
public class AudioInterfacePCM
Implements the audio interface for 16-bit signed linear audio (PCM_SIGNED). It also provides support for CODECs that can convert to and from Signed LIN16.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface audio.AudioInterface |
---|
AudioInterface.Packetizer |
Field Summary | |
---|---|
private java.lang.Thread |
audioPlayerThread
|
private AudioInterface.Packetizer |
audioSender
|
private java.lang.Thread |
audioSenderThread
|
private long |
callLength
Measured call length in milliseconds |
private long |
deltaTimePlayerMinusMic
|
private static int |
FRAME_COUNT
Audio buffering depth in number of frames |
private static int |
FRAME_INTERVAL
Frame interval in milliseconds |
private boolean |
jitBufFirst
|
private long |
jitBufFudge
|
private int |
jitBufGet
|
private int |
jitBufPut
|
private long |
lastMicTimestamp
|
private static int |
LLBS
Low-level water mark used for de-jittering |
private int |
micBufGet
|
private int |
micBufPut
|
private java.lang.Thread |
micRecorderThread
|
private javax.sound.sampled.AudioFormat |
mono44k
|
private javax.sound.sampled.AudioFormat |
mono8k
|
private AudioBuffer[] |
playBuffer
|
private boolean |
playerIsEnabled
|
private boolean |
propertyBigBuff
Big buffers |
private java.lang.String |
propertyInputDeviceName
Input device name |
private java.lang.String |
propertyOutputDeviceName
Output device name |
private boolean |
propertyStereoRec
Stereo recording |
private boolean |
providingRingBack
|
private AudioBuffer[] |
recordBuffer
|
private java.lang.Thread |
ringerThread
|
private byte[] |
ringSamples
|
private long |
ringTimer
|
private byte[] |
silenceSamples
|
private javax.sound.sampled.SourceDataLine |
sourceDataLine
|
private javax.sound.sampled.AudioFormat |
stereo8k
|
private javax.sound.sampled.TargetDataLine |
targetDataLine
|
Constructor Summary | |
---|---|
AudioInterfacePCM()
Constructor for the AudioInterfacePCM object |
Method Summary | |
---|---|
private void |
audioPlayerWorker()
Writes frames to audio output i.e. source data line |
void |
cleanUp()
Stops threads and cleans-up the instance. |
private void |
concealMissingDataForAudioOutput(int n)
Conceals missing data in the audio output buffer by averaging from samples taken from the the previous and next buffer. |
private javax.sound.sampled.DataLine |
findDataLineByPref(java.lang.String pref,
javax.sound.sampled.AudioFormat af,
java.lang.String name,
int sbuffsz,
java.lang.Class<?> lineClass,
java.lang.String debugInfo)
Searches for data line of either sort (source/targe) based on the pref string. |
private javax.sound.sampled.SourceDataLine |
findSourceDataLineByPref(java.lang.String pref,
javax.sound.sampled.AudioFormat af,
java.lang.String name,
int sbuffsz)
Searches for source data line according to preferences. |
private javax.sound.sampled.TargetDataLine |
fintTargetDataLineByPref(java.lang.String pref,
javax.sound.sampled.AudioFormat af,
java.lang.String name,
int sbuffsz)
Searches for target data line according to preferences. |
private boolean |
getAudioIn()
Returns audio input (target data line) |
private boolean |
getAudioOut()
Get audio output. |
AudioInterface |
getByFormat(java.lang.Integer format)
Gets audio interface by VoicePDU format |
int |
getSampleSize()
Returns preferred the minimum sample size for use in creating buffers etc. |
int |
getVoicePduSubclass()
Returns our VoicePDU format |
private void |
initializeRingerSamples()
Initializes ringer samples (ring singnal and silecce) samples |
private void |
micDataRead()
Called from micRecorder to record audio samples from microphone. |
private void |
micRecorderWorker()
Records audio samples from the microphone |
private void |
pduSenderWorker()
Sends audio frames to UDP channel at regular intervals (ticks) |
long |
readWithTimestamp(byte[] buff)
Read from the Microphone, into the buffer provided, but only filling getSampSize() bytes. |
private void |
resample(byte[] src,
byte[] dest)
Simple PCM down sampler. |
private void |
ringerWorker()
Writes ring signal samples to audio output |
private void |
sendAudioFrame(long set)
Called every FRAMEINTERVAL ms to send audio frame |
void |
setAudioSender(AudioInterface.Packetizer as)
Sets the active audio sender for the recorder |
void |
startPlay()
Starts the audio output worker thread |
long |
startRecording()
Start the audio recording worker thread |
void |
startRinging()
Starts ringing signal |
void |
stopPlay()
Stops the audio output worker thread |
void |
stopRecording()
Stops the audio recording worker thread |
void |
stopRinging()
Stops ringing singnal |
void |
writeBuffered(byte[] buff,
long timestamp)
Enqueue packet for playing into de-jitter buffer. |
private long |
writeBuffersToAudioOutput()
Writes de-jittered audio frames to audio output |
private long |
writeDirectIfAvail(byte[] samples)
Writes audio samples to audio output directly (without using jitter buffer). |
void |
writeDirectly(byte[] buff)
Writes directly to source line without buffering |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int FRAME_COUNT
private static final int LLBS
private static final int FRAME_INTERVAL
private boolean propertyStereoRec
private boolean propertyBigBuff
private java.lang.String propertyInputDeviceName
private java.lang.String propertyOutputDeviceName
private javax.sound.sampled.AudioFormat mono8k
private javax.sound.sampled.AudioFormat stereo8k
private javax.sound.sampled.AudioFormat mono44k
private javax.sound.sampled.TargetDataLine targetDataLine
private volatile java.lang.Thread audioSenderThread
private volatile java.lang.Thread micRecorderThread
private volatile AudioInterface.Packetizer audioSender
private AudioBuffer[] recordBuffer
private int micBufPut
private int micBufGet
private long lastMicTimestamp
private javax.sound.sampled.SourceDataLine sourceDataLine
private volatile java.lang.Thread audioPlayerThread
private AudioBuffer[] playBuffer
private int jitBufPut
private int jitBufGet
private long jitBufFudge
private boolean jitBufFirst
private boolean playerIsEnabled
private long deltaTimePlayerMinusMic
private long callLength
private volatile java.lang.Thread ringerThread
private byte[] ringSamples
private byte[] silenceSamples
private boolean providingRingBack
private long ringTimer
Constructor Detail |
---|
public AudioInterfacePCM()
Method Detail |
---|
public int getSampleSize()
getSampleSize
in interface AudioInterface
public int getVoicePduSubclass()
getVoicePduSubclass
in interface AudioInterface
public void setAudioSender(AudioInterface.Packetizer as)
setAudioSender
in interface AudioInterface
public void cleanUp()
cleanUp
in interface AudioInterface
private void audioPlayerWorker()
private long writeBuffersToAudioOutput()
private void concealMissingDataForAudioOutput(int n)
public void writeDirectly(byte[] buff)
writeDirectly
in interface AudioInterface
public void writeBuffered(byte[] buff, long timestamp) throws java.io.IOException
writeBuffered
in interface AudioInterface
java.io.IOException
private void pduSenderWorker()
private void sendAudioFrame(long set)
private void micRecorderWorker()
private void micDataRead()
public long readWithTimestamp(byte[] buff) throws java.io.IOException
readWithTimestamp
in interface AudioInterface
buff
- audio samples
java.io.IOException
- Description of Exceptionprivate void resample(byte[] src, byte[] dest)
src
- source buffer with audio samplesdest
- destination buffer with audio samplesprivate void ringerWorker()
private long writeDirectIfAvail(byte[] samples)
private void initializeRingerSamples()
private boolean getAudioOut()
private boolean getAudioIn()
private javax.sound.sampled.DataLine findDataLineByPref(java.lang.String pref, javax.sound.sampled.AudioFormat af, java.lang.String name, int sbuffsz, java.lang.Class<?> lineClass, java.lang.String debugInfo)
private javax.sound.sampled.TargetDataLine fintTargetDataLineByPref(java.lang.String pref, javax.sound.sampled.AudioFormat af, java.lang.String name, int sbuffsz)
private javax.sound.sampled.SourceDataLine findSourceDataLineByPref(java.lang.String pref, javax.sound.sampled.AudioFormat af, java.lang.String name, int sbuffsz)
public void stopRecording()
stopRecording
in interface AudioInterface
public long startRecording()
startRecording
in interface AudioInterface
public void startPlay()
startPlay
in interface AudioInterface
public void stopPlay()
stopPlay
in interface AudioInterface
public AudioInterface getByFormat(java.lang.Integer format)
getByFormat
in interface AudioInterface
public void startRinging()
startRinging
in interface AudioInterface
public void stopRinging()
stopRinging
in interface AudioInterface
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |