support setting read buffer size on macOS (#6128) (#6131)

This commit is contained in:
Alessandro Ros
2026-08-25 06:19:31 +00:00
committed by GitHub
parent ccf1b61e20
commit 3f2b3cd3f5
3 changed files with 5 additions and 39 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ require (
github.com/asticode/go-astits v1.16.0
github.com/bluenviron/gohlslib/v2 v2.4.3
github.com/bluenviron/gortmplib v1.0.1
github.com/bluenviron/gortsplib/v5 v5.6.4
github.com/bluenviron/gortsplib/v5 v5.6.5-0.20260824141635-0b2984eceb55
github.com/bluenviron/mediacommon/v2 v2.9.3
github.com/datarhei/gosrt v0.11.1-0.20260812091715-a77b40bb4b76
github.com/fsnotify/fsnotify v1.10.1
+2 -2
View File
@@ -37,8 +37,8 @@ github.com/bluenviron/gohlslib/v2 v2.4.3 h1:ej9Rl+iLoibazinoX8g721CTXp4VYsIVen9q
github.com/bluenviron/gohlslib/v2 v2.4.3/go.mod h1:8q/hhKxS0wALwPj7xQptVFbwePTSQc8kqcetaKWyUsk=
github.com/bluenviron/gortmplib v1.0.1 h1:+8DIpYvY6Ewyd159VNPauXV1uk/OU56knCDYDkisIrI=
github.com/bluenviron/gortmplib v1.0.1/go.mod h1:zOFIIBd09RX2WrgF1KdyOFz9la1bZCA5Jt5bEANMkDA=
github.com/bluenviron/gortsplib/v5 v5.6.4 h1:e3h1QMYUlh+c+yLvxqr6kPL/2dCH5Sk18XRm9k4u2zU=
github.com/bluenviron/gortsplib/v5 v5.6.4/go.mod h1:0bjv+O0C5AbH8SqrjvjOX67NNpHtpGBtmMEVMQQ6VXU=
github.com/bluenviron/gortsplib/v5 v5.6.5-0.20260824141635-0b2984eceb55 h1:GoeFP7rqEGMN72c+0VtsDrTwx2STm20YGkMkKCHmmH4=
github.com/bluenviron/gortsplib/v5 v5.6.5-0.20260824141635-0b2984eceb55/go.mod h1:9YjnvA/y3YhCMhaKvgneU8VTN8NoRU//Gri8xWwvJrU=
github.com/bluenviron/mediacommon/v2 v2.9.3 h1:cT52JxFnOG2EvI8Imp0sy0NZI773Id+QmY3eOEryR9Y=
github.com/bluenviron/mediacommon/v2 v2.9.3/go.mod h1:QHNpEjVsUnmP2tfYZ+hgQRfvupR1GRBUd2FJqSvC/qo=
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
+2 -36
View File
@@ -6,12 +6,12 @@ import (
"errors"
"fmt"
"reflect"
"runtime"
"sort"
"sync"
"syscall"
"time"
"github.com/bluenviron/gortsplib/v5/pkg/readbuffer"
srt "github.com/datarhei/gosrt"
"github.com/google/uuid"
@@ -115,41 +115,7 @@ func (s *Server) Initialize() error {
if s.UDPReadBufferSize > 0 {
bufSize := int(s.UDPReadBufferSize)
conf.ListenerControl = func(_, _ string, rawConn syscall.RawConn) error {
var err2 error
err := rawConn.Control(func(fd uintptr) {
err2 = syscall.SetsockoptInt(rawSocket(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, bufSize)
})
if err != nil {
return err
}
if err2 != nil {
return err2
}
var v int
err = rawConn.Control(func(fd uintptr) {
v, err2 = syscall.GetsockoptInt(rawSocket(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF)
})
if err != nil {
return err
}
if err2 != nil {
return err2
}
if runtime.GOOS != "windows" {
v /= 2 // on Linux, SO_RCVBUF is double the size of the actual buffer
}
if v != bufSize {
return fmt.Errorf("unable to set UDP read buffer size to %d, got %d, check that the operating system allows that",
bufSize, v)
}
return nil
return readbuffer.SetReadBufferRaw(rawConn, bufSize)
}
}