Manual negotiation and plan-b support

This commit is contained in:
David Zhao
2021-04-16 00:56:25 -07:00
parent 04f6b61ae1
commit 93d10b2640
16 changed files with 231 additions and 64 deletions
+7
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"io"
"net/http"
"strconv"
"strings"
"github.com/gorilla/websocket"
@@ -55,6 +56,8 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
roomName := r.FormValue("room")
reconnectParam := r.FormValue("reconnect")
protocolParam := r.FormValue("protocol")
planBParam := r.FormValue("planb")
claims := GetGrants(r.Context())
// require a claim
@@ -65,6 +68,7 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
pi := routing.ParticipantInit{
Reconnect: boolValue(reconnectParam),
Identity: claims.Identity,
UsePlanB: boolValue(planBParam),
}
// only use permissions if any of them are set, default permissive
if claims.Video.CanPublish || claims.Video.CanSubscribe {
@@ -73,6 +77,9 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
CanPublish: claims.Video.CanPublish,
}
}
if pv, err := strconv.Atoi(protocolParam); err == nil {
pi.ProtocolVersion = int32(pv)
}
onlyName, err := EnsureJoinPermission(r.Context())
if err != nil {