#include "third_party/blink/renderer/modules/webcodecs/video_decoder_broker.h"
#include <limits>
#include <memory>
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/task/sequenced_task_runner.h"
#include "build/buildflag.h"
#include "media/base/decoder_factory.h"
#include "media/base/decoder_status.h"
#include "media/base/media_util.h"
#include "media/base/video_decoder_config.h"
#include "media/mojo/buildflags.h"
#include "media/mojo/clients/mojo_decoder_factory.h"
#include "media/mojo/mojom/interface_factory.mojom.h"
#include "media/renderers/default_decoder_factory.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/modules/webcodecs/decoder_selector.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/worker_pool.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_mojo.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "ui/gfx/color_space.h"
#if BUILDFLAG(IS_FUCHSIA)
#include "media/fuchsia/video/fuchsia_decoder_factory.h"
#endif
DecoderDetails;
namespace WTF {
template <>
struct CrossThreadCopier<media::VideoDecoderConfig>
: public CrossThreadCopierPassThrough<media::VideoDecoderConfig> { … };
template <>
struct CrossThreadCopier<media::DecoderStatus>
: public CrossThreadCopierPassThrough<media::DecoderStatus> { … };
template <>
struct CrossThreadCopier<std::optional<DecoderDetails>>
: public CrossThreadCopierPassThrough<std::optional<DecoderDetails>> { … };
}
namespace blink {
class MediaVideoTaskWrapper { … };
VideoDecoderBroker::VideoDecoderBroker(
ExecutionContext& execution_context,
media::GpuVideoAcceleratorFactories* gpu_factories,
media::MediaLog* media_log)
: … { … }
VideoDecoderBroker::~VideoDecoderBroker() { … }
media::VideoDecoderType VideoDecoderBroker::GetDecoderType() const { … }
bool VideoDecoderBroker::IsPlatformDecoder() const { … }
void VideoDecoderBroker::SetHardwarePreference(
HardwarePreference hardware_preference) { … }
void VideoDecoderBroker::Initialize(const media::VideoDecoderConfig& config,
bool low_delay,
media::CdmContext* cdm_context,
InitCB init_cb,
const OutputCB& output_cb,
const media::WaitingCB& waiting_cb) { … }
int VideoDecoderBroker::CreateCallbackId() { … }
void VideoDecoderBroker::OnInitialize(media::DecoderStatus status,
std::optional<DecoderDetails> details) { … }
void VideoDecoderBroker::Decode(scoped_refptr<media::DecoderBuffer> buffer,
DecodeCB decode_cb) { … }
void VideoDecoderBroker::OnDecodeDone(int cb_id, media::DecoderStatus status) { … }
void VideoDecoderBroker::Reset(base::OnceClosure reset_cb) { … }
bool VideoDecoderBroker::NeedsBitstreamConversion() const { … }
bool VideoDecoderBroker::CanReadWithoutStalling() const { … }
int VideoDecoderBroker::GetMaxDecodeRequests() const { … }
void VideoDecoderBroker::OnReset(int cb_id) { … }
void VideoDecoderBroker::OnDecodeOutput(scoped_refptr<media::VideoFrame> frame,
bool can_read_without_stalling) { … }
}