Class 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
    • 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 video
        device - the MediaDevice the new instance is to use for both capture and playback of video exchanged via the specified StreamConnector
        srtpControl - 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 preferredHeight
        preferredWidth - the width of the VideoFormat to be selected
        preferredHeight - 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 the RtxTransformer, if any, used by the MediaStream.
        Overrides:
        getRtxTransformer in class MediaStreamImpl
        Returns:
        the RtxTransformer used by the MediaStream or null
      • 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:
        true iff the remote end supports RTCP FIR.
      • supportsPli

        public boolean supportsPli()
        Returns:
        true iff the remote end supports RTCP PLI.
      • addRemoteSourceID

        protected void addRemoteSourceID​(long ssrc)
        Set remote SSRC.
        Overrides:
        addRemoteSourceID in class MediaStreamImpl
        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:
        addVideoListener in interface VideoMediaStream
        Parameters:
        listener - the VideoListener to be notified when visual/video Components are being added or removed in this VideoMediaStream
      • configureDataOutputStream

        protected void configureDataOutputStream​(RTPConnectorOutputStream dataOutputStream)
        Performs any optional configuration on a specific RTPConnectorOuputStream of an RTPManager to be used by this MediaStreamImpl.
        Overrides:
        configureDataOutputStream in class MediaStreamImpl
        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:
        configureRTPManagerBufferControl in class MediaStreamImpl
        Parameters:
        rtpManager - the RTPManager which is to be used by this MediaStreamImpl
        bufferControl - the BufferControl of rtpManager on which any optional configuration is to be performed
      • 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:
        deviceSessionChanged in class MediaStreamImpl
        Parameters:
        oldValue - the MediaDeviceSession with the MediaDevice this instance used work with
        newValue - 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 video
        visualComponent - the visual Component depicting video which has been added or removed in this VideoMediaStream
        origin - VideoEvent.LOCAL if the origin of the video is local (e.g. it is being locally captured); VideoEvent.REMOTE if 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 instance
        wait - true if the call is to wait till the specified VideoEvent has been delivered to the VideoListeners; otherwise, false
      • getLocalVisualComponent

        public Component getLocalVisualComponent()
        Gets the visual Component, if any, depicting the video streamed from the local peer to the remote peer.
        Specified by:
        getLocalVisualComponent in interface VideoMediaStream
        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:
        getPriority in class MediaStreamImpl
        Returns:
        video priority.
      • getVisualComponent

        public Component getVisualComponent​(long ssrc)
        Gets the visual Components rendering the ReceiveStream corresponding to the given ssrc.
        Specified by:
        getVisualComponent in interface VideoMediaStream
        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
      • handleAttributes

        protected void handleAttributes​(MediaFormat format,
                                        Map<String,​String> attrs)
        Handles attributes contained in MediaFormat.
        Overrides:
        handleAttributes in class AbstractMediaStream
        Parameters:
        format - the MediaFormat to handle the attributes of
        attrs - the attributes Map to handle
      • movePartialDesktopStreaming

        public void movePartialDesktopStreaming​(int x,
                                                int y)
        Move origin of a partial desktop streaming MediaDevice.
        Specified by:
        movePartialDesktopStreaming in interface VideoMediaStream
        Parameters:
        x - new x coordinate origin
        y - 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:
        removeVideoListener in interface VideoMediaStream
        Parameters:
        listener - the VideoListener to no longer be notified when visual/video Components are being added or removed in this VideoMediaStream
      • setLocalSourceID

        protected void setLocalSourceID​(long localSourceID)
        Sets the local SSRC identifier and fires the corresponding PropertyChangeEvent.
        Overrides:
        setLocalSourceID in class MediaStreamImpl
        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:
        updateQualityControl in interface VideoMediaStream
        Parameters:
        advancedParams - parameters of advanced attributes that may affect quality control