Skip to content

Commit

Permalink
hls: apply readTimeout to HLS sources (bluenviron#2627)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Nov 2, 2023
1 parent 68b862c commit 15f1c73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/core/static_source_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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://"):
Expand Down
5 changes: 4 additions & 1 deletion internal/staticsources/hls/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand All @@ -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),
},
Expand Down
3 changes: 1 addition & 2 deletions internal/staticsources/webrtc/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 15f1c73

Please sign in to comment.