async def test_recv_transport(self): device = Device(handlerFactory=AiortcHandler.createFactory( tracks=TRACKS)) await device.load(generateRouterRtpCapabilities()) id, iceParameters, iceCandidates, dtlsParameters, sctpParameters = generateTransportRemoteParameters( ) recvTransport = device.createRecvTransport( id=id, iceParameters=iceParameters, iceCandidates=iceCandidates, dtlsParameters=dtlsParameters, sctpParameters=sctpParameters) self.assertTrue(isinstance(recvTransport, Transport)) self.assertEqual(recvTransport.id, id) self.assertFalse(recvTransport.closed) self.assertEqual(recvTransport.direction, 'recv') self.assertTrue(isinstance(recvTransport.handler, AiortcHandler)) self.assertEqual(recvTransport.connectionState, 'new') self.assertDictEqual(recvTransport.appData, {}) # transport.produce() in a receiving Transport rejects with UnsupportedError with self.assertRaises(UnsupportedError): await recvTransport.produce(track=audioTrack, stopTracks=False, appData={'foo': 'FOO'})
async def load(self): # Init device self._device = Device(handlerFactory=AiortcHandler.createFactory( tracks=self._tracks)) # Get Router RtpCapabilities reqId = self.generateRandomNumber() req = { 'request': True, 'id': reqId, 'method': 'getRouterRtpCapabilities', 'data': {} } await self._websocket.send(json.dumps(req)) await asyncio.wait_for(self.wait_answer_ready(reqId), timeout=10) ans = self._answers.get(reqId) # Load Router RtpCapabilities await self._device.load(ans['data'])
async def test_send_transport(self): device = Device(handlerFactory=AiortcHandler.createFactory( tracks=TRACKS)) await device.load(generateRouterRtpCapabilities()) id, iceParameters, iceCandidates, dtlsParameters, sctpParameters = generateTransportRemoteParameters( ) sendTransport = device.createSendTransport( id=id, iceParameters=iceParameters, iceCandidates=iceCandidates, dtlsParameters=dtlsParameters, sctpParameters=sctpParameters, appData={'baz': 'BAZ'}) self.assertTrue(isinstance(sendTransport, Transport)) self.assertEqual(sendTransport.id, id) self.assertFalse(sendTransport.closed) self.assertEqual(sendTransport.direction, 'send') self.assertTrue(isinstance(sendTransport.handler, AiortcHandler)) self.assertEqual(sendTransport.connectionState, 'new') self.assertDictEqual(sendTransport.appData, {'baz': 'BAZ'})
async def test_device_can_produce_video(self): device = Device(handlerFactory=AiortcHandler.createFactory( tracks=TRACKS)) await device.load(generateRouterRtpCapabilities()) self.assertTrue(device.canProduce('video'))
async def test_device_sctp_capabilities(self): device = Device(handlerFactory=AiortcHandler.createFactory( tracks=TRACKS)) await device.load(generateRouterRtpCapabilities()) self.assertTrue(isinstance(device.sctpCapabilities, SctpCapabilities))
async def test_device_load(self): device = Device(handlerFactory=AiortcHandler.createFactory( tracks=TRACKS)) await device.load(generateRouterRtpCapabilities()) self.assertEqual(device.handlerName, 'aiortc') self.assertTrue(device.loaded)
def test_create_device(self): device = Device(handlerFactory=AiortcHandler.createFactory( tracks=TRACKS)) self.assertEqual(device.loaded, False)