com.cloudgarden.audio
Class AudioClientSink

java.lang.Object
  |
  +--com.cloudgarden.audio.DefaultAudioObject
        |
        +--com.cloudgarden.audio.DefaultAudioSink
              |
              +--com.cloudgarden.audio.AudioClientSink
All Implemented Interfaces:
AudioObject, AudioSink

public class AudioClientSink
extends DefaultAudioSink

This class provides an AudioSink wrapper around a handle to a remote AudioServerSource RMI object. It is used on the client-side to send audio data to a remote AudioSource. (Note: the remote object is an AudioSource because it provides audio data to classes on the remote machine, and this is an AudioSink because it recieves audio data from the local (client) classes).


Fields inherited from class com.cloudgarden.audio.DefaultAudioSink
getThread, getting, source
 
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
AudioClientSink(java.lang.String remoteName, java.lang.String server, int port)
          Creates new AudioClientSink, and connects to the remote AudioInputSocketI identified by the server, port and remoteName parameters.
 
Method Summary
 void closeConnection()
          Informs the AudioServerSource 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 AudioServerSource that this client is initiating a connection - causes the AudioServer to send a CLIENT_ADDED signal - this is called automatically when the AudioClientSink is created, but should be called after closeConnection if you wish to inform the server that this client is starting a new session.
 void setAudioFormat(javax.sound.sampled.AudioFormat format)
          Tries to set the AudioFormat of the remote AudioSource.
 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.
 int write(byte[] data, int len)
          Convenience method - should call write(data, 0, len)
 int write(byte[] data, int offset, int len)
          Writes audio data to the remote AudioSource.
 
Methods inherited from class com.cloudgarden.audio.DefaultAudioSink
getSource, setSource
 
Methods inherited from class com.cloudgarden.audio.DefaultAudioObject
addTransferListener, blockWhilePaused, blockWhileWaiting, bytesTransferred, canSetAudioFormat, drain, 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, drain, isPaused, isWaiting, removeTransferListener, setPaused
 

Constructor Detail

AudioClientSink

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

closeConnection

public void closeConnection()
                     throws java.rmi.RemoteException
Informs the AudioServerSource 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 AudioServerSource that this client is initiating a connection - causes the AudioServer to send a CLIENT_ADDED signal - this is called automatically when the AudioClientSink 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)
Tries to set the AudioFormat of the remote AudioSource. Generally the client should try to set it's own audio format to match that of the remote AudioSource.
Overrides:
setAudioFormat in class DefaultAudioSink
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 DefaultAudioSink

getContentType

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

write

public int write(byte[] data,
                 int len)
          throws java.io.IOException
Description copied from interface: AudioSink
Convenience method - should call write(data, 0, len)
Overrides:
write in class DefaultAudioSink

write

public int write(byte[] data,
                 int offset,
                 int len)
          throws java.io.IOException
Writes audio data to the remote AudioSource. Will throw an exception if access to the remote AudioSource is not allowed
See Also:
AudioServerSource