Package org.jitsi.service.neomedia
Class AbstractMediaStream
- java.lang.Object
-
- org.jitsi.service.neomedia.AbstractMediaStream
-
- All Implemented Interfaces:
MediaStream
- Direct Known Subclasses:
MediaStreamImpl
public abstract class AbstractMediaStream extends Object implements MediaStream
Abstract base implementation of MediaStream to ease the implementation of the interface.- Author:
- Lyubomir Marinov, George Politis
-
-
Field Summary
Fields Modifier and Type Field Description protected RTPTranslatorrtpTranslatorThe RTPTranslator, if any, which forwards RTP and RTCP traffic between this and other MediaStreams.-
Fields inherited from interface org.jitsi.service.neomedia.MediaStream
PNAME_LOCAL_SSRC, PNAME_REMOTE_SSRC
-
-
Constructor Summary
Constructors Constructor Description AbstractMediaStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(PropertyChangeListener listener)Adds a PropertyChangelistener to this stream which is to be notified upon property changes such as a SSRC ID which becomes known.protected voidassertDirection(MediaDirection direction, MediaDirection deviceDirection, String illegalArgumentExceptionMessage)Asserts that the state of this instance will remain consistent if a specific MediaDirection (i.e.protected voidfirePropertyChange(String property, Object oldValue, Object newValue)Fires a new PropertyChangeEvent to the PropertyChangeListeners registered with this instance in order to notify about a change in the value of a specific property which had its old value modified to a specific new value.bytegetDynamicRTPPayloadType(String codec)Returns the payload type number that has been negotiated for the specified encoding or -1 if no payload type has been negotiated for it.MediaFormatgetFormat(byte pt)Returns the MediaFormat that is associated to the payload type passed in as a parameter.MediaStreamTrackReceivergetMediaStreamTrackReceiver()Gets theMediaStreamTrackReceiverof thisMediaStream.StringgetName()Returns the name of this stream or null if no name has been set.REDBlockgetPrimaryREDBlock(RawPacket pkt)Gets the primaryREDBlockthat contains the payload of the RTP packet passed in as a parameter.REDBlockgetPrimaryREDBlock(org.jitsi.utils.ByteArrayBuffer baf)Gets the primaryREDBlockthat contains the payload of the RTP packet passed in as a parameter.ObjectgetProperty(String propertyName)Gets the value of a specific opaque property of this MediaStream.RTPTranslatorgetRTPTranslator()Gets theRTPTranslatorwhich forwards RTP and RTCP traffic between this and otherMediaStreams.TransformEngineChaingetTransformEngineChain()Gets theTransformEngineChainof thisMediaStream.protected voidhandleAttributes(MediaFormat format, Map<String,String> attrs)Handles attributes contained in MediaFormat.voidinjectPacket(RawPacket pkt, boolean data)Sends a given RTP or RTCP packet to the remote peer/side.voidremovePropertyChangeListener(PropertyChangeListener listener)Removes the specified PropertyChangeListener from this stream so that it won't receive further property change events.voidsetName(String name)Sets the name of this stream.voidsetProperty(String propertyName, Object value)Sets the value of a specific opaque property of this MediaStream.voidsetRTPTranslator(RTPTranslator rtpTranslator)Sets the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams.voidsetTransportCCEngine(TransportCCEngine engine)Sets theTransportCCEngineof this media stream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jitsi.service.neomedia.MediaStream
addDynamicRTPPayloadType, addDynamicRTPPayloadTypeOverride, addRTPExtension, clearDynamicRTPPayloadTypes, clearRTPExtensions, close, getActiveRTPExtensions, getDevice, getDirection, getDynamicRTPPayloadTypes, getFormat, getLocalSourceID, getMediaStreamStats, getRemoteControlAddress, getRemoteDataAddress, getRemoteSourceID, getRemoteSourceIDs, getRetransmissionRequester, getSrtpControl, getStreamRTPManager, getTarget, getTransportProtocol, injectPacket, isKeyFrame, isKeyFrame, isMute, isStarted, removeReceiveStreamForSsrc, setConnector, setDevice, setDirection, setExternalTransformer, setFormat, setMute, setSSRCFactory, setTarget, start, stop
-
-
-
-
Field Detail
-
rtpTranslator
protected RTPTranslator rtpTranslator
The RTPTranslator, if any, which forwards RTP and RTCP traffic between this and other MediaStreams.
-
-
Method Detail
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangelistener to this stream which is to be notified upon property changes such as a SSRC ID which becomes known.- Specified by:
addPropertyChangeListenerin interfaceMediaStream- Parameters:
listener- the PropertyChangeListener to register for PropertyChangeEvents- See Also:
MediaStream.addPropertyChangeListener(PropertyChangeListener)
-
assertDirection
protected void assertDirection(MediaDirection direction, MediaDirection deviceDirection, String illegalArgumentExceptionMessage) throws IllegalArgumentException
Asserts that the state of this instance will remain consistent if a specific MediaDirection (i.e. direction) and a MediaDevice with a specific MediaDirection (i.e. deviceDirection) are both set on this instance.- Parameters:
direction- the MediaDirection to validate against the specified deviceDirectiondeviceDirection- the MediaDirection of a MediaDevice to validate against the specified directionillegalArgumentExceptionMessage- the message of the IllegalArgumentException to be thrown if the state of this instance would've been compromised if direction and the MediaDevice associated with deviceDirection were both set on this instance- Throws:
IllegalArgumentException- if the state of this instance would've been compromised were both direction and the MediaDevice associated with deviceDirection set on this instance
-
firePropertyChange
protected void firePropertyChange(String property, Object oldValue, Object newValue)
Fires a new PropertyChangeEvent to the PropertyChangeListeners registered with this instance in order to notify about a change in the value of a specific property which had its old value modified to a specific new value.- Parameters:
property- the name of the property of this instance which had its value changedoldValue- the value of the property with the specified name before the changenewValue- the value of the property with the specified name after the change
-
getName
public String getName()
Returns the name of this stream or null if no name has been set. A stream name is used by some protocols, for diagnostic purposes mostly. In XMPP for example this is the name of the content element that describes a stream.- Specified by:
getNamein interfaceMediaStream- Returns:
- the name of this stream or null if no name has been set.
-
getProperty
public Object getProperty(String propertyName)
Gets the value of a specific opaque property of this MediaStream.- Specified by:
getPropertyin interfaceMediaStream- Parameters:
propertyName- the name of the opaque property of this MediaStream the value of which is to be returned- Returns:
- the value of the opaque property of this MediaStream specified by propertyName
-
handleAttributes
protected void handleAttributes(MediaFormat format, Map<String,String> attrs)
Handles attributes contained in MediaFormat.- Parameters:
format- the MediaFormat to handle the attributes ofattrs- the attributes Map to handle
-
injectPacket
public void injectPacket(RawPacket pkt, boolean data) throws TransmissionFailedException
Sends a given RTP or RTCP packet to the remote peer/side.- Parameters:
pkt- the packet to send.data-trueto send an RTP packet orfalseto send an RTCP packet.- Throws:
TransmissionFailedException- if the transmission failed.
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the specified PropertyChangeListener from this stream so that it won't receive further property change events.- Specified by:
removePropertyChangeListenerin interfaceMediaStream- Parameters:
listener- the PropertyChangeListener to remove- See Also:
MediaStream.removePropertyChangeListener(PropertyChangeListener)
-
setName
public void setName(String name)
Sets the name of this stream. Stream names are used by some protocols, for diagnostic purposes mostly. In XMPP for example this is the name of the content element that describes a stream.- Specified by:
setNamein interfaceMediaStream- Parameters:
name- the name of this stream or null if no name has been set.
-
setProperty
public void setProperty(String propertyName, Object value)
Sets the value of a specific opaque property of this MediaStream.- Specified by:
setPropertyin interfaceMediaStream- Parameters:
propertyName- the name of the opaque property of this MediaStream the value of which is to be set to the specified valuevalue- the value of the opaque property of this MediaStream specified by propertyName to be set
-
setRTPTranslator
public void setRTPTranslator(RTPTranslator rtpTranslator)
Sets the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams.- Specified by:
setRTPTranslatorin interfaceMediaStream- Parameters:
rtpTranslator- the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams
-
getRTPTranslator
public RTPTranslator getRTPTranslator()
Gets theRTPTranslatorwhich forwards RTP and RTCP traffic between this and otherMediaStreams.- Specified by:
getRTPTranslatorin interfaceMediaStream- Returns:
- the
RTPTranslatorwhich forwards RTP and RTCP traffic between this and otherMediaStreams ornull
-
getTransformEngineChain
public TransformEngineChain getTransformEngineChain()
Gets theTransformEngineChainof thisMediaStream.- Specified by:
getTransformEngineChainin interfaceMediaStream
-
getDynamicRTPPayloadType
public byte getDynamicRTPPayloadType(String codec)
Returns the payload type number that has been negotiated for the specified encoding or -1 if no payload type has been negotiated for it. If multiple formats match the specified encoding, then this method would return the first one it encounters while iterating through the map.- Specified by:
getDynamicRTPPayloadTypein interfaceMediaStream- Parameters:
codec- the encoding whose payload type we are trying to obtain.- Returns:
- the payload type number that has been negotiated for the specified codec or -1 if no payload type has been negotiated for it.
-
getMediaStreamTrackReceiver
public MediaStreamTrackReceiver getMediaStreamTrackReceiver()
Gets theMediaStreamTrackReceiverof thisMediaStream.- Specified by:
getMediaStreamTrackReceiverin interfaceMediaStream- Returns:
- the
MediaStreamTrackReceiverof thisMediaStream, or null.
-
getFormat
public MediaFormat getFormat(byte pt)
Returns the MediaFormat that is associated to the payload type passed in as a parameter.- Specified by:
getFormatin interfaceMediaStream- Parameters:
pt- the payload type of the MediaFormat to get.- Returns:
- the MediaFormat that is associated to the payload type passed in as a parameter.
-
setTransportCCEngine
public void setTransportCCEngine(TransportCCEngine engine)
Sets theTransportCCEngineof this media stream. Note that for this to take effect it needs to be called early, before the transform chain is initialized (i.e. before a connector is set).- Specified by:
setTransportCCEnginein interfaceMediaStream- Parameters:
engine- the engine to set.
-
getPrimaryREDBlock
public REDBlock getPrimaryREDBlock(org.jitsi.utils.ByteArrayBuffer baf)
Gets the primaryREDBlockthat contains the payload of the RTP packet passed in as a parameter.- Specified by:
getPrimaryREDBlockin interfaceMediaStream- Parameters:
baf- theByteArrayBufferthat holds the RTP payload.- Returns:
- the primary
REDBlockthat contains the payload of the RTP packet passed in as a parameter, or null if the buffer is invalid.
-
getPrimaryREDBlock
public REDBlock getPrimaryREDBlock(RawPacket pkt)
Gets the primaryREDBlockthat contains the payload of the RTP packet passed in as a parameter.- Specified by:
getPrimaryREDBlockin interfaceMediaStream- Parameters:
pkt- theRawPacketthat holds the RTP payload.- Returns:
- the primary
REDBlockthat contains the payload of the RTP packet passed in as a parameter, or null if the buffer is invalid.
-
-