#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/muxers/webm_muxer.h"
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <memory>
#include <optional>
#include <string>
#include "base/check.h"
#include "base/containers/circular_deque.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/numerics/safe_math.h"
#include "base/sequence_checker.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "base/trace_event/trace_event.h"
#include "media/base/audio_codecs.h"
#include "media/base/audio_parameters.h"
#include "media/base/limits.h"
#include "media/base/video_codecs.h"
#include "media/base/video_frame.h"
#include "media/formats/common/opus_constants.h"
#include "media/muxers/muxer.h"
#include "third_party/libwebm/source/mkvmuxer.hpp"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/size.h"
namespace media {
namespace {
namespace av1 {
constexpr int high_bitdepth = …;
constexpr int twelve_bit = …;
constexpr int monochrome = …;
constexpr int initial_presentation_delay_present = …;
constexpr int initial_presentation_delay_minus_one = …;
constexpr int chroma_sample_position = …;
constexpr int seq_profile = …;
constexpr int seq_level_idx_0 = …;
constexpr int seq_tier_0 = …;
constexpr int chroma_subsampling_x = …;
constexpr int chroma_subsampling_y = …;
constexpr uint8_t codec_private[4] = …;
}
constexpr base::TimeDelta kMinimumForcedClusterDuration = …;
void WriteOpusHeader(const AudioParameters& params, uint8_t* header) { … }
static double GetFrameRate(const Muxer::VideoParameters& params) { … }
static const char kH264CodecId[] = …;
static const char kPcmCodecId[] = …;
static const char* MkvCodeIcForMediaVideoCodecId(VideoCodec video_codec) { … }
std::optional<mkvmuxer::Colour> ColorFromColorSpace(
const gfx::ColorSpace& color) { … }
}
WebmMuxer::Delegate::Delegate() { … }
WebmMuxer::Delegate::~Delegate() = default;
mkvmuxer::int32 WebmMuxer::Delegate::Write(const void* buf,
mkvmuxer::uint32 len) { … }
WebmMuxer::WebmMuxer(AudioCodec audio_codec,
bool has_video,
bool has_audio,
std::unique_ptr<Delegate> delegate,
std::optional<base::TimeDelta> max_data_output_interval)
: … { … }
WebmMuxer::~WebmMuxer() = default;
bool WebmMuxer::Flush() { … }
void WebmMuxer::AddVideoTrack(
const gfx::Size& frame_size,
double frame_rate,
const std::optional<gfx::ColorSpace>& color_space) { … }
void WebmMuxer::AddAudioTrack(const AudioParameters& params) { … }
bool WebmMuxer::PutFrame(EncodedFrame frame,
base::TimeDelta relative_timestamp) { … }
bool WebmMuxer::WriteWebmFrame(EncodedFrame frame,
base::TimeDelta relative_timestamp) { … }
void WebmMuxer::MaybeForceNewCluster() { … }
}