#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/modules/mediarecorder/vpx_encoder.h"
#include <algorithm>
#include <utility>
#include "base/numerics/safe_conversions.h"
#include "base/strings/strcat.h"
#include "base/system/sys_info.h"
#include "media/base/encoder_status.h"
#include "media/base/video_encoder_metrics_provider.h"
#include "media/base/video_frame.h"
#include "media/base/video_util.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "ui/gfx/geometry/size.h"
VideoFrameMetadata;
namespace blink {
void VpxEncoder::VpxCodecDeleter::operator()(vpx_codec_ctx_t* codec) { … }
static int GetNumberOfThreadsForEncoding() { … }
VpxEncoder::VpxEncoder(
scoped_refptr<base::SequencedTaskRunner> encoding_task_runner,
bool use_vp9,
const VideoTrackRecorder::OnEncodedVideoCB& on_encoded_video_cb,
uint32_t bits_per_second,
bool is_screencast,
const VideoTrackRecorder::OnErrorCB on_error_cb)
: … { … }
bool VpxEncoder::CanEncodeAlphaChannel() const { … }
void VpxEncoder::EncodeFrame(scoped_refptr<media::VideoFrame> frame,
base::TimeTicks capture_timestamp,
bool request_keyframe) { … }
void VpxEncoder::DoEncode(vpx_codec_ctx_t* const encoder,
const gfx::Size& frame_size,
const uint8_t* data,
const uint8_t* y_plane,
int y_stride,
const uint8_t* u_plane,
int u_stride,
const uint8_t* v_plane,
int v_stride,
const base::TimeDelta& duration,
bool force_keyframe,
std::string& output_data,
bool* const keyframe,
vpx_img_fmt_t img_fmt) { … }
bool VpxEncoder::ConfigureEncoder(const gfx::Size& size,
vpx_codec_enc_cfg_t* codec_config,
ScopedVpxCodecCtxPtr* encoder) { … }
bool VpxEncoder::IsInitialized(const vpx_codec_enc_cfg_t& codec_config) const { … }
base::TimeDelta VpxEncoder::EstimateFrameDuration(
const media::VideoFrame& frame) { … }
}