#include "media/mojo/services/mojo_video_decoder_service.h"
#include <memory>
#include <optional>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "base/types/optional_util.h"
#include "media/base/decoder_buffer.h"
#include "media/base/media_util.h"
#include "media/base/simple_sync_token_client.h"
#include "media/base/video_decoder.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_frame.h"
#include "media/mojo/common/media_type_converters.h"
#include "media/mojo/common/mojo_decoder_buffer_converter.h"
#include "media/mojo/services/mojo_cdm_service_context.h"
#include "media/mojo/services/mojo_media_client.h"
#include "media/mojo/services/mojo_media_log.h"
#include "mojo/public/c/system/types.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/system/buffer.h"
#include "mojo/public/cpp/system/handle.h"
namespace media {
namespace {
static int32_t g_num_active_mvd_instances = …;
const char kInitializeTraceName[] = …;
const char kDecodeTraceName[] = …;
const char kResetTraceName[] = …;
base::debug::CrashKeyString* GetNumVideoDecodersCrashKeyString() { … }
}
class VideoFrameHandleReleaserImpl final
: public mojom::VideoFrameHandleReleaser { … };
MojoVideoDecoderService::MojoVideoDecoderService(
MojoMediaClient* mojo_media_client,
MojoCdmServiceContext* mojo_cdm_service_context,
mojo::PendingRemote<stable::mojom::StableVideoDecoder>
oop_video_decoder_pending_remote)
: … { … }
MojoVideoDecoderService::~MojoVideoDecoderService() { … }
void MojoVideoDecoderService::GetSupportedConfigs(
GetSupportedConfigsCallback callback) { … }
void MojoVideoDecoderService::Construct(
mojo::PendingAssociatedRemote<mojom::VideoDecoderClient> client,
mojo::PendingRemote<mojom::MediaLog> media_log,
mojo::PendingReceiver<mojom::VideoFrameHandleReleaser>
video_frame_handle_releaser_receiver,
mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe,
mojom::CommandBufferIdPtr command_buffer_id,
const gfx::ColorSpace& target_color_space) { … }
void MojoVideoDecoderService::Initialize(
const VideoDecoderConfig& config,
bool low_delay,
const std::optional<base::UnguessableToken>& cdm_id,
InitializeCallback callback) { … }
void MojoVideoDecoderService::Decode(mojom::DecoderBufferPtr buffer,
DecodeCallback callback) { … }
void MojoVideoDecoderService::Reset(ResetCallback callback) { … }
void MojoVideoDecoderService::OnDecoderInitialized(DecoderStatus status) { … }
void MojoVideoDecoderService::OnReaderRead(
DecodeCallback callback,
std::unique_ptr<ScopedDecodeTrace> trace_event,
scoped_refptr<DecoderBuffer> buffer) { … }
void MojoVideoDecoderService::OnReaderFlushed() { … }
void MojoVideoDecoderService::OnDecoderDecoded(
DecodeCallback callback,
std::unique_ptr<ScopedDecodeTrace> trace_event,
media::DecoderStatus status) { … }
void MojoVideoDecoderService::OnDecoderReset() { … }
void MojoVideoDecoderService::OnDecoderOutput(scoped_refptr<VideoFrame> frame) { … }
void MojoVideoDecoderService::OnDecoderWaiting(WaitingReason reason) { … }
void MojoVideoDecoderService::OnOverlayInfoChanged(
const OverlayInfo& overlay_info) { … }
void MojoVideoDecoderService::OnDecoderRequestedOverlayInfo(
bool restart_for_transitions,
ProvideOverlayInfoCB provide_overlay_info_cb) { … }
}