com.cloudgarden.audio
Class AudioClientSource

java.lang.Object
  |
  +--com.cloudgarden.audio.DefaultAudioObject
        |
        +--com.cloudgarden.audio.DefaultAudioSource
              |
              +--com.cloudgarden.audio.AudioClientSource
All Implemented Interfaces:
AudioObject, AudioSource

public class AudioClientSource
extends DefaultAudioSource

This class provides an AudioSource wrapper around a handle to a remote AudioOutputSocket. This is the client-side connector to a server-side AudioServerSink.


Fields inherited from class com.cloudgarden.audio.DefaultAudioSource
sending, sendThread, sink
 
Fields inherited from class com.cloudgarden.audio.DefaultAudioObject
contentType, exception, format, listeners, paused, pauseSync, running, waiting
 
Fields inherited from interface com.cloudgarden.audio.AudioObject
END_OF_DATA
 
Constructor Summary
AudioClientSource(java.lang.String remoteName, java.lang.String server, int port)
          Creates new AudioClientSource, and connects to the remote AudioOutputSocketI identified by the server, port and remoteName parameters.
 
Method Summary
 void addServerListener(ServerListener listener)
           
 void closeConnection()
          Informs the AudioServerSink that this client has finished with it's connection - causes the AudioServer to send a CLIENT_REMOVED signal.
 javax.sound.sampled.AudioFormat getAudioFormat()
          Constructs and returns an AudioFormat using calls to the remote underlying AudioOutputSocket.
 java.lang.String getContentType()
           
 void openConnection()
          Informs the AudioServerSink that this client is initiating a connection - causes the AudioServer to send a CLIENT_ADDED signal - this is called automatically when the AudioClientSource is created, but should be called after closeConnection if you wish to inform the server that this client is starting a new session.
 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 removeServerListener(ServerListener listener)
           
protected  void serverClosed()
           
 void setAudioFormat(javax.sound.sampled.AudioFormat format)
          Sets the AudioFormat for this AudioObject.
 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.
 
Methods inherited from class com.cloudgarden.audio.DefaultAudioSource
drain, getSink, isSending, read, setBufferSize, setSink, startSending, stopSending
 
Methods inherited from class com.cloudgarden.audio.DefaultAudioObject
addTransferListener, blockWhilePaused, blockWhileWaiting, bytesTransferred, canSetAudioFormat, getLastException, isPaused, isWaiting, removeTransferListener, setPaused
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.cloudgarden.audio.AudioObject
addTransferListener, canSetAudioFormat, isPaused, isWaiting, removeTransferListener, setPaused
 

Constructor Detail

AudioClientSource

public AudioClientSource(java.lang.String remoteName,
                         java.lang.String server,
                         int port)
                  throws java.rmi.NotBoundException,
                         java.net.MalformedURLException,
                         java.rmi.RemoteException
Creates new AudioClientSource, and connects to the remote AudioOutputSocketI identified by the server, port and remoteName parameters.
Method Detail

closeConnection

public void closeConnection()
                     throws java.rmi.RemoteException
Informs the AudioServerSink that this client has finished with it's connection - causes the AudioServer to send a CLIENT_REMOVED signal.

openConnection

public void openConnection()
                    throws java.rmi.RemoteException
Informs the AudioServerSink that this client is initiating a connection - causes the AudioServer to send a CLIENT_ADDED signal - this is called automatically when the AudioClientSource is created, but should be called after closeConnection if you wish to inform the server that this client is starting a new session.

getAudioFormat

public javax.sound.sampled.AudioFormat getAudioFormat()
Constructs and returns an AudioFormat using calls to the remote underlying AudioOutputSocket. Any RemoteExceptions thrown by the remote calls are caught and a null AudioFormat is returned.
Overrides:
getAudioFormat in class DefaultAudioObject
Following copied from interface: com.cloudgarden.audio.AudioObject
See Also:
AudioObject.setAudioFormat(javax.sound.sampled.AudioFormat)

setAudioFormat

public void setAudioFormat(javax.sound.sampled.AudioFormat format)
                    throws java.io.IOException
Description copied from interface: AudioObject
Sets the AudioFormat for this AudioObject. If this object is connected to an AudioSource or an AudioSink, then the source/sink's AudioFormat is set equal to that of this AudioObject. Note: if the sink is an AudioConverter then the setIncomingAudioFormat method is called instead of setAudioFormat.

This ensures that the AudioFormat is uniform along a set of connected AudioObjects until the format is changed by an AudioConverter.

Overrides:
setAudioFormat in class DefaultAudioSource
Following copied from interface: com.cloudgarden.audio.AudioObject
Throws:
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).
See Also:
AudioObject.getAudioFormat()

setContentType

public void setContentType(java.lang.String contentType)
                    throws java.io.IOException
Description copied from interface: AudioObject
Sets the content type for this AudioObject - contentType must be one of the FileTypeDescriptor String fields, eg MPEG_AUDIO.
Overrides:
setContentType in class DefaultAudioSource

getContentType

public java.lang.String getContentType()
Overrides:
getContentType in class DefaultAudioObject
Following copied from interface: com.cloudgarden.audio.AudioObject
See Also:
setContentType

read

public int read(byte[] data,
                int offset,
                int len)
         throws java.io.IOException
Description copied from interface: AudioSource
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. Blocks if this source is paused. Returns the number of bytes read, or END_OF_DATA if all the available data has been read - eg if the end of a file has been reached, or if the stopSending() method has been called.
Following copied from interface: com.cloudgarden.audio.AudioSource
See Also:
AudioSource.setSink(com.cloudgarden.audio.AudioSink), AudioSink#startGetting, AudioObject.setPaused(boolean)

addServerListener

public void addServerListener(ServerListener listener)

removeServerListener

public void removeServerListener(ServerListener listener)

serverClosed

protected void serverClosed()