Shaka Packager SDK
Loading...
Searching...
No Matches
Public Member Functions | List of all members
shaka::media::BufferReader Class Reference

#include <buffer_reader.h>

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

Public Member Functions

 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)
 

Detailed Description

A simple buffer reader implementation, which reads data of various types from a fixed byte array.

Definition at line 21 of file buffer_reader.h.

Constructor & Destructor Documentation

◆ BufferReader()

shaka::media::BufferReader::BufferReader ( const uint8_t *  buf,
size_t  size 
)
inline

Create a BufferReader from a raw buffer.

Definition at line 24 of file buffer_reader.h.

◆ ~BufferReader()

shaka::media::BufferReader::~BufferReader ( )
inline

Definition at line 26 of file buffer_reader.h.

Member Function Documentation

◆ data()

const uint8_t * shaka::media::BufferReader::data ( ) const
inline

Definition at line 64 of file buffer_reader.h.

◆ HasBytes()

bool shaka::media::BufferReader::HasBytes ( size_t  count)
inline
Returns
true if there are more than count bytes in the stream, false otherwise.

Definition at line 30 of file buffer_reader.h.

◆ pos()

size_t shaka::media::BufferReader::pos ( ) const
inline

Definition at line 67 of file buffer_reader.h.

◆ Read1()

bool shaka::media::BufferReader::Read1 ( uint8_t *  v)

Read a value from the stream, performing endian correction, and advance the stream pointer.

Returns
false if there are not enough bytes in the buffer.

Definition at line 15 of file buffer_reader.cc.

◆ Read2()

bool shaka::media::BufferReader::Read2 ( uint16_t *  v)

Definition at line 23 of file buffer_reader.cc.

◆ Read2s()

bool shaka::media::BufferReader::Read2s ( int16_t *  v)

Definition at line 26 of file buffer_reader.cc.

◆ Read4()

bool shaka::media::BufferReader::Read4 ( uint32_t *  v)

Definition at line 29 of file buffer_reader.cc.

◆ Read4s()

bool shaka::media::BufferReader::Read4s ( int32_t *  v)

Definition at line 32 of file buffer_reader.cc.

◆ Read8()

bool shaka::media::BufferReader::Read8 ( uint64_t *  v)

Definition at line 35 of file buffer_reader.cc.

◆ Read8s()

bool shaka::media::BufferReader::Read8s ( int64_t *  v)

Definition at line 38 of file buffer_reader.cc.

◆ ReadCString()

bool shaka::media::BufferReader::ReadCString ( std::string *  str)

Reads a null-terminated string.

Definition at line 66 of file buffer_reader.cc.

◆ ReadNBytesInto8()

bool shaka::media::BufferReader::ReadNBytesInto8 ( uint64_t *  v,
size_t  num_bytes 
)

Read N-byte integer of the corresponding signedness and store it in the 8-byte return type.

Parameters
num_bytesshould not be larger than 8 bytes.
Returns
false if there are not enough bytes in the buffer, true otherwise.

Definition at line 41 of file buffer_reader.cc.

◆ ReadNBytesInto8s()

bool shaka::media::BufferReader::ReadNBytesInto8s ( int64_t *  v,
size_t  num_bytes 
)

Definition at line 44 of file buffer_reader.cc.

◆ ReadToString()

bool shaka::media::BufferReader::ReadToString ( std::string *  str,
size_t  size 
)

Definition at line 57 of file buffer_reader.cc.

◆ ReadToVector()

bool shaka::media::BufferReader::ReadToVector ( std::vector< uint8_t > *  t,
size_t  count 
)

Definition at line 48 of file buffer_reader.cc.

◆ set_size()

void shaka::media::BufferReader::set_size ( size_t  size)
inline

Definition at line 66 of file buffer_reader.h.

◆ size()

size_t shaka::media::BufferReader::size ( ) const
inline

Definition at line 65 of file buffer_reader.h.

◆ SkipBytes()

bool shaka::media::BufferReader::SkipBytes ( size_t  num_bytes)

Advance the stream by this many bytes.

Returns
false if there are not enough bytes in the buffer, true otherwise.

Definition at line 78 of file buffer_reader.cc.


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