mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-24 02:02:20 +00:00
Make viewer able to change quality
This commit is contained in:
parent
4cbb1d8192
commit
ff2ebd76f1
@ -40,7 +40,7 @@ export class GsWebSocket {
|
|||||||
setTimeout(() => this.sendDescription(localDescription, stream, quality), 100);
|
setTimeout(() => this.sendDescription(localDescription, stream, quality), 100);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("[WebSocket] Sending WebRTC local session description");
|
console.log(`[WebSocket] Sending WebRTC local session description for stream ${stream} quality ${quality}`);
|
||||||
this.socket.send(JSON.stringify({
|
this.socket.send(JSON.stringify({
|
||||||
"webRtcSdp": localDescription,
|
"webRtcSdp": localDescription,
|
||||||
"stream": stream,
|
"stream": stream,
|
||||||
|
@ -81,7 +81,7 @@ export function initViewerPage(stream, stunServers, viewersCounterRefreshPeriod)
|
|||||||
quality = event.target.value;
|
quality = event.target.value;
|
||||||
console.log(`Stream quality changed to ${quality}`);
|
console.log(`Stream quality changed to ${quality}`);
|
||||||
|
|
||||||
// Restart the connection with a new quality
|
// Restart WebRTC negociation
|
||||||
// FIXME
|
webrtc.createOffer();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
<div class="controls">
|
<div class="controls">
|
||||||
<span class="control-quality">
|
<span class="control-quality">
|
||||||
<select id="quality">
|
<select id="quality">
|
||||||
<option value="">Source</option>
|
<option value="source">Source</option>
|
||||||
<option value="@720p">720p</option>
|
<option value="720p">720p</option>
|
||||||
<option value="@480p">480p</option>
|
<option value="480p">480p</option>
|
||||||
<option value="@240p">240p</option>
|
<option value="240p">240p</option>
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
<code class="control-srt-link">srt://{{.Cfg.Hostname}}:{{.Cfg.SRTServerPort}}?streamid={{.Path}}</code>
|
<code class="control-srt-link">srt://{{.Cfg.Hostname}}:{{.Cfg.SRTServerPort}}?streamid={{.Path}}</code>
|
||||||
|
@ -36,21 +36,21 @@ func websocketHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
err = conn.ReadJSON(c)
|
err = conn.ReadJSON(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to receive client description: %s", err)
|
log.Printf("Failed to receive client description: %s", err)
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exchange session descriptions with WebRTC stream server
|
// Exchange session descriptions with WebRTC stream server
|
||||||
@ -61,7 +61,7 @@ func websocketHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Send new local description
|
// Send new local description
|
||||||
if err := conn.WriteJSON(localDescription); err != nil {
|
if err := conn.WriteJSON(localDescription); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user