👌 IMPROVE:增加对端口监听的判断

This commit is contained in:
dexter
2022-09-24 21:02:09 +08:00
parent 177cbc3f65
commit 657d08cc23
3 changed files with 11 additions and 4 deletions

11
main.go
View File

@@ -2,12 +2,14 @@ package webrtc
import (
"io/ioutil"
"m7s.live/engine/v4"
"net"
"net/http"
"regexp"
"time"
"go.uber.org/zap"
"m7s.live/engine/v4"
"github.com/pion/interceptor"
. "github.com/pion/webrtc/v3"
@@ -77,11 +79,14 @@ func (conf *WebRTCConfig) OnEvent(event any) {
// 是否多路复用UDP端口
if conf.InvitePortFixed {
// 创建共享WEBRTC端口 默认9000
udpListener, _ := net.ListenUDP("udp", &net.UDPAddr{
udpListener, err := net.ListenUDP("udp", &net.UDPAddr{
IP: net.IP{0, 0, 0, 0},
Port: conf.IceUdpMux,
})
if err != nil {
plugin.Fatal("webrtc listener udp", zap.Error(err))
}
plugin.Info("webrtc start listen", zap.Int("port", conf.IceUdpMux))
conf.s.SetICEUDPMux(NewICEUDPMux(nil, udpListener))
}