org.mobicents.media.server.impl
Class AbstractSink

java.lang.Object
  extended by org.mobicents.media.server.impl.BaseComponent
      extended by org.mobicents.media.server.impl.AbstractSink
All Implemented Interfaces:
java.io.Serializable, org.mobicents.media.Component, org.mobicents.media.MediaSink
Direct Known Subclasses:
AbstractSinkSet, DtmfBuffer, MeanderDetector, MixerInputStream, PhoneSignalDetector, PlayerImpl, RecorderImpl, SendStream, SpectraAnalyzer, TestSink

public abstract class AbstractSink
extends BaseComponent
implements org.mobicents.media.MediaSink

The base implementation of the media sink. AbstractSource and AbstractSink are implement general wirring contruct. All media components have to extend one of these classes.

Author:
Oleg Kulikov
See Also:
Serialized Form

Field Summary
protected  org.apache.log4j.Logger logger
           
protected  org.mobicents.media.MediaSource otherParty
           
 
Fields inherited from class org.mobicents.media.server.impl.BaseComponent
format
 
Constructor Summary
AbstractSink(java.lang.String name)
          Creates new instance of sink with specified name.
 
Method Summary
 void assignPreffered(org.mobicents.media.Format format)
           
 void connect(org.mobicents.media.MediaSource otherParty)
          (Non Java-doc).
 void connect(org.mobicents.media.Outlet outlet)
           
 void disconnect(org.mobicents.media.MediaSource otherParty)
          (Non Java-doc).
 void disconnect(org.mobicents.media.Outlet outlet)
           
protected  void failed(int eventID, java.lang.Exception e)
          Sends failure notification.
 long getBytesReceived()
          (Non Java-doc).
<T> T
getInterface(java.lang.Class<T> interfaceType)
           
 long getPacketsReceived()
          (Non Java-doc).
 org.mobicents.media.Format getPreffered(java.util.Collection<org.mobicents.media.Format> set)
          This methods is called by Media Source to determine the preffred format during connection procedure.
 boolean isConnected()
          (Non Java-doc).
 boolean isMultipleConnectionsAllowed()
           
 boolean isStarted()
          (Non Java-doc).
abstract  void onMediaTransfer(org.mobicents.media.Buffer buffer)
          This methos is called when new portion of media arrives.
 void receive(org.mobicents.media.Buffer buffer)
          (Non Java-doc).
 void resetStats()
          (Non Java-doc.)
protected  org.mobicents.media.Format selectPreffered(java.util.Collection<org.mobicents.media.Format> set)
          Implements the strategy of selecting preffred format from specified set.
 void start()
          (Non Java-doc).
protected  void started()
          Sends notification that media processing has been started.
 void stop()
          (Non Java-doc).
protected  void stopped()
          Sends notification that detection is terminated.
 
Methods inherited from class org.mobicents.media.server.impl.BaseComponent
addListener, getConnection, getEndpoint, getFormat, getId, getName, removeListener, sendEvent, setConnection, setEndpoint, subset, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mobicents.media.MediaSink
getFormats
 
Methods inherited from interface org.mobicents.media.Component
addListener, getConnection, getEndpoint, getFormat, getId, getName, removeListener, setConnection, setEndpoint
 

Field Detail

otherParty

protected transient org.mobicents.media.MediaSource otherParty

logger

protected org.apache.log4j.Logger logger
Constructor Detail

AbstractSink

public AbstractSink(java.lang.String name)
Creates new instance of sink with specified name.

Parameters:
name - the name of the sink to be created.
Method Detail

getPreffered

public org.mobicents.media.Format getPreffered(java.util.Collection<org.mobicents.media.Format> set)
This methods is called by Media Source to determine the preffred format during connection procedure.

Parameters:
set - the set of capable frmats
Returns:
format which is most preffred for this sink or null if this sink can not determine preffred.

assignPreffered

public void assignPreffered(org.mobicents.media.Format format)

selectPreffered

protected org.mobicents.media.Format selectPreffered(java.util.Collection<org.mobicents.media.Format> set)
Implements the strategy of selecting preffred format from specified set. The default implemntation takes first from set but other components can override this rule.

Parameters:
set - the set of formats.
Returns:
preffered format or null if sink can not determine it

isMultipleConnectionsAllowed

public boolean isMultipleConnectionsAllowed()
Specified by:
isMultipleConnectionsAllowed in interface org.mobicents.media.MediaSink

connect

public void connect(org.mobicents.media.MediaSource otherParty)
(Non Java-doc).

Specified by:
connect in interface org.mobicents.media.MediaSink
See Also:
org.mobicents.media.MediaSink#connect(MediaStream).

disconnect

public void disconnect(org.mobicents.media.MediaSource otherParty)
(Non Java-doc).

Specified by:
disconnect in interface org.mobicents.media.MediaSink
See Also:
org.mobicents.media.MediaSink#disconnect(MediaStream).

connect

public void connect(org.mobicents.media.Outlet outlet)
Specified by:
connect in interface org.mobicents.media.MediaSink

disconnect

public void disconnect(org.mobicents.media.Outlet outlet)
Specified by:
disconnect in interface org.mobicents.media.MediaSink

isConnected

public boolean isConnected()
(Non Java-doc).

Specified by:
isConnected in interface org.mobicents.media.MediaSink
See Also:
MediaSink.isConnected().

isStarted

public boolean isStarted()
(Non Java-doc).

Specified by:
isStarted in interface org.mobicents.media.MediaSink
See Also:
MediaSink.isStarted().

onMediaTransfer

public abstract void onMediaTransfer(org.mobicents.media.Buffer buffer)
                              throws java.io.IOException
This methos is called when new portion of media arrives.

Parameters:
buffer - the new portion of media data.
Throws:
java.io.IOException

start

public void start()
(Non Java-doc).

Specified by:
start in interface org.mobicents.media.MediaSink
See Also:
MediaSink.start().

stop

public void stop()
(Non Java-doc).

Specified by:
stop in interface org.mobicents.media.MediaSink
See Also:
MediaSink.stop().

receive

public void receive(org.mobicents.media.Buffer buffer)
             throws java.io.IOException
(Non Java-doc).

Specified by:
receive in interface org.mobicents.media.MediaSink
Throws:
java.io.IOException
See Also:
org.mobicents.media.MediaSink#receive().

failed

protected void failed(int eventID,
                      java.lang.Exception e)
Sends failure notification.

Parameters:
eventID - failure event identifier.
e - the exception caused failure.

getPacketsReceived

public long getPacketsReceived()
(Non Java-doc).

Specified by:
getPacketsReceived in interface org.mobicents.media.MediaSink
See Also:
MediaSink.getPacketsReceived().

getBytesReceived

public long getBytesReceived()
(Non Java-doc).

Specified by:
getBytesReceived in interface org.mobicents.media.MediaSink
See Also:
MediaSink.getBytesReceived()

resetStats

public void resetStats()
Description copied from class: BaseComponent
(Non Java-doc.)

Specified by:
resetStats in interface org.mobicents.media.Component
Overrides:
resetStats in class BaseComponent
See Also:
org.mobicents.media.Component#reserStats();

started

protected void started()
Sends notification that media processing has been started.


stopped

protected void stopped()
Sends notification that detection is terminated.


getInterface

public <T> T getInterface(java.lang.Class<T> interfaceType)
Specified by:
getInterface in interface org.mobicents.media.Component
Overrides:
getInterface in class BaseComponent


Copyright © 2010. All Rights Reserved.