Package org.jitsi.impl.neomedia
Class VideoMediaStreamImpl
- java.lang.Object
-
- org.jitsi.service.neomedia.AbstractMediaStream
-
- org.jitsi.impl.neomedia.MediaStreamImpl
-
- org.jitsi.impl.neomedia.VideoMediaStreamImpl
-
- All Implemented Interfaces:
EventListener,javax.media.rtp.ReceiveStreamListener,javax.media.rtp.RemoteListener,javax.media.rtp.SendStreamListener,javax.media.rtp.SessionListener,MediaStream,VideoMediaStream
public class VideoMediaStreamImpl extends MediaStreamImpl implements VideoMediaStream
Extends MediaStreamImpl in order to provide an implementation of VideoMediaStream.- Author:
- Lyubomir Marinov, Sebastien Vincent, George Politis
-
-
Field Summary
-
Fields inherited from class org.jitsi.impl.neomedia.MediaStreamImpl
PROPERTY_NAME_RECEIVE_BUFFER_LENGTH, sendStreamsAreCreated
-
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
-
Fields inherited from interface org.jitsi.service.neomedia.VideoMediaStream
REQUEST_RETRANSMISSIONS_PNAME
-
-
Constructor Summary
Constructors Constructor Description VideoMediaStreamImpl(StreamConnector connector, MediaDevice device, SrtpControl srtpControl)Initializes a new VideoMediaStreamImpl instance which will use the specified MediaDevice for both capture and playback of video exchanged via the specified StreamConnector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddRemoteSourceID(long ssrc)Set remote SSRC.voidaddVideoListener(VideoListener listener)Adds a specific VideoListener to this VideoMediaStream in order to receive notifications when visual/video Components are being added and removed.voidclose()Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.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 CachingTransformercreateCachingTransformer()Creates theCachingTransformerfor thisMediaStream.protected RetransmissionRequesterImplcreateRetransmissionRequester()Creates theRetransmissionRequesterImplfor thisMediaStream.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.protected booleanfireVideoEvent(int type, Component visualComponent, int origin, boolean wait)Notifies the VideoListeners registered with this VideoMediaStream about a specific type of change in the availability of a specific visual Component depicting video.protected voidfireVideoEvent(VideoEvent event, boolean wait)Notifies the VideoListeners registered with this instance about a specific VideoEvent.protected TransformEngineWrapper<FECTransformEngine>getFecTransformEngine()Creates the FECTransformEngine for this MediaStream.KeyFrameControlgetKeyFrameControl()ImplementsVideoMediaStream.getKeyFrameControl().ComponentgetLocalVisualComponent()Gets the visual Component, if any, depicting the video streamed from the local peer to the remote peer.MediaStreamTrackReceivergetMediaStreamTrackReceiver()Gets theMediaStreamTrackReceiverof thisMediaStream.BandwidthEstimatorgetOrCreateBandwidthEstimator()Creates an instance ofBandwidthEstimatorfor thisMediaStreamif one doesn't already exist.protected PaddingTerminationgetPaddingTermination()Gets thePaddingTerminationfor thisMediaStreamImpl.protected intgetPriority()The priority of the video is 5, which is meant to be higher than other threads and lower than the audio one.QualityControlgetQualityControl()Gets the QualityControl of this VideoMediaStream.RemoteBitrateEstimatorWrappergetRemoteBitrateEstimator()Gets the RemoteBitrateEstimator of this VideoMediaStream.protected TransformEnginegetRTCPTermination()Gets the RTCP termination for thisMediaStreamImpl.RtxTransformergetRtxTransformer()Gets theRtxTransformer, if any, used by theMediaStream.ComponentgetVisualComponent()Deprecated.ComponentgetVisualComponent(long ssrc)Gets the visual Components rendering the ReceiveStream corresponding to the given ssrc.List<Component>getVisualComponents()Gets a list of the visual Components where video from the remote peer is being rendered.protected voidhandleAttributes(MediaFormat format, Map<String,String> attrs)Handles attributes contained in MediaFormat.voidmovePartialDesktopStreaming(int x, int y)Move origin of a partial desktop streaming MediaDevice.static Dimension[]parseSendRecvResolution(String imgattr)Extracts and returns maximum resolution can receive from the image attribute.voidremoveVideoListener(VideoListener listener)Removes a specific VideoListener from this VideoMediaStream in order to have to no longer receive notifications when visual/video Components are being added and removed.protected 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.static DimensionselectVideoSize(javax.media.protocol.DataSource videoDS, int preferredWidth, int preferredHeight)Selects the VideoFormat from the list of supported formats of a specific video DataSource which has a size as close as possible to a specific size and sets it as the format of the specified video DataSource.protected voidsetFecTransformEngine(FECTransformEngine fecTransformEngine)Sets theFECTransformEnginefor thisMediaStreamBy default, nothing is done with the passed engine, allowing extenders to implement itprotected voidsetLocalSourceID(long localSourceID)Sets the local SSRC identifier and fires the corresponding PropertyChangeEvent.voidsetSupportsFir(boolean supportsFir)Sets the value of the flag which indicates whether the remote end supports RTCP FIR or not.voidsetSupportsPli(boolean supportsPli)Sets the value of the flag which indicates whether the remote end supports RTCP PLI or not.voidsetSupportsRemb(boolean supportsRemb)Sets the value of the flag which indicates whether the remote end supports RTCP REMB or not.booleansupportsFir()booleansupportsPli()voidupdateQualityControl(Map<String,String> advancedParams)Updates the QualityControl of this VideoMediaStream.-
Methods inherited from class org.jitsi.impl.neomedia.MediaStreamImpl
addDynamicRTPPayloadType, addDynamicRTPPayloadTypeOverride, addRTPExtension, clearDynamicRTPPayloadTypes, clearRTPExtensions, configureDataInputStream, createAbsSendTimeEngine, createDiscardEngine, createDtmfTransformEngine, createSendStreams, createSsrcTransformEngine, getActiveRTPExtensionID, getActiveRTPExtensions, getCachingTransformer, getCsrcEngine, getDevice, getDeviceSession, getDiagnosticContext, getDirection, getDynamicRTPPayloadType, getDynamicRTPPayloadTypes, getFormat, getFormat, getLocalContributingSourceIDs, getLocalControlAddress, getLocalDataAddress, getLocalSourceID, getMediaStreamStats, getMediaType, getPrimaryREDBlock, getPrimaryREDBlock, getReceiveStream, getReceiveStreams, getRedTransformEngine, getRemoteContributingSourceIDs, getRemoteControlAddress, getRemoteDataAddress, getRemoteSourceID, getRemoteSourceIDs, getRetransmissionRequester, getRTPConnector, getRTPManager, getSpatialID, getSrtpControl, getStreamRTPManager, getTarget, getTemporalID, getTransformEngineChain, getTransportCCEngine, getTransportProtocol, injectPacket, injectPacket, isEndOfFrame, isKeyFrame, isKeyFrame, isMute, isStarted, isStartOfFrame, packetToString, queryRTPManager, recreateSendStreams, registerCustomCodecFormats, removeReceiveStreamForSsrc, setConnector, setDevice, setDirection, setExternalTransformer, setFormat, setMute, setRTPTranslator, setSSRCFactory, setTarget, setTransportCCEngine, start, stop, supportsFrameBoundaries, toString, update, update, update, update
-
Methods inherited from class org.jitsi.service.neomedia.AbstractMediaStream
addPropertyChangeListener, assertDirection, firePropertyChange, getName, getProperty, getRTPTranslator, injectPacket, removePropertyChangeListener, setName, setProperty
-
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, addPropertyChangeListener, addRTPExtension, clearDynamicRTPPayloadTypes, clearRTPExtensions, getActiveRTPExtensions, getDevice, getDirection, getDynamicRTPPayloadType, getDynamicRTPPayloadTypes, getFormat, getFormat, getLocalSourceID, getMediaStreamStats, getName, getPrimaryREDBlock, getPrimaryREDBlock, getProperty, getRemoteControlAddress, getRemoteDataAddress, getRemoteSourceID, getRemoteSourceIDs, getRetransmissionRequester, getRTPTranslator, getSrtpControl, getStreamRTPManager, getTarget, getTransformEngineChain, getTransportProtocol, injectPacket, isKeyFrame, isKeyFrame, isMute, isStarted, removePropertyChangeListener, removeReceiveStreamForSsrc, setConnector, setDevice, setDirection, setExternalTransformer, setFormat, setMute, setName, setProperty, setRTPTranslator, setSSRCFactory, setTarget, setTransportCCEngine, start, stop
-
-
-
-
Constructor Detail
-
VideoMediaStreamImpl
public VideoMediaStreamImpl(StreamConnector connector, MediaDevice device, SrtpControl srtpControl)
Initializes a new VideoMediaStreamImpl instance which will use the specified MediaDevice for both capture and playback of video exchanged via the specified StreamConnector.- Parameters:
connector- the StreamConnector the new instance is to use for sending and receiving videodevice- the MediaDevice the new instance is to use for both capture and playback of video exchanged via the specified StreamConnectorsrtpControl- a control which is already created, used to control the srtp operations.
-
-
Method Detail
-
parseSendRecvResolution
public static Dimension[] parseSendRecvResolution(String imgattr)
Extracts and returns maximum resolution can receive from the image attribute.- Parameters:
imgattr- send/recv resolution string- Returns:
- maximum resolution array (first element is send, second one is recv). Elements could be null if image attribute is not present or if resolution is a wildcard.
-
selectVideoSize
public static Dimension selectVideoSize(javax.media.protocol.DataSource videoDS, int preferredWidth, int preferredHeight)
Selects the VideoFormat from the list of supported formats of a specific video DataSource which has a size as close as possible to a specific size and sets it as the format of the specified video DataSource.- Parameters:
videoDS- the video DataSource which is to have its supported formats examined and its format changed to the VideoFormat which is as close as possible to the specified preferredWidth and preferredHeightpreferredWidth- the width of the VideoFormat to be selectedpreferredHeight- the height of the VideoFormat to be selected- Returns:
- the size of the VideoFormat from the list of supported formats of videoDS which is as close as possible to preferredWidth and preferredHeight and which has been set as the format of videoDS
-
getRtxTransformer
public RtxTransformer getRtxTransformer()
Gets theRtxTransformer, if any, used by theMediaStream.- Overrides:
getRtxTransformerin classMediaStreamImpl- Returns:
- the
RtxTransformerused by theMediaStreamornull
-
getFecTransformEngine
protected TransformEngineWrapper<FECTransformEngine> getFecTransformEngine()
Creates the FECTransformEngine for this MediaStream. By default none is created, allows extenders to implement it.- Overrides:
getFecTransformEnginein classMediaStreamImpl- 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- Overrides:
setFecTransformEnginein classMediaStreamImpl
-
setSupportsFir
public void setSupportsFir(boolean supportsFir)
Sets the value of the flag which indicates whether the remote end supports RTCP FIR or not.- Parameters:
supportsFir- the value to set.
-
setSupportsPli
public void setSupportsPli(boolean supportsPli)
Sets the value of the flag which indicates whether the remote end supports RTCP PLI or not.- Parameters:
supportsPli- the value to set.
-
setSupportsRemb
public void setSupportsRemb(boolean supportsRemb)
Sets the value of the flag which indicates whether the remote end supports RTCP REMB or not.- Parameters:
supportsRemb- the value to set.
-
supportsFir
public boolean supportsFir()
- Returns:
trueiff the remote end supports RTCP FIR.
-
supportsPli
public boolean supportsPli()
- Returns:
trueiff the remote end supports RTCP PLI.
-
addRemoteSourceID
protected void addRemoteSourceID(long ssrc)
Set remote SSRC.- Overrides:
addRemoteSourceIDin classMediaStreamImpl- Parameters:
ssrc- remote SSRC
-
addVideoListener
public void addVideoListener(VideoListener listener)
Adds a specific VideoListener to this VideoMediaStream in order to receive notifications when visual/video Components are being added and removed.Adding a listener which has already been added does nothing i.e. it is not added more than once and thus does not receive one and the same VideoEvent multiple times.
- Specified by:
addVideoListenerin interfaceVideoMediaStream- Parameters:
listener- the VideoListener to be notified when visual/video Components are being added or removed in this VideoMediaStream
-
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- Overrides:
closein classMediaStreamImpl- See Also:
MediaStream.close()
-
configureDataOutputStream
protected void configureDataOutputStream(RTPConnectorOutputStream dataOutputStream)
Performs any optional configuration on a specific RTPConnectorOuputStream of an RTPManager to be used by this MediaStreamImpl.- Overrides:
configureDataOutputStreamin classMediaStreamImpl- 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.- Overrides:
configureRTPManagerBufferControlin classMediaStreamImpl- 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
-
getMediaStreamTrackReceiver
public MediaStreamTrackReceiver getMediaStreamTrackReceiver()
Gets theMediaStreamTrackReceiverof thisMediaStream.- Specified by:
getMediaStreamTrackReceiverin interfaceMediaStream- Overrides:
getMediaStreamTrackReceiverin classAbstractMediaStream- Returns:
- the
MediaStreamTrackReceiverof thisMediaStream, or null.
-
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. Makes sure that the VideoListeners of this instance get VideoEvents for the new/current VideoMediaDeviceSession and not for the old one. Note: this overloaded method gets executed in the MediaStreamImpl constructor. As a consequence we cannot assume proper initialization of the fields specific to VideoMediaStreamImpl.- Overrides:
deviceSessionChangedin classMediaStreamImpl- Parameters:
oldValue- the MediaDeviceSession with the MediaDevice this instance used work withnewValue- the MediaDeviceSession with the MediaDevice this instance is to work with- See Also:
MediaStreamImpl.deviceSessionChanged(MediaDeviceSession, MediaDeviceSession)
-
fireVideoEvent
protected boolean fireVideoEvent(int type, Component visualComponent, int origin, boolean wait)Notifies the VideoListeners registered with this VideoMediaStream about a specific type of change in the availability of a specific visual Component depicting video.- Parameters:
type- the type of change as defined by VideoEvent in the availability of the specified visual Component depicting videovisualComponent- the visual Component depicting video which has been added or removed in this VideoMediaStreamorigin-VideoEvent.LOCALif the origin of the video is local (e.g. it is being locally captured);VideoEvent.REMOTEif the origin of the video is remote (e.g. a remote peer is streaming it)wait- true if the call is to wait till the specified VideoEvent has been delivered to the VideoListeners; otherwise, false- Returns:
- true if this event and, more specifically, the visual Component it describes have been consumed and should be considered owned, referenced (which is important because Components belong to a single Container at a time); otherwise, false
-
fireVideoEvent
protected void fireVideoEvent(VideoEvent event, boolean wait)
Notifies the VideoListeners registered with this instance about a specific VideoEvent.- Parameters:
event- the VideoEvent to be fired to the VideoListeners registered with this instancewait- true if the call is to wait till the specified VideoEvent has been delivered to the VideoListeners; otherwise, false
-
getKeyFrameControl
public KeyFrameControl getKeyFrameControl()
ImplementsVideoMediaStream.getKeyFrameControl(). Gets the KeyFrameControl of this VideoMediaStream.- Specified by:
getKeyFrameControlin interfaceVideoMediaStream- Returns:
- the KeyFrameControl of this VideoMediaStream
- See Also:
VideoMediaStream.getKeyFrameControl()
-
getLocalVisualComponent
public Component getLocalVisualComponent()
Gets the visual Component, if any, depicting the video streamed from the local peer to the remote peer.- Specified by:
getLocalVisualComponentin interfaceVideoMediaStream- Returns:
- the visual Component depicting the local video if local video is actually being streamed from the local peer to the remote peer; otherwise, null
-
getPriority
protected int getPriority()
The priority of the video is 5, which is meant to be higher than other threads and lower than the audio one.- Overrides:
getPriorityin classMediaStreamImpl- Returns:
- video priority.
-
getQualityControl
public QualityControl getQualityControl()
Gets the QualityControl of this VideoMediaStream.- Specified by:
getQualityControlin interfaceVideoMediaStream- Returns:
- the QualityControl of this VideoMediaStream
-
getRemoteBitrateEstimator
public RemoteBitrateEstimatorWrapper getRemoteBitrateEstimator()
Gets the RemoteBitrateEstimator of this VideoMediaStream.- Overrides:
getRemoteBitrateEstimatorin classMediaStreamImpl- Returns:
- the RemoteBitrateEstimator of this VideoMediaStream if any; otherwise, null
-
getVisualComponent
@Deprecated public Component getVisualComponent()
Deprecated.Gets the visual Component where video from the remote peer is being rendered or null if no video is currently being rendered.- Specified by:
getVisualComponentin interfaceVideoMediaStream- Returns:
- the visual Component where video from the remote peer is being rendered or null if no video is currently being rendered
- See Also:
VideoMediaStream.getVisualComponent()
-
getVisualComponent
public Component getVisualComponent(long ssrc)
Gets the visual Components rendering the ReceiveStream corresponding to the given ssrc.- Specified by:
getVisualComponentin interfaceVideoMediaStream- Parameters:
ssrc- the src-id of the receive stream, which visual Component we're looking for- Returns:
- the visual Component rendering the ReceiveStream corresponding to the given ssrc
-
getVisualComponents
public List<Component> getVisualComponents()
Gets a list of the visual Components where video from the remote peer is being rendered.- Specified by:
getVisualComponentsin interfaceVideoMediaStream- Returns:
- a list of the visual Components where video from the remote peer is being rendered
- See Also:
VideoMediaStream.getVisualComponents()
-
handleAttributes
protected void handleAttributes(MediaFormat format, Map<String,String> attrs)
Handles attributes contained in MediaFormat.- Overrides:
handleAttributesin classAbstractMediaStream- Parameters:
format- the MediaFormat to handle the attributes ofattrs- the attributes Map to handle
-
movePartialDesktopStreaming
public void movePartialDesktopStreaming(int x, int y)Move origin of a partial desktop streaming MediaDevice.- Specified by:
movePartialDesktopStreamingin interfaceVideoMediaStream- Parameters:
x- new x coordinate originy- new y coordinate origin
-
removeVideoListener
public void removeVideoListener(VideoListener listener)
Removes a specific VideoListener from this VideoMediaStream in order to have to no longer receive notifications when visual/video Components are being added and removed.- Specified by:
removeVideoListenerin interfaceVideoMediaStream- Parameters:
listener- the VideoListener to no longer be notified when visual/video Components are being added or removed in this VideoMediaStream
-
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.- Overrides:
rtpConnectorChangedin classMediaStreamImpl- Parameters:
oldValue- the RTPConnector of this MediaStream implementation before it got changed to newValuenewValue- the current RTPConnector of this MediaStream which replaced oldValue- See Also:
MediaStreamImpl.rtpConnectorChanged(AbstractRTPConnector, AbstractRTPConnector)
-
setLocalSourceID
protected void setLocalSourceID(long localSourceID)
Sets the local SSRC identifier and fires the corresponding PropertyChangeEvent.- Overrides:
setLocalSourceIDin classMediaStreamImpl- Parameters:
localSourceID- the SSRC identifier that this stream will be using in outgoing RTP packets from now on
-
updateQualityControl
public void updateQualityControl(Map<String,String> advancedParams)
Updates the QualityControl of this VideoMediaStream.- Specified by:
updateQualityControlin interfaceVideoMediaStream- Parameters:
advancedParams- parameters of advanced attributes that may affect quality control
-
createCachingTransformer
protected CachingTransformer createCachingTransformer()
Creates theCachingTransformerfor thisMediaStream.- Overrides:
createCachingTransformerin classMediaStreamImpl- Returns:
- the created
CachingTransformer.
-
createRetransmissionRequester
protected RetransmissionRequesterImpl createRetransmissionRequester()
Creates theRetransmissionRequesterImplfor thisMediaStream.- Overrides:
createRetransmissionRequesterin classMediaStreamImpl- Returns:
- the created
RetransmissionRequesterImpl.
-
getRTCPTermination
protected TransformEngine getRTCPTermination()
Gets the RTCP termination for thisMediaStreamImpl.- Overrides:
getRTCPTerminationin classMediaStreamImpl
-
getPaddingTermination
protected PaddingTermination getPaddingTermination()
Gets thePaddingTerminationfor thisMediaStreamImpl.- Overrides:
getPaddingTerminationin classMediaStreamImpl
-
getOrCreateBandwidthEstimator
public BandwidthEstimator getOrCreateBandwidthEstimator()
Creates an instance ofBandwidthEstimatorfor thisMediaStreamif one doesn't already exist. Returns the instance.- Specified by:
getOrCreateBandwidthEstimatorin interfaceVideoMediaStream
-
-