Skip to content

Commit

Permalink
update gohlslib (#1565)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Mar 12, 2023
1 parent 45727a6 commit f4b9133
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
go-version: "1.19"

- run: |
go mod download
go mod tidy
git diff --exit-code
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:

- run: |
sed -i '/gortsplib/d' go.mod
go mod download
go mod tidy
git diff --exit-code
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<h1 align="center">
<img src="logo.png" alt="MediaMTX / rtsp-simple-server">
</h1>
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
5 changes: 3 additions & 2 deletions internal/core/hls_muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
_ "embed"
"errors"
"fmt"
"io"
"net"
"net/http"
"sync"
Expand Down Expand Up @@ -97,7 +98,6 @@ func newHLSMuxer(
partDuration conf.StringDuration,
segmentMaxSize conf.StringSize,
readBufferCount int,
req *hlsMuxerRequest,
wg *sync.WaitGroup,
pathName string,
pathManager hlsMuxerPathManager,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)),
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions internal/core/hls_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
}

Expand Down Expand Up @@ -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))
}
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit f4b9133

Please sign in to comment.