From 392a9d7fc34fdd8f568ddf6a5826ecb1e12a3d7c Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 6 Oct 2020 09:20:25 +0200 Subject: [PATCH] Quality selector reload stream --- web/static/js/videoQuality.js | 8 ++++---- web/static/js/viewer.js | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/web/static/js/videoQuality.js b/web/static/js/videoQuality.js index 1959b88..ba6e15e 100644 --- a/web/static/js/videoQuality.js +++ b/web/static/js/videoQuality.js @@ -2,8 +2,8 @@ document.getElementById("quality").addEventListener("change", (event) => { console.log(`Stream quality changed to ${event.target.value}`) // Restart the connection with a new quality - // FIXME: set quality - peerConnection.createOffer({ "iceRestart": true }).then(offer => { - return peerConnection.setLocalDescription(offer) - }).catch(console.log) + peerConnection.close() + peerConnection = null + streamPath = window.location.href + event.target.value + startPeerConnection() }) diff --git a/web/static/js/viewer.js b/web/static/js/viewer.js index b9b7f20..fbe5c92 100644 --- a/web/static/js/viewer.js +++ b/web/static/js/viewer.js @@ -1,4 +1,5 @@ -let peerConnection; +let peerConnection +let streamPath = window.location.href startPeerConnection = () => { // Init peer connection @@ -52,7 +53,7 @@ startPeerConnection = () => { // The server replies with its description // After setRemoteDescription, the browser will fire ontrack events console.log("Sending session description to server") - fetch(window.location.href + document.quality_form.quality.value, { + fetch(streamPath, { method: 'POST', headers: { 'Accept': 'application/json',