mirror of
https://github.com/jech/galene.git
synced 2024-11-08 17:55:59 +01:00
Passive ICE TCP.
This commit is contained in:
parent
3083b89db9
commit
1ec0e7540a
2 changed files with 37 additions and 0 deletions
|
@ -8,6 +8,7 @@ package group
|
|||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
@ -136,6 +137,18 @@ func (g *Group) API() *webrtc.API {
|
|||
return groups.api
|
||||
}
|
||||
|
||||
var tcpListener net.Listener
|
||||
|
||||
func StartTCPListener(addr *net.TCPAddr) error {
|
||||
if tcpListener != nil {
|
||||
tcpListener.Close()
|
||||
tcpListener = nil
|
||||
}
|
||||
var err error
|
||||
tcpListener, err = net.ListenTCP("tcp", addr)
|
||||
return err
|
||||
}
|
||||
|
||||
func Add(name string, desc *description) (*Group, error) {
|
||||
groups.mu.Lock()
|
||||
defer groups.mu.Unlock()
|
||||
|
@ -143,6 +156,16 @@ func Add(name string, desc *description) (*Group, error) {
|
|||
if groups.groups == nil {
|
||||
groups.groups = make(map[string]*Group)
|
||||
s := webrtc.SettingEngine{}
|
||||
if tcpListener != nil {
|
||||
mux := webrtc.NewICETCPMux(nil, tcpListener, 8)
|
||||
s.SetICETCPMux(mux)
|
||||
s.SetNetworkTypes([]webrtc.NetworkType{
|
||||
webrtc.NetworkTypeUDP4,
|
||||
webrtc.NetworkTypeUDP6,
|
||||
webrtc.NetworkTypeTCP4,
|
||||
webrtc.NetworkTypeTCP6,
|
||||
})
|
||||
}
|
||||
m := webrtc.MediaEngine{}
|
||||
m.RegisterCodec(webrtc.NewRTPVP8CodecExt(
|
||||
webrtc.DefaultPayloadTypeVP8, 90000,
|
||||
|
|
14
sfu.go
14
sfu.go
|
@ -8,6 +8,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
|
@ -22,10 +23,14 @@ import (
|
|||
|
||||
func main() {
|
||||
var cpuprofile, memprofile, mutexprofile, httpAddr, dataDir string
|
||||
var tcpPort int
|
||||
|
||||
flag.StringVar(&httpAddr, "http", ":8443", "web server `address`")
|
||||
flag.StringVar(&webserver.StaticRoot, "static", "./static/",
|
||||
"web server root `directory`")
|
||||
flag.IntVar(&tcpPort, "tcp-port", -1,
|
||||
"TCP listener `port`. If 0, an ephemeral port is used.\n"+
|
||||
"If -1, the TCP listerer is disabled")
|
||||
flag.StringVar(&dataDir, "data", "./data/",
|
||||
"data `directory`")
|
||||
flag.StringVar(&group.Directory, "groups", "./groups/",
|
||||
|
@ -80,6 +85,15 @@ func main() {
|
|||
|
||||
group.IceFilename = filepath.Join(dataDir, "ice-servers.json")
|
||||
|
||||
if tcpPort >= 0 {
|
||||
err := group.StartTCPListener(&net.TCPAddr{
|
||||
Port: tcpPort,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Couldn't start ICE TCP: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
go group.ReadPublicGroups()
|
||||
|
||||
serverDone := make(chan struct{})
|
||||
|
|
Loading…
Reference in a new issue