webrtc: prevent pion/webrtc from writing log lines (#2681)

This commit is contained in:
Alessandro Ros 2023-11-12 13:46:25 +01:00 committed by GitHub
parent 5ae35af464
commit 83a3086de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

2
go.mod
View File

@ -20,6 +20,7 @@ require (
github.com/notedit/rtmp v0.0.2
github.com/pion/ice/v2 v2.3.11
github.com/pion/interceptor v0.1.25
github.com/pion/logging v0.2.2
github.com/pion/rtcp v1.2.12
github.com/pion/rtp v1.8.3
github.com/pion/sdp/v3 v3.0.6
@ -52,7 +53,6 @@ require (
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pion/datachannel v1.5.5 // indirect
github.com/pion/dtls/v2 v2.2.7 // indirect
github.com/pion/logging v0.2.2 // indirect
github.com/pion/mdns v0.0.8 // indirect
github.com/pion/randutil v0.1.0 // indirect
github.com/pion/sctp v1.8.8 // indirect

View File

@ -16,6 +16,7 @@ import (
"github.com/google/uuid"
"github.com/pion/ice/v2"
"github.com/pion/logging"
pwebrtc "github.com/pion/webrtc/v3"
"github.com/bluenviron/mediamtx/internal/conf"
@ -32,6 +33,14 @@ const (
webrtcPayloadMaxSize = 1188 // 1200 - 12 (RTP header)
)
type nilWriter struct{}
func (nilWriter) Write(p []byte) (int, error) {
return len(p), nil
}
var webrtcNilLogger = logging.NewDefaultLeveledLoggerForScope("", 0, &nilWriter{})
func randInt63() (int64, error) {
var b [8]byte
_, err := rand.Read(b[:])
@ -257,7 +266,7 @@ func newWebRTCManager(
ctxCancel()
return nil, err
}
iceUDPMux = pwebrtc.NewICEUDPMux(nil, m.udpMuxLn)
iceUDPMux = pwebrtc.NewICEUDPMux(webrtcNilLogger, m.udpMuxLn)
}
var iceTCPMux ice.TCPMux
@ -270,7 +279,7 @@ func newWebRTCManager(
ctxCancel()
return nil, err
}
iceTCPMux = pwebrtc.NewICETCPMux(nil, m.tcpMuxLn, 8)
iceTCPMux = pwebrtc.NewICETCPMux(webrtcNilLogger, m.tcpMuxLn, 8)
}
m.api, err = webrtc.NewAPI(webrtc.APIConf{