arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
SpoolFileSampleTableStore< T > Class Template Reference

Writes every entry to a caller-provided scratch file as it's appended, instead of keeping it in RAM - get() seeks that file and reads the entry back. Unlike SourceSeekSampleTableStore this needs no knowledge of (or seekability in) the original MP4 source - it works even when that source is a live, non-seekable stream, since it's writing its own local, sequential copy as data streams past. The tradeoff is disk I/O (both a write during parsing and a seek+read during playback) instead of a pure RAM cost. More...

#include <SampleTableStore.h>

Inheritance diagram for SpoolFileSampleTableStore< T >:
SampleTableStore< T >

Public Member Functions

 SpoolFileSampleTableStore (SpoolStorage &spool)
 
void append (T value) override
 Appends one entry - call in file order, once per table entry.
 
void clear () override
 Resets to empty - call once per begin()/track.
 
get (size_t index) override
 Reads back entry 'index' - index must be < size().
 
virtual void setNextEntryOffset (uint64_t fileOffset)
 
virtual void setOnDiskEntrySize (size_t bytes)
 
size_t size () override
 Number of entries appended so far.
 

Protected Attributes

size_t entry_count = 0
 
SpoolStoragep_spool
 

Detailed Description

template<typename T>
class audio_tools::SpoolFileSampleTableStore< T >

Writes every entry to a caller-provided scratch file as it's appended, instead of keeping it in RAM - get() seeks that file and reads the entry back. Unlike SourceSeekSampleTableStore this needs no knowledge of (or seekability in) the original MP4 source - it works even when that source is a live, non-seekable stream, since it's writing its own local, sequential copy as data streams past. The tradeoff is disk I/O (both a write during parsing and a seek+read during playback) instead of a pure RAM cost.

Unlike SourceSeekSampleTableStore there's no endianness/on-disk-width concern here - this store's on-disk layout is its own private format (whatever bytes T's native in-memory representation happens to be), not MP4's, so a plain byte-for-byte round-trip is correct as long as the same host reads back what it wrote (true here - never persisted across runs).

Each instance needs its own dedicated SpoolStorage - see DemuxerMP4::setSpoolStorageFactory() for how one gets created per table per track.

Constructor & Destructor Documentation

◆ SpoolFileSampleTableStore()

template<typename T >
SpoolFileSampleTableStore ( SpoolStorage spool)
inline

'spool' must be open for reading, writing and seeking, and empty/truncated at construction time.

Member Function Documentation

◆ append()

template<typename T >
void append ( value)
inlineoverridevirtual

Appends one entry - call in file order, once per table entry.

Implements SampleTableStore< T >.

◆ clear()

template<typename T >
void clear ( )
inlineoverridevirtual

Resets to empty - call once per begin()/track.

Implements SampleTableStore< T >.

◆ get()

template<typename T >
T get ( size_t  index)
inlineoverridevirtual

Reads back entry 'index' - index must be < size().

Implements SampleTableStore< T >.

◆ setNextEntryOffset()

template<typename T >
virtual void setNextEntryOffset ( uint64_t  fileOffset)
inlinevirtualinherited

Only meaningful for SourceSeekSampleTableStore: the absolute byte offset (from the start of the original MP4 file) of the entry about to be appended next. Default no-op - other implementations ignore it, so callers can always call this unconditionally before append() without needing to know which implementation is active.

Reimplemented in SourceSeekSampleTableStore< T >.

◆ setOnDiskEntrySize()

template<typename T >
virtual void setOnDiskEntrySize ( size_t  bytes)
inlinevirtualinherited

Only meaningful for SourceSeekSampleTableStore, and only for tables whose on-disk width isn't a fixed sizeof(T) - see its comment. Default no-op.

Reimplemented in SourceSeekSampleTableStore< T >.

◆ size()

template<typename T >
size_t size ( )
inlineoverridevirtual

Number of entries appended so far.

Implements SampleTableStore< T >.

Member Data Documentation

◆ entry_count

template<typename T >
size_t entry_count = 0
protected

◆ p_spool

template<typename T >
SpoolStorage* p_spool
protected

The documentation for this class was generated from the following file: