chromium/media/capture/video/video_capture_effects_processor.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/capture/video/video_capture_effects_processor.h"

#include <optional>

#include "base/containers/span.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "base/types/expected.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/shared_image_usage.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "media/base/video_types.h"
#include "media/capture/video/video_capture_gpu_channel_host.h"
#include "ui/gl/gl_bindings.h"

namespace media {
namespace {

// Helper, creates VideoBufferHandle for the given buffer.
// `shared_image` will be populated if the returned buffer handle refers to a
// GPU memory buffer. This is needed to ensure that the caller can maintain
// ownership of the shared image while it's in use.
mojom::VideoBufferHandlePtr CreateBufferHandle(
    const VideoCaptureDevice::Client::Buffer& buffer,
    const mojom::VideoFrameInfo& frame_info,
    VideoCaptureBufferType buffer_type,
    scoped_refptr<gpu::ClientSharedImage>& shared_image) {}

}  // namespace

PostProcessDoneInfo::PostProcessDoneInfo(
    VideoCaptureDevice::Client::Buffer buffer,
    mojom::VideoFrameInfoPtr info)
    :{}

PostProcessDoneInfo::PostProcessDoneInfo(PostProcessDoneInfo&& other) = default;
PostProcessDoneInfo& PostProcessDoneInfo::operator=(
    PostProcessDoneInfo&& other) = default;

PostProcessDoneInfo::~PostProcessDoneInfo() = default;

VideoCaptureEffectsProcessor::VideoCaptureEffectsProcessor(
    mojo::PendingRemote<video_effects::mojom::VideoEffectsProcessor>
        video_effects_processor)
    :{}

VideoCaptureEffectsProcessor::~VideoCaptureEffectsProcessor() {}

void VideoCaptureEffectsProcessor::PostProcessData(
    base::span<const uint8_t> data,
    mojom::VideoFrameInfoPtr frame_info,
    VideoCaptureDevice::Client::Buffer out_buffer,
    const VideoCaptureFormat& out_buffer_format,
    VideoCaptureBufferType out_buffer_type,
    VideoCaptureEffectsProcessor::PostProcessDoneCallback post_process_cb) {}

void VideoCaptureEffectsProcessor::PostProcessDataOnValidSequence(
    PostProcessContext context,
    mojom::VideoBufferHandlePtr in_buffer_handle,
    mojom::VideoFrameInfoPtr frame_info,
    mojom::VideoBufferHandlePtr out_buffer_handle,
    const VideoCaptureFormat& out_buffer_format) {}

void VideoCaptureEffectsProcessor::PostProcessBuffer(
    VideoCaptureDevice::Client::Buffer in_buffer,
    mojom::VideoFrameInfoPtr frame_info,
    VideoCaptureBufferType in_buffer_type,
    VideoCaptureDevice::Client::Buffer out_buffer,
    const VideoCaptureFormat& out_buffer_format,
    VideoCaptureBufferType out_buffer_type,
    VideoCaptureEffectsProcessor::PostProcessDoneCallback post_process_cb) {}

void VideoCaptureEffectsProcessor::OnPostProcess(
    VideoCaptureEffectsProcessor::PostProcessContext context,
    video_effects::mojom::PostProcessResultPtr result) {}

VideoCaptureEffectsProcessor::PostProcessContext::PostProcessContext(
    std::optional<VideoCaptureDevice::Client::Buffer> in_buffer,
    scoped_refptr<gpu::ClientSharedImage> in_shared_image,
    VideoCaptureDevice::Client::Buffer out_buffer,
    scoped_refptr<gpu::ClientSharedImage> out_shared_image,
    VideoCaptureEffectsProcessor::PostProcessDoneCallback post_process_cb)
    :{}

VideoCaptureEffectsProcessor::PostProcessContext::PostProcessContext(
    VideoCaptureEffectsProcessor::PostProcessContext&& other) = default;

VideoCaptureEffectsProcessor::PostProcessContext::~PostProcessContext() =
    default;

}  // namespace media