From d2b3cde2cff3cdfc0cf435e91fad6d40cbc8e85e Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Tue, 15 Sep 2026 00:07:06 +0200 Subject: fragment: parse packaged media segments --- track/track.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'track/track.go') diff --git a/track/track.go b/track/track.go index 40eb3cb..e5ec14b 100644 --- a/track/track.go +++ b/track/track.go @@ -299,6 +299,16 @@ func (s Sample) Size() uint32 { return s.size &^ syncBit } // IsSync reports whether the sample is a sync sample (keyframe). func (s Sample) IsSync() bool { return s.size&syncBit != 0 } +// SetSize sets the sample's byte size and sync flag, which share one packed +// field. It is how code that produces samples, rather than parsing them, fills +// a Sample. The size must stay below the sync bit, 2 GiB. +func (s *Sample) SetSize(size uint32, sync bool) { + s.size = size &^ syncBit + if sync { + s.size |= syncBit + } +} + // PTS returns the presentation timestamp. func (s Sample) PTS() int64 { return s.DTS + int64(s.PresentationOffset) -- cgit v1.3.1