Parse JSON from server SDP

This commit is contained in:
Alexandre Iooss 2020-10-22 08:23:35 +02:00
parent ba8bf426e0
commit a2a74761bb
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
3 changed files with 7 additions and 7 deletions

View File

@ -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);
}
}

View File

@ -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);
});
}
}

View File

@ -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