From 35b3541e4fc4830cb3e3079efb5f43bd1ab19c06 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Fri, 29 Apr 2022 12:02:11 +0200 Subject: [PATCH] hls client: add limit on AU size --- go.mod | 2 +- go.sum | 4 ++-- internal/core/hls_source_test.go | 4 ++-- internal/core/rtmp_conn.go | 4 ++-- internal/core/rtmp_source.go | 2 +- internal/hls/client_test.go | 2 +- internal/hls/client_video_processor.go | 2 +- internal/hls/muxer_ts_generator.go | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 4b37fd77..c4e27ecf 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5 - github.com/aler9/gortsplib v0.0.0-20220421115218-aa09a71cf4b1 + github.com/aler9/gortsplib v0.0.0-20220429092609-4a4cc67128f1 github.com/asticode/go-astits v1.10.1-0.20220319093903-4abe66a9b757 github.com/fsnotify/fsnotify v1.4.9 github.com/gin-gonic/gin v1.7.2 diff --git a/go.sum b/go.sum index fb3c64dd..bdcc6b41 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/aler9/gortsplib v0.0.0-20220421115218-aa09a71cf4b1 h1:reXoDO1Ew8q6Kfm/5dcOrhGIkSPoJ81e/wY05nyIxVM= -github.com/aler9/gortsplib v0.0.0-20220421115218-aa09a71cf4b1/go.mod h1:Mezkz7Jb5zrIWP6MxJ2uBgt5xwywZkcdmuQZ2QrFYsM= +github.com/aler9/gortsplib v0.0.0-20220429092609-4a4cc67128f1 h1:UrUPMao/+e88YSA2lvySPesQ7tbzExxcMkHVbGU0rZg= +github.com/aler9/gortsplib v0.0.0-20220429092609-4a4cc67128f1/go.mod h1:Mezkz7Jb5zrIWP6MxJ2uBgt5xwywZkcdmuQZ2QrFYsM= github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927 h1:95mXJ5fUCYpBRdSOnLAQAdJHHKxxxJrVCiaqDi965YQ= github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927/go.mod h1:vzuE21rowz+lT1NGsWbreIvYulgBpCGnQyeTyFblUHc= github.com/asticode/go-astikit v0.20.0 h1:+7N+J4E4lWx2QOkRdOf6DafWJMv6O4RRfgClwQokrH8= diff --git a/internal/core/hls_source_test.go b/internal/core/hls_source_test.go index ba1caced..73a9d6b7 100644 --- a/internal/core/hls_source_test.go +++ b/internal/core/hls_source_test.go @@ -70,7 +70,7 @@ func (ts *testHLSServer) onSegment(ctx *gin.Context) { mux.WriteTables() - enc, _ := h264.EncodeAnnexB([][]byte{ + enc, _ := h264.AnnexBEncode([][]byte{ {7, 1, 2, 3}, // SPS {8}, // PPS }) @@ -94,7 +94,7 @@ func (ts *testHLSServer) onSegment(ctx *gin.Context) { time.Sleep(1 * time.Second) - enc, _ = h264.EncodeAnnexB([][]byte{ + enc, _ = h264.AnnexBEncode([][]byte{ {5}, // IDR }) diff --git a/internal/core/rtmp_conn.go b/internal/core/rtmp_conn.go index 18ac0f15..5e908df6 100644 --- a/internal/core/rtmp_conn.go +++ b/internal/core/rtmp_conn.go @@ -386,7 +386,7 @@ func (c *rtmpConn) runRead(ctx context.Context) error { } } - avcc, err := h264.EncodeAVCC(data.h264NALUs) + avcc, err := h264.AVCCEncode(data.h264NALUs) if err != nil { return err } @@ -565,7 +565,7 @@ func (c *rtmpConn) runPublish(ctx context.Context) error { return fmt.Errorf("received an H264 packet, but track is not set up") } - nalus, err := h264.DecodeAVCC(pkt.Data) + nalus, err := h264.AVCCDecode(pkt.Data) if err != nil { return err } diff --git a/internal/core/rtmp_source.go b/internal/core/rtmp_source.go index 3608a3c2..55ff268b 100644 --- a/internal/core/rtmp_source.go +++ b/internal/core/rtmp_source.go @@ -182,7 +182,7 @@ func (s *rtmpSource) runInner() bool { return fmt.Errorf("received an H264 packet, but track is not set up") } - nalus, err := h264.DecodeAVCC(pkt.Data) + nalus, err := h264.AVCCDecode(pkt.Data) if err != nil { return err } diff --git a/internal/hls/client_test.go b/internal/hls/client_test.go index ac3d8f3c..6ce3292c 100644 --- a/internal/hls/client_test.go +++ b/internal/hls/client_test.go @@ -142,7 +142,7 @@ func newTestHLSServer(ca string) (*testHLSServer, error) { mux.SetPCRPID(256) mux.WriteTables() - enc, _ := h264.EncodeAnnexB([][]byte{ + enc, _ := h264.AnnexBEncode([][]byte{ {7, 1, 2, 3}, // SPS {8}, // PPS {5}, // IDR diff --git a/internal/hls/client_video_processor.go b/internal/hls/client_video_processor.go index c7fbfece..9e038988 100644 --- a/internal/hls/client_video_processor.go +++ b/internal/hls/client_video_processor.go @@ -83,7 +83,7 @@ func (p *clientVideoProcessor) doProcess( } } - nalus, err := h264.DecodeAnnexB(data) + nalus, err := h264.AnnexBDecode(data) if err != nil { p.logger.Log(logger.Warn, "unable to decode Annex-B: %s", err) return nil diff --git a/internal/hls/muxer_ts_generator.go b/internal/hls/muxer_ts_generator.go index e1074284..a981ed41 100644 --- a/internal/hls/muxer_ts_generator.go +++ b/internal/hls/muxer_ts_generator.go @@ -117,7 +117,7 @@ func (m *muxerTSGenerator) writeH264(pts time.Duration, nalus [][]byte) error { // prepend an AUD. This is required by video.js and iOS nalus = append([][]byte{{byte(h264.NALUTypeAccessUnitDelimiter), 240}}, nalus...) - enc, err := h264.EncodeAnnexB(nalus) + enc, err := h264.AnnexBEncode(nalus) if err != nil { if m.currentSegment.buf.Len() > 0 { m.streamPlaylist.pushSegment(m.currentSegment)