mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-02-11 18:11:26 +00:00
Compare commits
2 Commits
90d7bd4760
...
a2a74761bb
Author | SHA1 | Date | |
---|---|---|---|
|
a2a74761bb | ||
|
ba8bf426e0 |
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -16,9 +16,9 @@ var upgrader = websocket.Upgrader{
|
||||
|
||||
// clientDescription is sent by new client
|
||||
type clientDescription struct {
|
||||
webRtcSdp webrtc.SessionDescription
|
||||
stream string
|
||||
quality string
|
||||
WebRtcSdp webrtc.SessionDescription
|
||||
Stream string
|
||||
Quality string
|
||||
}
|
||||
|
||||
// websocketHandler exchanges WebRTC SDP and viewer count
|
||||
@ -40,22 +40,22 @@ func websocketHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Get requested stream
|
||||
stream, err := streams.Get(c.stream)
|
||||
stream, err := streams.Get(c.Stream)
|
||||
if err != nil {
|
||||
log.Printf("Stream not found: %s", c.stream)
|
||||
log.Printf("Stream not found: %s", c.Stream)
|
||||
return
|
||||
}
|
||||
|
||||
// Get requested quality
|
||||
q, err := stream.GetQuality(c.quality)
|
||||
q, err := stream.GetQuality(c.Quality)
|
||||
if err != nil {
|
||||
log.Printf("Quality not found: %s", c.quality)
|
||||
log.Printf("Quality not found: %s", c.Quality)
|
||||
return
|
||||
}
|
||||
|
||||
// Exchange session descriptions with WebRTC stream server
|
||||
// FIXME: Add trickle ICE support
|
||||
q.WebRtcRemoteSdp <- c.webRtcSdp
|
||||
q.WebRtcRemoteSdp <- c.WebRtcSdp
|
||||
localDescription := <-q.WebRtcLocalSdp
|
||||
|
||||
// Send new local description
|
||||
|
Loading…
x
Reference in New Issue
Block a user