Browse Source

hls: apply readTimeout to HLS sources (#2627)

pull/2628/head
Alessandro Ros 2 years ago committed by GitHub
parent
commit
15f1c73314
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      internal/core/static_source_handler.go
  2. 5
      internal/staticsources/hls/source.go
  3. 3
      internal/staticsources/webrtc/source.go

3
internal/core/static_source_handler.go

@ -83,7 +83,8 @@ func newStaticSourceHandler( @@ -83,7 +83,8 @@ func newStaticSourceHandler(
case strings.HasPrefix(cnf.Source, "http://") ||
strings.HasPrefix(cnf.Source, "https://"):
s.instance = &hlssource.Source{
Parent: s,
ReadTimeout: readTimeout,
Parent: s,
}
case strings.HasPrefix(cnf.Source, "udp://"):

5
internal/staticsources/hls/source.go

@ -10,6 +10,7 @@ import ( @@ -10,6 +10,7 @@ import (
"github.com/bluenviron/gortsplib/v4/pkg/description"
"github.com/bluenviron/gortsplib/v4/pkg/format"
"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/logger"
"github.com/bluenviron/mediamtx/internal/protocols/tls"
@ -19,7 +20,8 @@ import ( @@ -19,7 +20,8 @@ import (
// Source is a HLS static source.
type Source struct {
Parent defs.StaticSourceParent
ReadTimeout conf.StringDuration
Parent defs.StaticSourceParent
}
// Log implements StaticSource.
@ -43,6 +45,7 @@ func (s *Source) Run(params defs.StaticSourceRunParams) error { @@ -43,6 +45,7 @@ func (s *Source) Run(params defs.StaticSourceRunParams) error {
c = &gohlslib.Client{
URI: params.Conf.Source,
HTTPClient: &http.Client{
Timeout: time.Duration(s.ReadTimeout),
Transport: &http.Transport{
TLSClientConfig: tls.ConfigForFingerprint(params.Conf.SourceFingerprint),
},

3
internal/staticsources/webrtc/source.go

@ -20,8 +20,7 @@ import ( @@ -20,8 +20,7 @@ import (
// Source is a WebRTC static source.
type Source struct {
ReadTimeout conf.StringDuration
Parent defs.StaticSourceParent
Parent defs.StaticSourceParent
}
// Log implements StaticSource.

Loading…
Cancel
Save