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);
|
||||
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({
|
||||
"webRtcSdp": localDescription,
|
||||
"stream": stream,
|
||||
|
|
|
@ -81,7 +81,7 @@ export function initViewerPage(stream, stunServers, viewersCounterRefreshPeriod)
|
|||
quality = event.target.value;
|
||||
console.log(`Stream quality changed to ${quality}`);
|
||||
|
||||
// Restart the connection with a new quality
|
||||
// FIXME
|
||||
// Restart WebRTC negociation
|
||||
webrtc.createOffer();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
<div class="controls">
|
||||
<span class="control-quality">
|
||||
<select id="quality">
|
||||
<option value="">Source</option>
|
||||
<option value="@720p">720p</option>
|
||||
<option value="@480p">480p</option>
|
||||
<option value="@240p">240p</option>
|
||||
<option value="source">Source</option>
|
||||
<option value="720p">720p</option>
|
||||
<option value="480p">480p</option>
|
||||
<option value="240p">240p</option>
|
||||
</select>
|
||||
</span>
|
||||
<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)
|
||||
if err != nil {
|
||||
log.Printf("Failed to receive client description: %s", err)
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
// Get requested stream
|
||||
stream, err := streams.Get(c.Stream)
|
||||
if err != nil {
|
||||
log.Printf("Stream not found: %s", c.Stream)
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
// Get requested quality
|
||||
q, err := stream.GetQuality(c.Quality)
|
||||
if err != nil {
|
||||
log.Printf("Quality not found: %s", c.Quality)
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
// Exchange session descriptions with WebRTC stream server
|
||||
|
@ -61,7 +61,7 @@ func websocketHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// Send new local description
|
||||
if err := conn.WriteJSON(localDescription); err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue