Shaka Packager SDK
Public Member Functions | Static Public Member Functions | List of all members
shaka::media::mp4::BoxReader Class Reference

Class for reading MP4 boxes. More...

#include <box_reader.h>

Inheritance diagram for shaka::media::mp4::BoxReader:
shaka::media::BufferReader

Public Member Functions

bool ScanChildren ()
 
bool ChildExist (Box *child)
 
bool ReadChild (Box *child)
 
bool TryReadChild (Box *child)
 
template<typename T >
bool ReadChildren (std::vector< T > *children)
 
template<typename T >
bool TryReadChildren (std::vector< T > *children)
 
template<typename T >
bool ReadAllChildren (std::vector< T > *children)
 
bool ReadFourCC (FourCC *fourcc)
 
FourCC type () const
 
- Public Member Functions inherited from shaka::media::BufferReader
 BufferReader (const uint8_t *buf, size_t size)
 Create a BufferReader from a raw buffer.
 
bool HasBytes (size_t count)
 
bool ReadToVector (std::vector< uint8_t > *t, size_t count)
 
bool ReadToString (std::string *str, size_t size)
 
bool ReadCString (std::string *str)
 Reads a null-terminated string.
 
bool SkipBytes (size_t num_bytes)
 
const uint8_t * data () const
 
size_t size () const
 
void set_size (size_t size)
 
size_t pos () const
 
bool Read1 (uint8_t *v)
 
bool Read2 (uint16_t *v)
 
bool Read2s (int16_t *v)
 
bool Read4 (uint32_t *v)
 
bool Read4s (int32_t *v)
 
bool Read8 (uint64_t *v)
 
bool Read8s (int64_t *v)
 
bool ReadNBytesInto8 (uint64_t *v, size_t num_bytes)
 
bool ReadNBytesInto8s (int64_t *v, size_t num_bytes)
 

Static Public Member Functions

static BoxReaderReadBox (const uint8_t *buf, const size_t buf_size, bool *err)
 
static bool StartBox (const uint8_t *buf, const size_t buf_size, FourCC *type, uint64_t *box_size, bool *err)
 

Detailed Description

Class for reading MP4 boxes.

Definition at line 28 of file box_reader.h.

Member Function Documentation

◆ ChildExist()

bool shaka::media::mp4::BoxReader::ChildExist ( Box child)
Returns
true if child with type child.BoxType() exists.

Definition at line 104 of file box_reader.cc.

◆ ReadAllChildren()

template<typename T >
bool shaka::media::mp4::BoxReader::ReadAllChildren ( std::vector< T > *  children)

Read all children. It expects all children to be of type T. Note that this method is mutually exclusive with ScanChildren().

Returns
true on success, false otherwise.

Definition at line 160 of file box_reader.h.

◆ ReadBox()

BoxReader * shaka::media::mp4::BoxReader::ReadBox ( const uint8_t *  buf,
const size_t  buf_size,
bool *  err 
)
static

Create a BoxReader from a buffer.

Parameters
bufis retained but not owned, and must outlive the BoxReader instance.
buf_sizeindicates the size of the input buffer.
[out]erris set to true if there was a stream-level error when reading the box.
Returns
New box reader if successful, NULL otherwise. Note that this function may return NULL if an intact, complete box is not available in the buffer. For MDAT box only, a BoxReader object is returned as long as the box header is available.

Definition at line 38 of file box_reader.cc.

◆ ReadChild()

bool shaka::media::mp4::BoxReader::ReadChild ( Box child)

Read exactly one child box from the set of children. The type of the child will be determined by the BoxType() of child.

Returns
true on success, false otherwise.

Definition at line 92 of file box_reader.cc.

◆ ReadChildren()

template<typename T >
bool shaka::media::mp4::BoxReader::ReadChildren ( std::vector< T > *  children)

Read at least one child.

Returns
false on error or no child of type <T> present.

Definition at line 131 of file box_reader.h.

◆ ScanChildren()

bool shaka::media::mp4::BoxReader::ScanChildren ( )

Scan through all boxes within the current box, starting at the current buffer position. Must be called before any of the *Child functions work.

Returns
true on success, false otherwise.

Definition at line 69 of file box_reader.cc.

◆ StartBox()

bool shaka::media::mp4::BoxReader::StartBox ( const uint8_t *  buf,
const size_t  buf_size,
FourCC *  type,
uint64_t *  box_size,
bool *  err 
)
static

Read the box header from the current buffer.

Parameters
bufis not retained.
buf_sizeindicates the size of the input buffer.
[out]typeis filled with the fourcc of the box on success.
[out]box_sizeis filled with the size of the box on success.
[out]erris set to true if there was a stream-level error when reading the box.
Returns
true if there is enough data to read the header and the header is sane, which does not imply that the entire box is in the buffer.

Definition at line 56 of file box_reader.cc.

◆ TryReadChild()

bool shaka::media::mp4::BoxReader::TryReadChild ( Box child)

Read one child if available.

Returns
false on error, true on successful read or on child absent.

Definition at line 108 of file box_reader.cc.

◆ TryReadChildren()

template<typename T >
bool shaka::media::mp4::BoxReader::TryReadChildren ( std::vector< T > *  children)

Read any number of children.

Returns
false on error.

Definition at line 137 of file box_reader.h.


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