Browse Source

update gohlslib (#1565)

pull/1566/head v0.21.6
Alessandro Ros 2 years ago committed by GitHub
parent
commit
f4b9133bb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .github/workflows/lint.yml
  2. 1
      .github/workflows/release.yml
  3. 1
      README.md
  4. 2
      go.mod
  5. 4
      go.sum
  6. 5
      internal/core/hls_muxer.go
  7. 8
      internal/core/hls_server.go

1
.github/workflows/lint.yml

@ -32,7 +32,6 @@ jobs: @@ -32,7 +32,6 @@ jobs:
go-version: "1.19"
- run: |
go mod download
go mod tidy
git diff --exit-code

1
.github/workflows/release.yml

@ -19,7 +19,6 @@ jobs: @@ -19,7 +19,6 @@ jobs:
- run: |
sed -i '/gortsplib/d' go.mod
go mod download
go mod tidy
git diff --exit-code

1
README.md

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
<h1 align="center">
<img src="logo.png" alt="MediaMTX / rtsp-simple-server">
</h1>

2
go.mod

@ -7,7 +7,7 @@ require ( @@ -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

4
go.sum

@ -12,8 +12,8 @@ github.com/asticode/go-astikit v0.30.0 h1:DkBkRQRIxYcknlaU7W7ksNfn4gMFsB0tqMJflx @@ -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=

5
internal/core/hls_muxer.go

@ -6,6 +6,7 @@ import ( @@ -6,6 +6,7 @@ import (
_ "embed"
"errors"
"fmt"
"io"
"net"
"net/http"
"sync"
@ -97,7 +98,6 @@ func newHLSMuxer( @@ -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{}) @@ -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 @@ -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)),
}
}
}

8
internal/core/hls_server.go

@ -204,7 +204,7 @@ outer: @@ -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: @@ -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) { @@ -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) { @@ -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 @@ -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,

Loading…
Cancel
Save