cnrg.itx.datax
Class Channel

java.lang.Object
  |
  +--cnrg.itx.datax.Channel

public class Channel
extends java.lang.Object
implements java.lang.Runnable, Statistics, Properties

Class representing a channel in the Connection object. A Channel acts as a pipe between a Source and all the Destination objects and copies data between them.


Field Summary
static int INPUT
          Constant to specify that a channel is an input channel.
static int OTHER
          Constant to specify that a channel is neither an output nor input channel (maybe a hybrid).
static int OUTPUT
          Constant to specify that a channel is an output channel.
static int SAMPLE_SIZE
          Default channel sample size
 
Constructor Summary
Channel()
          Default constructor for a channel.
Channel(int sampleSize)
          Constructor for a channel.
 
Method Summary
 void addDestination(Destination d)
          Method to add a destination for the Channel.
 void close()
          Method to close the Channel.
 PropertiesCollection getProperties()
          Gets the properties for this audioConnection
 Source getSource()
          Method to get the source for the Channel.
 Stats getStatistics()
          Method to get the statistics from the channel.
 void mute(boolean state)
          Method to mute all the sources and destinations
 void open()
          Method to open the Channel.
 void push(byte[] bData)
          Method that receives the data from the source.
 void removeAllDestinations()
          Method to remove all destinations.
 boolean removeDestination(Destination d)
          Method to remove a destination from the list.
 void run()
          Channel reader thread function.
 void setPeerProperties(PropertiesCollection pc)
          Interface to set the given properties collection into the device.
 void setProperties(PropertiesCollection pc)
          Sets the properties for this audioConnection
 void setSource(Source source)
          Method to set the source for the Channel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAMPLE_SIZE

public static final int SAMPLE_SIZE
Default channel sample size

INPUT

public static final int INPUT
Constant to specify that a channel is an input channel.

OUTPUT

public static final int OUTPUT
Constant to specify that a channel is an output channel.

OTHER

public static final int OTHER
Constant to specify that a channel is neither an output nor input channel (maybe a hybrid).
Constructor Detail

Channel

public Channel()
Default constructor for a channel. Constructs a null channel.

Channel

public Channel(int sampleSize)
Constructor for a channel. Constructs a null channel.
Parameters:
sampleSize - size (in bytes) read by the channel read thread
Method Detail

setSource

public void setSource(Source source)
Method to set the source for the Channel.
Parameters:
source - The Source for the Channel

getSource

public Source getSource()
Method to get the source for the Channel.
Returns:
Source The Channel's Source object

addDestination

public void addDestination(Destination d)
                    throws DuplicateDestinationException
Method to add a destination for the Channel. This will add the destination to the list of destinations.
Parameters:
d - The destination to add to the list of destination for the channel
Throws:
DuplicateDestinationException -  

open

public void open()
          throws DataException
Method to open the Channel. This method starts the channel thread that copies data from the source to all the destinations.

run

public void run()
Channel reader thread function.
Specified by:
run in interface java.lang.Runnable

push

public void push(byte[] bData)
Method that receives the data from the source.

Note: the buffer that is passed should persist for some time.

Parameters:
bData - buffer that will be guaranteed to be unchanged for some amount of time. FIXME: what to do with excetions?

close

public void close()
Method to close the Channel. This method first stops the channel thread and then clears all the resources held by the Channel.

removeDestination

public boolean removeDestination(Destination d)
Method to remove a destination from the list.
Parameters:
d - The Destination object to remove
Returns:
boolean True if the destination was found and removed

removeAllDestinations

public void removeAllDestinations()
Method to remove all destinations.

mute

public void mute(boolean state)
Method to mute all the sources and destinations
Parameters:
state - The state of the mute. true to mute and false to unmute

getStatistics

public Stats getStatistics()
Method to get the statistics from the channel. This method gets the statistics from the devices connected to the channel.
Specified by:
getStatistics in interface Statistics
Returns:
Stats the statistics for the channel

getProperties

public PropertiesCollection getProperties()
Gets the properties for this audioConnection
Specified by:
getProperties in interface Properties
Returns:
the ProertiesCollection

setProperties

public void setProperties(PropertiesCollection pc)
Sets the properties for this audioConnection
Specified by:
setProperties in interface Properties

setPeerProperties

public void setPeerProperties(PropertiesCollection pc)
                       throws DataException
Interface to set the given properties collection into the device. WOrks under the assumption that this is the properties collection of the peer.
Specified by:
setPeerProperties in interface Properties