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

#include <box_buffer.h>

Public Member Functions

 BoxBuffer (BoxReader *reader)
 
 BoxBuffer (BufferWriter *writer)
 
bool Reading () const
 
size_t Pos () const
 
size_t Size () const
 
size_t BytesLeft () const
 
bool ReadWriteUInt64NBytes (uint64_t *v, size_t num_bytes)
 
bool ReadWriteInt64NBytes (int64_t *v, size_t num_bytes)
 
bool ReadWriteVector (std::vector< uint8_t > *vector, size_t count)
 
bool ReadWriteString (std::string *str, size_t size)
 
bool ReadWriteCString (std::string *str)
 
bool ReadWriteFourCC (FourCC *fourcc)
 
bool PrepareChildren ()
 
bool ReadWriteChild (Box *box)
 
bool TryReadWriteChild (Box *box)
 
bool IgnoreBytes (size_t num_bytes)
 
BoxReaderreader ()
 
BufferWriterwriter ()
 
Read/write integers of various sizes and signedness.
bool ReadWriteUInt8 (uint8_t *v)
 
bool ReadWriteUInt16 (uint16_t *v)
 
bool ReadWriteUInt32 (uint32_t *v)
 
bool ReadWriteUInt64 (uint64_t *v)
 
bool ReadWriteInt16 (int16_t *v)
 
bool ReadWriteInt32 (int32_t *v)
 
bool ReadWriteInt64 (int64_t *v)
 

Detailed Description

Class for MP4 box I/O. Box I/O is symmetric and exclusive, so we can define a single method to do either reading or writing box objects. BoxBuffer wraps either BoxReader for reading or BufferWriter for writing. Thus it is capable of doing either reading or writing, but not both.

Definition at line 27 of file box_buffer.h.

Constructor & Destructor Documentation

◆ BoxBuffer() [1/2]

shaka::media::mp4::BoxBuffer::BoxBuffer ( BoxReader reader)
inlineexplicit

Create a reader version of the BoxBuffer.

Parameters
readershould not be NULL.

Definition at line 31 of file box_buffer.h.

◆ BoxBuffer() [2/2]

shaka::media::mp4::BoxBuffer::BoxBuffer ( BufferWriter writer)
inlineexplicit

Create a writer version of the BoxBuffer.

Parameters
writershould not be NULL.

Definition at line 36 of file box_buffer.h.

Member Function Documentation

◆ BytesLeft()

size_t shaka::media::mp4::BoxBuffer::BytesLeft ( ) const
inline
Returns
In read mode, return the number of bytes left in the box. In write mode, return 0.

Definition at line 64 of file box_buffer.h.

◆ IgnoreBytes()

bool shaka::media::mp4::BoxBuffer::IgnoreBytes ( size_t  num_bytes)
inline
Parameters
num_bytesspecifies number of bytes to skip in read mode or number of bytes to be padded with zero in write mode.
Returns
true on success, false otherwise.

Definition at line 201 of file box_buffer.h.

◆ Pos()

size_t shaka::media::mp4::BoxBuffer::Pos ( ) const
inline
Returns
Current read/write position. In read mode, this is the current read position. In write mode, it is the same as Size().

Definition at line 46 of file box_buffer.h.

◆ PrepareChildren()

bool shaka::media::mp4::BoxBuffer::PrepareChildren ( )
inline

Prepare child boxes for reading/writing.

Returns
true on success, false otherwise.

Definition at line 169 of file box_buffer.h.

◆ reader()

BoxReader* shaka::media::mp4::BoxBuffer::reader ( )
inline
Returns
A pointer to the inner reader object.

Definition at line 210 of file box_buffer.h.

◆ Reading()

bool shaka::media::mp4::BoxBuffer::Reading ( ) const
inline
Returns
true for reader, false for writer.

Definition at line 42 of file box_buffer.h.

◆ ReadWriteChild()

bool shaka::media::mp4::BoxBuffer::ReadWriteChild ( Box box)
inline

Read/write child box.

Returns
true on success, false otherwise.

Definition at line 178 of file box_buffer.h.

◆ ReadWriteString()

bool shaka::media::mp4::BoxBuffer::ReadWriteString ( std::string *  str,
size_t  size 
)
inline

Reads size characters from the buffer and sets it to str. Writes str to the buffer. Write mode ignores size.

Definition at line 141 of file box_buffer.h.

◆ ReadWriteUInt64NBytes()

bool shaka::media::mp4::BoxBuffer::ReadWriteUInt64NBytes ( uint64_t *  v,
size_t  num_bytes 
)
inline

Read/write the least significant |num_bytes| of |v| from/to the buffer.

Parameters
num_bytesshould not be larger than sizeof(v), i.e. 8.
Returns
true on success, false otherwise.

Definition at line 119 of file box_buffer.h.

◆ Size()

size_t shaka::media::mp4::BoxBuffer::Size ( ) const
inline
Returns
Total buffer size. In read mode, it includes data that has already been read or skipped, and will not change. In write mode, it includes all data that has been written, and will change as more data is written.

Definition at line 56 of file box_buffer.h.

◆ TryReadWriteChild()

bool shaka::media::mp4::BoxBuffer::TryReadWriteChild ( Box box)
inline

Read/write child box if exists.

Returns
true on success, false otherwise.

Definition at line 189 of file box_buffer.h.

◆ writer()

BufferWriter* shaka::media::mp4::BoxBuffer::writer ( )
inline
Returns
A pointer to the inner writer object.

Definition at line 212 of file box_buffer.h.


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