Shaka Player Embedded
Public Member Functions | List of all members
shaka::util::BufferReader Class Reference

#include <buffer_reader.h>

Public Member Functions

 BufferReader ()
 
 BufferReader (const uint8_t *data, size_t data_size)
 
const uint8_t * data () const
 
bool empty () const
 
size_t BytesRemaining () const
 
void SetBuffer (const uint8_t *data, size_t data_size)
 
size_t Read (uint8_t *dest, size_t dest_size)
 
size_t Skip (size_t count)
 
size_t SkipBits (size_t count)
 
uint8_t ReadUint8 ()
 
uint32_t ReadUint32 (Endianness endianness=kBigEndian)
 
uint64_t ReadBits (size_t count, Endianness endianness=kBigEndian)
 
uint64_t ReadExpGolomb ()
 

Detailed Description

A simple utility class to read bytes from a buffer. This does not own the data and is not thread safe.

Definition at line 41 of file buffer_reader.h.

Constructor & Destructor Documentation

§ BufferReader() [1/2]

shaka::util::BufferReader::BufferReader ( )

Definition at line 26 of file buffer_reader.cc.

§ BufferReader() [2/2]

shaka::util::BufferReader::BufferReader ( const uint8_t *  data,
size_t  data_size 
)

Definition at line 27 of file buffer_reader.cc.

Member Function Documentation

§ BytesRemaining()

size_t shaka::util::BufferReader::BytesRemaining ( ) const
inline
Returns
The number of bytes left to read.

Definition at line 56 of file buffer_reader.h.

§ data()

const uint8_t* shaka::util::BufferReader::data ( ) const
inline
Returns
The data pointer for the current position.

Definition at line 47 of file buffer_reader.h.

§ empty()

bool shaka::util::BufferReader::empty ( ) const
inline

Definition at line 51 of file buffer_reader.h.

§ Read()

size_t shaka::util::BufferReader::Read ( uint8_t *  dest,
size_t  dest_size 
)

Reads up to |dest_size| bytes and copies them into |dest|.

Parameters
destThe buffer to copy the data to.
dest_sizeThe number of bytes in |dest|.
Returns
The number of bytes read.

Definition at line 36 of file buffer_reader.cc.

§ ReadBits()

uint64_t shaka::util::BufferReader::ReadBits ( size_t  count,
Endianness  endianness = kBigEndian 
)

Reads the given number of bits. If there aren't enough bits, this will fill remaining bits with 0. This can only read up to 64 bits.

Little endian mode can only be used at a byte-aligned position and can only read whole bytes.

Definition at line 63 of file buffer_reader.cc.

§ ReadExpGolomb()

uint64_t shaka::util::BufferReader::ReadExpGolomb ( )

Reads a variably-sized integer in a Exponential-Golomb format.

See also
https://en.wikipedia.org/wiki/Exponential-Golomb_coding

Definition at line 99 of file buffer_reader.cc.

§ ReadUint32()

uint32_t shaka::util::BufferReader::ReadUint32 ( Endianness  endianness = kBigEndian)
inline

Reads a 32-bit integer from the buffer.

Definition at line 94 of file buffer_reader.h.

§ ReadUint8()

uint8_t shaka::util::BufferReader::ReadUint8 ( )
inline

Reads a 8-bit integer from the buffer. If the reader is empty, this returns 0.

Definition at line 89 of file buffer_reader.h.

§ SetBuffer()

void shaka::util::BufferReader::SetBuffer ( const uint8_t *  data,
size_t  data_size 
)

Resets the buffer that this type will read from.

Definition at line 30 of file buffer_reader.cc.

§ Skip()

size_t shaka::util::BufferReader::Skip ( size_t  count)
inline

Skips the given number of bytes.

Returns
The number of bytes skipped.

Definition at line 75 of file buffer_reader.h.

§ SkipBits()

size_t shaka::util::BufferReader::SkipBits ( size_t  count)

Skips the given number of bits.

Returns
The number of bits skipped.

Definition at line 52 of file buffer_reader.cc.


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