accept durations expressed as days (i.e. '1d') (#4094)

This commit is contained in:
Alessandro Ros 2025-01-02 12:44:15 +01:00 committed by GitHub
parent 8cbbbc05c3
commit b49acb1e00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 378 additions and 257 deletions

View file

@ -42,7 +42,7 @@ type httpServer struct {
serverCert string
allowOrigin string
trustedProxies conf.IPNetworks
readTimeout conf.StringDuration
readTimeout conf.Duration
pathManager serverPathManager
parent *Server

View file

@ -50,11 +50,11 @@ type muxer struct {
remoteAddr string
variant conf.HLSVariant
segmentCount int
segmentDuration conf.StringDuration
partDuration conf.StringDuration
segmentDuration conf.Duration
partDuration conf.Duration
segmentMaxSize conf.StringSize
directory string
closeAfter conf.StringDuration
closeAfter conf.Duration
wg *sync.WaitGroup
pathName string
pathManager serverPathManager

View file

@ -17,8 +17,8 @@ import (
type muxerInstance struct {
variant conf.HLSVariant
segmentCount int
segmentDuration conf.StringDuration
partDuration conf.StringDuration
segmentDuration conf.Duration
partDuration conf.Duration
segmentMaxSize conf.StringSize
directory string
pathName string

View file

@ -69,12 +69,12 @@ type Server struct {
AlwaysRemux bool
Variant conf.HLSVariant
SegmentCount int
SegmentDuration conf.StringDuration
PartDuration conf.StringDuration
SegmentDuration conf.Duration
PartDuration conf.Duration
SegmentMaxSize conf.StringSize
Directory string
ReadTimeout conf.StringDuration
MuxerCloseAfter conf.StringDuration
ReadTimeout conf.Duration
MuxerCloseAfter conf.Duration
PathManager serverPathManager
Parent serverParent

View file

@ -65,7 +65,7 @@ func TestPreflightRequest(t *testing.T) {
s := &Server{
Address: "127.0.0.1:8888",
AllowOrigin: "*",
ReadTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
Parent: test.NilLogger,
}
err := s.Initialize()
@ -122,13 +122,13 @@ func TestServerNotFound(t *testing.T) {
AlwaysRemux: ca == "always remux on",
Variant: conf.HLSVariant(gohlslib.MuxerVariantMPEGTS),
SegmentCount: 7,
SegmentDuration: conf.StringDuration(1 * time.Second),
PartDuration: conf.StringDuration(200 * time.Millisecond),
SegmentDuration: conf.Duration(1 * time.Second),
PartDuration: conf.Duration(200 * time.Millisecond),
SegmentMaxSize: 50 * 1024 * 1024,
AllowOrigin: "",
TrustedProxies: conf.IPNetworks{},
Directory: "",
ReadTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
PathManager: pm,
Parent: test.NilLogger,
}
@ -195,13 +195,13 @@ func TestServerRead(t *testing.T) {
AlwaysRemux: false,
Variant: conf.HLSVariant(gohlslib.MuxerVariantMPEGTS),
SegmentCount: 7,
SegmentDuration: conf.StringDuration(1 * time.Second),
PartDuration: conf.StringDuration(200 * time.Millisecond),
SegmentDuration: conf.Duration(1 * time.Second),
PartDuration: conf.Duration(200 * time.Millisecond),
SegmentMaxSize: 50 * 1024 * 1024,
AllowOrigin: "",
TrustedProxies: conf.IPNetworks{},
Directory: "",
ReadTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
PathManager: pm,
Parent: test.NilLogger,
}
@ -290,13 +290,13 @@ func TestServerRead(t *testing.T) {
AlwaysRemux: true,
Variant: conf.HLSVariant(gohlslib.MuxerVariantMPEGTS),
SegmentCount: 7,
SegmentDuration: conf.StringDuration(1 * time.Second),
PartDuration: conf.StringDuration(200 * time.Millisecond),
SegmentDuration: conf.Duration(1 * time.Second),
PartDuration: conf.Duration(200 * time.Millisecond),
SegmentMaxSize: 50 * 1024 * 1024,
AllowOrigin: "",
TrustedProxies: conf.IPNetworks{},
Directory: "",
ReadTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
PathManager: pm,
Parent: test.NilLogger,
}
@ -385,13 +385,13 @@ func TestDirectory(t *testing.T) {
AlwaysRemux: true,
Variant: conf.HLSVariant(gohlslib.MuxerVariantMPEGTS),
SegmentCount: 7,
SegmentDuration: conf.StringDuration(1 * time.Second),
PartDuration: conf.StringDuration(200 * time.Millisecond),
SegmentDuration: conf.Duration(1 * time.Second),
PartDuration: conf.Duration(200 * time.Millisecond),
SegmentMaxSize: 50 * 1024 * 1024,
AllowOrigin: "",
TrustedProxies: conf.IPNetworks{},
Directory: filepath.Join(dir, "mydir"),
ReadTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
PathManager: pm,
Parent: test.NilLogger,
}

View file

@ -42,8 +42,8 @@ type conn struct {
parentCtx context.Context
isTLS bool
rtspAddress string
readTimeout conf.StringDuration
writeTimeout conf.StringDuration
readTimeout conf.Duration
writeTimeout conf.Duration
runOnConnect string
runOnConnectRestart bool
runOnDisconnect string

View file

@ -64,8 +64,8 @@ type serverParent interface {
// Server is a RTMP server.
type Server struct {
Address string
ReadTimeout conf.StringDuration
WriteTimeout conf.StringDuration
ReadTimeout conf.Duration
WriteTimeout conf.Duration
IsTLS bool
ServerCert string
ServerKey string

View file

@ -109,8 +109,8 @@ func TestServerPublish(t *testing.T) {
s := &Server{
Address: "127.0.0.1:1935",
ReadTimeout: conf.StringDuration(10 * time.Second),
WriteTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
WriteTimeout: conf.Duration(10 * time.Second),
IsTLS: encrypt == "tls",
ServerCert: serverCertFpath,
ServerKey: serverKeyFpath,
@ -220,8 +220,8 @@ func TestServerRead(t *testing.T) {
s := &Server{
Address: "127.0.0.1:1935",
ReadTimeout: conf.StringDuration(10 * time.Second),
WriteTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
WriteTimeout: conf.Duration(10 * time.Second),
IsTLS: encrypt == "tls",
ServerCert: serverCertFpath,
ServerKey: serverKeyFpath,

View file

@ -32,7 +32,7 @@ type conn struct {
isTLS bool
rtspAddress string
authMethods []rtspauth.ValidateMethod
readTimeout conf.StringDuration
readTimeout conf.Duration
runOnConnect string
runOnConnectRestart bool
runOnDisconnect string

View file

@ -61,8 +61,8 @@ type serverParent interface {
type Server struct {
Address string
AuthMethods []auth.ValidateMethod
ReadTimeout conf.StringDuration
WriteTimeout conf.StringDuration
ReadTimeout conf.Duration
WriteTimeout conf.Duration
WriteQueueSize int
UseUDP bool
UseMulticast bool

View file

@ -94,8 +94,8 @@ func TestServerPublish(t *testing.T) {
s := &Server{
Address: "127.0.0.1:8557",
AuthMethods: []auth.ValidateMethod{auth.ValidateMethodBasic},
ReadTimeout: conf.StringDuration(10 * time.Second),
WriteTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
WriteTimeout: conf.Duration(10 * time.Second),
WriteQueueSize: 512,
UseUDP: false,
UseMulticast: false,
@ -188,8 +188,8 @@ func TestServerRead(t *testing.T) {
s := &Server{
Address: "127.0.0.1:8557",
AuthMethods: []auth.ValidateMethod{auth.ValidateMethodBasic},
ReadTimeout: conf.StringDuration(10 * time.Second),
WriteTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
WriteTimeout: conf.Duration(10 * time.Second),
WriteQueueSize: 512,
UseUDP: false,
UseMulticast: false,

View file

@ -51,8 +51,8 @@ const (
type conn struct {
parentCtx context.Context
rtspAddress string
readTimeout conf.StringDuration
writeTimeout conf.StringDuration
readTimeout conf.Duration
writeTimeout conf.Duration
udpMaxPayloadSize int
connReq srt.ConnRequest
runOnConnect string

View file

@ -67,8 +67,8 @@ type serverParent interface {
type Server struct {
Address string
RTSPAddress string
ReadTimeout conf.StringDuration
WriteTimeout conf.StringDuration
ReadTimeout conf.Duration
WriteTimeout conf.Duration
UDPMaxPayloadSize int
RunOnConnect string
RunOnConnectRestart bool

View file

@ -91,8 +91,8 @@ func TestServerPublish(t *testing.T) {
s := &Server{
Address: "127.0.0.1:8890",
RTSPAddress: "",
ReadTimeout: conf.StringDuration(10 * time.Second),
WriteTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
WriteTimeout: conf.Duration(10 * time.Second),
UDPMaxPayloadSize: 1472,
RunOnConnect: "",
RunOnConnectRestart: false,
@ -192,8 +192,8 @@ func TestServerRead(t *testing.T) {
s := &Server{
Address: "127.0.0.1:8890",
RTSPAddress: "",
ReadTimeout: conf.StringDuration(10 * time.Second),
WriteTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
WriteTimeout: conf.Duration(10 * time.Second),
UDPMaxPayloadSize: 1472,
RunOnConnect: "",
RunOnConnectRestart: false,

View file

@ -79,7 +79,7 @@ type httpServer struct {
serverCert string
allowOrigin string
trustedProxies conf.IPNetworks
readTimeout conf.StringDuration
readTimeout conf.Duration
pathManager serverPathManager
parent *Server

View file

@ -181,15 +181,15 @@ type Server struct {
ServerCert string
AllowOrigin string
TrustedProxies conf.IPNetworks
ReadTimeout conf.StringDuration
ReadTimeout conf.Duration
LocalUDPAddress string
LocalTCPAddress string
IPsFromInterfaces bool
IPsFromInterfacesList []string
AdditionalHosts []string
ICEServers []conf.WebRTCICEServer
HandshakeTimeout conf.StringDuration
TrackGatherTimeout conf.StringDuration
HandshakeTimeout conf.Duration
TrackGatherTimeout conf.Duration
ExternalCmdPool *externalcmd.Pool
PathManager serverPathManager
Parent serverParent

View file

@ -108,15 +108,15 @@ func initializeTestServer(t *testing.T) *Server {
ServerCert: "",
AllowOrigin: "*",
TrustedProxies: conf.IPNetworks{},
ReadTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
LocalUDPAddress: "127.0.0.1:8887",
LocalTCPAddress: "127.0.0.1:8887",
IPsFromInterfaces: true,
IPsFromInterfacesList: []string{},
AdditionalHosts: []string{},
ICEServers: []conf.WebRTCICEServer{},
HandshakeTimeout: conf.StringDuration(10 * time.Second),
TrackGatherTimeout: conf.StringDuration(2 * time.Second),
HandshakeTimeout: conf.Duration(10 * time.Second),
TrackGatherTimeout: conf.Duration(2 * time.Second),
ExternalCmdPool: nil,
PathManager: pm,
Parent: test.NilLogger,
@ -192,7 +192,7 @@ func TestServerOptionsICEServer(t *testing.T) {
ServerCert: "",
AllowOrigin: "",
TrustedProxies: conf.IPNetworks{},
ReadTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
LocalUDPAddress: "127.0.0.1:8887",
LocalTCPAddress: "127.0.0.1:8887",
IPsFromInterfaces: true,
@ -203,8 +203,8 @@ func TestServerOptionsICEServer(t *testing.T) {
Username: "myuser",
Password: "mypass",
}},
HandshakeTimeout: conf.StringDuration(10 * time.Second),
TrackGatherTimeout: conf.StringDuration(2 * time.Second),
HandshakeTimeout: conf.Duration(10 * time.Second),
TrackGatherTimeout: conf.Duration(2 * time.Second),
ExternalCmdPool: nil,
PathManager: pathManager,
Parent: test.NilLogger,
@ -260,15 +260,15 @@ func TestServerPublish(t *testing.T) {
ServerCert: "",
AllowOrigin: "",
TrustedProxies: conf.IPNetworks{},
ReadTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
LocalUDPAddress: "127.0.0.1:8887",
LocalTCPAddress: "127.0.0.1:8887",
IPsFromInterfaces: true,
IPsFromInterfacesList: []string{},
AdditionalHosts: []string{},
ICEServers: []conf.WebRTCICEServer{},
HandshakeTimeout: conf.StringDuration(10 * time.Second),
TrackGatherTimeout: conf.StringDuration(2 * time.Second),
HandshakeTimeout: conf.Duration(10 * time.Second),
TrackGatherTimeout: conf.Duration(2 * time.Second),
ExternalCmdPool: nil,
PathManager: pathManager,
Parent: test.NilLogger,
@ -541,15 +541,15 @@ func TestServerRead(t *testing.T) {
ServerCert: "",
AllowOrigin: "",
TrustedProxies: conf.IPNetworks{},
ReadTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
LocalUDPAddress: "127.0.0.1:8887",
LocalTCPAddress: "127.0.0.1:8887",
IPsFromInterfaces: true,
IPsFromInterfacesList: []string{},
AdditionalHosts: []string{},
ICEServers: []conf.WebRTCICEServer{},
HandshakeTimeout: conf.StringDuration(10 * time.Second),
TrackGatherTimeout: conf.StringDuration(2 * time.Second),
HandshakeTimeout: conf.Duration(10 * time.Second),
TrackGatherTimeout: conf.Duration(2 * time.Second),
ExternalCmdPool: nil,
PathManager: pathManager,
Parent: test.NilLogger,
@ -629,15 +629,15 @@ func TestServerReadNotFound(t *testing.T) {
ServerCert: "",
AllowOrigin: "",
TrustedProxies: conf.IPNetworks{},
ReadTimeout: conf.StringDuration(10 * time.Second),
ReadTimeout: conf.Duration(10 * time.Second),
LocalUDPAddress: "127.0.0.1:8887",
LocalTCPAddress: "127.0.0.1:8887",
IPsFromInterfaces: true,
IPsFromInterfacesList: []string{},
AdditionalHosts: []string{},
ICEServers: []conf.WebRTCICEServer{},
HandshakeTimeout: conf.StringDuration(10 * time.Second),
TrackGatherTimeout: conf.StringDuration(2 * time.Second),
HandshakeTimeout: conf.Duration(10 * time.Second),
TrackGatherTimeout: conf.Duration(2 * time.Second),
ExternalCmdPool: nil,
PathManager: pm,
Parent: test.NilLogger,