From 13fa14168fba0c57b127d8ffe611e10b4b888c2e Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Thu, 23 Feb 2023 15:20:02 +0100 Subject: [PATCH] tests: fix race condition in TestHLSSource (#1506) --- internal/core/hls_source_test.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/internal/core/hls_source_test.go b/internal/core/hls_source_test.go index c011974c..11cdf8a2 100644 --- a/internal/core/hls_source_test.go +++ b/internal/core/hls_source_test.go @@ -88,8 +88,7 @@ func (ts *testHLSServer) onSegment1(ctx *gin.Context) { mux.WriteTables() enc, _ := h264.AnnexBMarshal([][]byte{ - {7, 1, 2, 3}, // SPS - {8}, // PPS + {1}, // non-IDR }) mux.WriteData(&astits.MuxerData{ @@ -153,6 +152,26 @@ func (ts *testHLSServer) onSegment2(ctx *gin.Context) { mux.WriteTables() + enc, _ := h264.AnnexBMarshal([][]byte{ + {7, 1, 2, 3}, // SPS + {8}, // PPS + }) + + mux.WriteData(&astits.MuxerData{ + PID: 256, + PES: &astits.PESData{ + Header: &astits.PESHeader{ + OptionalHeader: &astits.PESOptionalHeader{ + MarkerBits: 2, + PTSDTSIndicator: astits.PTSDTSIndicatorOnlyPTS, + PTS: &astits.ClockReference{Base: int64(2 * 90000)}, + }, + StreamID: 224, // = video + }, + Data: enc, + }, + }) + pkts := mpeg4audio.ADTSPackets{ { Type: 2, @@ -161,7 +180,7 @@ func (ts *testHLSServer) onSegment2(ctx *gin.Context) { AU: []byte{0x01, 0x02, 0x03, 0x04}, }, } - enc, _ := pkts.Marshal() + enc, _ = pkts.Marshal() mux.WriteData(&astits.MuxerData{ PID: 257,