mirror of
https://github.com/jech/galene.git
synced 2024-11-23 00:55:58 +01:00
Implement -udp command-line flag.
This commit is contained in:
parent
3e09c0ab29
commit
b80e515eb0
2 changed files with 35 additions and 0 deletions
|
@ -45,6 +45,8 @@ func main() {
|
||||||
"store mutex profile in `file`")
|
"store mutex profile in `file`")
|
||||||
flag.StringVar(&udpRange, "udp-range", "",
|
flag.StringVar(&udpRange, "udp-range", "",
|
||||||
"UDP port `range`")
|
"UDP port `range`")
|
||||||
|
flag.StringVar(&group.UDPAddr, "udp", "",
|
||||||
|
"UDP `address:port` (default dynamic)")
|
||||||
flag.BoolVar(&group.UseMDNS, "mdns", false, "gather mDNS addresses")
|
flag.BoolVar(&group.UseMDNS, "mdns", false, "gather mDNS addresses")
|
||||||
flag.BoolVar(&ice.ICERelayOnly, "relay-only", false,
|
flag.BoolVar(&ice.ICERelayOnly, "relay-only", false,
|
||||||
"require use of TURN relays for all media traffic")
|
"require use of TURN relays for all media traffic")
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -21,6 +22,10 @@ var Directory string
|
||||||
var UseMDNS bool
|
var UseMDNS bool
|
||||||
var UDPMin, UDPMax uint16
|
var UDPMin, UDPMax uint16
|
||||||
|
|
||||||
|
var UDPAddr string
|
||||||
|
var udpListenerMu sync.Mutex
|
||||||
|
var udpListener *net.UDPConn
|
||||||
|
|
||||||
var ErrNotAuthorised = errors.New("not authorised")
|
var ErrNotAuthorised = errors.New("not authorised")
|
||||||
|
|
||||||
type UserError string
|
type UserError string
|
||||||
|
@ -333,6 +338,14 @@ func APIFromCodecs(codecs []webrtc.RTPCodecParameters) (*webrtc.API, error) {
|
||||||
webrtc.RTPHeaderExtensionCapability{sdp.SDESRTPStreamIDURI},
|
webrtc.RTPHeaderExtensionCapability{sdp.SDESRTPStreamIDURI},
|
||||||
webrtc.RTPCodecTypeVideo)
|
webrtc.RTPCodecTypeVideo)
|
||||||
|
|
||||||
|
listener, err := getUDPListener()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if listener != nil {
|
||||||
|
s.SetICEUDPMux(webrtc.NewICEUDPMux(nil, listener))
|
||||||
|
}
|
||||||
|
|
||||||
return webrtc.NewAPI(
|
return webrtc.NewAPI(
|
||||||
webrtc.WithSettingEngine(s),
|
webrtc.WithSettingEngine(s),
|
||||||
webrtc.WithMediaEngine(&m),
|
webrtc.WithMediaEngine(&m),
|
||||||
|
@ -356,6 +369,26 @@ func APIFromNames(names []string) (*webrtc.API, error) {
|
||||||
return APIFromCodecs(codecs)
|
return APIFromCodecs(codecs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getUDPListener() (*net.UDPConn, error) {
|
||||||
|
if UDPAddr == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
udpListenerMu.Lock()
|
||||||
|
defer udpListenerMu.Unlock()
|
||||||
|
if udpListener == nil {
|
||||||
|
addr, err := net.ResolveUDPAddr("udp", UDPAddr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
udpListener, err = net.ListenUDP("udp", addr)
|
||||||
|
if err != nil {
|
||||||
|
udpListener = nil
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return udpListener, nil
|
||||||
|
}
|
||||||
|
|
||||||
func Add(name string, desc *Description) (*Group, error) {
|
func Add(name string, desc *Description) (*Group, error) {
|
||||||
g, notify, err := add(name, desc)
|
g, notify, err := add(name, desc)
|
||||||
for _, c := range notify {
|
for _, c := range notify {
|
||||||
|
|
Loading…
Reference in a new issue