From f4b9133bb86a0a04567d4674864ff4911dc87ce2 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Sun, 12 Mar 2023 13:22:57 +0100 Subject: [PATCH] update gohlslib (#1565) --- .github/workflows/lint.yml | 1 - .github/workflows/release.yml | 1 - README.md | 1 - go.mod | 2 +- go.sum | 4 ++-- internal/core/hls_muxer.go | 5 +++-- internal/core/hls_server.go | 8 ++++---- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0ad3284d..a3cd304f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,7 +32,6 @@ jobs: go-version: "1.19" - run: | - go mod download go mod tidy git diff --exit-code diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ea89828a..6b1a4db4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,6 @@ jobs: - run: | sed -i '/gortsplib/d' go.mod - go mod download go mod tidy git diff --exit-code diff --git a/README.md b/README.md index 4f89ca6b..edb76c17 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -

MediaMTX / rtsp-simple-server

diff --git a/go.mod b/go.mod index bb603e4d..8313a58b 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/alecthomas/kong v0.7.1 github.com/aler9/gortsplib/v2 v2.1.4 github.com/asticode/go-astits v1.11.0 - github.com/bluenviron/gohlslib v0.0.0-20230310115623-ec8d496cca25 + github.com/bluenviron/gohlslib v0.0.0-20230312114838-5feec7e35841 github.com/fsnotify/fsnotify v1.4.9 github.com/gin-gonic/gin v1.9.0 github.com/google/uuid v1.3.0 diff --git a/go.sum b/go.sum index acf3ad9f..ab8696b4 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,8 @@ github.com/asticode/go-astikit v0.30.0 h1:DkBkRQRIxYcknlaU7W7ksNfn4gMFsB0tqMJflx github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0= github.com/asticode/go-astits v1.11.0 h1:GTHUXht0ZXAJXsVbsLIcyfHr1Bchi4QQwMARw2ZWAng= github.com/asticode/go-astits v1.11.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI= -github.com/bluenviron/gohlslib v0.0.0-20230310115623-ec8d496cca25 h1:F5rtyEy7a8yILctfOrWjuCAFQhL9MG3E+rWrG8gKZV8= -github.com/bluenviron/gohlslib v0.0.0-20230310115623-ec8d496cca25/go.mod h1:lIJHdX5oH3VLUfH3cjA+w3HGIswtgiriB9koNv6ZKCc= +github.com/bluenviron/gohlslib v0.0.0-20230312114838-5feec7e35841 h1:J5AIpE6ue/l/IgIlLCi/QQJL2MNBTFQrAkDScGbUaDs= +github.com/bluenviron/gohlslib v0.0.0-20230312114838-5feec7e35841/go.mod h1:SYixOK6Kux6cA9AGR1sg1GJdU2TmYiccVpPmS/Rxdt0= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA= github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= diff --git a/internal/core/hls_muxer.go b/internal/core/hls_muxer.go index a5c9a2f6..d914403a 100644 --- a/internal/core/hls_muxer.go +++ b/internal/core/hls_muxer.go @@ -6,6 +6,7 @@ import ( _ "embed" "errors" "fmt" + "io" "net" "net/http" "sync" @@ -97,7 +98,6 @@ func newHLSMuxer( partDuration conf.StringDuration, segmentMaxSize conf.StringSize, readBufferCount int, - req *hlsMuxerRequest, wg *sync.WaitGroup, pathName string, pathManager hlsMuxerPathManager, @@ -305,6 +305,7 @@ func (m *hlsMuxer) runInner(innerCtx context.Context, innerReady chan struct{}) uint64(m.segmentMaxSize), videoFormat, audioFormat, + "", ) if err != nil { return fmt.Errorf("muxer error: %v", err) @@ -540,7 +541,7 @@ func (m *hlsMuxer) handleRequest(req *hlsMuxerRequest) func() *hls.MuxerFileResp Header: map[string]string{ "Content-Type": `text/html`, }, - Body: bytes.NewReader(hlsIndex), + Body: io.NopCloser(bytes.NewReader(hlsIndex)), } } } diff --git a/internal/core/hls_server.go b/internal/core/hls_server.go index 08c8652d..35ed3de1 100644 --- a/internal/core/hls_server.go +++ b/internal/core/hls_server.go @@ -204,7 +204,7 @@ outer: select { case pa := <-s.chPathSourceReady: if s.alwaysRemux { - s.createMuxer(pa.name, "", nil) + s.createMuxer(pa.name, "") } case pa := <-s.chPathSourceNotReady: @@ -226,7 +226,7 @@ outer: req.res <- nil default: - r := s.createMuxer(req.path, req.ctx.ClientIP(), req) + r := s.createMuxer(req.path, req.ctx.ClientIP()) r.processRequest(req) } @@ -331,6 +331,7 @@ func (s *hlsServer) onRequest(ctx *gin.Context) { ctx.Writer.WriteHeader(res.Status) if res.Body != nil { + defer res.Body.Close() n, _ := io.Copy(ctx.Writer, res.Body) res1.muxer.addSentBytes(uint64(n)) } @@ -340,7 +341,7 @@ func (s *hlsServer) onRequest(ctx *gin.Context) { } } -func (s *hlsServer) createMuxer(pathName string, remoteAddr string, req *hlsMuxerRequest) *hlsMuxer { +func (s *hlsServer) createMuxer(pathName string, remoteAddr string) *hlsMuxer { r := newHLSMuxer( s.ctx, pathName, @@ -353,7 +354,6 @@ func (s *hlsServer) createMuxer(pathName string, remoteAddr string, req *hlsMuxe s.partDuration, s.segmentMaxSize, s.readBufferCount, - req, &s.wg, pathName, s.pathManager,