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 {
|
type callConfig struct {
|
||||||
iceServers []webrtc.ICEServer
|
iceServers []webrtc.ICEServer
|
||||||
|
allowVideo bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// This configuration is intialized as soon as
|
// This configuration is intialized as soon as
|
||||||
@ -28,4 +29,7 @@ func setCallConfig(data map[string]interface{}) {
|
|||||||
URLs: []string{server.(string)},
|
URLs: []string{server.(string)},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update allow video status
|
||||||
|
callConf.allowVideo = data["allowVideo"].(bool)
|
||||||
}
|
}
|
||||||
|
19
relay.go
19
relay.go
@ -261,11 +261,13 @@ func newCall(mainOffer receivedSignal, r *activeRelay) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Allow us to receive 1 audio & 1 video track
|
// Allow us to receive 1 audio & 1 video track
|
||||||
if _, err = mainPeerConnection.AddTransceiverFromKind(webrtc.RTPCodecTypeVideo,
|
if callConf.allowVideo {
|
||||||
webrtc.RtpTransceiverInit{Direction: webrtc.RTPTransceiverDirectionRecvonly}); err != nil {
|
if _, err = mainPeerConnection.AddTransceiverFromKind(webrtc.RTPCodecTypeVideo,
|
||||||
log.Println("Error: could not prepare to receive video track!", err)
|
webrtc.RtpTransceiverInit{Direction: webrtc.RTPTransceiverDirectionRecvonly}); err != nil {
|
||||||
askForClose(r)
|
log.Println("Error: could not prepare to receive video track!", err)
|
||||||
return
|
askForClose(r)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = mainPeerConnection.AddTransceiverFromKind(webrtc.RTPCodecTypeAudio,
|
if _, err = mainPeerConnection.AddTransceiverFromKind(webrtc.RTPCodecTypeAudio,
|
||||||
@ -304,6 +306,13 @@ func newCall(mainOffer receivedSignal, r *activeRelay) {
|
|||||||
trackID := "audio"
|
trackID := "audio"
|
||||||
trackLabel := "pion" // We need only one track label
|
trackLabel := "pion" // We need only one track label
|
||||||
if remoteTrack.Kind() == webrtc.RTPCodecTypeVideo {
|
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
|
trackID = "video" // We need two different track ids
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
ws.go
2
ws.go
@ -6,6 +6,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@ -76,6 +77,7 @@ func openWs(conf *Config) {
|
|||||||
case "config":
|
case "config":
|
||||||
println("Got call configuration")
|
println("Got call configuration")
|
||||||
setCallConfig(msg.Data.(map[string]interface{}))
|
setCallConfig(msg.Data.(map[string]interface{}))
|
||||||
|
fmt.Println("Enable video calls:", callConf.allowVideo)
|
||||||
break
|
break
|
||||||
|
|
||||||
// Remote signal
|
// Remote signal
|
||||||
|
Loading…
Reference in New Issue
Block a user