From 27ec772831cf224c207bf3d545129cdd116cb0ec Mon Sep 17 00:00:00 2001 From: Matthew Tancik Date: Wed, 23 Nov 2022 14:19:17 -0800 Subject: [PATCH] Improve webrtc stability (#1014) debugging webrtc failed connections --- .../src/modules/WebRtcWindow/WebRtcWindow.jsx | 1 + nerfstudio/viewer/server/viewer_utils.py | 27 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/nerfstudio/viewer/app/src/modules/WebRtcWindow/WebRtcWindow.jsx b/nerfstudio/viewer/app/src/modules/WebRtcWindow/WebRtcWindow.jsx index 900ee95918..80d69523de 100644 --- a/nerfstudio/viewer/app/src/modules/WebRtcWindow/WebRtcWindow.jsx +++ b/nerfstudio/viewer/app/src/modules/WebRtcWindow/WebRtcWindow.jsx @@ -18,6 +18,7 @@ export default function WebRtcWindow() { const getRTCPeerConnection = () => { const pc = new RTCPeerConnection({ iceServers: [ + { urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:openrelay.metered.ca:80', }, diff --git a/nerfstudio/viewer/server/viewer_utils.py b/nerfstudio/viewer/server/viewer_utils.py index 040bd61e7d..4486b95530 100644 --- a/nerfstudio/viewer/server/viewer_utils.py +++ b/nerfstudio/viewer/server/viewer_utils.py @@ -28,7 +28,12 @@ import numpy as np import torch -from aiortc import RTCPeerConnection, RTCSessionDescription +from aiortc import ( + RTCConfiguration, + RTCIceServer, + RTCPeerConnection, + RTCSessionDescription, +) from cryptography.utils import CryptographyDeprecationWarning from rich.console import Console @@ -503,7 +508,25 @@ async def send_webrtc_answer(self, data): # returns the description to for WebRTC to the specific websocket connection offer = RTCSessionDescription(data["sdp"], data["type"]) - pc = RTCPeerConnection() + pc = RTCPeerConnection( + configuration=RTCConfiguration( + iceServers=[ + RTCIceServer(urls="stun:stun.l.google.com:19302"), + RTCIceServer(urls="stun:openrelay.metered.ca:80"), + RTCIceServer( + urls="turn:openrelay.metered.ca:80", username="openrelayproject", credential="openrelayproject" + ), + RTCIceServer( + urls="turn:openrelay.metered.ca:443", username="openrelayproject", credential="openrelayproject" + ), + RTCIceServer( + urls="turn:openrelay.metered.ca:443?transport=tcp", + username="openrelayproject", + credential="openrelayproject", + ), + ] + ) + ) self.pcs.add(pc) video = SingleFrameStreamTrack()