Package org.jitsi.impl.neomedia
Class MediaStreamImpl
- java.lang.Object
-
- org.jitsi.service.neomedia.AbstractMediaStream
-
- org.jitsi.impl.neomedia.MediaStreamImpl
-
- All Implemented Interfaces:
EventListener,javax.media.rtp.ReceiveStreamListener,javax.media.rtp.RemoteListener,javax.media.rtp.SendStreamListener,javax.media.rtp.SessionListener,MediaStream
- Direct Known Subclasses:
AudioMediaStreamImpl,VideoMediaStreamImpl
public class MediaStreamImpl extends AbstractMediaStream implements javax.media.rtp.ReceiveStreamListener, javax.media.rtp.SendStreamListener, javax.media.rtp.SessionListener, javax.media.rtp.RemoteListener
Implements MediaStream using JMF.- Author:
- Lyubomir Marinov, Emil Ivov, Sebastien Vincent, Boris Grozev, George Politis
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringPROPERTY_NAME_RECEIVE_BUFFER_LENGTHThe name of the property indicating the length of our receive buffer.protected booleansendStreamsAreCreatedThe indicator which determines whethercreateSendStreams()has been executed forrtpManager.-
Fields inherited from class org.jitsi.service.neomedia.AbstractMediaStream
rtpTranslator
-
Fields inherited from interface org.jitsi.service.neomedia.MediaStream
PNAME_LOCAL_SSRC, PNAME_REMOTE_SSRC
-
-
Constructor Summary
Constructors Constructor Description MediaStreamImpl(MediaDevice device, SrtpControl srtpControl)Initializes a new MediaStreamImpl instance which will use the specified MediaDevice for both capture and playback of media.MediaStreamImpl(StreamConnector connector, MediaDevice device, SrtpControl srtpControl)Initializes a new MediaStreamImpl instance which will use the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDynamicRTPPayloadType(byte rtpPayloadType, MediaFormat format)Adds a new association in this MediaStream of the specified RTP payload type with the specified MediaFormat in order to allow it to report rtpPayloadType in RTP flows sending and receiving media in format.voidaddDynamicRTPPayloadTypeOverride(byte originalPt, byte overloadPt)Adds an additional RTP payload mapping that will overriding one that we've set withaddDynamicRTPPayloadType(byte, MediaFormat).protected voidaddRemoteSourceID(long remoteSourceID)Sets the remote SSRC identifier and fires the corresponding PropertyChangeEvent.voidaddRTPExtension(byte extensionID, RTPExtension rtpExtension)Maps or updates the mapping between extensionID and rtpExtension.voidclearDynamicRTPPayloadTypes()Clears the dynamic RTP payload type associations in this MediaStream.voidclearRTPExtensions()Clears the RTP header extension associations stored in this instance.voidclose()Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.protected voidconfigureDataInputStream(RTPConnectorInputStream<?> dataInputStream)Performs any optional configuration on a specific RTPConnectorInputStream of an RTPManager to be used by this MediaStreamImpl.protected voidconfigureDataOutputStream(RTPConnectorOutputStream dataOutputStream)Performs any optional configuration on a specific RTPConnectorOuputStream of an RTPManager to be used by this MediaStreamImpl.protected voidconfigureRTPManagerBufferControl(StreamRTPManager rtpManager, javax.media.control.BufferControl bufferControl)Performs any optional configuration on the BufferControl of the specified RTPManager which is to be used as the RTPManager of this MediaStreamImpl.protected AbsSendTimeEnginecreateAbsSendTimeEngine()Creates theAbsSendTimeEnginefor thisMediaStream.protected CachingTransformercreateCachingTransformer()Creates theCachingTransformerfor thisMediaStream.protected DiscardTransformEnginecreateDiscardEngine()Creates theDiscardTransformEnginefor this stream.protected DtmfTransformEnginecreateDtmfTransformEngine()A stub that allows audio oriented streams to create and keep a reference to a DtmfTransformEngine.protected RetransmissionRequesterImplcreateRetransmissionRequester()Creates theRetransmissionRequesterImplfor thisMediaStream.protected voidcreateSendStreams()Creates new SendStream instances for the streams ofdeviceSessionthroughrtpManager.protected SsrcTransformEnginecreateSsrcTransformEngine()protected voiddeviceSessionChanged(MediaDeviceSession oldValue, MediaDeviceSession newValue)Notifies this MediaStream that the MediaDevice (and respectively the MediaDeviceSession with it) which this instance uses for capture and playback of media has been changed.bytegetActiveRTPExtensionID(RTPExtension rtpExtension)Returns the ID currently assigned to a specific RTP extension.Map<Byte,RTPExtension>getActiveRTPExtensions()Returns a map containing all currently active RTPExtensions in use by this stream.CachingTransformergetCachingTransformer()Gets theCachingTransformerwhich (optionally) caches outgoing packets for thisMediaStreamImpl, if it exists.protected CsrcTransformEnginegetCsrcEngine()Returns the engine that is responsible for adding the list of CSRC identifiers to outgoing RTP packets during a conference.AbstractMediaDevicegetDevice()Gets the MediaDevice that this stream uses to play back and capture media.MediaDeviceSessiongetDeviceSession()Gets the MediaDeviceSession which represents the work of this MediaStream with its associated MediaDevice.org.jitsi.utils.logging.DiagnosticContextgetDiagnosticContext()Gets theDiagnosticContextof this instance.MediaDirectiongetDirection()Gets the direction in which this MediaStream is allowed to stream media.bytegetDynamicRTPPayloadType(String encoding)Returns the payload type number that has been negotiated for the specified encoding or -1 if no payload type has been negotiated for it.Map<Byte,MediaFormat>getDynamicRTPPayloadTypes()Gets the existing associations in this MediaStream of RTP payload types to MediaFormats.protected TransformEngineWrapper<FECTransformEngine>getFecTransformEngine()Creates the FECTransformEngine for this MediaStream.MediaFormatgetFormat()Gets the MediaFormat that this stream is currently transmitting in.MediaFormatgetFormat(byte pt)Returns the MediaFormat that is associated to the payload type passed in as a parameter.long[]getLocalContributingSourceIDs()Returns the list of CSRC identifiers for all parties currently known to contribute to the media that this stream is sending toward its remote counter part.InetSocketAddressgetLocalControlAddress()Gets the local address that this stream is sending RTCP traffic from.InetSocketAddressgetLocalDataAddress()Gets the local address that this stream is sending RTP traffic from.longgetLocalSourceID()Gets the synchronization source (SSRC) identifier of the local peer or -1 if it is not yet known.MediaStreamStats2ImplgetMediaStreamStats()Returns the statistical information gathered about this MediaStream.org.jitsi.utils.MediaTypegetMediaType()Gets the MediaType of this MediaStream.protected PaddingTerminationgetPaddingTermination()Gets thePaddingTerminationfor thisMediaStreamImpl.REDBlockgetPrimaryREDBlock(RawPacket pkt)Gets theREDBlockthat contains the payload of the 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.protected intgetPriority()Used to set the priority of the receive/send streams.javax.media.rtp.ReceiveStreamgetReceiveStream(int ssrc)Gets a ReceiveStream which this instance plays back on its associated MediaDevice and which has a specific synchronization source identifier (SSRC).Collection<javax.media.rtp.ReceiveStream>getReceiveStreams()Gets a list of the ReceiveStreams this instance plays back on its associated MediaDevice.protected REDTransformEnginegetRedTransformEngine()Creates the REDTransformEngine for this MediaStream.RemoteBitrateEstimatorWrappergetRemoteBitrateEstimator()Gets the RemoteBitrateEstimator of this VideoMediaStream.long[]getRemoteContributingSourceIDs()Returns the List of CSRC identifiers representing the parties contributing to the stream that we are receiving from this MediaStream's remote party.InetSocketAddressgetRemoteControlAddress()Gets the address that this stream is sending RTCP traffic to.InetSocketAddressgetRemoteDataAddress()Gets the address that this stream is sending RTP traffic to.longgetRemoteSourceID()Gets the synchronization source (SSRC) identifier of the remote peer or -1 if that identifier is not yet known at this point in the execution.List<Long>getRemoteSourceIDs()Gets the synchronization source (SSRC) identifiers of the remote peer.RetransmissionRequestergetRetransmissionRequester()protected TransformEnginegetRTCPTermination()Gets the RTCP termination for thisMediaStreamImpl.protected AbstractRTPConnectorgetRTPConnector()Gets the RTPConnector through which this instance sends and receives RTP and RTCP traffic.StreamRTPManagergetRTPManager()Gets the RTPManager instance which sends and receives RTP and RTCP traffic on behalf of this MediaStream.RtxTransformergetRtxTransformer()Gets theRtxTransformer, if any, used by theMediaStream.intgetSpatialID(RawPacket pkt)Utility method that determines the spatial layer index (SID) of an RTP packet.SrtpControlgetSrtpControl()Gets the SrtpControl which controls the SRTP of this stream.StreamRTPManagergetStreamRTPManager()Gets theStreamRTPManagerwhich is to forward RTP and RTCP traffic between this and otherMediaStreams.MediaStreamTargetgetTarget()Returns the target of this MediaStream to which it is to send and from which it is to receive data (e.g.intgetTemporalID(RawPacket pkt)Utility method that determines the temporal layer index (TID) of an RTP packet.TransformEngineChaingetTransformEngineChain()Gets theTransformEngineChainof thisMediaStream.TransportCCEnginegetTransportCCEngine()Gets theTransportCCEngineinstance, if any, for thisMediaStream.StreamConnector.ProtocolgetTransportProtocol()Returns the transport protocol used by the streams.voidinjectPacket(RawPacket pkt, boolean data, TransformEngine after)Sends a given RTP or RTCP packet to the remote peer/side.voidinjectPacket(RawPacket pkt, boolean data, TransformEngine after, boolean create)Sends a given RTP or RTCP packet to the remote peer/side.booleanisEndOfFrame(RawPacket pkt)Utility method that determines whether or not a packet is an end of frame.booleanisKeyFrame(byte[] buf, int off, int len)Utility method that determines whether or not a packet is a key frame.booleanisKeyFrame(RawPacket pkt)Utility method that determines whether or not a packet is a key frame.booleanisMute()Determines whether this MediaStream is set to transmit "silence" instead of the media being fed from its MediaDevice.booleanisStarted()booleanisStartOfFrame(RawPacket pkt)Utility method that determines whether or not a packet is a start of frame.StringpacketToString(RawPacket pkt)StreamRTPManagerqueryRTPManager()Gets the RTPManager instance which sends and receives RTP and RTCP traffic on behalf of this MediaStream.protected voidrecreateSendStreams()Recreates the SendStreams of this instance (i.e.protected voidregisterCustomCodecFormats(StreamRTPManager rtpManager)Registers any custom JMF Formats with a specific RTPManager.voidremoveReceiveStreamForSsrc(long ssrc)Removes the ReceiveStream with SSRC ssrc, if there is such a ReceiveStream, from the receive streams of this MediaStreamprotected voidrtpConnectorChanged(AbstractRTPConnector oldValue, AbstractRTPConnector newValue)Notifies this MediaStream implementation that its RTPConnector instance has changed from a specific old value to a specific new value.voidsetConnector(StreamConnector connector)Sets the StreamConnector to be used by this instance for sending and receiving media.voidsetDevice(MediaDevice device)Sets the MediaDevice that this stream should use to play back and capture media.voidsetDirection(MediaDirection direction)Sets the direction in which media in this MediaStream is to be streamed.voidsetExternalTransformer(TransformEngine transformEngine)Sets the external (application-provided) TransformEngine of this MediaStream.protected voidsetFecTransformEngine(FECTransformEngine fecTransformEngine)Sets theFECTransformEnginefor thisMediaStreamBy default, nothing is done with the passed engine, allowing extenders to implement itvoidsetFormat(MediaFormat format)Sets the MediaFormat that this MediaStream should transmit in.protected voidsetLocalSourceID(long localSourceID)Sets the local SSRC identifier and fires the corresponding PropertyChangeEvent.voidsetMute(boolean mute)Causes this MediaStream to stop transmitting the media being fed from this stream's MediaDevice and transmit "silence" instead.voidsetRTPTranslator(RTPTranslator rtpTranslator)Sets the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams.voidsetSSRCFactory(SSRCFactory ssrcFactory)Sets the SSRCFactory which is to generate new synchronization source (SSRC) identifiers.voidsetTarget(MediaStreamTarget target)Sets the target of this MediaStream to which it is to send and from which it is to receive data (e.g.voidsetTransportCCEngine(TransportCCEngine engine)Sets theTransportCCEngineof this media stream.voidstart()Starts capturing media from this stream's MediaDevice and then streaming it through the local StreamConnector toward the stream's target address and port.voidstop()Stops all streaming and capturing in this MediaStream and closes and releases all open/allocated devices/resources.booleansupportsFrameBoundaries(RawPacket pkt)Returns a boolean that indicates whether or not our we're able to detect the frame boundaries for the codec of the packet that is specified as an argument.static StringtoString(javax.media.protocol.DataSource dataSource)Returns a human-readable representation of a specific DataSource instance in the form of a String value.voidupdate(javax.media.rtp.event.ReceiveStreamEvent ev)Notifies this ReceiveStreamListener that the RTPManager it is registered with has generated an event related to a ReceiveStream.voidupdate(javax.media.rtp.event.RemoteEvent ev)Method called back in the RemoteListener to notify listener of all RTP Remote Events.RemoteEvents are one of ReceiverReportEvent, SenderReportEvent or RemoteCollisionEventvoidupdate(javax.media.rtp.event.SendStreamEvent ev)Notifies this SendStreamListener that the RTPManager it is registered with has generated an event related to a SendStream.voidupdate(javax.media.rtp.event.SessionEvent ev)Notifies this SessionListener that the RTPManager it is registered with has generated an event which pertains to the session as a whole and does not belong to a ReceiveStream or a SendStream or a remote participant necessarily.-
Methods inherited from class org.jitsi.service.neomedia.AbstractMediaStream
addPropertyChangeListener, assertDirection, firePropertyChange, getMediaStreamTrackReceiver, getName, getProperty, getRTPTranslator, handleAttributes, injectPacket, removePropertyChangeListener, setName, setProperty
-
-
-
-
Field Detail
-
PROPERTY_NAME_RECEIVE_BUFFER_LENGTH
protected static final String PROPERTY_NAME_RECEIVE_BUFFER_LENGTH
The name of the property indicating the length of our receive buffer.- See Also:
- Constant Field Values
-
sendStreamsAreCreated
protected boolean sendStreamsAreCreated
The indicator which determines whethercreateSendStreams()has been executed forrtpManager. If true, the SendStreams have to be recreated when the MediaDevice, respectively the MediaDeviceSession, of this instance is changed.
-
-
Constructor Detail
-
MediaStreamImpl
public MediaStreamImpl(MediaDevice device, SrtpControl srtpControl)
Initializes a new MediaStreamImpl instance which will use the specified MediaDevice for both capture and playback of media. The new instance will not have an associated StreamConnector and it must be set later for the new instance to be able to exchange media with a remote peer.- Parameters:
device- the MediaDevice the new instance is to use for both capture and playback of mediasrtpControl- an existing control instance to control the SRTP operations
-
MediaStreamImpl
public MediaStreamImpl(StreamConnector connector, MediaDevice device, SrtpControl srtpControl)
Initializes a new MediaStreamImpl instance which will use the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.- Parameters:
connector- the StreamConnector the new instance is to use for sending and receiving media or null if the StreamConnector of the new instance is to not be set at initialization time but specified later ondevice- the MediaDevice the new instance is to use for both capture and playback of media exchanged via the specified StreamConnectorsrtpControl- an existing control instance to control the ZRTP operations or null if a new control instance is to be created by the new MediaStreamImpl
-
-
Method Detail
-
toString
public static String toString(javax.media.protocol.DataSource dataSource)
Returns a human-readable representation of a specific DataSource instance in the form of a String value.- Parameters:
dataSource- the DataSource to return a human-readable representation of- Returns:
- a String value which gives a human-readable representation of the specified dataSource
-
getDiagnosticContext
public org.jitsi.utils.logging.DiagnosticContext getDiagnosticContext()
Gets theDiagnosticContextof this instance.
-
addDynamicRTPPayloadType
public void addDynamicRTPPayloadType(byte rtpPayloadType, MediaFormat format)Adds a new association in this MediaStream of the specified RTP payload type with the specified MediaFormat in order to allow it to report rtpPayloadType in RTP flows sending and receiving media in format. Usually, rtpPayloadType will be in the range of dynamic RTP payload types.- Specified by:
addDynamicRTPPayloadTypein interfaceMediaStream- Parameters:
rtpPayloadType- the RTP payload type to be associated in this MediaStream with the specified MediaFormatformat- the MediaFormat to be associated in this MediaStream with rtpPayloadType- See Also:
MediaStream.addDynamicRTPPayloadType(byte, MediaFormat)
-
clearDynamicRTPPayloadTypes
public void clearDynamicRTPPayloadTypes()
Clears the dynamic RTP payload type associations in this MediaStream.- Specified by:
clearDynamicRTPPayloadTypesin interfaceMediaStream
-
addDynamicRTPPayloadTypeOverride
public void addDynamicRTPPayloadTypeOverride(byte originalPt, byte overloadPt)Adds an additional RTP payload mapping that will overriding one that we've set withaddDynamicRTPPayloadType(byte, MediaFormat). This is necessary so that we can support the RFC3264 case where the answerer has the right to declare what payload type mappings it wants to receive RTP packets with even if they are different from those in the offer. RFC3264 claims this is for support of legacy protocols such as H.323 but we've been bumping with a number of cases where multi-component pure SIP systems also need to behave this way.- Specified by:
addDynamicRTPPayloadTypeOverridein interfaceMediaStream- Parameters:
originalPt- the payload type that we are overridingoverloadPt- the payload type that we are overriding it with
-
addRemoteSourceID
protected void addRemoteSourceID(long remoteSourceID)
Sets the remote SSRC identifier and fires the corresponding PropertyChangeEvent.- Parameters:
remoteSourceID- the SSRC identifier that this stream will be using in outgoing RTP packets from now on.
-
addRTPExtension
public void addRTPExtension(byte extensionID, RTPExtension rtpExtension)Maps or updates the mapping between extensionID and rtpExtension. If rtpExtension's MediaDirection attribute is set to INACTIVE the mapping is removed from the local extensions table and the extension would not be transmitted or handled by this stream's RTPConnector.- Specified by:
addRTPExtensionin interfaceMediaStream- Parameters:
extensionID- the ID that is being mapped to rtpExtensionrtpExtension- the RTPExtension that we are mapping.
-
clearRTPExtensions
public void clearRTPExtensions()
Clears the RTP header extension associations stored in this instance.- Specified by:
clearRTPExtensionsin interfaceMediaStream
-
close
public void close()
Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.- Specified by:
closein interfaceMediaStream- See Also:
MediaStream.close()
-
configureDataInputStream
protected void configureDataInputStream(RTPConnectorInputStream<?> dataInputStream)
Performs any optional configuration on a specific RTPConnectorInputStream of an RTPManager to be used by this MediaStreamImpl. Allows extenders to override.- Parameters:
dataInputStream- the RTPConnectorInputStream to be used by an RTPManager of this MediaStreamImpl and to be configured
-
configureDataOutputStream
protected void configureDataOutputStream(RTPConnectorOutputStream dataOutputStream)
Performs any optional configuration on a specific RTPConnectorOuputStream of an RTPManager to be used by this MediaStreamImpl. Allows extenders to override.- Parameters:
dataOutputStream- the RTPConnectorOutputStream to be used by an RTPManager of this MediaStreamImpl and to be configured
-
configureRTPManagerBufferControl
protected void configureRTPManagerBufferControl(StreamRTPManager rtpManager, javax.media.control.BufferControl bufferControl)
Performs any optional configuration on the BufferControl of the specified RTPManager which is to be used as the RTPManager of this MediaStreamImpl. Allows extenders to override.- Parameters:
rtpManager- the RTPManager which is to be used by this MediaStreamImplbufferControl- the BufferControl of rtpManager on which any optional configuration is to be performed
-
createDtmfTransformEngine
protected DtmfTransformEngine createDtmfTransformEngine()
A stub that allows audio oriented streams to create and keep a reference to a DtmfTransformEngine.- Returns:
- a DtmfTransformEngine if this is an audio oriented stream and null otherwise.
-
createSendStreams
protected void createSendStreams()
Creates new SendStream instances for the streams ofdeviceSessionthroughrtpManager.
-
createSsrcTransformEngine
protected SsrcTransformEngine createSsrcTransformEngine()
-
createAbsSendTimeEngine
protected AbsSendTimeEngine createAbsSendTimeEngine()
Creates theAbsSendTimeEnginefor thisMediaStream.- Returns:
- the created
AbsSendTimeEngine.
-
createCachingTransformer
protected CachingTransformer createCachingTransformer()
Creates theCachingTransformerfor thisMediaStream.- Returns:
- the created
CachingTransformer.
-
createRetransmissionRequester
protected RetransmissionRequesterImpl createRetransmissionRequester()
Creates theRetransmissionRequesterImplfor thisMediaStream.- Returns:
- the created
RetransmissionRequesterImpl.
-
deviceSessionChanged
protected void deviceSessionChanged(MediaDeviceSession oldValue, MediaDeviceSession newValue)
Notifies this MediaStream that the MediaDevice (and respectively the MediaDeviceSession with it) which this instance uses for capture and playback of media has been changed. Allows extenders to override and provide additional processing of oldValue and newValue.- Parameters:
oldValue- the MediaDeviceSession with the MediaDevice this instance used work withnewValue- the MediaDeviceSession with the MediaDevice this instance is to work with
-
getTransportCCEngine
public TransportCCEngine getTransportCCEngine()
Gets theTransportCCEngineinstance, if any, for thisMediaStream. The instance could be shared between more than oneMediaStream, if they all use the same transport.
-
getActiveRTPExtensionID
public byte getActiveRTPExtensionID(RTPExtension rtpExtension)
Returns the ID currently assigned to a specific RTP extension.- Parameters:
rtpExtension- the RTP extension to get the currently assigned ID of- Returns:
- the ID currently assigned to the specified RTP extension or -1 if no ID has been defined for this extension so far
-
getActiveRTPExtensions
public Map<Byte,RTPExtension> getActiveRTPExtensions()
Returns a map containing all currently active RTPExtensions in use by this stream.- Specified by:
getActiveRTPExtensionsin interfaceMediaStream- Returns:
- a map containing all currently active RTPExtensions in use by this stream.
-
getCsrcEngine
protected CsrcTransformEngine getCsrcEngine()
Returns the engine that is responsible for adding the list of CSRC identifiers to outgoing RTP packets during a conference.- Returns:
- the engine that is responsible for adding the list of CSRC identifiers to outgoing RTP packets during a conference.
-
getDevice
public AbstractMediaDevice getDevice()
Gets the MediaDevice that this stream uses to play back and capture media.- Specified by:
getDevicein interfaceMediaStream- Returns:
- the MediaDevice that this stream uses to play back and capture media
- See Also:
MediaStream.getDevice()
-
getDeviceSession
public MediaDeviceSession getDeviceSession()
Gets the MediaDeviceSession which represents the work of this MediaStream with its associated MediaDevice.- Returns:
- the MediaDeviceSession which represents the work of this MediaStream with its associated MediaDevice
-
getDirection
public MediaDirection getDirection()
Gets the direction in which this MediaStream is allowed to stream media.- Specified by:
getDirectionin interfaceMediaStream- Returns:
- the MediaDirection in which this MediaStream is allowed to stream media
- See Also:
MediaStream.getDirection()
-
getDynamicRTPPayloadType
public byte getDynamicRTPPayloadType(String encoding)
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- Overrides:
getDynamicRTPPayloadTypein classAbstractMediaStream- Parameters:
encoding- the encoding whose payload type we are trying to obtain.- Returns:
- the payload type number that has been negotiated for the specified encoding or -1 if no payload type has been negotiated for it.
-
getDynamicRTPPayloadTypes
public Map<Byte,MediaFormat> getDynamicRTPPayloadTypes()
Gets the existing associations in this MediaStream of RTP payload types to MediaFormats. The returned Map only contains associations previously added in this instance withaddDynamicRTPPayloadType(byte, MediaFormat)and not globally or well-known associations reported byMediaFormat.getRTPPayloadType().- Specified by:
getDynamicRTPPayloadTypesin interfaceMediaStream- Returns:
- a Map of RTP payload type expressed as Byte to MediaFormat describing the existing (dynamic) associations in this instance of RTP payload types to MediaFormats. The Map represents a snapshot of the existing associations at the time of the getDynamicRTPPayloadTypes() method call and modifications to it are not reflected on the internal storage
- See Also:
MediaStream.getDynamicRTPPayloadTypes()
-
getFecTransformEngine
protected TransformEngineWrapper<FECTransformEngine> getFecTransformEngine()
Creates the FECTransformEngine for this MediaStream. By default none is created, allows extenders to implement it.- Returns:
- a TransformEngineWrapper around a FECTransformEngine. The
wrapper is necessary as we may not have created the
FECTransformEnginein time
-
setFecTransformEngine
protected void setFecTransformEngine(FECTransformEngine fecTransformEngine)
Sets theFECTransformEnginefor thisMediaStreamBy default, nothing is done with the passed engine, allowing extenders to implement it
-
getFormat
public MediaFormat getFormat()
Gets the MediaFormat that this stream is currently transmitting in.- Specified by:
getFormatin interfaceMediaStream- Returns:
- the MediaFormat that this stream is currently transmitting in
- See Also:
MediaStream.getFormat()
-
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- Overrides:
getFormatin classAbstractMediaStream- 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.
-
getLocalContributingSourceIDs
public long[] getLocalContributingSourceIDs()
Returns the list of CSRC identifiers for all parties currently known to contribute to the media that this stream is sending toward its remote counter part. In other words, the method returns the list of CSRC IDs that this stream will include in outgoing RTP packets. This method will return an null in case this stream is not part of a mixed conference call.- Returns:
- a long[] array of CSRC IDs representing parties that are currently known to contribute to the media that this stream is sending or an null in case this MediaStream is not part of a conference call.
-
getLocalControlAddress
public InetSocketAddress getLocalControlAddress()
Gets the local address that this stream is sending RTCP traffic from.- Returns:
- an InetSocketAddress instance indicating the local address that this stream is sending RTCP traffic from.
-
getLocalDataAddress
public InetSocketAddress getLocalDataAddress()
Gets the local address that this stream is sending RTP traffic from.- Returns:
- an InetSocketAddress instance indicating the local address that this stream is sending RTP traffic from.
-
getLocalSourceID
public long getLocalSourceID()
Gets the synchronization source (SSRC) identifier of the local peer or -1 if it is not yet known.- Specified by:
getLocalSourceIDin interfaceMediaStream- Returns:
- the synchronization source (SSRC) identifier of the local peer or -1 if it is not yet known
- See Also:
MediaStream.getLocalSourceID()
-
getMediaStreamStats
public MediaStreamStats2Impl getMediaStreamStats()
Returns the statistical information gathered about this MediaStream.- Specified by:
getMediaStreamStatsin interfaceMediaStream- Returns:
- the statistical information gathered about this MediaStream
-
getMediaType
public org.jitsi.utils.MediaType getMediaType()
Gets the MediaType of this MediaStream.- Returns:
- the MediaType of this MediaStream
-
getPriority
protected int getPriority()
Used to set the priority of the receive/send streams. Underling implementations can override this and return different than current default value.- Returns:
- the priority for the current thread.
-
getReceiveStream
public javax.media.rtp.ReceiveStream getReceiveStream(int ssrc)
Gets a ReceiveStream which this instance plays back on its associated MediaDevice and which has a specific synchronization source identifier (SSRC).- Parameters:
ssrc- the synchronization source identifier of the ReceiveStream to return- Returns:
- a ReceiveStream which this instance plays back on its associated MediaDevice and which has the specified ssrc
-
getReceiveStreams
public Collection<javax.media.rtp.ReceiveStream> getReceiveStreams()
Gets a list of the ReceiveStreams this instance plays back on its associated MediaDevice.- Returns:
- a list of the ReceiveStreams this instance plays back on its associated MediaDevice
-
getRedTransformEngine
protected REDTransformEngine getRedTransformEngine()
Creates the REDTransformEngine for this MediaStream. By default none is created, allows extenders to implement it.- Returns:
- the REDTransformEngine created.
-
getRemoteContributingSourceIDs
public long[] getRemoteContributingSourceIDs()
Returns the List of CSRC identifiers representing the parties contributing to the stream that we are receiving from this MediaStream's remote party.- Returns:
- a List of CSRC identifiers representing the parties contributing to the stream that we are receiving from this MediaStream's remote party.
-
getRemoteControlAddress
public InetSocketAddress getRemoteControlAddress()
Gets the address that this stream is sending RTCP traffic to.- Specified by:
getRemoteControlAddressin interfaceMediaStream- Returns:
- an InetSocketAddress instance indicating the address that this stream is sending RTCP traffic to
- See Also:
MediaStream.getRemoteControlAddress()
-
getRemoteDataAddress
public InetSocketAddress getRemoteDataAddress()
Gets the address that this stream is sending RTP traffic to.- Specified by:
getRemoteDataAddressin interfaceMediaStream- Returns:
- an InetSocketAddress instance indicating the address that this stream is sending RTP traffic to
- See Also:
MediaStream.getRemoteDataAddress()
-
getRemoteSourceID
public long getRemoteSourceID()
Gets the synchronization source (SSRC) identifier of the remote peer or -1 if that identifier is not yet known at this point in the execution.Warning: A MediaStream may receive multiple RTP streams and may thus have multiple remote SSRCs. Since it is not clear how this MediaStream instance chooses which of the multiple remote SSRCs to be returned by the method, it is advisable to always consider
MediaStream.getRemoteSourceIDs()first. Returns the last element ofgetRemoteSourceIDs()which may or may not always be appropriate.- Specified by:
getRemoteSourceIDin interfaceMediaStream- Returns:
- the synchronization source (SSRC) identifier of the remote peer or -1 if that identifier is not yet known at this point in the execution
- See Also:
MediaStream.getRemoteSourceID()
-
getRemoteSourceIDs
public List<Long> getRemoteSourceIDs()
Gets the synchronization source (SSRC) identifiers of the remote peer.- Specified by:
getRemoteSourceIDsin interfaceMediaStream- Returns:
- the synchronization source (SSRC) identifiers of the remote peer
-
getRTPConnector
protected AbstractRTPConnector getRTPConnector()
Gets the RTPConnector through which this instance sends and receives RTP and RTCP traffic.- Returns:
- the RTPConnector through which this instance sends and receives RTP and RTCP traffic
-
getRTPManager
public StreamRTPManager getRTPManager()
Gets the RTPManager instance which sends and receives RTP and RTCP traffic on behalf of this MediaStream. If the RTPManager does not exist yet, it is created.- Returns:
- the RTPManager instance which sends and receives RTP and RTCP traffic on behalf of this MediaStream
-
getStreamRTPManager
public StreamRTPManager getStreamRTPManager()
Gets theStreamRTPManagerwhich is to forward RTP and RTCP traffic between this and otherMediaStreams.- Specified by:
getStreamRTPManagerin interfaceMediaStream- Returns:
- the
StreamRTPManagerwhich is to forward RTP and RTCP traffic between this and otherMediaStreams
-
getSrtpControl
public SrtpControl getSrtpControl()
Gets the SrtpControl which controls the SRTP of this stream.- Specified by:
getSrtpControlin interfaceMediaStream- Returns:
- the SrtpControl which controls the SRTP of this stream
-
getTarget
public MediaStreamTarget getTarget()
Returns the target of this MediaStream to which it is to send and from which it is to receive data (e.g. RTP) and control data (e.g. RTCP).- Specified by:
getTargetin interfaceMediaStream- Returns:
- the MediaStreamTarget describing the data (e.g. RTP) and the control data (e.g. RTCP) locations to which this MediaStream is to send and from which it is to receive
- See Also:
MediaStream.setTarget(MediaStreamTarget)
-
getTransportProtocol
public StreamConnector.Protocol getTransportProtocol()
Returns the transport protocol used by the streams.- Specified by:
getTransportProtocolin interfaceMediaStream- Returns:
- the transport protocol (UDP or TCP) used by the streams. null if the stream connector is not instantiated.
-
isMute
public boolean isMute()
Determines whether this MediaStream is set to transmit "silence" instead of the media being fed from its MediaDevice. "Silence" for video is understood as video data which is not the captured video data and may represent, for example, a black image.- Specified by:
isMutein interfaceMediaStream- Returns:
- true if this MediaStream is set to transmit "silence" instead of the media fed from its MediaDevice; false, otherwise
- See Also:
MediaStream.isMute()
-
isStarted
public boolean isStarted()
Determines whetherstart()has been called on this MediaStream withoutstop()orclose()afterwards.- Specified by:
isStartedin interfaceMediaStream- Returns:
- true if
start()has been called on this MediaStream withoutstop()orclose()afterwards - See Also:
MediaStream.isStarted()
-
queryRTPManager
public StreamRTPManager queryRTPManager()
Gets the RTPManager instance which sends and receives RTP and RTCP traffic on behalf of this MediaStream. If the RTPManager does not exist yet, it is not created.- Returns:
- the RTPManager instance which sends and receives RTP and RTCP traffic on behalf of this MediaStream
-
recreateSendStreams
protected void recreateSendStreams()
Recreates the SendStreams of this instance (i.e. of its RTPManager) as necessary. For example, if there was no attempt to create the SendStreams prior to the call, does nothing. If they were created prior to the call, closes them and creates them again. If they were not started prior to the call, does not start them after recreating them.
-
registerCustomCodecFormats
protected void registerCustomCodecFormats(StreamRTPManager rtpManager)
Registers any custom JMF Formats with a specific RTPManager. Extenders should override in order to register their own customizations and should call back to this super implementation during the execution of their override in order to register the associations defined in this instance of (dynamic) RTP payload types to MediaFormats.- Parameters:
rtpManager- the RTPManager to register any custom JMF Formats with
-
removeReceiveStreamForSsrc
public void removeReceiveStreamForSsrc(long ssrc)
Removes the ReceiveStream with SSRC ssrc, if there is such a ReceiveStream, from the receive streams of this MediaStream- Specified by:
removeReceiveStreamForSsrcin interfaceMediaStream- Parameters:
ssrc- the SSRC for which to remove a ReceiveStream
-
rtpConnectorChanged
protected void rtpConnectorChanged(AbstractRTPConnector oldValue, AbstractRTPConnector newValue)
Notifies this MediaStream implementation that its RTPConnector instance has changed from a specific old value to a specific new value. Allows extenders to override and perform additional processing after this MediaStream has changed its RTPConnector instance.- Parameters:
oldValue- the RTPConnector of this MediaStream implementation before it got changed to newValuenewValue- the current RTPConnector of this MediaStream which replaced oldValue
-
setConnector
public void setConnector(StreamConnector connector)
Sets the StreamConnector to be used by this instance for sending and receiving media.- Specified by:
setConnectorin interfaceMediaStream- Parameters:
connector- the StreamConnector to be used by this instance for sending and receiving media
-
setDevice
public void setDevice(MediaDevice device)
Sets the MediaDevice that this stream should use to play back and capture media.Note: Also resets any previous direction set with
setDirection(MediaDirection)to the direction of the specified MediaDevice.- Specified by:
setDevicein interfaceMediaStream- Parameters:
device- the MediaDevice that this stream should use to play back and capture media- See Also:
MediaStream.setDevice(MediaDevice)
-
setDirection
public void setDirection(MediaDirection direction)
Sets the direction in which media in this MediaStream is to be streamed. If this MediaStream is not currently started, calls tostart()later on will start it only in the specified direction. If it is currently started in a direction different than the specified, directions other than the specified will be stopped.- Specified by:
setDirectionin interfaceMediaStream- Parameters:
direction- the MediaDirection in which this MediaStream is to stream media when it is started- See Also:
MediaStream.setDirection(MediaDirection)
-
setFormat
public void setFormat(MediaFormat format)
Sets the MediaFormat that this MediaStream should transmit in.- Specified by:
setFormatin interfaceMediaStream- Parameters:
format- the MediaFormat that this MediaStream should transmit in- See Also:
MediaStream.setFormat(MediaFormat)
-
setLocalSourceID
protected void setLocalSourceID(long localSourceID)
Sets the local SSRC identifier and fires the corresponding PropertyChangeEvent.- Parameters:
localSourceID- the SSRC identifier that this stream will be using in outgoing RTP packets from now on
-
setMute
public void setMute(boolean mute)
Causes this MediaStream to stop transmitting the media being fed from this stream's MediaDevice and transmit "silence" instead. "Silence" for video is understood as video data which is not the captured video data and may represent, for example, a black image.- Specified by:
setMutein interfaceMediaStream- Parameters:
mute- true to have this MediaStream transmit "silence" instead of the actual media data that it captures from its MediaDevice; false to transmit actual media data captured from the MediaDevice of this MediaStream- See Also:
MediaStream.setMute(boolean)
-
setSSRCFactory
public void setSSRCFactory(SSRCFactory ssrcFactory)
Sets the SSRCFactory which is to generate new synchronization source (SSRC) identifiers.- Specified by:
setSSRCFactoryin interfaceMediaStream- Parameters:
ssrcFactory- the SSRCFactory which is to generate new synchronization source (SSRC) identifiers or null if this MediaStream is to employ internal logic to generate new synchronization source (SSRC) identifiers
-
setTarget
public void setTarget(MediaStreamTarget target)
Sets the target of this MediaStream to which it is to send and from which it is to receive data (e.g. RTP) and control data (e.g. RTCP).- Specified by:
setTargetin interfaceMediaStream- Parameters:
target- the MediaStreamTarget describing the data (e.g. RTP) and the control data (e.g. RTCP) locations to which this MediaStream is to send and from which it is to receive- See Also:
MediaStream.setTarget(MediaStreamTarget)
-
start
public void start()
Starts capturing media from this stream's MediaDevice and then streaming it through the local StreamConnector toward the stream's target address and port. Also puts the MediaStream in a listening state which make it play all media received from the StreamConnector on the stream's MediaDevice.- Specified by:
startin interfaceMediaStream- See Also:
MediaStream.start()
-
stop
public void stop()
Stops all streaming and capturing in this MediaStream and closes and releases all open/allocated devices/resources. Has no effect if this MediaStream is already closed and is simply ignored.- Specified by:
stopin interfaceMediaStream- See Also:
MediaStream.stop()
-
update
public void update(javax.media.rtp.event.ReceiveStreamEvent ev)
Notifies this ReceiveStreamListener that the RTPManager it is registered with has generated an event related to a ReceiveStream.- Specified by:
updatein interfacejavax.media.rtp.ReceiveStreamListener- Parameters:
ev- the ReceiveStreamEvent which specifies the ReceiveStream that is the cause of the event and the very type of the event- See Also:
ReceiveStreamListener.update(ReceiveStreamEvent)
-
update
public void update(javax.media.rtp.event.RemoteEvent ev)
Method called back in the RemoteListener to notify listener of all RTP Remote Events.RemoteEvents are one of ReceiverReportEvent, SenderReportEvent or RemoteCollisionEvent- Specified by:
updatein interfacejavax.media.rtp.RemoteListener- Parameters:
ev- the event
-
update
public void update(javax.media.rtp.event.SendStreamEvent ev)
Notifies this SendStreamListener that the RTPManager it is registered with has generated an event related to a SendStream.- Specified by:
updatein interfacejavax.media.rtp.SendStreamListener- Parameters:
ev- the SendStreamEvent which specifies the SendStream that is the cause of the event and the very type of the event- See Also:
SendStreamListener.update(SendStreamEvent)
-
update
public void update(javax.media.rtp.event.SessionEvent ev)
Notifies this SessionListener that the RTPManager it is registered with has generated an event which pertains to the session as a whole and does not belong to a ReceiveStream or a SendStream or a remote participant necessarily.- Specified by:
updatein interfacejavax.media.rtp.SessionListener- Parameters:
ev- the SessionEvent which specifies the source and the very type of the event- See Also:
SessionListener.update(SessionEvent)
-
setExternalTransformer
public void setExternalTransformer(TransformEngine transformEngine)
Sets the external (application-provided) TransformEngine of this MediaStream.- Specified by:
setExternalTransformerin interfaceMediaStream- Parameters:
transformEngine- the TransformerEngine to use.
-
injectPacket
public void injectPacket(RawPacket pkt, boolean data, TransformEngine after) throws TransmissionFailedException
Sends a given RTP or RTCP packet to the remote peer/side.- Specified by:
injectPacketin interfaceMediaStream- Parameters:
pkt- the packet to send.data-trueto send an RTP packet orfalseto send an RTCP packet.after- theTransformEnginein theTransformEnginechain of thisMediaStreamafter which the injection is to begin. If the specifiedafteris not in theTransformEnginechain of thisMediaStream,pktwill be injected at the beginning of theTransformEnginechain of thisMediaStream. Generally, the value ofaftershould benullunless the injection is being performed by aTransformEngineitself (while executingtransformorreverseTransformof aPacketTransformerof its own even).- Throws:
TransmissionFailedException- if the transmission failed.
-
injectPacket
public void injectPacket(RawPacket pkt, boolean data, TransformEngine after, boolean create) throws TransmissionFailedException
Sends a given RTP or RTCP packet to the remote peer/side.- Parameters:
create- true to create the OutputDataStream which is to be used to write RTP data to be sent to the remote targets if it does not exist yet; otherwise, false- Throws:
TransmissionFailedException
-
getTemporalID
public int getTemporalID(RawPacket pkt)
Utility method that determines the temporal layer index (TID) of an RTP packet.- Parameters:
pkt- the packet from which to get the temporal layer id- Returns:
- the TID of the packet, -1 otherwise.
FIXME(gp) conceptually this belongs to the
VideoMediaStreamImpl, but I don't want to be obliged to cast to use this method.
-
getSpatialID
public int getSpatialID(RawPacket pkt)
Utility method that determines the spatial layer index (SID) of an RTP packet.- Parameters:
pkt- the RTP packet.- Returns:
- the SID of the packet, -1 otherwise.
FIXME(gp) conceptually this belongs to the
VideoMediaStreamImpl, but I don't want to be obliged to cast to use this method.
-
supportsFrameBoundaries
public boolean supportsFrameBoundaries(RawPacket pkt)
Returns a boolean that indicates whether or not our we're able to detect the frame boundaries for the codec of the packet that is specified as an argument.- Parameters:
pkt- theRawPacketthat holds the RTP packet.- Returns:
- true if we're able to detect the frame boundaries for the codec of the packet that is specified as an argument, false otherwise.
-
isStartOfFrame
public boolean isStartOfFrame(RawPacket pkt)
Utility method that determines whether or not a packet is a start of frame.- Parameters:
pkt- raw rtp packet.- Returns:
- true if the packet is the start of a frame, false otherwise.
FIXME(gp) conceptually this belongs to the
VideoMediaStreamImpl, but I don't want to be obliged to cast to use this method.
-
isEndOfFrame
public boolean isEndOfFrame(RawPacket pkt)
Utility method that determines whether or not a packet is an end of frame.- Parameters:
pkt- raw rtp packet.- Returns:
- true if the packet is the end of a frame, false otherwise.
FIXME(gp) conceptually this belongs to the
VideoMediaStreamImpl, but I don't want to be obliged to cast to use this method.
-
isKeyFrame
public boolean isKeyFrame(byte[] buf, int off, int len)Utility method that determines whether or not a packet is a key frame. This is absolutely terrible, but we need a RawPacket and the method is used from RTPTranslator, which doesn't work with RawPacket.- Specified by:
isKeyFramein interfaceMediaStream- Parameters:
buf- the buffer that holds the RTP packet.off- the offset in the buff where the RTP packet is found.len- then length of the RTP packet in the buffer.- Returns:
- true if the packet is a key frame, false otherwise.
-
isKeyFrame
public boolean isKeyFrame(RawPacket pkt)
Utility method that determines whether or not a packet is a key frame.- Specified by:
isKeyFramein interfaceMediaStream- Parameters:
pkt- the packet.
-
getCachingTransformer
public CachingTransformer getCachingTransformer()
Gets theCachingTransformerwhich (optionally) caches outgoing packets for thisMediaStreamImpl, if it exists.- Returns:
- the
CachingTransformerfor thisMediaStreamImpl.
-
getRetransmissionRequester
public RetransmissionRequester getRetransmissionRequester()
- Specified by:
getRetransmissionRequesterin interfaceMediaStream- Returns:
- the
RetransmissionRequesterfor this media stream.
-
getTransformEngineChain
public TransformEngineChain getTransformEngineChain()
Gets theTransformEngineChainof thisMediaStream.
Note that the chain is only initialized when aStreamConnectoris set for theMediaStreamImplviasetConnector(StreamConnector)or by passing a non-null connector to the constructor. Until the chain is initialized, this method will return null.- Specified by:
getTransformEngineChainin interfaceMediaStream- Overrides:
getTransformEngineChainin classAbstractMediaStream
-
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- Overrides:
getPrimaryREDBlockin classAbstractMediaStream- 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 theREDBlockthat contains the payload of the packet passed in as a parameter.- Specified by:
getPrimaryREDBlockin interfaceMediaStream- Overrides:
getPrimaryREDBlockin classAbstractMediaStream- Parameters:
pkt- the packet from which we want to get the primary RED block- Returns:
- the
REDBlockthat contains the payload of the packet passed in as a parameter, or null if the buffer is invalid.
-
getRtxTransformer
public RtxTransformer getRtxTransformer()
Gets theRtxTransformer, if any, used by theMediaStream.- Returns:
- the
RtxTransformerused by theMediaStreamornull
-
createDiscardEngine
protected DiscardTransformEngine createDiscardEngine()
Creates theDiscardTransformEnginefor this stream. Allows extenders to override.
-
getRTCPTermination
protected TransformEngine getRTCPTermination()
Gets the RTCP termination for thisMediaStreamImpl.
-
getPaddingTermination
protected PaddingTermination getPaddingTermination()
Gets thePaddingTerminationfor thisMediaStreamImpl.
-
getRemoteBitrateEstimator
public RemoteBitrateEstimatorWrapper getRemoteBitrateEstimator()
Gets the RemoteBitrateEstimator of this VideoMediaStream.- Returns:
- the RemoteBitrateEstimator of this VideoMediaStream if any; otherwise, null
-
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- Overrides:
setTransportCCEnginein classAbstractMediaStream- Parameters:
engine- the engine to 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- Overrides:
setRTPTranslatorin classAbstractMediaStream- Parameters:
rtpTranslator- the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams
-
-