def test_stun_multiple_servers(self): self.assertEqual(connection_kwargs([ RTCIceServer('stun:stun.l.google.com:19302'), RTCIceServer('stun:stun.example.com'), ]), { 'stun_server': ('stun.l.google.com', 19302), })
def test_stun_multiple_servers(self): self.assertEqual( connection_kwargs([ RTCIceServer("stun:stun.l.google.com:19302"), RTCIceServer("stun:stun.example.com"), ]), {"stun_server": ("stun.l.google.com", 19302)}, )
def test_turn_multiple_servers(self): self.assertEqual(connection_kwargs([ RTCIceServer('turn:turn.example.com'), RTCIceServer('turn:turn.example.net'), ]), { 'turn_password': None, 'turn_server': ('turn.example.com', 3478), 'turn_username': None, })
def test_turn_multiple_servers(self): self.assertEqual( connection_kwargs([ RTCIceServer("turn:turn.example.com"), RTCIceServer("turn:turn.example.net"), ]), { "turn_password": None, "turn_server": ("turn.example.com", 3478), "turn_ssl": False, "turn_transport": "udp", "turn_username": None, }, )
async def pnp_service_connect() -> Peer: """Create a Peer instance and register with PnP signaling server.""" # Create own peer object with connection to shared PeerJS server logger.info('creating peer') # If we already have an assigned peerId, we will reuse it forever. # We expect that peerId is crypto secure. No need to replace. # Unless the user explicitly requests a refresh. global savedPeerId global config logger.info('last saved savedPeerId {}', savedPeerId) new_token = util.randomToken() logger.info('Peer session token {}', new_token) options = PeerOptions( host=config['signaling_server'], port=config['port'], secure=config['secure'], token=new_token, config=RTCConfiguration( iceServers=[RTCIceServer(**srv) for srv in config['ice_servers']])) peer = Peer(id=savedPeerId, peer_options=options) logger.info('pnpService: peer created with id {} , options: {}', peer.id, peer.options) await peer.start() logger.info('peer activated') _setPnPServiceConnectionHandlers(peer) return peer
def test_turn_with_token(self): self.assertEqual(connection_kwargs([ RTCIceServer( urls='turn:turn.example.com', username='******', credential='bar', credentialType='token', ), ]), {})
def test_stun_multiple_urls(self): self.assertEqual(connection_kwargs([ RTCIceServer([ 'stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302', ]), ]), { 'stun_server': ('stun1.l.google.com', 19302), })
def test_stun_multiple_urls(self): self.assertEqual( connection_kwargs([ RTCIceServer([ "stun:stun1.l.google.com:19302", "stun:stun2.l.google.com:19302", ]) ]), {"stun_server": ("stun1.l.google.com", 19302)}, )
def test_turn_over_tcp(self): self.assertEqual( connection_kwargs([ RTCIceServer('turn:turn.example.com?transport=tcp'), ]), { 'turn_password': None, 'turn_server': ('turn.example.com', 3478), 'turn_transport': 'tcp', 'turn_username': None, })
def test_turn_multiple_urls(self): self.assertEqual(connection_kwargs([ RTCIceServer([ 'turn:turn1.example.com', 'turn:turn2.example.com', ]) ]), { 'turn_password': None, 'turn_server': ('turn1.example.com', 3478), 'turn_username': None, })
def test_turns(self): self.assertEqual( connection_kwargs([ RTCIceServer('turns:turn.example.com'), ]), { 'turn_password': None, 'turn_server': ('turn.example.com', 5349), 'turn_ssl': True, 'turn_transport': 'tcp', 'turn_username': None, })
def test_turn_over_tcp(self): self.assertEqual( connection_kwargs([RTCIceServer("turn:turn.example.com?transport=tcp")]), { "turn_password": None, "turn_server": ("turn.example.com", 3478), "turn_ssl": False, "turn_transport": "tcp", "turn_username": None, }, )
def test_turns(self): self.assertEqual( connection_kwargs([RTCIceServer("turns:turn.example.com")]), { "turn_password": None, "turn_server": ("turn.example.com", 5349), "turn_ssl": True, "turn_transport": "tcp", "turn_username": None, }, )
def test_turn_with_password(self): self.assertEqual(connection_kwargs([ RTCIceServer( urls='turn:turn.example.com', username='******', credential='bar' ), ]), { 'turn_password': '******', 'turn_server': ('turn.example.com', 3478), 'turn_username': '******', })
def test_turn_with_token(self): self.assertEqual( connection_kwargs([ RTCIceServer( urls="turn:turn.example.com", username="******", credential="bar", credentialType="token", ) ]), {}, )
def test_turn_with_password(self): self.assertEqual( connection_kwargs([ RTCIceServer(urls="turn:turn.example.com", username="******", credential="bar") ]), { "turn_password": "******", "turn_server": ("turn.example.com", 3478), "turn_ssl": False, "turn_transport": "udp", "turn_username": "******", }, )
from uuid import uuid4 # import msgpack from aiortc.rtcconfiguration import RTCConfiguration, RTCIceServer # import asyncio # import aiofiles log = logging.getLogger(__name__) DEFAULT_CONFIG = RTCConfiguration(iceServers=[ RTCIceServer(urls=[ "stun:stun1.l.google.com:19302", "stun:stun2.l.google.com:19302", "stun:stun3.l.google.com:19302", "stun:stun4.l.google.com:19302", "stun:stun.l.google.com:19302", "stun:stun.services.mozilla.com:3478", "stun:stunserver.org:3478", ]), RTCIceServer(urls=['turn:numb.viagenie.ca'], username='******', credential='muazkh'), RTCIceServer(urls=['turn:192.158.29.39:3478?transport=udp'], credential='JZEOEt2V3Qb0y27GRntt2u2PAYA=', username='******'), RTCIceServer(urls=['turn:192.158.29.39:3478?transport=tcp'], credential='JZEOEt2V3Qb0y27GRntt2u2PAYA=', username='******'), RTCIceServer(urls=['turn:turn.bistri.com:80'], credential='homeo',
def test_turn_over_bogus(self): self.assertEqual( connection_kwargs( [RTCIceServer("turn:turn.example.com?transport=bogus")]), {}, )
from dataclasses import dataclass from uuid import uuid4 import os # import msgpack from aiortc.rtcconfiguration import RTCConfiguration, RTCIceServer # import asyncio # import aiofiles log = logging.getLogger(__name__) default_ice_servers = [{"urls": ["stun:stun.l.google.com:19302"]}] DEFAULT_CONFIG = RTCConfiguration( iceServers=[RTCIceServer(**srv) for srv in default_ice_servers]) @dataclass class UtilSupports: """WebRTC parameters supported by this library.""" webRTC: bool = True browser: str = 'aiortc' audioVideo: bool = True data: bool = True binaryBlob: bool = False reliable: bool = True class Util:
def test_turn_over_tcp(self): self.assertEqual(connection_kwargs([ RTCIceServer('turn:turn.example.com?transport=tcp'), ]), {})
def test_default_ice_servers(self): self.assertEqual( RTCIceGatherer.getDefaultIceServers(), [RTCIceServer(urls="stun:stun.l.google.com:19302")], )
def test_stun(self): self.assertEqual( connection_kwargs([RTCIceServer("stun:stun.l.google.com:19302")]), {"stun_server": ("stun.l.google.com", 19302)}, )
def test_turns_over_udp(self): self.assertEqual( connection_kwargs( [RTCIceServer("turns:turn.example.com?transport=udp")]), {}, )