Shaka Packager SDK
List of all members
shaka::media::mp2t::Mpeg1Header Class Reference

#include <mpeg1_header.h>

Inheritance diagram for shaka::media::mp2t::Mpeg1Header:
shaka::media::mp2t::AudioHeader

Public Member Functions

AudioHeader implementation overrides.
bool IsSyncWord (const uint8_t *buf) const override
 
size_t GetMinFrameSize () const override
 
size_t GetSamplesPerFrame () const override
 
bool Parse (const uint8_t *mpeg1_frame, size_t mpeg1_frame_size) override
 
size_t GetHeaderSize () const override
 
size_t GetFrameSize () const override
 
size_t GetFrameSizeWithoutParsing (const uint8_t *data, size_t num_bytes) const override
 
void GetAudioSpecificConfig (std::vector< uint8_t > *buffer) const override
 
uint8_t GetObjectType () const override
 
uint32_t GetSamplingFrequency () const override
 
uint8_t GetNumChannels () const override
 

Detailed Description

Class which parses Mpeg1 audio frame (header / metadata) and synthesizes AudioSpecificConfig from audio frame content.

See https://www.datavoyage.com/mpgscript/mpeghdr.htm

Definition at line 16 of file mpeg1_header.h.

Member Function Documentation

◆ GetAudioSpecificConfig()

void shaka::media::mp2t::Mpeg1Header::GetAudioSpecificConfig ( std::vector< uint8_t > *  buffer) const
overridevirtual

Synthesize an AudioSpecificConfig record from the fields within the audio header. Should only be called after a successful Parse.

Parameters
[out]bufferis a pointer to a vector to contain the AudioSpecificConfig.
Returns
true if successful, false otherwise.

Implements shaka::media::mp2t::AudioHeader.

Definition at line 190 of file mpeg1_header.cc.

◆ GetFrameSize()

size_t shaka::media::mp2t::Mpeg1Header::GetFrameSize ( ) const
overridevirtual

Should only be called after a successful Parse.

Returns
the size of frame (header + payload).

Implements shaka::media::mp2t::AudioHeader.

Definition at line 168 of file mpeg1_header.cc.

◆ GetFrameSizeWithoutParsing()

size_t shaka::media::mp2t::Mpeg1Header::GetFrameSizeWithoutParsing ( const uint8_t *  data,
size_t  num_bytes 
) const
overridevirtual

Obtain the size of the frame from the header data without doing a full Parse.

Returns
the size of the frame (header + payload).

Implements shaka::media::mp2t::AudioHeader.

Definition at line 172 of file mpeg1_header.cc.

◆ GetHeaderSize()

size_t shaka::media::mp2t::Mpeg1Header::GetHeaderSize ( ) const
overridevirtual

Should only be called after a successful Parse.

Returns
The size of audio header.

Implements shaka::media::mp2t::AudioHeader.

Definition at line 162 of file mpeg1_header.cc.

◆ GetMinFrameSize()

size_t shaka::media::mp2t::Mpeg1Header::GetMinFrameSize ( ) const
overridevirtual
Returns
The minium frame size.

Implements shaka::media::mp2t::AudioHeader.

Definition at line 111 of file mpeg1_header.cc.

◆ GetNumChannels()

uint8_t shaka::media::mp2t::Mpeg1Header::GetNumChannels ( ) const
overridevirtual

Should only be called after a successful Parse.

Returns
Number of channels for this frame.

Implements shaka::media::mp2t::AudioHeader.

Definition at line 243 of file mpeg1_header.cc.

◆ GetObjectType()

uint8_t shaka::media::mp2t::Mpeg1Header::GetObjectType ( ) const
overridevirtual

Should only be called after a successful Parse.

Returns
The audio profile for this frame. Only meaningful for AAC.

Implements shaka::media::mp2t::AudioHeader.

Definition at line 226 of file mpeg1_header.cc.

◆ GetSamplesPerFrame()

size_t shaka::media::mp2t::Mpeg1Header::GetSamplesPerFrame ( ) const
overridevirtual
Returns
Number of audio samples per frame.

Implements shaka::media::mp2t::AudioHeader.

Definition at line 115 of file mpeg1_header.cc.

◆ GetSamplingFrequency()

uint32_t shaka::media::mp2t::Mpeg1Header::GetSamplingFrequency ( ) const
overridevirtual

Should only be called after a successful Parse.

Returns
The sampling frequency for this frame.

Implements shaka::media::mp2t::AudioHeader.

Definition at line 239 of file mpeg1_header.cc.

◆ IsSyncWord()

bool shaka::media::mp2t::Mpeg1Header::IsSyncWord ( const uint8_t *  buf) const
overridevirtual

Check if the leading word (2 bytes) is sync signal.

Parameters
bufpoints to the buffer to be checked. Must be at least 2 bytes.
Returns
true if corresponds to a syncword.

Implements shaka::media::mp2t::AudioHeader.

Definition at line 102 of file mpeg1_header.cc.

◆ Parse()

bool shaka::media::mp2t::Mpeg1Header::Parse ( const uint8_t *  audio_frame,
size_t  audio_frame_size 
)
overridevirtual

Parse a partial audio frame, extracting the fields within. Only audio frame header / metadata is parsed. The audio_frame_size must contain the full header / metadata.

Parameters
audio_frameis an input parameter pointing to an audio frame.
audio_frame_sizeis the size, in bytes of the input data. It can be smaller than the actual frame size, but it should not be smaller than the header size.
Returns
true if successful, false otherwise.

Implements shaka::media::mp2t::AudioHeader.

Definition at line 121 of file mpeg1_header.cc.


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