diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-09-15 00:07:06 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-09-15 00:07:06 +0200 |
| commit | d2b3cde2cff3cdfc0cf435e91fad6d40cbc8e85e (patch) | |
| tree | e4293a705a3151646bff7a849ebff6b4583fa31f /track/track.go | |
| parent | 6216b2ed1fcd0b06a9e0b3ae74e5373a8cccd114 (diff) | |
| download | mp4-d2b3cde2cff3cdfc0cf435e91fad6d40cbc8e85e.tar.gz mp4-d2b3cde2cff3cdfc0cf435e91fad6d40cbc8e85e.zip | |
fragment: parse packaged media segments
Diffstat (limited to 'track/track.go')
| -rw-r--r-- | track/track.go | 10 |
1 files changed, 10 insertions, 0 deletions
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) |
