Skip to content

Commit

Permalink
webrtc: prevent pion/webrtc from writing log lines
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Nov 12, 2023
1 parent 5ae35af commit 7a2e56e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions internal/core/webrtc_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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[:])
Expand Down Expand Up @@ -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
Expand All @@ -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{
Expand Down

0 comments on commit 7a2e56e

Please sign in to comment.