#include "media/mojo/clients/mojo_video_encode_accelerator.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/threading/thread_restrictions.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "media/base/media_log.h"
#include "media/base/video_frame.h"
#include "media/gpu/gpu_video_accelerator_util.h"
#include "media/mojo/clients/mojo_media_log_service.h"
#include "media/mojo/mojom/video_encoder_info.mojom.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace media {
namespace {
class VideoEncodeAcceleratorClient
: public mojom::VideoEncodeAcceleratorClient { … };
VideoEncodeAcceleratorClient::VideoEncodeAcceleratorClient(
VideoEncodeAccelerator::Client* client,
mojo::PendingAssociatedReceiver<mojom::VideoEncodeAcceleratorClient>
receiver)
: … { … }
void VideoEncodeAcceleratorClient::RequireBitstreamBuffers(
uint32_t input_count,
const gfx::Size& input_coded_size,
uint32_t output_buffer_size) { … }
void VideoEncodeAcceleratorClient::BitstreamBufferReady(
int32_t bitstream_buffer_id,
const media::BitstreamBufferMetadata& metadata) { … }
void VideoEncodeAcceleratorClient::NotifyErrorStatus(
const EncoderStatus& status) { … }
void VideoEncodeAcceleratorClient::NotifyEncoderInfoChange(
const VideoEncoderInfo& info) { … }
}
MojoVideoEncodeAccelerator::MojoVideoEncodeAccelerator(
mojo::PendingRemote<mojom::VideoEncodeAccelerator> vea)
: … { … }
VideoEncodeAccelerator::SupportedProfiles
MojoVideoEncodeAccelerator::GetSupportedProfiles() { … }
bool MojoVideoEncodeAccelerator::Initialize(
const Config& config,
Client* client,
std::unique_ptr<MediaLog> media_log) { … }
void MojoVideoEncodeAccelerator::Encode(scoped_refptr<VideoFrame> frame,
bool force_keyframe) { … }
void MojoVideoEncodeAccelerator::Encode(
scoped_refptr<VideoFrame> frame,
const VideoEncoder::EncodeOptions& options) { … }
void MojoVideoEncodeAccelerator::UseOutputBitstreamBuffer(
BitstreamBuffer buffer) { … }
void MojoVideoEncodeAccelerator::RequestEncodingParametersChange(
const Bitrate& bitrate,
uint32_t framerate,
const std::optional<gfx::Size>& size) { … }
void MojoVideoEncodeAccelerator::RequestEncodingParametersChange(
const VideoBitrateAllocation& bitrate,
uint32_t framerate,
const std::optional<gfx::Size>& size) { … }
bool MojoVideoEncodeAccelerator::IsFlushSupported() { … }
void MojoVideoEncodeAccelerator::Flush(FlushCallback flush_callback) { … }
void MojoVideoEncodeAccelerator::Destroy() { … }
MojoVideoEncodeAccelerator::~MojoVideoEncodeAccelerator() { … }
void MojoVideoEncodeAccelerator::MojoDisconnectionHandler() { … }
}