#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 {
MainThreadTaskRunnerRestricted AccessMainThreadForGpuMemoryBufferManager() { … }
namespace {
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
class TransferringOptimizer : public WritableStreamTransferringOptimizer { … };
gpu::GpuMemoryBufferManager* GetGmbManager() { … }
}
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) { … }
}