1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-02-12 06:21:16 +00:00

Compare commits

..

No commits in common. "a2a74761bb49910cd0131b264f2626a1e546d375" and "90d7bd4760a792a1d9a81c43cbfefc28081e4a58" have entirely different histories.

4 changed files with 15 additions and 15 deletions

View File

@ -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 {RTCSessionDescription} sdp Session description data * @param {*} data Session description data
*/ */
setRemoteDescription(sdp) { setRemoteDescription(data) {
this.pc.setRemoteDescription(sdp); this.pc.setRemoteDescription(new RTCSessionDescription(data));
} }
} }

View File

@ -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);
const sdp = new RTCSessionDescription(JSON.parse(event.data)); callback(event.data);
callback(sdp);
}); });
} }
} }

View File

@ -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(sdp => { s.onDescription(data => {
c.setRemoteDescription(sdp); c.setRemoteDescription(data);
}); });
// Register keyboard events // Register keyboard events

View File

@ -16,9 +16,9 @@ var upgrader = websocket.Upgrader{
// clientDescription is sent by new client // clientDescription is sent by new client
type clientDescription struct { type clientDescription struct {
WebRtcSdp webrtc.SessionDescription webRtcSdp webrtc.SessionDescription
Stream string stream string
Quality string quality string
} }
// websocketHandler exchanges WebRTC SDP and viewer count // websocketHandler exchanges WebRTC SDP and viewer count
@ -40,22 +40,22 @@ func websocketHandler(w http.ResponseWriter, r *http.Request) {
} }
// Get requested stream // Get requested stream
stream, err := streams.Get(c.Stream) stream, err := streams.Get(c.stream)
if err != nil { if err != nil {
log.Printf("Stream not found: %s", c.Stream) log.Printf("Stream not found: %s", c.stream)
return return
} }
// Get requested quality // Get requested quality
q, err := stream.GetQuality(c.Quality) q, err := stream.GetQuality(c.quality)
if err != nil { if err != nil {
log.Printf("Quality not found: %s", c.Quality) log.Printf("Quality not found: %s", c.quality)
return return
} }
// Exchange session descriptions with WebRTC stream server // Exchange session descriptions with WebRTC stream server
// FIXME: Add trickle ICE support // FIXME: Add trickle ICE support
q.WebRtcRemoteSdp <- c.WebRtcSdp q.WebRtcRemoteSdp <- c.webRtcSdp
localDescription := <-q.WebRtcLocalSdp localDescription := <-q.WebRtcLocalSdp
// Send new local description // Send new local description