From b4e4f54729919a6de70b3fdc2a56990fd3341742 Mon Sep 17 00:00:00 2001 From: boenshao <65853605+boenshao@users.noreply.github.com> Date: Sun, 23 Nov 2025 07:41:55 +0800 Subject: [PATCH] test: fix and assert that all tracks are recorded (#5166) Co-authored-by: aler9 <46489434+aler9@users.noreply.github.com> --- internal/recorder/recorder_test.go | 93 ++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 6 deletions(-) diff --git a/internal/recorder/recorder_test.go b/internal/recorder/recorder_test.go index adf516ca..6e1b8a3f 100644 --- a/internal/recorder/recorder_test.go +++ b/internal/recorder/recorder_test.go @@ -90,9 +90,22 @@ func TestRecorder(t *testing.T) { strm.WriteUnit(desc.Medias[1], desc.Medias[1].Formats[0], &unit.Unit{ PTS: pts, Payload: unit.PayloadH265{ - test.FormatH265.VPS, - test.FormatH265.SPS, - test.FormatH265.PPS, + { + 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, + 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x78, 0xba, 0x02, 0x40, + }, + { + 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, + 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, + 0x00, 0x78, 0xa0, 0x03, 0xc0, 0x80, 0x11, 0x07, + 0xcb, 0x96, 0xe9, 0x29, 0x30, 0xbc, 0x05, 0xa0, + 0x20, 0x00, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, + 0x03, 0x03, 0xc1, + }, + { + 0x44, 0x01, 0xc0, 0x73, 0xc1, 0x89, + }, {0x26, 0x1, 0xaf, 0x8, 0x42, 0x23, 0x48, 0x8a, 0x43, 0xe2}, }, }) @@ -238,9 +251,22 @@ func TestRecorder(t *testing.T) { ID: 2, TimeScale: 90000, Codec: &mp4.CodecH265{ - VPS: test.FormatH265.VPS, - SPS: test.FormatH265.SPS, - PPS: test.FormatH265.PPS, + VPS: []byte{ + 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, + 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x78, 0xba, 0x02, 0x40, + }, + SPS: []byte{ + 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, + 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, + 0x00, 0x78, 0xa0, 0x03, 0xc0, 0x80, 0x11, 0x07, + 0xcb, 0x96, 0xe9, 0x29, 0x30, 0xbc, 0x05, 0xa0, + 0x20, 0x00, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, + 0x03, 0x03, 0xc1, + }, + PPS: []byte{ + 0x44, 0x01, 0xc0, 0x73, 0xc1, 0x89, + }, }, }, { @@ -307,6 +333,61 @@ func TestRecorder(t *testing.T) { _, err = os.Stat(filepath.Join(dir, "mypath", "2010-05-20_22-15-25-000000."+ext)) require.NoError(t, err) + + if ca == "fmp4" { + var byts []byte + byts, err = os.ReadFile(filepath.Join(dir, "mypath", "2008-05-20_22-15-25-000000.mp4")) + require.NoError(t, err) + + var parts fmp4.Parts + err = parts.Unmarshal(byts) + require.NoError(t, err) + + for _, part := range parts { + for _, track := range part.Tracks { + track.Samples = nil + } + } + + require.Equal(t, fmp4.Parts{ + { + Tracks: []*fmp4.PartTrack{{ + ID: 1, + }}, + }, + { + SequenceNumber: 1, + Tracks: []*fmp4.PartTrack{{ + ID: 2, + }}, + }, + { + SequenceNumber: 2, + Tracks: []*fmp4.PartTrack{{ + ID: 3, + }}, + }, + { + SequenceNumber: 3, + Tracks: []*fmp4.PartTrack{{ + ID: 4, + }}, + }, + { + SequenceNumber: 4, + Tracks: []*fmp4.PartTrack{{ + ID: 5, + }}, + }, + { + SequenceNumber: 5, + Tracks: []*fmp4.PartTrack{{ + ID: 1, + BaseTime: 9000, + }}, + }, + }, parts) + } }) } }