DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Types | Public Member Functions | Static Public Member Functions | List of all members
shaka::media::NaluReader Class Reference

#include <nalu_reader.h>

Public Types

enum  Result { kOk, kInvalidStream, kEOStream }
 

Public Member Functions

 NaluReader (Nalu::CodecType type, uint8_t nal_length_size, const uint8_t *stream, uint64_t stream_size)
 
 NaluReader (Nalu::CodecType type, uint8_t nal_length_size, const uint8_t *stream, uint64_t stream_size, const std::vector< SubsampleEntry > &subsamples)
 
Result Advance (Nalu *nalu)
 
bool StartsWithStartCode ()
 

Static Public Member Functions

static bool FindStartCode (const uint8_t *data, uint64_t data_size, uint64_t *offset, uint8_t *start_code_size)
 
static bool FindStartCodeInClearRange (const uint8_t *data, uint64_t data_size, uint64_t *offset, uint8_t *start_code_size, const std::vector< SubsampleEntry > &subsamples)
 

Detailed Description

Helper class used to read NAL units based on several formats:

Definition at line 149 of file nalu_reader.h.

Constructor & Destructor Documentation

shaka::media::NaluReader::NaluReader ( Nalu::CodecType  type,
uint8_t  nal_length_size,
const uint8_t *  stream,
uint64_t  stream_size 
)
Parameters
nalu_length_sizeshould be set to 0 for AnnexB byte streams; otherwise, it indicates the size of NAL unit length for the NAL unit stream.

Definition at line 212 of file nalu_reader.cc.

shaka::media::NaluReader::NaluReader ( Nalu::CodecType  type,
uint8_t  nal_length_size,
const uint8_t *  stream,
uint64_t  stream_size,
const std::vector< SubsampleEntry > &  subsamples 
)
Parameters
typeis the codec type of the NALU unit.
nalu_length_sizeshould be set to 0 for AnnexB byte streams; otherwise, it indicates the size of NAL unit length for the NAL unit stream.
streamis the input stream.
stream_sizeis the size of stream.
subsamplesspecifies the clear and encrypted sections of the stream starting from the beginning of the stream. If subsamples doesn't cover the entire stream, then the rest is assumed to be in the clear.

Definition at line 222 of file nalu_reader.cc.

Member Function Documentation

NaluReader::Result shaka::media::NaluReader::Advance ( Nalu nalu)

Reads a NALU from the stream into |*nalu|, if one exists, and then advances to the next NALU.

Parameters
nalucontains the NALU read if it exists.
Returns
kOk if a NALU is read; kEOStream if the stream is at the end-of-stream; kInvalidStream on error.

Definition at line 239 of file nalu_reader.cc.

bool shaka::media::NaluReader::FindStartCodeInClearRange ( const uint8_t *  data,
uint64_t  data_size,
uint64_t *  offset,
uint8_t *  start_code_size,
const std::vector< SubsampleEntry > &  subsamples 
)
static

Same as FindStartCode() but also specify the subsamples. This searches for start codes in the clear section and will not scan for start codes in the encrypted section. Even if there is a real NALU start code in the encrypted section, this will skip them.

Parameters
subsamplesstarting from the start of data. If subsamples does not cover the whole data, the rest is assumed to be in the clear.
Returns
true if it finds a NALU. false otherwise.

Definition at line 344 of file nalu_reader.cc.

bool shaka::media::NaluReader::StartsWithStartCode ( )
Returns
true if the current position points to a start code.

Definition at line 297 of file nalu_reader.cc.


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