コード例 #1
0
    def test_extension(self):
        self.thisRTP.extension = None
        self.assertEqual(self.thisRTP.extension, None)

        newExt = Extension()
        self.thisRTP.extension = newExt
        self.assertEqual(self.thisRTP.extension, newExt)
コード例 #2
0
    def test_toBytearray_extension(self, startBits, headerExtension):
        self.thisRTP.sequenceNumber = 0
        self.thisRTP.ssrc = 0
        newExt = Extension()
        newExt.startBits = bytearray(startBits)
        newExt.headerExtension = bytearray(headerExtension)

        expected = bytearray(
            b'\x80\x60\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
        expected[0] |= 1 << 4
        expected[12:12] = newExt.toBytearray()
        self.thisRTP.extension = newExt
        self.assertEqual(self.thisRTP.toBytearray(), expected)
コード例 #3
0
    def test_fromBytearray(self, startBits, headerExtension):
        bArray = bytearray(len(headerExtension) + 4)
        bArray[0:2] = startBits
        bArray[2:4] = int(len(headerExtension)/4).to_bytes(2, byteorder='big')
        bArray[4:] = headerExtension

        self.thisExt.fromBytearray(bArray)

        self.assertEqual(self.thisExt.startBits, startBits)
        self.assertEqual(self.thisExt.headerExtension, headerExtension)

        duplicateExt = Extension().fromBytearray(bArray)

        self.assertEqual(duplicateExt, self.thisExt)
コード例 #4
0
    def test_fromBytearray_extension(self, startBits, headerExtension):
        self.thisRTP.sequenceNumber = 0
        self.thisRTP.ssrc = 0
        newExt = Extension()
        newExt.startBits = bytearray(startBits)
        newExt.headerExtension = bytearray(headerExtension)

        payload = bytearray(
            b'\x80\x60\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
        payload[0] |= 1 << 4
        payload[12:12] = newExt.toBytearray()
        newRTP = RTP().fromBytearray(payload)

        self.thisRTP.extension = newExt
        self.assertEqual(newRTP, self.thisRTP)
コード例 #5
0
    def test_init(self, padding, marker, payloadType, sequenceNumber,
                  timestamp, ssrc, csrcList, payload):
        newExt = Extension()
        newRTP = RTP(version=2,
                     padding=padding,
                     marker=marker,
                     payloadType=payloadType,
                     sequenceNumber=sequenceNumber,
                     timestamp=timestamp,
                     ssrc=ssrc,
                     extension=newExt,
                     csrcList=csrcList,
                     payload=bytearray(payload))

        self.assertEqual(newRTP.version, 2)
        self.assertEqual(newRTP.padding, padding)
        self.assertEqual(newRTP.marker, marker)
        self.assertEqual(newRTP.payloadType, payloadType)
        self.assertEqual(newRTP.sequenceNumber, sequenceNumber)
        self.assertEqual(newRTP.timestamp, timestamp)
        self.assertEqual(newRTP.ssrc, ssrc)
        self.assertEqual(newRTP.extension, newExt)
        self.assertEqual(newRTP.csrcList, csrcList)
        self.assertEqual(newRTP.payload, payload)
コード例 #6
0
    def test_bytearray_default(self):
        expected = bytearray(4)
        self.assertEqual(bytes(self.thisExt), expected)

        newExt = Extension().fromBytearray(expected)
        self.assertEqual(newExt, self.thisExt)
コード例 #7
0
    def test_init(self, startBits, headerExtension):
        newExt = Extension(bytearray(startBits), bytearray(headerExtension))

        self.assertEqual(newExt.startBits, startBits)
        self.assertEqual(newExt.headerExtension, headerExtension)
コード例 #8
0
 def setUp(self):
     self.thisExt = Extension()