mirror of
https://gitlab.com/comunic/ComunicRTCProxy
synced 2024-11-17 02:51:12 +00:00
Apply video policy on proxy
This commit is contained in:
parent
a98a65936f
commit
50bb04af5e
@ -12,6 +12,7 @@ import (
|
||||
|
||||
type callConfig struct {
|
||||
iceServers []webrtc.ICEServer
|
||||
allowVideo bool
|
||||
}
|
||||
|
||||
// This configuration is intialized as soon as
|
||||
@ -28,4 +29,7 @@ func setCallConfig(data map[string]interface{}) {
|
||||
URLs: []string{server.(string)},
|
||||
})
|
||||
}
|
||||
|
||||
// Update allow video status
|
||||
callConf.allowVideo = data["allowVideo"].(bool)
|
||||
}
|
||||
|
9
relay.go
9
relay.go
@ -261,12 +261,14 @@ func newCall(mainOffer receivedSignal, r *activeRelay) {
|
||||
})
|
||||
|
||||
// Allow us to receive 1 audio & 1 video track
|
||||
if callConf.allowVideo {
|
||||
if _, err = mainPeerConnection.AddTransceiverFromKind(webrtc.RTPCodecTypeVideo,
|
||||
webrtc.RtpTransceiverInit{Direction: webrtc.RTPTransceiverDirectionRecvonly}); err != nil {
|
||||
log.Println("Error: could not prepare to receive video track!", err)
|
||||
askForClose(r)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if _, err = mainPeerConnection.AddTransceiverFromKind(webrtc.RTPCodecTypeAudio,
|
||||
webrtc.RtpTransceiverInit{Direction: webrtc.RTPTransceiverDirectionRecvonly}); err != nil {
|
||||
@ -304,6 +306,13 @@ func newCall(mainOffer receivedSignal, r *activeRelay) {
|
||||
trackID := "audio"
|
||||
trackLabel := "pion" // We need only one track label
|
||||
if remoteTrack.Kind() == webrtc.RTPCodecTypeVideo {
|
||||
|
||||
// Check if video calls are allowed
|
||||
if !callConf.allowVideo {
|
||||
log.Printf("Blocked a video stream! Call hash: %s", r.callHash)
|
||||
return
|
||||
}
|
||||
|
||||
trackID = "video" // We need two different track ids
|
||||
}
|
||||
|
||||
|
2
ws.go
2
ws.go
@ -6,6 +6,7 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
@ -76,6 +77,7 @@ func openWs(conf *Config) {
|
||||
case "config":
|
||||
println("Got call configuration")
|
||||
setCallConfig(msg.Data.(map[string]interface{}))
|
||||
fmt.Println("Enable video calls:", callConf.allowVideo)
|
||||
break
|
||||
|
||||
// Remote signal
|
||||
|
Loading…
Reference in New Issue
Block a user