More thorough checks for RTP packets, make sure that no false-positives come from DTLS for example (fix inaccurate loss calculations and "RTP loss >5%" messages being logged).
This commit is contained in:
parent
be112c1aae
commit
c95952f0b2
@ -640,7 +640,7 @@ public class DelegatingDatagramSocket
|
||||
|
||||
// no exception packet is successfully received, log it.
|
||||
// If this is not a STUN/TURN packet, then this is a RTP packet.
|
||||
if(!StunDatagramPacketFilter.isStunPacket(p))
|
||||
if(isRtpPacket(p))
|
||||
{
|
||||
++nbReceivedRtpPackets;
|
||||
}
|
||||
@ -980,7 +980,7 @@ public class DelegatingDatagramSocket
|
||||
public void updateRtpLosses(DatagramPacket p)
|
||||
{
|
||||
// If this is not a STUN/TURN packet, then this is a RTP packet.
|
||||
if(!StunDatagramPacketFilter.isStunPacket(p))
|
||||
if(isRtpPacket(p))
|
||||
{
|
||||
long newSeq = getRtpSequenceNumber(p);
|
||||
if(this.lastRtpSequenceNumber != -1)
|
||||
@ -1004,7 +1004,7 @@ public class DelegatingDatagramSocket
|
||||
* @param totalNbLost The total number of lost packet since the beginning of
|
||||
* this stream.
|
||||
* @param totalNbReceived The total number of received packet since the
|
||||
* begnining of this tream.
|
||||
* beginning of this stream.
|
||||
* @param lastLogTime The last time we have logged information about RTP
|
||||
* losses.
|
||||
*
|
||||
@ -1082,7 +1082,7 @@ public class DelegatingDatagramSocket
|
||||
* DelegatingDatagramSocket#setDefaultReceiveBufferSize() won't
|
||||
* automatically be applied to sockets obtain from the factory.
|
||||
*
|
||||
* @param factory The factory asigned to generates the new DatagramSocket
|
||||
* @param factory The factory assigned to generates the new DatagramSocket
|
||||
* for each new DelegatingDatagramSocket which do not use a delegate socket.
|
||||
*/
|
||||
public static void setDefaultDelegateFactory(DatagramSocketFactory factory)
|
||||
@ -1126,4 +1126,28 @@ public class DelegatingDatagramSocket
|
||||
super.setReceiveBufferSize(defaultReceiveBufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether <tt>p</tt> is an RTP packet (and something else, like,
|
||||
* a STUN, RTCP or DTLS packet).
|
||||
* @param p the packet.
|
||||
* @return <tt>true</tt> if <tt>p</tt> appears to be an RTP packet.
|
||||
*/
|
||||
private boolean isRtpPacket(DatagramPacket p)
|
||||
{
|
||||
byte[] data = p.getData();
|
||||
int off = p.getOffset();
|
||||
int len = p.getLength();
|
||||
|
||||
if (len >= 4)
|
||||
{
|
||||
if (((data[off + 0] & 0xc0) >> 6) == 2)
|
||||
{
|
||||
//Either RTP or RTCP
|
||||
return !RtcpDemuxPacketFilter.isRtcpPacket(p);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public class RtcpDemuxPacketFilter
|
||||
* @return <tt>true</tt> if <tt>p</tt> is an RTCP and this filter accepts it
|
||||
* and <tt>false</tt> otherwise.
|
||||
*/
|
||||
public boolean accept(DatagramPacket p)
|
||||
public static boolean isRtcpPacket(DatagramPacket p)
|
||||
{
|
||||
int len = p.getLength();
|
||||
if (len >= 4) //minimum RTCP message length
|
||||
@ -63,4 +63,16 @@ public class RtcpDemuxPacketFilter
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this <tt>RtcpDemuxPacketFilter</tt> should
|
||||
* accept <tt>p</tt>, that is, if <tt>p</tt> looks like an RTCP packet.
|
||||
* See {@link #isRtcpPacket(java.net.DatagramPacket)}
|
||||
* @return <tt>true</tt> if <tt>p</tt> looks like an RTCP packet.
|
||||
*/
|
||||
public boolean accept(DatagramPacket p)
|
||||
{
|
||||
return isRtcpPacket(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user