From a2a74761bb49910cd0131b264f2626a1e546d375 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Thu, 22 Oct 2020 08:23:35 +0200 Subject: [PATCH] Parse JSON from server SDP --- web/static/js/modules/webrtc.js | 6 +++--- web/static/js/modules/websocket.js | 4 ++-- web/static/js/viewer.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/web/static/js/modules/webrtc.js b/web/static/js/modules/webrtc.js index fea8037..df359e7 100644 --- a/web/static/js/modules/webrtc.js +++ b/web/static/js/modules/webrtc.js @@ -90,9 +90,9 @@ export class GsWebRTC { /** * Set WebRTC remote description * After that, the connection will be established and ontrack will be fired. - * @param {*} data Session description data + * @param {RTCSessionDescription} sdp Session description data */ - setRemoteDescription(data) { - this.pc.setRemoteDescription(new RTCSessionDescription(data)); + setRemoteDescription(sdp) { + this.pc.setRemoteDescription(sdp); } } diff --git a/web/static/js/modules/websocket.js b/web/static/js/modules/websocket.js index 0f33a84..b9f017c 100644 --- a/web/static/js/modules/websocket.js +++ b/web/static/js/modules/websocket.js @@ -55,9 +55,9 @@ export class GsWebSocket { */ onDescription(callback) { this.socket.addEventListener("message", (event) => { - // FIXME: json to session description console.log("Message from server ", event.data); - callback(event.data); + const sdp = new RTCSessionDescription(JSON.parse(event.data)); + callback(sdp); }); } } diff --git a/web/static/js/viewer.js b/web/static/js/viewer.js index 48b3020..1e0e7d3 100644 --- a/web/static/js/viewer.js +++ b/web/static/js/viewer.js @@ -26,8 +26,8 @@ export function initViewerPage(stream, stunServers, viewersCounterRefreshPeriod) c.onICECandidate(localDescription => { s.sendDescription(localDescription, stream, quality); }); - s.onDescription(data => { - c.setRemoteDescription(data); + s.onDescription(sdp => { + c.setRemoteDescription(sdp); }); // Register keyboard events