|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.rmi.server.RemoteObject | +--java.rmi.server.RemoteServer | +--java.rmi.server.UnicastRemoteObject | +--com.cloudgarden.audio.AudioServer | +--com.cloudgarden.audio.AudioServerSource
This class receives audio input from a remote (client) machine. The port it uses, it's remote name and (optionally) the IP address of the client permitted to send the audio data, are specified in the constructor.
Field Summary | |
protected boolean |
paused
|
protected boolean |
waiting
|
Fields inherited from class com.cloudgarden.audio.AudioServer |
clientAddress, clientListeners, clients, closed, contentType, format, listeners, open, port, registry, remoteName |
Fields inherited from class java.rmi.server.RemoteObject |
ref |
Fields inherited from interface com.cloudgarden.audio.AudioObject |
END_OF_DATA |
Constructor Summary | |
AudioServerSource(java.lang.String remoteName,
java.net.InetAddress clientAddress,
int port)
Creates, initializes and binds an AudioInputSocket to the given remoteName in the local registry. |
Method Summary | |
int |
acceptBytes(byte[] bytes,
int offset,
int len)
An RMI method called by the remote client to send data to this class. |
boolean |
canSetAudioFormat()
Returns false if the AudioFormat cannot be set - eg some Recognizers may not be able to change their input format, so the CGAudioManager (which is an AudioSink) for that Recognizer will return false here. |
void |
drain()
Blocks until END_OF_DATA is written to or read from this AudioObject. |
AudioSink |
getSink()
Returns the AudioSink set using setSink |
boolean |
isPaused()
|
boolean |
isSending()
Returns true if the thread started by the startSending method is still writing data to the AudioSink. |
boolean |
isWaiting()
Returns true if no data has yet been written or read from this AudioObject |
int |
read(byte[] data,
int len)
Convenience method - should call read(data, 0, len) |
int |
read(byte[] data,
int offset,
int len)
Used to read data from this source - called by the AudioSink which this source is connected to (if its startGetting method is used) so need not be called explicitly by an application. |
void |
setAudioFormat(javax.sound.sampled.AudioFormat format)
Sets the AudioFormat for this AudioObject. |
void |
setBufferSize(int size)
Sets the buffer size of the internal AudioPipe |
void |
setContentType(java.lang.String contentType)
Sets the content type for this AudioObject - contentType must be one of the FileTypeDescriptor String fields, eg MPEG_AUDIO. |
void |
setPaused(boolean paused)
If paused is true, writing or reading data to or from this AudioObject will block until setPaused(false) is called. |
void |
setSink(AudioSink sink)
Sets the sink for this source - this method should also call the setSource method on the sink object (making sure to avaoid an endless loop) to ensure that source and sink are connected to each other (and not to different sinks/sources). |
void |
startSending()
This method should start a thread which repeatedly writes data to the AudioSink object which this object is connected to, until it writes data with length END_OF_DATA, or until the stopSending method is called. |
void |
stopSending()
|
Methods inherited from class com.cloudgarden.audio.AudioServer |
addClient, addClientListener, addTransferListener, bytesTransferred, bytesTransferred, checkClient, closeConnection, closeServer, getAudioFormat, getChannels, getClients, getContentType, getSampleRate, getSampleSizeInBits, isBigEndian, isOpen, isSigned, openConnection, removeClient, removeClientListener, removeTransferListener, setAudioFormat |
Methods inherited from class java.rmi.server.UnicastRemoteObject |
clone, exportObject, exportObject, exportObject, unexportObject |
Methods inherited from class java.rmi.server.RemoteServer |
getClientHost, getLog, setLog |
Methods inherited from class java.rmi.server.RemoteObject |
equals, getRef, hashCode, toString, toStub |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.cloudgarden.audio.AudioServerI |
closeConnection, getChannels, getContentType, getSampleRate, getSampleSizeInBits, isBigEndian, isSigned, openConnection, setAudioFormat |
Methods inherited from interface com.cloudgarden.audio.AudioObject |
addTransferListener, getAudioFormat, getContentType, removeTransferListener |
Field Detail |
protected boolean waiting
protected boolean paused
Constructor Detail |
public AudioServerSource(java.lang.String remoteName, java.net.InetAddress clientAddress, int port) throws java.rmi.RemoteException
remoteName
- is the name with which this object is registered in the registry
and so must be unique to this machine. Note that multiple Recognizers can each
have an AudioInputSocket on the same machine.clientAddress
- may be null for no restriction on allowed IP addressport
- may be set to -1 to use the default port (Registry.REGISTRY_PORT)Method Detail |
public void setBufferSize(int size)
public void setSink(AudioSink sink) throws java.io.IOException
AudioSource
If the sink's AudioFormat is null or the sink's format differs from this AudioSource's format, then the sink's format is set equal to that of this AudioSource.
If the sink's AudioFormat is not null and this AudioSource's format is null then this AudioSource's format is set equal to the sink's.
The same is done for the ContentType as described above for the AudioFormat.
Note: if the sink is an AudioConverter then the get/setIncomingAudioFormat method is called instead of get/setAudioFormat.
setSink
in interface AudioSource
com.cloudgarden.audio.AudioSource
AudioSource.getSink()
public AudioSink getSink()
AudioSource
getSink
in interface AudioSource
com.cloudgarden.audio.AudioSource
AudioSource.setSink(com.cloudgarden.audio.AudioSink)
public int acceptBytes(byte[] bytes, int offset, int len) throws java.rmi.RemoteException
acceptBytes
in interface AudioInputServerI
public void stopSending()
stopSending
in interface AudioSource
com.cloudgarden.audio.AudioSource
AudioSource.startSending()
public void startSending() throws java.io.IOException
AudioSource
startSending
in interface AudioSource
com.cloudgarden.audio.AudioSource
an
- IOException if the source is unable to start sending data - for example,
if an audio file is unable to be opened to supply the data to be sent.AudioSource.setSink(com.cloudgarden.audio.AudioSink)
,
AudioObject.drain()
public boolean isSending()
AudioSource
isSending
in interface AudioSource
com.cloudgarden.audio.AudioSource
AudioSource.startSending()
public void drain() throws java.io.IOException
AudioObject
drain
in interface AudioObject
public int read(byte[] data, int len) throws java.io.IOException
AudioSource
read
in interface AudioSource
public int read(byte[] data, int offset, int len) throws java.io.IOException
AudioSource
read
in interface AudioSource
com.cloudgarden.audio.AudioSource
AudioSource.setSink(com.cloudgarden.audio.AudioSink)
,
AudioSink#startGetting
,
AudioObject.setPaused(boolean)
public boolean isWaiting()
AudioObject
isWaiting
in interface AudioObject
public void setPaused(boolean paused)
AudioObject
setPaused
in interface AudioObject
public boolean isPaused()
isPaused
in interface AudioObject
public void setAudioFormat(javax.sound.sampled.AudioFormat format) throws java.io.IOException
AudioObject
This ensures that the AudioFormat is uniform along a set of connected AudioObjects until the format is changed by an AudioConverter.
setAudioFormat
in interface AudioObject
setAudioFormat
in class AudioServer
com.cloudgarden.audio.AudioObject
java.io.IOException
- if unable to set the AudioFormat for any reason
(eg. if canSetAudioFormat returns false and setAudioFormat is used
to try to change the AudioFormat).AudioObject.getAudioFormat()
public void setContentType(java.lang.String contentType)
AudioObject
setContentType
in interface AudioServerI
setContentType
in class AudioServer
public boolean canSetAudioFormat()
AudioObject
canSetAudioFormat
in interface AudioObject
canSetAudioFormat
in class AudioServer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |