#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/formats/webm/tracks_builder.h"
#include <cstring>
#include "base/check_op.h"
#include "media/formats/webm/webm_constants.h"
namespace media {
static int GetUIntMkvSize(uint64_t value) { … }
static int GetUIntSize(uint64_t value) { … }
static int MasterElementSize(int element_id, int payload_size) { … }
static int UIntElementSize(int element_id, uint64_t value) { … }
static int DoubleElementSize(int element_id) { … }
static int StringElementSize(int element_id, const std::string& value) { … }
static void SerializeInt(uint8_t** buf_ptr,
int* buf_size_ptr,
int64_t value,
int size) { … }
static void SerializeDouble(uint8_t** buf_ptr,
int* buf_size_ptr,
double value) { … }
static void WriteElementId(uint8_t** buf, int* buf_size, int element_id) { … }
static void WriteUInt(uint8_t** buf, int* buf_size, uint64_t value) { … }
static void WriteMasterElement(uint8_t** buf,
int* buf_size,
int element_id,
int payload_size) { … }
static void WriteUIntElement(uint8_t** buf,
int* buf_size,
int element_id,
uint64_t value) { … }
static void WriteDoubleElement(uint8_t** buf,
int* buf_size,
int element_id,
double value) { … }
static void WriteStringElement(uint8_t** buf_ptr,
int* buf_size_ptr,
int element_id,
const std::string& value) { … }
TracksBuilder::TracksBuilder(bool allow_invalid_values)
: … { … }
TracksBuilder::TracksBuilder()
: … { … }
TracksBuilder::~TracksBuilder() = default;
void TracksBuilder::AddVideoTrack(int track_num,
uint64_t track_uid,
const std::string& codec_id,
const std::string& name,
const std::string& language,
int default_duration,
int video_pixel_width,
int video_pixel_height) { … }
void TracksBuilder::AddAudioTrack(int track_num,
uint64_t track_uid,
const std::string& codec_id,
const std::string& name,
const std::string& language,
int default_duration,
int audio_channels,
double audio_sampling_frequency) { … }
void TracksBuilder::AddTextTrack(int track_num,
uint64_t track_uid,
const std::string& codec_id,
const std::string& name,
const std::string& language) { … }
std::vector<uint8_t> TracksBuilder::Finish() { … }
void TracksBuilder::AddTrackInternal(int track_num,
int track_type,
uint64_t track_uid,
const std::string& codec_id,
const std::string& name,
const std::string& language,
int default_duration,
int video_pixel_width,
int video_pixel_height,
int audio_channels,
double audio_sampling_frequency) { … }
int TracksBuilder::GetTracksSize() const { … }
int TracksBuilder::GetTracksPayloadSize() const { … }
void TracksBuilder::WriteTracks(uint8_t* buf, int buf_size) const { … }
TracksBuilder::Track::Track(int track_num,
int track_type,
uint64_t track_uid,
const std::string& codec_id,
const std::string& name,
const std::string& language,
int default_duration,
int video_pixel_width,
int video_pixel_height,
int audio_channels,
double audio_sampling_frequency,
bool allow_invalid_values)
: … { … }
TracksBuilder::Track::Track(const Track& other) = default;
int TracksBuilder::Track::GetSize() const { … }
int TracksBuilder::Track::GetVideoPayloadSize() const { … }
int TracksBuilder::Track::GetAudioPayloadSize() const { … }
int TracksBuilder::Track::GetPayloadSize() const { … }
void TracksBuilder::Track::Write(uint8_t** buf, int* buf_size) const { … }
}