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)
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)
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)
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)
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)
def test_bytearray_default(self): expected = bytearray(4) self.assertEqual(bytes(self.thisExt), expected) newExt = Extension().fromBytearray(expected) self.assertEqual(newExt, self.thisExt)
def test_init(self, startBits, headerExtension): newExt = Extension(bytearray(startBits), bytearray(headerExtension)) self.assertEqual(newExt.startBits, startBits) self.assertEqual(newExt.headerExtension, headerExtension)
def setUp(self): self.thisExt = Extension()