Make viewer able to change quality

This commit is contained in:
Alexandre Iooss 2020-10-22 18:41:14 +02:00
parent 4cbb1d8192
commit ff2ebd76f1
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
4 changed files with 11 additions and 11 deletions

View File

@ -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,

View File

@ -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();
});
}

View File

@ -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>

View File

@ -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
}
}
}