File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ class Config:
4141 http_api_base_url : str = os .getenv ("HTTP_API_BASE_URL" , "wrong" )
4242 websocket_api_base_url : str = os .getenv ("WEBSOCKET_API_BASE_URL" , "wrong" )
4343 max_polling_time_mins : int = int (os .getenv ("MAX_POLLING_TIME_MINS" , 5 ))
44+ turn_url : str | None = os .getenv ("TURN_URL" )
45+ turn_username : str | None = os .getenv ("TURN_USERNAME" )
46+ turn_credential : str | None = os .getenv ("TURN_CREDENTIAL" )
4447
4548
4649logging .basicConfig (level = logging .DEBUG if Config .debug_mode else logging .INFO )
Original file line number Diff line number Diff line change @@ -136,14 +136,23 @@ async def setup_peer_connection(self):
136136 if old_pc :
137137 await old_pc .close ()
138138
139- pc = RTCPeerConnection (
140- configuration = RTCConfiguration (
141- iceServers = [
142- RTCIceServer (urls = "stun:stun.l.google.com:19302" ),
143- RTCIceServer (urls = "stun:stun1.l.google.com:19302" ),
144- ]
139+ ice_servers = [
140+ RTCIceServer (urls = "stun:stun.l.google.com:19302" ),
141+ RTCIceServer (urls = "stun:stun1.l.google.com:19302" ),
142+ ]
143+ if (
144+ self .config .turn_url
145+ and self .config .turn_username
146+ and self .config .turn_credential
147+ ):
148+ ice_servers .append (
149+ RTCIceServer (
150+ urls = self .config .turn_url ,
151+ username = self .config .turn_username ,
152+ credential = self .config .turn_credential ,
153+ )
145154 )
146- )
155+ pc = RTCPeerConnection ( configuration = RTCConfiguration ( iceServers = ice_servers ) )
147156 self .pc = pc
148157
149158 @pc .on ("connectionstatechange" )
You can’t perform that action at this time.
0 commit comments