#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/formats/mpeg/mpeg_audio_stream_parser_base.h"
#include <memory>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/numerics/checked_math.h"
#include "base/time/time.h"
#include "media/base/byte_queue.h"
#include "media/base/media_log.h"
#include "media/base/media_tracks.h"
#include "media/base/media_util.h"
#include "media/base/stream_parser.h"
#include "media/base/stream_parser_buffer.h"
#include "media/base/timestamp_constants.h"
#include "media/base/video_decoder_config.h"
namespace media {
static const int kMpegAudioTrackId = …;
static const uint32_t kICYStartCode = …;
static const int kMaxIcecastHeaderSize = …;
static const uint32_t kID3StartCodeMask = …;
static const uint32_t kID3v1StartCode = …;
static const int kID3v1Size = …;
static const int kID3v1ExtendedSize = …;
static const uint32_t kID3v2StartCode = …;
static int LocateEndOfHeaders(const uint8_t* buf, int buf_len, int i) { … }
MPEGAudioStreamParserBase::MPEGAudioStreamParserBase(uint32_t start_code_mask,
AudioCodec audio_codec,
int codec_delay)
: … { … }
MPEGAudioStreamParserBase::~MPEGAudioStreamParserBase() = default;
void MPEGAudioStreamParserBase::Init(
InitCB init_cb,
NewConfigCB config_cb,
NewBuffersCB new_buffers_cb,
EncryptedMediaInitDataCB encrypted_media_init_data_cb,
NewMediaSegmentCB new_segment_cb,
EndMediaSegmentCB end_of_segment_cb,
MediaLog* media_log) { … }
void MPEGAudioStreamParserBase::Flush() { … }
bool MPEGAudioStreamParserBase::GetGenerateTimestampsFlag() const { … }
bool MPEGAudioStreamParserBase::AppendToParseBuffer(
base::span<const uint8_t> buf) { … }
StreamParser::ParseStatus MPEGAudioStreamParserBase::Parse(
int max_pending_bytes_to_inspect) { … }
void MPEGAudioStreamParserBase::ChangeState(State state) { … }
int MPEGAudioStreamParserBase::ParseFrame(const uint8_t* data,
int size,
BufferQueue* buffers) { … }
int MPEGAudioStreamParserBase::ParseIcecastHeader(const uint8_t* data,
int size) { … }
int MPEGAudioStreamParserBase::ParseID3v1(const uint8_t* data, int size) { … }
int MPEGAudioStreamParserBase::ParseID3v2(const uint8_t* data, int size) { … }
bool MPEGAudioStreamParserBase::ParseSyncSafeInt(BitReader* reader,
int32_t* value) { … }
int MPEGAudioStreamParserBase::FindNextValidStartCode(const uint8_t* data,
int size) { … }
bool MPEGAudioStreamParserBase::SendBuffers(BufferQueue* buffers,
bool end_of_segment) { … }
}