From 6b8c65f5d795d3388f060b7fe64baa0560ed2410 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Thu, 18 May 2023 14:58:19 +0200 Subject: [PATCH] webrtc: fix exception in browser when webrtcICEServers is empty (#1817) (#1821) this fixes a regression introduced in v0.23.0. --- internal/core/webrtc_publish_index.html | 4 ++-- internal/core/webrtc_read_index.html | 6 +++--- mediamtx.yml | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/internal/core/webrtc_publish_index.html b/internal/core/webrtc_publish_index.html index 74921000c6f..b6b7e86598b 100644 --- a/internal/core/webrtc_publish_index.html +++ b/internal/core/webrtc_publish_index.html @@ -111,7 +111,7 @@ const restartPause = 2000; const linkToIceServers = (links) => ( - links.split(', ').map((link) => { + (links !== null) ? links.split(', ').map((link) => { const m = link.match(/^<(.+?)>; rel="ice-server"(; username="(.*?)"; credential="(.*?)"; credential-type="password")?/i); const ret = { urls: [m[1]], @@ -124,7 +124,7 @@ } return ret; - }) + }) : [] ); const parseOffer = (offer) => { diff --git a/internal/core/webrtc_read_index.html b/internal/core/webrtc_read_index.html index 3e3a8b6f73c..0f1a6c1a4ca 100644 --- a/internal/core/webrtc_read_index.html +++ b/internal/core/webrtc_read_index.html @@ -26,8 +26,8 @@ const restartPause = 2000; const linkToIceServers = (links) => ( - links.split(', ').map((link) => { - const m = link.match(/^<(.+?)>; rel="ice-server"(; username="(.+?)"; credential="(.+?)"; credential-type="password")?/i); + (links !== null) ? links.split(', ').map((link) => { + const m = link.match(/^<(.+?)>; rel="ice-server"(; username="(.*?)"; credential="(.*?)"; credential-type="password")?/i); const ret = { urls: [m[1]], }; @@ -39,7 +39,7 @@ } return ret; - }) + }) : [] ); const parseOffer = (offer) => { diff --git a/mediamtx.yml b/mediamtx.yml index ab8c8926554..002b97e8711 100644 --- a/mediamtx.yml +++ b/mediamtx.yml @@ -199,25 +199,27 @@ webrtcAllowOrigin: '*' # If the server receives a request from one of these entries, IP in logs # will be taken from the X-Forwarded-For header. webrtcTrustedProxies: [] -# List of ICE servers, in format type:user:pass:host:port or type:host:port. +# List of ICE servers, in format type:user:password:host:port or type:host:port. # type can be "stun", "turn" or "turns". -# STUN servers are used to get the public IP of both server and clients. -# TURN/TURNS servers are used as relay when a direct connection between server and clients is not possible. +# STUN servers are used to obtain the public IP of server and clients. They are +# needed when server and clients are on different LANs. +# TURN servers are needed when a direct connection between server and clients +# is not possible. All traffic is routed through the chosen TURN server. # if user is "AUTH_SECRET", then authentication is secret based. -# the secret must be inserted into the pass field. +# the secret must be inserted into the password field. webrtcICEServers: [stun:stun.l.google.com:19302] # List of public IP addresses that are to be used as a host. # This is used typically for servers that are behind 1:1 D-NAT. webrtcICEHostNAT1To1IPs: [] # Address of a ICE UDP listener in format host:port. -# If filled, ICE traffic will come through a single UDP port, +# If filled, ICE traffic will pass through a single UDP port, # allowing the deployment of the server inside a container or behind a NAT. webrtcICEUDPMuxAddress: # Address of a ICE TCP listener in format host:port. -# If filled, ICE traffic will come through a single TCP port, +# If filled, ICE traffic will pass through a single TCP port, # allowing the deployment of the server inside a container or behind a NAT. -# At the moment, setting this parameter forces usage of the TCP protocol, -# which is not optimal for WebRTC. +# Setting this parameter forces usage of the TCP protocol, which is not +# optimal for WebRTC. webrtcICETCPMuxAddress: ###############################################