Class MediaStreamStatsImpl

  • All Implemented Interfaces:
    MediaStreamStats
    Direct Known Subclasses:
    MediaStreamStats2Impl

    public class MediaStreamStatsImpl
    extends Object
    implements MediaStreamStats
    Class used to compute stats concerning a MediaStream. Note: please do not add more code here. New code should be added to MediaStreamStats2Impl instead, where we can manage the complexity and consistency better.
    Author:
    Vincent Lucas, Boris Grozev, Lyubomir Marinov, Hristo Terezov
    • Constructor Detail

      • MediaStreamStatsImpl

        public MediaStreamStatsImpl​(MediaStreamImpl mediaStreamImpl)
        Creates a new instance of stats concerning a MediaStream.
        Parameters:
        mediaStreamImpl - The MediaStreamImpl used to compute the stats.
    • Method Detail

      • getJitterBufferControl

        public static javax.media.control.JitterBufferControl getJitterBufferControl​(javax.media.rtp.ReceiveStream receiveStream)
        Gets the JitterBufferControl of a ReceiveStream.
        Parameters:
        receiveStream - the ReceiveStream to get the JitterBufferControl of
        Returns:
        the JitterBufferControl of receiveStream.
      • getDownloadJitterMs

        public double getDownloadJitterMs()
        Returns the jitter average of this download stream.
        Specified by:
        getDownloadJitterMs in interface MediaStreamStats
        Returns:
        the last jitter average computed (in ms).
      • getDownloadNbPacketLost

        public long getDownloadNbPacketLost()
        Returns the number of lost packets for the receive streams.
        Specified by:
        getDownloadNbPacketLost in interface MediaStreamStats
        Returns:
        the number of lost packets for the receive streams.
      • getUploadNbPacketLost

        public long getUploadNbPacketLost()
        Returns the total number of sent packets lost.
        Specified by:
        getUploadNbPacketLost in interface MediaStreamStats
        Returns:
        the total number of sent packets lost.
      • getDownloadPercentLoss

        public double getDownloadPercentLoss()
        Returns the percent loss of the download stream.
        Specified by:
        getDownloadPercentLoss in interface MediaStreamStats
        Returns:
        the last loss rate computed (in %).
      • getDownloadRateKiloBitPerSec

        public double getDownloadRateKiloBitPerSec()
        Returns the bandwidth used by this download stream.
        Specified by:
        getDownloadRateKiloBitPerSec in interface MediaStreamStats
        Returns:
        the last used download bandwidth computed (in Kbit/s).
      • getDownloadVideoSize

        public Dimension getDownloadVideoSize()
        Returns the download video size if this stream downloads a video, or null if not.
        Specified by:
        getDownloadVideoSize in interface MediaStreamStats
        Returns:
        the download video size if this stream downloads a video, or null if not.
      • getEncoding

        public String getEncoding()
        Returns the MediaStream enconding.
        Specified by:
        getEncoding in interface MediaStreamStats
        Returns:
        the encoding used by the stream.
      • getEncodingClockRate

        public String getEncodingClockRate()
        Returns the MediaStream enconding rate (in Hz)..
        Specified by:
        getEncodingClockRate in interface MediaStreamStats
        Returns:
        the encoding rate used by the stream.
      • getJitterBufferDelayMs

        public int getJitterBufferDelayMs()
        Returns the delay in milliseconds introduced by the jitter buffer. Since there might be multiple ReceiveStreams, returns the biggest delay found in any of them.
        Specified by:
        getJitterBufferDelayMs in interface MediaStreamStats
        Returns:
        the delay in milliseconds introduces by the jitter buffer
      • getJitterBufferDelayPackets

        public int getJitterBufferDelayPackets()
        Returns the delay in number of packets introduced by the jitter buffer. Since there might be multiple ReceiveStreams, returns the biggest delay found in any of them.
        Specified by:
        getJitterBufferDelayPackets in interface MediaStreamStats
        Returns:
        the delay in number of packets introduced by the jitter buffer
      • getMinDownloadJitterMs

        public double getMinDownloadJitterMs()
        Gets the minimum RTP jitter value reported by us in an RTCP report, in milliseconds. Returns -1D if the value is unknown.
        Specified by:
        getMinDownloadJitterMs in interface MediaStreamStats
        Returns:
        the minimum RTP jitter value reported by us in an RTCP report, in milliseconds.
      • getMaxDownloadJitterMs

        public double getMaxDownloadJitterMs()
        Gets the maximum RTP jitter value reported by us in an RTCP report, in milliseconds. Returns -1D if the value is unknown.
        Specified by:
        getMaxDownloadJitterMs in interface MediaStreamStats
        Returns:
        the maximum RTP jitter value reported by us in an RTCP report, in milliseconds.
      • getMinUploadJitterMs

        public double getMinUploadJitterMs()
        Gets the minimum RTP jitter value reported to us in an RTCP report, in milliseconds. Returns -1D if the value is unknown.
        Specified by:
        getMinUploadJitterMs in interface MediaStreamStats
        Returns:
        the minimum RTP jitter value reported to us in an RTCP report, in milliseconds.
      • getMaxUploadJitterMs

        public double getMaxUploadJitterMs()
        Gets the maximum RTP jitter value reported to us in an RTCP report, in milliseconds. Returns -1D if the value is unknown.
        Specified by:
        getMaxUploadJitterMs in interface MediaStreamStats
        Returns:
        the maximum RTP jitter value reported to us in an RTCP report, in milliseconds.
      • getAvgDownloadJitterMs

        public double getAvgDownloadJitterMs()
        Gets the average of the RTP jitter values reported to us in RTCP reports, in milliseconds. Returns -1D if the value is unknown.
        Specified by:
        getAvgDownloadJitterMs in interface MediaStreamStats
        Returns:
        the average of the RTP jitter values reported to us in RTCP reports, in milliseconds. Returns -1D if the value is unknown.
      • getAvgUploadJitterMs

        public double getAvgUploadJitterMs()
        Gets the average of the RTP jitter values reported to us in RTCP reports, in milliseconds. Returns -1D if the value is unknown.
        Specified by:
        getAvgUploadJitterMs in interface MediaStreamStats
        Returns:
        the average of the RTP jitter values reported to us in RTCP reports, in milliseconds. Returns -1D if the value is unknown.
      • updateRemoteJitter

        public void updateRemoteJitter​(long remoteJitter)
        Notifies this instance that an RTCP report with the given value for RTP jitter was received.
        Parameters:
        remoteJitter - the jitter received, in RTP time units.
      • getLocalIPAddress

        public String getLocalIPAddress()
        Returns the local IP address of the MediaStream.
        Specified by:
        getLocalIPAddress in interface MediaStreamStats
        Returns:
        the local IP address of the stream.
      • getLocalPort

        public int getLocalPort()
        Returns the local port of the MediaStream.
        Specified by:
        getLocalPort in interface MediaStreamStats
        Returns:
        the local port of the stream.
      • getNbDiscarded

        public long getNbDiscarded()
        Returns the total number of Protocol Data Units (PDU) discarded by the FMJ packet queue since the beginning of the session. It's the sum over all ReceiveStreams of the MediaStream
        Specified by:
        getNbDiscarded in interface MediaStreamStats
        Returns:
        the number of discarded packets.
      • getNbDiscardedFull

        public int getNbDiscardedFull()
        Returns the number of Protocol Data Units (PDU) discarded by the FMJ packet queue since the beginning of the session because it was full. It's the sum over all ReceiveStreams of the MediaStream
        Specified by:
        getNbDiscardedFull in interface MediaStreamStats
        Returns:
        the number of discarded packets because it was full.
      • getNbDiscardedLate

        public int getNbDiscardedLate()
        Returns the number of Protocol Data Units (PDU) discarded by the FMJ packet queue since the beginning of the session because they were late. It's the sum over all ReceiveStreams of the MediaStream
        Specified by:
        getNbDiscardedLate in interface MediaStreamStats
        Returns:
        the number of discarded packets because they were late.
      • getNbDiscardedReset

        public int getNbDiscardedReset()
        Returns the number of Protocol Data Units (PDU) discarded by the FMJ packet queue since the beginning of the session during resets. It's the sum over all ReceiveStreams of the MediaStream
        Specified by:
        getNbDiscardedReset in interface MediaStreamStats
        Returns:
        the number of discarded packets during resets.
      • getNbDiscardedShrink

        public int getNbDiscardedShrink()
        Returns the number of Protocol Data Units (PDU) discarded by the FMJ packet queue since the beginning of the session due to shrinking. It's the sum over all ReceiveStreams of the MediaStream
        Specified by:
        getNbDiscardedShrink in interface MediaStreamStats
        Returns:
        the number of discarded packets due to shrinking.
      • getNbFec

        public long getNbFec()
        Returns the number of packets for which FEC data was decoded. Currently this is cumulative over all ReceiveStreams.
        Specified by:
        getNbFec in interface MediaStreamStats
        Returns:
        the number of packets for which FEC data was decoded. Currently this is cumulative over all ReceiveStreams.
        See Also:
        updateNbFec()
      • getNbPackets

        public long getNbPackets()
        Returns the total number of packets that are send or receive for this stream since the stream is created.
        Specified by:
        getNbPackets in interface MediaStreamStats
        Returns:
        the total number of packets.
      • getNbPacketsLost

        public long getNbPacketsLost()
        Returns the number of lost packets for that stream.
        Specified by:
        getNbPacketsLost in interface MediaStreamStats
        Returns:
        the number of lost packets.
      • getNbPacketsSent

        public long getNbPacketsSent()
        Returns the number of packets sent since the beginning of the session.
        Specified by:
        getNbPacketsSent in interface MediaStreamStats
        Returns:
        the number of packets sent since the beginning of the session.
      • getNbPacketsReceived

        public long getNbPacketsReceived()
        Returns the number of packets received since the beginning of the session.
        Specified by:
        getNbPacketsReceived in interface MediaStreamStats
        Returns:
        the number of packets received since the beginning of the session.
      • getNbReceivedBytes

        public long getNbReceivedBytes()
        Description copied from interface: MediaStreamStats
        Returns the number of received bytes since the beginning of the session.
        Specified by:
        getNbReceivedBytes in interface MediaStreamStats
        Returns:
        the number of received bytes for this stream.
      • getNbSentBytes

        public long getNbSentBytes()
        Description copied from interface: MediaStreamStats
        Returns the number of sent bytes since the beginning of the session.
        Specified by:
        getNbSentBytes in interface MediaStreamStats
        Returns:
        the number of sent bytes for this stream.
      • getPacketQueueCountPackets

        public int getPacketQueueCountPackets()
        Returns the number of packets in the first JitterBufferControl found via getJitterBufferControls.
        Specified by:
        getPacketQueueCountPackets in interface MediaStreamStats
        Returns:
        the number of packets in the first JitterBufferControl found via getJitterBufferControls.
      • getPacketQueueSize

        public int getPacketQueueSize()
        Returns the size of the first JitterBufferControl found via getJitterBufferControls.
        Specified by:
        getPacketQueueSize in interface MediaStreamStats
        Returns:
        the size of the first JitterBufferControl found via getJitterBufferControls.
      • getPercentDiscarded

        public double getPercentDiscarded()
        Returns the percent of discarded packets
        Specified by:
        getPercentDiscarded in interface MediaStreamStats
        Returns:
        the percent of discarded packets
      • getRemoteIPAddress

        public String getRemoteIPAddress()
        Returns the remote IP address of the MediaStream.
        Specified by:
        getRemoteIPAddress in interface MediaStreamStats
        Returns:
        the remote IP address of the stream.
      • getRemotePort

        public int getRemotePort()
        Returns the remote port of the MediaStream.
        Specified by:
        getRemotePort in interface MediaStreamStats
        Returns:
        the remote port of the stream.
      • getRTCPReports

        public RTCPReports getRTCPReports()
        Gets the detailed statistics about the RTCP reports sent and received by the associated local peer.
        Specified by:
        getRTCPReports in interface MediaStreamStats
        Returns:
        the detailed statistics about the RTCP reports sent and received by the associated local peer
      • getRttMs

        public long getRttMs()
        Returns the RTT computed with the RTCP feedback (cf. RFC3550, section 6.4.1, subsection "delay since last SR (DLSR): 32 bits").
        Specified by:
        getRttMs in interface MediaStreamStats
        Returns:
        The RTT computed with the RTCP feedback. Returns -1 if the RTT has not been computed yet. Otherwise the RTT in ms.
      • getUploadJitterMs

        public double getUploadJitterMs()
        Returns the jitter average of this upload stream.
        Specified by:
        getUploadJitterMs in interface MediaStreamStats
        Returns:
        the last jitter average computed (in ms).
      • getUploadPercentLoss

        public double getUploadPercentLoss()
        Returns the percent loss of the upload stream.
        Specified by:
        getUploadPercentLoss in interface MediaStreamStats
        Returns:
        the last loss rate computed (in %).
      • getUploadRateKiloBitPerSec

        public double getUploadRateKiloBitPerSec()
        Returns the bandwidth used by this download stream.
        Specified by:
        getUploadRateKiloBitPerSec in interface MediaStreamStats
        Returns:
        the last used upload bandwidth computed (in Kbit/s).
      • getUploadVideoSize

        public Dimension getUploadVideoSize()
        Returns the upload video size if this stream uploads a video, or null if not.
        Specified by:
        getUploadVideoSize in interface MediaStreamStats
        Returns:
        the upload video size if this stream uploads a video, or null if not.
      • isAdaptiveBufferEnabled

        public boolean isAdaptiveBufferEnabled()
        Description copied from interface: MediaStreamStats
        Checks whether there is an adaptive jitter buffer enabled for at least one of the ReceiveStreams of the MediaStreamImpl.
        Specified by:
        isAdaptiveBufferEnabled in interface MediaStreamStats
        Returns:
        true if there is an adaptive jitter buffer enabled for at least one of the ReceiveStreams of the MediaStreamImpl; otherwise, false
      • updateStats

        public void updateStats()
        Computes and updates information for a specific stream.
        Specified by:
        updateStats in interface MediaStreamStats
      • rembReceived

        public void rembReceived​(RTCPREMBPacket remb)
        Notifies this instance that an RTCP REMB packet was received.
        Parameters:
        remb - the packet.
      • nackReceived

        public void nackReceived​(NACKPacket nack)
        Notifies this instance that an RTCP NACK packet was received.
        Parameters:
        nack - the packet.
      • srReceived

        public void srReceived​(net.sf.fmj.media.rtp.RTCPSRPacket sr)
        Notifies this instance that an RTCP SR packet was received.
        Parameters:
        sr - the packet.
      • removeRTCPPacketListener

        public void removeRTCPPacketListener​(RTCPPacketListener listener)
        Removes a listener from the list of listeners which will be notified when RTCP packets are received.
        Specified by:
        removeRTCPPacketListener in interface MediaStreamStats
        Parameters:
        listener - the listener.
      • getSendingBitrate

        public long getSendingBitrate()
        Gets the rate at which we are currently sending data to the remote endpoint in bits per second. This is almost the same as MediaStreamStats.getUploadRateKiloBitPerSec(). The duplication is necessary, because of implementation details. This method is different from getUploadRateKiloBitPerSec() in that: 1. It is not necessary for updateStats() to be called periodically by the user of libjitsi in order for it to return correct values. 2. The returned value is based on the average bitrate over a fixed window, as opposed to an EWMA. 3. The measurement is performed after the MediaStream's transformations, notably after simulcast layers are dropped (i.e. closer to the network interface). The return value includes RTP payload and RTP headers, as well as RTCP.
        Specified by:
        getSendingBitrate in interface MediaStreamStats
        Returns:
        the rate at which we are currently sending data to the remote endpoint, in bits per second.
      • tccPacketReceived

        public void tccPacketReceived​(RTCPTCCPacket tccPacket)
        Notifies listeners that a transport-wide-cc packet was received. Listeners may include Remote Bitrate Estimators or Bandwidth Estimators