Browse Source

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

v4
dexter 2 years ago
parent
commit
657d08cc23
  1. 2
      go.mod
  2. 2
      go.sum
  3. 11
      main.go

2
go.mod

@ -5,7 +5,7 @@ go 1.18
require ( require (
github.com/pion/interceptor v0.1.11 github.com/pion/interceptor v0.1.11
github.com/pion/rtcp v1.2.9 github.com/pion/rtcp v1.2.9
github.com/pion/webrtc/v3 v3.1.43 github.com/pion/webrtc/v3 v3.1.44
m7s.live/engine/v4 v4.6.8 m7s.live/engine/v4 v4.6.8
) )

2
go.sum

@ -101,6 +101,8 @@ github.com/pion/udp v0.1.1 h1:8UAPvyqmsxK8oOjloDk4wUt63TzFe9WEJkg5lChlj7o=
github.com/pion/udp v0.1.1/go.mod h1:6AFo+CMdKQm7UiA0eUPA8/eVCTx8jBIITLZHc9DWX5M= github.com/pion/udp v0.1.1/go.mod h1:6AFo+CMdKQm7UiA0eUPA8/eVCTx8jBIITLZHc9DWX5M=
github.com/pion/webrtc/v3 v3.1.43 h1:YT3ZTO94UT4kSBvZnRAH82+0jJPUruiKr9CEstdlQzk= github.com/pion/webrtc/v3 v3.1.43 h1:YT3ZTO94UT4kSBvZnRAH82+0jJPUruiKr9CEstdlQzk=
github.com/pion/webrtc/v3 v3.1.43/go.mod h1:G/J8k0+grVsjC/rjCZ24AKoCCxcFFODgh7zThNZGs0M= github.com/pion/webrtc/v3 v3.1.43/go.mod h1:G/J8k0+grVsjC/rjCZ24AKoCCxcFFODgh7zThNZGs0M=
github.com/pion/webrtc/v3 v3.1.44 h1:uY11C9cOupY36bS3Q16NI298c/XKhl5S9EMCo/TxH3Y=
github.com/pion/webrtc/v3 v3.1.44/go.mod h1:G/J8k0+grVsjC/rjCZ24AKoCCxcFFODgh7zThNZGs0M=
github.com/pixelbender/go-sdp v1.1.0/go.mod h1:6IBlz9+BrUHoFTea7gcp4S54khtOhjCW/nVDLhmZBAs= github.com/pixelbender/go-sdp v1.1.0/go.mod h1:6IBlz9+BrUHoFTea7gcp4S54khtOhjCW/nVDLhmZBAs=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

11
main.go

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

Loading…
Cancel
Save