Archived
2
0

Fix WebRTC mux issues.

This commit is contained in:
Miroslav Šedivý 2022-12-13 23:40:22 +01:00
parent c8c39b0f83
commit bd73dfae9d
2 changed files with 14 additions and 7 deletions

View File

@ -2,6 +2,9 @@
## master branch ## master branch
### Bugs
- Fixed TCP mux occasional freeze by adding write buffer to it.
## [n.eko v2.7](https://github.com/m1k1o/neko/releases/tag/v2.7) ## [n.eko v2.7](https://github.com/m1k1o/neko/releases/tag/v2.7)
### New Features ### New Features

View File

@ -9,6 +9,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/pion/ice/v2"
"github.com/pion/interceptor" "github.com/pion/interceptor"
"github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v3/pkg/media" "github.com/pion/webrtc/v3/pkg/media"
@ -125,7 +126,12 @@ func (manager *WebRTCManager) initAPI() error {
return err return err
} }
tcpMux := webrtc.NewICETCPMux(logger.NewLogger("ice-tcp"), tcpListener, 32) tcpMux := ice.NewTCPMuxDefault(ice.TCPMuxParams{
Listener: tcpListener,
Logger: logger.NewLogger("ice-tcp"),
ReadBufferSize: 32, // receiving channel size
WriteBufferSize: 4 * 1024 * 1024, // write buffer size, 4MB
})
settings.SetICETCPMux(tcpMux) settings.SetICETCPMux(tcpMux)
networkType = append(networkType, webrtc.NetworkTypeTCP4) networkType = append(networkType, webrtc.NetworkTypeTCP4)
@ -134,20 +140,18 @@ func (manager *WebRTCManager) initAPI() error {
// Add UDP Mux // Add UDP Mux
if manager.config.UDPMUX > 0 { if manager.config.UDPMUX > 0 {
udpListener, err := net.ListenUDP("udp", &net.UDPAddr{ udpMux, err := ice.NewMultiUDPMuxFromPort(manager.config.UDPMUX,
IP: net.IP{0, 0, 0, 0}, ice.UDPMuxFromPortWithLogger(logger.NewLogger("ice-udp")),
Port: manager.config.UDPMUX, )
})
if err != nil { if err != nil {
return err return err
} }
udpMux := webrtc.NewICEUDPMux(logger.NewLogger("ice-udp"), udpListener)
settings.SetICEUDPMux(udpMux) settings.SetICEUDPMux(udpMux)
networkType = append(networkType, webrtc.NetworkTypeUDP4) networkType = append(networkType, webrtc.NetworkTypeUDP4)
manager.logger.Info().Str("listener", udpListener.LocalAddr().String()).Msg("using UDP MUX") manager.logger.Info().Int("port", manager.config.UDPMUX).Msg("using UDP MUX")
} }
// Enable support for TCP and UDP ICE candidates // Enable support for TCP and UDP ICE candidates