def test_no_loss_cycle(self): counter = StreamStatistics(ssrc=0, clockrate=8000) # receive 10 packets (with sequence cycle) for packet in self.create_packets(10, 65530): counter.add(packet) self.assertEqual(counter.max_seq, 3) self.assertEqual(counter.packets_received, 10) self.assertEqual(counter.packets_lost, 0) self.assertEqual(counter.fraction_lost, 0)
def test_no_loss(self): counter = StreamStatistics(ssrc=0, clockrate=8000) packets = self.create_packets(20, 0) # receive 10 packets for packet in packets[0:10]: counter.add(packet) self.assertEqual(counter.max_seq, 9) self.assertEqual(counter.packets_received, 10) self.assertEqual(counter.packets_lost, 0) self.assertEqual(counter.fraction_lost, 0) # receive 10 more packets for packet in packets[10:20]: counter.add(packet) self.assertEqual(counter.max_seq, 19) self.assertEqual(counter.packets_received, 20) self.assertEqual(counter.packets_lost, 0) self.assertEqual(counter.fraction_lost, 0)
def test_with_loss(self): counter = StreamStatistics(ssrc=0, clockrate=8000) packets = self.create_packets(20, 0) packets.pop(1) # receive 9 packets (one missing) for packet in packets[0:9]: counter.add(packet) self.assertEqual(counter.max_seq, 9) self.assertEqual(counter.packets_received, 9) self.assertEqual(counter.packets_lost, 1) self.assertEqual(counter.fraction_lost, 25) # receive 10 more packets for packet in packets[9:19]: counter.add(packet) self.assertEqual(counter.max_seq, 19) self.assertEqual(counter.packets_received, 19) self.assertEqual(counter.packets_lost, 1) self.assertEqual(counter.fraction_lost, 0)
def test_no_jitter(self, mock_time): counter = StreamStatistics(ssrc=0, clockrate=8000) packets = self.create_packets(3, 0) mock_time.return_value = 1531562330.00 counter.add(packets[0]) self.assertEqual(counter._jitter_q4, 0) self.assertEqual(counter.jitter, 0) mock_time.return_value = 1531562330.02 counter.add(packets[1]) self.assertEqual(counter._jitter_q4, 0) self.assertEqual(counter.jitter, 0) mock_time.return_value = 1531562330.04 counter.add(packets[2]) self.assertEqual(counter._jitter_q4, 0) self.assertEqual(counter.jitter, 0)