#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/formats/webm/webm_cluster_parser.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/logging.h"
#include "base/numerics/byte_conversions.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "base/types/optional_util.h"
#include "media/base/decrypt_config.h"
#include "media/base/stream_parser_buffer.h"
#include "media/base/timestamp_constants.h"
#include "media/base/webvtt_util.h"
#include "media/formats/webm/webm_constants.h"
#include "media/formats/webm/webm_crypto_helpers.h"
#include "media/formats/webm/webm_webvtt_parser.h"
namespace media {
const uint16_t WebMClusterParser::kOpusFrameDurationsMu[] = …;
enum { … };
WebMClusterParser::WebMClusterParser(
int64_t timecode_scale_ns,
int audio_track_num,
base::TimeDelta audio_default_duration,
int video_track_num,
base::TimeDelta video_default_duration,
const std::set<int64_t>& ignored_tracks,
const std::string& audio_encryption_key_id,
const std::string& video_encryption_key_id,
const AudioCodec audio_codec,
MediaLog* media_log)
: … { … }
WebMClusterParser::~WebMClusterParser() = default;
void WebMClusterParser::Reset() { … }
int WebMClusterParser::Parse(const uint8_t* buf, int size) { … }
void WebMClusterParser::GetBuffers(StreamParser::BufferQueueMap* buffers) { … }
base::TimeDelta WebMClusterParser::TryGetEncodedAudioDuration(
const uint8_t* data,
int size) { … }
base::TimeDelta WebMClusterParser::ReadOpusDuration(const uint8_t* data,
int size) { … }
WebMParserClient* WebMClusterParser::OnListStart(int id) { … }
bool WebMClusterParser::OnListEnd(int id) { … }
bool WebMClusterParser::OnUInt(int id, int64_t val) { … }
bool WebMClusterParser::ParseBlock(bool is_simple_block,
const uint8_t* buf,
int size,
const uint8_t* additional,
int additional_size,
int duration,
int64_t discard_padding,
bool reference_block_set) { … }
bool WebMClusterParser::OnBinary(int id, const uint8_t* data_ptr, int size) { … }
bool WebMClusterParser::OnBlock(bool is_simple_block,
int track_num,
int timecode,
int block_duration,
const uint8_t* data,
int size,
const uint8_t* additional,
int additional_size,
int64_t discard_padding,
bool is_keyframe) { … }
WebMClusterParser::Track::Track(int track_num,
TrackType track_type,
base::TimeDelta default_duration,
MediaLog* media_log)
: … { … }
WebMClusterParser::Track::Track(const Track& other) = default;
WebMClusterParser::Track::~Track() = default;
DecodeTimestamp WebMClusterParser::Track::GetReadyUpperBound() { … }
void WebMClusterParser::Track::ExtractReadyBuffers(
const DecodeTimestamp before_timestamp) { … }
bool WebMClusterParser::Track::AddBuffer(
scoped_refptr<StreamParserBuffer> buffer) { … }
void WebMClusterParser::Track::ApplyDurationEstimateIfNeeded() { … }
void WebMClusterParser::Track::ClearReadyBuffers() { … }
void WebMClusterParser::Track::Reset() { … }
bool WebMClusterParser::Track::QueueBuffer(
scoped_refptr<StreamParserBuffer> buffer) { … }
base::TimeDelta WebMClusterParser::Track::GetDurationEstimate() { … }
void WebMClusterParser::UpdateReadyBuffers() { … }
}