From 09c5ba0d0620eb96f2b9edc3525dbaa349e3274e Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Thu, 16 Sep 2021 17:17:36 +0200 Subject: [PATCH] Protect against tracks without a stream. --- rtpconn/webclient.go | 2 +- static/protocol.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index 7a6bc59..58ede34 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -368,7 +368,7 @@ func addDownTrackUnlocked(conn *rtpDownConnection, remoteTrack *rtpUpTrack) erro id = remoteTrack.track.Kind().String() } msid := remoteTrack.track.StreamID() - if msid == "" { + if msid == "" || msid == "-" { log.Println("Got track with empty msid") msid = remoteTrack.conn.Label() } diff --git a/static/protocol.js b/static/protocol.js index 54ca3fe..65e2fc5 100644 --- a/static/protocol.js +++ b/static/protocol.js @@ -677,6 +677,10 @@ ServerConnection.prototype.gotOffer = async function(id, label, source, username }; c.pc.ontrack = function(e) { + if(e.streams.length < 1) { + console.error("Got track with no stream"); + return; + } c.stream = e.streams[0]; let changed = recomputeUserStreams(sc, source, c); if(c.ondowntrack) {