chromium/third_party/blink/renderer/modules/breakout_box/media_stream_video_track_underlying_sink.cc

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

#include "third_party/blink/renderer/modules/breakout_box/media_stream_video_track_underlying_sink.h"

#include "base/feature_list.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "media/base/video_types.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_video_frame.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/streams/writable_stream_transferring_optimizer.h"
#include "third_party/blink/renderer/modules/breakout_box/metrics.h"
#include "third_party/blink/renderer/modules/webcodecs/video_frame.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h"
#include "third_party/blink/renderer/platform/graphics/web_graphics_context_3d_video_frame_pool.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"

namespace blink {

// Cannot be in the anonymous namespace because it is friended by
// MainThreadTaskRunnerRestricted.
MainThreadTaskRunnerRestricted AccessMainThreadForGpuMemoryBufferManager() {}

namespace {
// Enables conversion of input frames in RGB format to NV12 GMB-backed format
// if GMB readback from texture is supported.
BASE_FEATURE();

// If BreakoutBoxEagerConversion is enabled, this feature enables frame
// conversion even if the sinks connected to the track backed by the
// MediaStreamVideoTrackUnderlyingSink have not sent the RequireMappedFrame
// signal.
// This feature has no effect if BreakoutBoxEagerConversion is disabled.
BASE_FEATURE();

// If BreakoutBoxWriteVideoFrameCaptureTimestamp is enabled, the timestamp from
// a blink::VideoFrame written to a MediaStreamVideoTrackUnderlyingSink is also
// set as the capture timestamp for its underlying media::VideoFrame.
// TODO(crbug.com/343870500): Remove this feature once WebCodec VideoFrames
// expose the capture time as metadata.
BASE_FEATURE();

class TransferringOptimizer : public WritableStreamTransferringOptimizer {};

gpu::GpuMemoryBufferManager* GetGmbManager() {}

}  // namespace

MediaStreamVideoTrackUnderlyingSink::MediaStreamVideoTrackUnderlyingSink(
    scoped_refptr<PushableMediaStreamVideoSource::Broker> source_broker,
    gpu::GpuMemoryBufferManager* gmb_manager)
    :{}

MediaStreamVideoTrackUnderlyingSink::MediaStreamVideoTrackUnderlyingSink(
    scoped_refptr<PushableMediaStreamVideoSource::Broker> source_broker)
    :{}

MediaStreamVideoTrackUnderlyingSink::~MediaStreamVideoTrackUnderlyingSink() =
    default;

ScriptPromise<IDLUndefined> MediaStreamVideoTrackUnderlyingSink::start(
    ScriptState* script_state,
    WritableStreamDefaultController* controller,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> MediaStreamVideoTrackUnderlyingSink::write(
    ScriptState* script_state,
    ScriptValue chunk,
    WritableStreamDefaultController* controller,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> MediaStreamVideoTrackUnderlyingSink::abort(
    ScriptState* script_state,
    ScriptValue reason,
    ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> MediaStreamVideoTrackUnderlyingSink::close(
    ScriptState* script_state,
    ExceptionState& exception_state) {}

std::unique_ptr<WritableStreamTransferringOptimizer>
MediaStreamVideoTrackUnderlyingSink::GetTransferringOptimizer() {}

void MediaStreamVideoTrackUnderlyingSink::Disconnect() {}

void MediaStreamVideoTrackUnderlyingSink::CreateAcceleratedFramePool(
    gpu::GpuMemoryBufferManager* gmb_manager) {}

std::optional<ScriptPromise<IDLUndefined>>
MediaStreamVideoTrackUnderlyingSink::MaybeConvertToNV12GMBVideoFrame(
    ScriptState* script_state,
    scoped_refptr<media::VideoFrame> video_frame,
    base::TimeTicks estimated_capture_time) {}

void MediaStreamVideoTrackUnderlyingSink::ConvertDone(
    ScriptPromiseResolver<IDLUndefined>* resolver,
    scoped_refptr<media::VideoFrame> orig_video_frame,
    base::TimeTicks estimated_capture_time,
    scoped_refptr<media::VideoFrame> converted_video_frame) {}

}  // namespace blink