RtpStatistics { public void onRtpReceive(RtpPacket packet) { this.rtpRxPackets++; this.rtpRxOctets += packet.getPayloadLength(); this.rtpReceivedOn = this.wallClock.getTime(); if(RtcpPacketType.RTCP_REPORT.equals(this.rtcpNextPacketType)) { long syncSource = packet.getSyncSource(); RtpMember member = getMember(syncSource); if (member == null) { member = addMember(syncSource); } if (!isSender(syncSource)) { addSender(syncSource); } member.onReceiveRtp(packet); } } RtpStatistics(final RtpClock clock, final long ssrc, final String cname);  RtpStatistics(final RtpClock clock, final long ssrc);  RtpStatistics(final RtpClock clock); void setSsrc(long ssrc); void setCname(String cname); long getLastHeartbeat(); void setLastHeartbeat(long rtpKeepAlive); long getTime(); long getCurrentTime(); long getRtpTime(long time); long getSsrc(); String getCname(); long getRtpPacketsReceived(); long getRtpOctetsReceived(); long getRtpPacketsSent(); long getRtpOctetsSent(); long getRtpReceivedOn(); long getRtpSentOn(); long getRtpTimestamp(); boolean hasSent(); double getRtcpBw(); RtcpPacketType getRtcpPacketType(); void setRtcpPacketType(RtcpPacketType packetType); int getSenders(); boolean isSender(long ssrc); void clearSenders(); int getPmembers(); int getMembers(); RtpMember getMember(long ssrc); List<Long> getMembersList(); boolean isMember(long ssrc); void confirmMembers(); void resetMembers(); double getRtcpAvgSize(); void setRtcpAvgSize(double avgSize); long getRtcpPacketsSent(); long getRtcpOctetsSent(); long rtcpInterval(boolean initial); long rtcpReceiverInterval(boolean initial); boolean isSenderTimeout(); void reset(); void onRtpSent(RtpPacket packet); void onRtpReceive(RtpPacket packet); void onRtcpSent(RtcpPacket packet); void onRtcpReceive(RtcpPacket rtcpPacket); static final int RTP_DEFAULT_BW; static final double RTCP_BW_FRACTION; static final double RTCP_DEFAULT_BW; static final double RTCP_SENDER_BW_FRACTION; static final double RTCP_RECEIVER_BW_FRACTION; static final double RTCP_DEFAULT_AVG_SIZE; }
@Test public void testOnRtpReceive() { RtpStatistics stats = new RtpStatistics(rtpClock, SSRC, CNAME); RtpPacket p1 = new RtpPacket(172, false); RtpPacket p2 = new RtpPacket(172, false); p1.wrap(false, 8, 1, 160 * 1, 123, new byte[160], 0, 160); p2.wrap(false, 8, 1, 160 * 2, 456, new byte[160], 0, 160); stats.onRtpReceive(p1); wallClock.tick(20000000L); stats.onRtpReceive(p2); assertEquals(2, stats.getRtpPacketsReceived()); assertEquals(p1.getPayloadLength() + p2.getPayloadLength(), stats.getRtpOctetsReceived()); assertEquals(wallClock.getTime(), stats.getRtpReceivedOn()); assertFalse(stats.hasSent()); assertEquals(2, stats.getSenders()); assertTrue(stats.isSender(p1.getSyncSource())); assertTrue(stats.isMember(p1.getSyncSource())); assertNotNull(stats.getMember(p1.getSyncSource())); assertTrue(stats.isSender(p2.getSyncSource())); assertTrue(stats.isMember(p2.getSyncSource())); assertNotNull(stats.getMember(p2.getSyncSource())); assertEquals(3, stats.getMembers()); assertEquals(1, stats.getPmembers()); }