@@ -254,22 +254,6 @@ def decrypt_message(encrypted_data, iv, phrase):
254
254
print (f"Error decoding message: { e } " )
255
255
return None
256
256
257
- def setup_ice_servers (webrtc , params ):
258
- try :
259
- if args .stun_server :
260
- webrtc .set_property ('stun-server' , args .stun_server )
261
- elif not params .no_stun : # Fall back to defaults if not disabled
262
- for server in ["stun://stun.cloudflare.com:3478" , "stun://stun.l.google.com:19302" ]:
263
- webrtc .set_property ('stun-server' , server )
264
-
265
- if args .turn_server :
266
- webrtc .set_property ('turn-server' , args .turn_server )
267
-
268
- if args .ice_transport_policy :
269
- webrtc .set_property ('ice-transport-policy' , args .ice_transport_policy )
270
-
271
- except Exception as E :
272
- printwarn (get_exception_info (E ))
273
257
274
258
class WebRTCClient :
275
259
def __init__ (self , params ):
@@ -336,9 +320,26 @@ def __init__(self, params):
336
320
337
321
if self .save_file :
338
322
self .pipe = Gst .parse_launch (self .pipeline )
339
- setup_ice_servers (self .pipe .get_by_name ('sendrecv' ))
323
+ self . setup_ice_servers (self .pipe .get_by_name ('sendrecv' ))
340
324
self .pipe .set_state (Gst .State .PLAYING )
341
325
print ("RECORDING TO DISK STARTED" )
326
+
327
+ def setup_ice_servers (self , webrtc ):
328
+ try :
329
+ if hasattr (self , 'stun_server' ) and self .stun_server :
330
+ webrtc .set_property ('stun-server' , self .stun_server )
331
+ elif not hasattr (self , 'no_stun' ) or not self .no_stun :
332
+ for server in ["stun://stun.cloudflare.com:3478" , "stun://stun.l.google.com:19302" ]:
333
+ webrtc .set_property ('stun-server' , server )
334
+
335
+ if hasattr (self , 'turn_server' ) and self .turn_server :
336
+ webrtc .set_property ('turn-server' , self .turn_server )
337
+
338
+ if hasattr (self , 'ice_transport_policy' ) and self .ice_transport_policy :
339
+ webrtc .set_property ('ice-transport-policy' , self .ice_transport_policy )
340
+
341
+ except Exception as E :
342
+ printwarn (get_exception_info (E ))
342
343
343
344
async def connect (self ):
344
345
print ("Connecting to handshake server" )
@@ -1373,7 +1374,7 @@ def on_stats(promise, abin, data):
1373
1374
if self .streamin :
1374
1375
client ['webrtc' ] = Gst .ElementFactory .make ("webrtcbin" , client ['UUID' ])
1375
1376
client ['webrtc' ].set_property ('bundle-policy' , "max-bundle" )
1376
- setup_ice_servers (client ['webrtc' ])
1377
+ ssetup_ice_servers (client ['webrtc' ], self )
1377
1378
1378
1379
try :
1379
1380
client ['webrtc' ].set_property ('latency' , self .buffer )
@@ -1393,12 +1394,12 @@ def on_stats(promise, abin, data):
1393
1394
1394
1395
elif not self .multiviewer :
1395
1396
client ['webrtc' ] = self .pipe .get_by_name ('sendrecv' )
1396
- setup_ice_servers (client ['webrtc' ])
1397
+ self . setup_ice_servers (client ['webrtc' ])
1397
1398
pass
1398
1399
else :
1399
1400
client ['webrtc' ] = Gst .ElementFactory .make ("webrtcbin" , client ['UUID' ])
1400
1401
client ['webrtc' ].set_property ('bundle-policy' , 'max-bundle' )
1401
- setup_ice_servers (client ['webrtc' ])
1402
+ self . setup_ice_servers (client ['webrtc' ])
1402
1403
1403
1404
try :
1404
1405
client ['webrtc' ].set_property ('latency' , self .buffer )
0 commit comments