org.mobicents.media.server.impl
Class AbstractSource

java.lang.Object
  extended by org.mobicents.media.server.impl.BaseComponent
      extended by org.mobicents.media.server.impl.AbstractSource
All Implemented Interfaces:
java.io.Serializable, org.mobicents.media.Component, org.mobicents.media.MediaSource, org.mobicents.media.server.spi.clock.Task
Direct Known Subclasses:
AbstractSourceSet, AudioNoiseGenerator, AudioPlayerImpl, GeneratorImpl, MeanderGenerator, MixerOutput, PhoneSignalGenerator, ReceiveStream, SineGenerator, VideoPlayerImpl

public abstract class AbstractSource
extends BaseComponent
implements org.mobicents.media.MediaSource

The base implementation of the Media source. 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.MediaSink otherParty
           
 
Fields inherited from class org.mobicents.media.server.impl.BaseComponent
format
 
Constructor Summary
AbstractSource(java.lang.String name)
          Creates new instance of source with specified name.
 
Method Summary
 void afterStop()
          This method is called immediately after processing termination.
protected  void beforeStart()
          This method is called just before start.
 void cancel()
           
protected  void completed()
          Sends notification that signal is completed.
 void connect(org.mobicents.media.Inlet inlet)
           
 void connect(org.mobicents.media.MediaSink otherParty)
          (Non Java-doc).
 void disconnect(org.mobicents.media.Inlet inlet)
           
 void disconnect(org.mobicents.media.MediaSink otherParty)
          (Non Java-doc).
abstract  void evolve(org.mobicents.media.Buffer buffer, long timestamp)
          This method must be overriden by concrete media source.
protected  void failed(int eventID, java.lang.Exception e)
          Sends failure notification.
 long getBytesTransmitted()
          (Non Java-doc).
 long getDuration()
          (Non Java-doc).
<T> T
getInterface(java.lang.Class<T> interfaceType)
           
 long getMediaTime()
          (Non Java-doc).
 long getPacketsTransmitted()
          (Non Java-doc).
protected  java.lang.String getSupportedFormatList()
           
 org.mobicents.media.server.spi.SyncSource getSyncSource()
          (Non Java-doc).
 boolean isActive()
           
 boolean isConnected()
          (Non Java-doc).
 boolean isMultipleConnectionsAllowed()
           
 boolean isStarted()
          (Non Java-doc).
 int perform()
           
 void resetStats()
          (Non Java-doc.)
 void setDuration(long duration)
          (Non Java-doc).
 void setMediaTime(long timestamp)
          (Non Java-doc).
 void setPreffered(org.mobicents.media.Format format)
          This methods is called by media sink to setup preffered format.
 void setSyncSource(org.mobicents.media.server.spi.SyncSource syncSource)
          (Non Java-doc).
 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.MediaSource
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.MediaSink otherParty

logger

protected org.apache.log4j.Logger logger
Constructor Detail

AbstractSource

public AbstractSource(java.lang.String name)
Creates new instance of source with specified name.

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

getSyncSource

public org.mobicents.media.server.spi.SyncSource getSyncSource()
(Non Java-doc).

Specified by:
getSyncSource in interface org.mobicents.media.MediaSource
See Also:
MediaSource.getSyncSource()

getMediaTime

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

Specified by:
getMediaTime in interface org.mobicents.media.MediaSource
See Also:
MediaSource.getMediaTime();

setMediaTime

public void setMediaTime(long timestamp)
(Non Java-doc).

Specified by:
setMediaTime in interface org.mobicents.media.MediaSource
See Also:
MediaSource.setMediaTime(long timestamp);

getDuration

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

Specified by:
getDuration in interface org.mobicents.media.MediaSource
See Also:
org.mobicents.media.MediaSource#getDuration(long duration);

setDuration

public void setDuration(long duration)
(Non Java-doc).

Specified by:
setDuration in interface org.mobicents.media.MediaSource
See Also:
MediaSource.setDuration(long duration);

setSyncSource

public void setSyncSource(org.mobicents.media.server.spi.SyncSource syncSource)
(Non Java-doc).

Specified by:
setSyncSource in interface org.mobicents.media.MediaSource
See Also:
MediaSource.setSyncSource(SyncSource)

beforeStart

protected void beforeStart()
                    throws java.lang.Exception
This method is called just before start. The descendant classes can verride this method and put additional logic

Throws:
java.lang.Exception

start

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

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

stop

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

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

cancel

public void cancel()
Specified by:
cancel in interface org.mobicents.media.server.spi.clock.Task

isActive

public boolean isActive()
Specified by:
isActive in interface org.mobicents.media.server.spi.clock.Task

afterStop

public void afterStop()
This method is called immediately after processing termination.


isMultipleConnectionsAllowed

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

setPreffered

public void setPreffered(org.mobicents.media.Format format)
This methods is called by media sink to setup preffered format. Media source in opposite direction can ask media sink to get preffered format by calling sink.getPreffred(Collection) where collection is a subset of common formats.

Parameters:
format - preffred format.

connect

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

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

disconnect

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

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

connect

public void connect(org.mobicents.media.Inlet inlet)
Specified by:
connect in interface org.mobicents.media.MediaSource

disconnect

public void disconnect(org.mobicents.media.Inlet inlet)
Specified by:
disconnect in interface org.mobicents.media.MediaSource

isConnected

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

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

isStarted

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

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

evolve

public abstract void evolve(org.mobicents.media.Buffer buffer,
                            long timestamp)
This method must be overriden by concrete media source. The media have to fill buffer with media data and attributes.

Parameters:
buffer - the buffer object for media.
sequenceNumber - the number of timer ticks from the begining.

getSupportedFormatList

protected java.lang.String getSupportedFormatList()

perform

public int perform()
Specified by:
perform in interface org.mobicents.media.server.spi.clock.Task

started

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


failed

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

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

completed

protected void completed()
Sends notification that signal is completed.


stopped

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


getPacketsTransmitted

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

Specified by:
getPacketsTransmitted in interface org.mobicents.media.MediaSource
See Also:
org.mobicents.media.MediaSource#getPacketsReceived()

getBytesTransmitted

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

Specified by:
getBytesTransmitted in interface org.mobicents.media.MediaSource
See Also:
MediaSource.getBytesTransmitted()

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();

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.