mirror of
				https://gitlab.crans.org/nounous/ghostream.git
				synced 2025-11-04 04:12:10 +01:00 
			
		
		
		
	Parse JSON from server SDP
This commit is contained in:
		@@ -90,9 +90,9 @@ export class GsWebRTC {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Set WebRTC remote description
 | 
					     * Set WebRTC remote description
 | 
				
			||||||
     * After that, the connection will be established and ontrack will be fired.
 | 
					     * 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) {
 | 
					    setRemoteDescription(sdp) {
 | 
				
			||||||
        this.pc.setRemoteDescription(new RTCSessionDescription(data));
 | 
					        this.pc.setRemoteDescription(sdp);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,9 +55,9 @@ export class GsWebSocket {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    onDescription(callback) {
 | 
					    onDescription(callback) {
 | 
				
			||||||
        this.socket.addEventListener("message", (event) => {
 | 
					        this.socket.addEventListener("message", (event) => {
 | 
				
			||||||
            // FIXME: json to session description
 | 
					 | 
				
			||||||
            console.log("Message from server ", event.data);
 | 
					            console.log("Message from server ", event.data);
 | 
				
			||||||
            callback(event.data);
 | 
					            const sdp = new RTCSessionDescription(JSON.parse(event.data));
 | 
				
			||||||
 | 
					            callback(sdp);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,8 +26,8 @@ export function initViewerPage(stream, stunServers, viewersCounterRefreshPeriod)
 | 
				
			|||||||
    c.onICECandidate(localDescription => {
 | 
					    c.onICECandidate(localDescription => {
 | 
				
			||||||
        s.sendDescription(localDescription, stream, quality);
 | 
					        s.sendDescription(localDescription, stream, quality);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    s.onDescription(data => {
 | 
					    s.onDescription(sdp => {
 | 
				
			||||||
        c.setRemoteDescription(data);
 | 
					        c.setRemoteDescription(sdp);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Register keyboard events
 | 
					    // Register keyboard events
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user