#include "media/mojo/clients/mojo_stable_video_decoder.h"
#include <optional>
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_macros.h"
#include "components/viz/common/resources/shared_image_format.h"
#include "gpu/command_buffer/client/client_shared_image.h"
#include "gpu/command_buffer/client/shared_image_interface.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/mailbox_holder.h"
#include "gpu/command_buffer/common/shared_image_capabilities.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "media/base/supported_video_decoder_config.h"
#include "media/base/video_frame.h"
#include "media/base/video_types.h"
#include "media/base/video_util.h"
#include "media/gpu/chromeos/frame_resource.h"
#include "media/gpu/chromeos/oop_video_decoder.h"
#include "media/gpu/macros.h"
#include "media/video/gpu_video_accelerator_factories.h"
#include "third_party/skia/include/core/SkAlphaType.h"
#include "third_party/skia/include/gpu/GrTypes.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
namespace media {
const char kMojoStableVideoDecoderDecodeLatencyHistogram[] = …;
namespace {
std::optional<viz::SharedImageFormat> GetSharedImageFormat(
VideoPixelFormat format) { … }
}
class MojoStableVideoDecoder::SharedImageHolder
: public base::RefCountedThreadSafe<SharedImageHolder> { … };
MojoStableVideoDecoder::MojoStableVideoDecoder(
scoped_refptr<base::SequencedTaskRunner> media_task_runner,
GpuVideoAcceleratorFactories* gpu_factories,
MediaLog* media_log,
mojo::PendingRemote<stable::mojom::StableVideoDecoder>
pending_remote_decoder)
: … { … }
MojoStableVideoDecoder::~MojoStableVideoDecoder() { … }
bool MojoStableVideoDecoder::IsPlatformDecoder() const { … }
bool MojoStableVideoDecoder::SupportsDecryption() const { … }
void MojoStableVideoDecoder::Initialize(const VideoDecoderConfig& config,
bool low_delay,
CdmContext* cdm_context,
InitCB init_cb,
const OutputCB& output_cb,
const WaitingCB& waiting_cb) { … }
void MojoStableVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
DecodeCB decode_cb) { … }
void MojoStableVideoDecoder::Reset(base::OnceClosure closure) { … }
bool MojoStableVideoDecoder::NeedsBitstreamConversion() const { … }
bool MojoStableVideoDecoder::CanReadWithoutStalling() const { … }
int MojoStableVideoDecoder::GetMaxDecodeRequests() const { … }
VideoDecoderType MojoStableVideoDecoder::GetDecoderType() const { … }
void MojoStableVideoDecoder::InitializeOnceSupportedConfigsAreKnown(
const VideoDecoderConfig& config,
bool low_delay,
CdmContext* cdm_context,
InitCB init_cb,
const OutputCB& output_cb,
const WaitingCB& waiting_cb,
mojo::PendingRemote<stable::mojom::StableVideoDecoder>
pending_remote_decoder) { … }
scoped_refptr<MojoStableVideoDecoder::SharedImageHolder>
MojoStableVideoDecoder::CreateOrUpdateSharedImageForFrame(
const scoped_refptr<FrameResource>& frame_resource) { … }
void MojoStableVideoDecoder::UnregisterSharedImage(
gfx::GenericSharedMemoryId frame_id) { … }
void MojoStableVideoDecoder::OnFrameResourceDecoded(
scoped_refptr<FrameResource> frame_resource) { … }
OOPVideoDecoder* MojoStableVideoDecoder::oop_video_decoder() { … }
const OOPVideoDecoder* MojoStableVideoDecoder::oop_video_decoder() const { … }
}