示例#1
0
    def test_no_loss(self):
        generator = NackGenerator()

        for packet in create_rtp_packets(20, 0):
            missed = generator.add(packet)
            self.assertEqual(missed, False)

        self.assertEqual(generator.missing, set())
示例#2
0
    def test_with_loss(self):
        generator = NackGenerator()

        # receive packets: 0, <1 missing>, 2
        packets = create_rtp_packets(3, 0)
        missing = packets.pop(1)
        for packet in packets:
            missed = generator.add(packet)
            self.assertEqual(missed, packet.sequence_number == 2)

        self.assertEqual(generator.missing, set([1]))

        # late arrival
        missed = generator.add(missing)
        self.assertEqual(missed, False)
        self.assertEqual(generator.missing, set())
示例#3
0
    def test_with_loss_truncate(self):
        generator = NackGenerator()
        packets = create_rtp_packets(259, 0)

        generator.add(packets[0])
        generator.add(packets[129])
        self.assertEqual(generator.missing, set(range(1, 129)))

        generator.add(packets[258])
        self.assertEqual(generator.missing, set(range(130, 258)))
示例#4
0
    def create_generator(self):
        class FakeReceiver:
            def __init__(self):
                self.nack = []
                self.pli = []

            async def _send_rtcp_nack(self, media_ssrc, lost):
                self.nack.append((media_ssrc, lost))

            async def _send_rtcp_pli(self, media_ssrc, lost):
                self.pli.append(media_ssrc)

        receiver = FakeReceiver()
        return NackGenerator(receiver), receiver