Package org.jitsi.impl.neomedia
Class MediaStreamStatsImpl
- java.lang.Object
-
- org.jitsi.impl.neomedia.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 toMediaStreamStats2Implinstead, where we can manage the complexity and consistency better.- Author:
- Vincent Lucas, Boris Grozev, Lyubomir Marinov, Hristo Terezov
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMediaStreamStatsImpl.StreamDirectionEnumeration of the direction (DOWNLOAD or UPLOAD) used for the stats.
-
Constructor Summary
Constructors Constructor Description MediaStreamStatsImpl(MediaStreamImpl mediaStreamImpl)Creates a new instance of stats concerning a MediaStream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRTCPPacketListener(RTCPPacketListener listener)Adds a listener which will be notified when RTCP packets are received.doublegetAvgDownloadJitterMs()Gets the average of the RTP jitter values reported to us in RTCP reports, in milliseconds.doublegetAvgUploadJitterMs()Gets the average of the RTP jitter values reported to us in RTCP reports, in milliseconds.doublegetDownloadJitterMs()Returns the jitter average of this download stream.longgetDownloadNbPacketLost()Returns the number of lost packets for the receive streams.doublegetDownloadPercentLoss()Returns the percent loss of the download stream.doublegetDownloadRateKiloBitPerSec()Returns the bandwidth used by this download stream.DimensiongetDownloadVideoSize()Returns the download video size if this stream downloads a video, or null if not.StringgetEncoding()Returns the MediaStream enconding.StringgetEncodingClockRate()Returns the MediaStream enconding rate (in Hz)..static javax.media.control.JitterBufferControlgetJitterBufferControl(javax.media.rtp.ReceiveStream receiveStream)Gets the JitterBufferControl of a ReceiveStream.intgetJitterBufferDelayMs()Returns the delay in milliseconds introduced by the jitter buffer.intgetJitterBufferDelayPackets()Returns the delay in number of packets introduced by the jitter buffer.StringgetLocalIPAddress()Returns the local IP address of the MediaStream.intgetLocalPort()Returns the local port of the MediaStream.doublegetMaxDownloadJitterMs()Gets the maximum RTP jitter value reported by us in an RTCP report, in milliseconds.doublegetMaxUploadJitterMs()Gets the maximum RTP jitter value reported to us in an RTCP report, in milliseconds.doublegetMinDownloadJitterMs()Gets the minimum RTP jitter value reported by us in an RTCP report, in milliseconds.doublegetMinUploadJitterMs()Gets the minimum RTP jitter value reported to us in an RTCP report, in milliseconds.longgetNbDiscarded()Returns the total number of Protocol Data Units (PDU) discarded by the FMJ packet queue since the beginning of the session.intgetNbDiscardedFull()Returns the number of Protocol Data Units (PDU) discarded by the FMJ packet queue since the beginning of the session because it was full.intgetNbDiscardedLate()Returns the number of Protocol Data Units (PDU) discarded by the FMJ packet queue since the beginning of the session because they were late.intgetNbDiscardedReset()Returns the number of Protocol Data Units (PDU) discarded by the FMJ packet queue since the beginning of the session during resets.intgetNbDiscardedShrink()Returns the number of Protocol Data Units (PDU) discarded by the FMJ packet queue since the beginning of the session due to shrinking.longgetNbFec()Returns the number of packets for which FEC data was decoded.longgetNbPackets()Returns the total number of packets that are send or receive for this stream since the stream is created.longgetNbPacketsLost()Returns the number of lost packets for that stream.longgetNbPacketsReceived()Returns the number of packets received since the beginning of the session.longgetNbPacketsSent()Returns the number of packets sent since the beginning of the session.longgetNbReceivedBytes()Returns the number of received bytes since the beginning of the session.longgetNbSentBytes()Returns the number of sent bytes since the beginning of the session.intgetPacketQueueCountPackets()Returns the number of packets in the first JitterBufferControl found via getJitterBufferControls.intgetPacketQueueSize()Returns the size of the first JitterBufferControl found via getJitterBufferControls.doublegetPercentDiscarded()Returns the percent of discarded packetsStringgetRemoteIPAddress()Returns the remote IP address of the MediaStream.intgetRemotePort()Returns the remote port of the MediaStream.RTCPReportsgetRTCPReports()Gets the detailed statistics about the RTCP reports sent and received by the associated local peer.longgetRttMs()Returns the RTT computed with the RTCP feedback (cf.longgetSendingBitrate()Gets the rate at which we are currently sending data to the remote endpoint in bits per second.doublegetUploadJitterMs()Returns the jitter average of this upload stream.longgetUploadNbPacketLost()Returns the total number of sent packets lost.doublegetUploadPercentLoss()Returns the percent loss of the upload stream.doublegetUploadRateKiloBitPerSec()Returns the bandwidth used by this download stream.DimensiongetUploadVideoSize()Returns the upload video size if this stream uploads a video, or null if not.booleanisAdaptiveBufferEnabled()Checks whether there is an adaptive jitter buffer enabled for at least one of the ReceiveStreams of the MediaStreamImpl.voidnackReceived(NACKPacket nack)Notifies this instance that an RTCP NACK packet was received.voidrembReceived(RTCPREMBPacket remb)Notifies this instance that an RTCP REMB packet was received.voidremoveRTCPPacketListener(RTCPPacketListener listener)Removes a listener from the list of listeners which will be notified when RTCP packets are received.voidsrReceived(net.sf.fmj.media.rtp.RTCPSRPacket sr)Notifies this instance that an RTCP SR packet was received.voidtccPacketReceived(RTCPTCCPacket tccPacket)Notifies listeners that a transport-wide-cc packet was received.voidupdateRemoteJitter(long remoteJitter)Notifies this instance that an RTCP report with the given value for RTP jitter was received.voidupdateStats()Computes and updates information for a specific stream.
-
-
-
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:
getDownloadJitterMsin interfaceMediaStreamStats- Returns:
- the last jitter average computed (in ms).
-
getDownloadNbPacketLost
public long getDownloadNbPacketLost()
Returns the number of lost packets for the receive streams.- Specified by:
getDownloadNbPacketLostin interfaceMediaStreamStats- Returns:
- the number of lost packets for the receive streams.
-
getUploadNbPacketLost
public long getUploadNbPacketLost()
Returns the total number of sent packets lost.- Specified by:
getUploadNbPacketLostin interfaceMediaStreamStats- Returns:
- the total number of sent packets lost.
-
getDownloadPercentLoss
public double getDownloadPercentLoss()
Returns the percent loss of the download stream.- Specified by:
getDownloadPercentLossin interfaceMediaStreamStats- Returns:
- the last loss rate computed (in %).
-
getDownloadRateKiloBitPerSec
public double getDownloadRateKiloBitPerSec()
Returns the bandwidth used by this download stream.- Specified by:
getDownloadRateKiloBitPerSecin interfaceMediaStreamStats- 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:
getDownloadVideoSizein interfaceMediaStreamStats- 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:
getEncodingin interfaceMediaStreamStats- Returns:
- the encoding used by the stream.
-
getEncodingClockRate
public String getEncodingClockRate()
Returns the MediaStream enconding rate (in Hz)..- Specified by:
getEncodingClockRatein interfaceMediaStreamStats- 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:
getJitterBufferDelayMsin interfaceMediaStreamStats- 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:
getJitterBufferDelayPacketsin interfaceMediaStreamStats- 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:
getMinDownloadJitterMsin interfaceMediaStreamStats- 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:
getMaxDownloadJitterMsin interfaceMediaStreamStats- 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:
getMinUploadJitterMsin interfaceMediaStreamStats- 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:
getMaxUploadJitterMsin interfaceMediaStreamStats- 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:
getAvgDownloadJitterMsin interfaceMediaStreamStats- 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:
getAvgUploadJitterMsin interfaceMediaStreamStats- 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:
getLocalIPAddressin interfaceMediaStreamStats- Returns:
- the local IP address of the stream.
-
getLocalPort
public int getLocalPort()
Returns the local port of the MediaStream.- Specified by:
getLocalPortin interfaceMediaStreamStats- 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:
getNbDiscardedin interfaceMediaStreamStats- 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:
getNbDiscardedFullin interfaceMediaStreamStats- 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:
getNbDiscardedLatein interfaceMediaStreamStats- 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:
getNbDiscardedResetin interfaceMediaStreamStats- 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:
getNbDiscardedShrinkin interfaceMediaStreamStats- 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:
getNbFecin interfaceMediaStreamStats- 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:
getNbPacketsin interfaceMediaStreamStats- Returns:
- the total number of packets.
-
getNbPacketsLost
public long getNbPacketsLost()
Returns the number of lost packets for that stream.- Specified by:
getNbPacketsLostin interfaceMediaStreamStats- Returns:
- the number of lost packets.
-
getNbPacketsSent
public long getNbPacketsSent()
Returns the number of packets sent since the beginning of the session.- Specified by:
getNbPacketsSentin interfaceMediaStreamStats- 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:
getNbPacketsReceivedin interfaceMediaStreamStats- Returns:
- the number of packets received since the beginning of the session.
-
getNbReceivedBytes
public long getNbReceivedBytes()
Description copied from interface:MediaStreamStatsReturns the number of received bytes since the beginning of the session.- Specified by:
getNbReceivedBytesin interfaceMediaStreamStats- Returns:
- the number of received bytes for this stream.
-
getNbSentBytes
public long getNbSentBytes()
Description copied from interface:MediaStreamStatsReturns the number of sent bytes since the beginning of the session.- Specified by:
getNbSentBytesin interfaceMediaStreamStats- 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:
getPacketQueueCountPacketsin interfaceMediaStreamStats- 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:
getPacketQueueSizein interfaceMediaStreamStats- Returns:
- the size of the first JitterBufferControl found via getJitterBufferControls.
-
getPercentDiscarded
public double getPercentDiscarded()
Returns the percent of discarded packets- Specified by:
getPercentDiscardedin interfaceMediaStreamStats- Returns:
- the percent of discarded packets
-
getRemoteIPAddress
public String getRemoteIPAddress()
Returns the remote IP address of the MediaStream.- Specified by:
getRemoteIPAddressin interfaceMediaStreamStats- Returns:
- the remote IP address of the stream.
-
getRemotePort
public int getRemotePort()
Returns the remote port of the MediaStream.- Specified by:
getRemotePortin interfaceMediaStreamStats- 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:
getRTCPReportsin interfaceMediaStreamStats- 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:
getRttMsin interfaceMediaStreamStats- 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:
getUploadJitterMsin interfaceMediaStreamStats- Returns:
- the last jitter average computed (in ms).
-
getUploadPercentLoss
public double getUploadPercentLoss()
Returns the percent loss of the upload stream.- Specified by:
getUploadPercentLossin interfaceMediaStreamStats- Returns:
- the last loss rate computed (in %).
-
getUploadRateKiloBitPerSec
public double getUploadRateKiloBitPerSec()
Returns the bandwidth used by this download stream.- Specified by:
getUploadRateKiloBitPerSecin interfaceMediaStreamStats- 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:
getUploadVideoSizein interfaceMediaStreamStats- Returns:
- the upload video size if this stream uploads a video, or null if not.
-
isAdaptiveBufferEnabled
public boolean isAdaptiveBufferEnabled()
Description copied from interface:MediaStreamStatsChecks whether there is an adaptive jitter buffer enabled for at least one of the ReceiveStreams of the MediaStreamImpl.- Specified by:
isAdaptiveBufferEnabledin interfaceMediaStreamStats- 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:
updateStatsin interfaceMediaStreamStats
-
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.
-
addRTCPPacketListener
public void addRTCPPacketListener(RTCPPacketListener listener)
Adds a listener which will be notified when RTCP packets are received.- Specified by:
addRTCPPacketListenerin interfaceMediaStreamStats- Parameters:
listener- the listener.
-
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:
removeRTCPPacketListenerin interfaceMediaStreamStats- 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 asMediaStreamStats.getUploadRateKiloBitPerSec(). The duplication is necessary, because of implementation details. This method is different fromgetUploadRateKiloBitPerSec()in that: 1. It is not necessary forupdateStats()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 theMediaStream'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:
getSendingBitratein interfaceMediaStreamStats- 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
-
-