From aca3bab23891b2b3cdfd45fc9c854cddedd8fe0f Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Sun, 18 Dec 2022 22:38:44 +0300 Subject: [PATCH] Fix Firefox WebRTC support --- www/video-rtc.js | 5 +++-- www/webrtc.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/www/video-rtc.js b/www/video-rtc.js index dddeaed0..cd5c8a1e 100644 --- a/www/video-rtc.js +++ b/www/video-rtc.js @@ -422,7 +422,8 @@ class VideoRTC extends HTMLElement { video2.addEventListener("loadeddata", () => { console.debug("VideoRTC.video.loadeddata", video2.readyState, pc.connectionState); - if (pc.connectionState === "connected" || pc.connectionState === "connecting") { + // Firefox doesn't support pc.connectionState + if (pc.connectionState === "connected" || pc.connectionState === "connecting" || !pc.connectionState) { // Video+Audio > Video, H265 > H264, Video > Audio, WebRTC > MSE let rtcPriority = 0, msePriority = 0; @@ -498,7 +499,7 @@ class VideoRTC extends HTMLElement { this.onmessage["webrtc"] = msg => { switch (msg.type) { case "webrtc/candidate": - pc.addIceCandidate({candidate: msg.value, sdpMid: ""}).catch(() => console.debug); + pc.addIceCandidate({candidate: msg.value, sdpMid: "0"}).catch(() => console.debug); break; case "webrtc/answer": pc.setRemoteDescription({type: "answer", sdp: msg.value}).catch(() => console.debug); diff --git a/www/webrtc.html b/www/webrtc.html index 9ab660bc..ca6bbab0 100644 --- a/www/webrtc.html +++ b/www/webrtc.html @@ -48,7 +48,7 @@ console.debug('ws.onmessage', msg); if (msg.type === 'webrtc/candidate') { - pc.addIceCandidate({candidate: msg.value, sdpMid: ''}); + pc.addIceCandidate({candidate: msg.value, sdpMid: '0'}); } else if (msg.type === 'webrtc/answer') { pc.setRemoteDescription({type: 'answer', sdp: msg.value}); }