// Copyright 2014 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MEDIA_VIDEO_FRAME_COMPOSITOR_H_ #define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MEDIA_VIDEO_FRAME_COMPOSITOR_H_ #include <utility> #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "base/memory/scoped_refptr.h" #include "base/synchronization/lock.h" #include "base/task/single_thread_task_runner.h" #include "base/thread_annotations.h" #include "base/time/tick_clock.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "base/trace_event/auto_open_close_event.h" #include "cc/layers/surface_layer.h" #include "cc/layers/video_frame_provider.h" #include "media/base/video_renderer_sink.h" #include "third_party/blink/public/platform/web_common.h" #include "third_party/blink/public/platform/web_media_player.h" #include "third_party/blink/public/platform/web_video_frame_submitter.h" namespace base { class WaitableEvent; } namespace media { class VideoFrame; } namespace viz { class SurfaceId; } namespace blink { // VideoFrameCompositor acts as a bridge between the media and cc layers for // rendering video frames. I.e. a media::VideoRenderer will talk to this class // from the media side, while a cc::VideoFrameProvider::Client will talk to it // from the cc side. // // This class is responsible for requesting new frames from a video renderer in // response to requests from the VFP::Client. Since the VFP::Client may stop // issuing requests in response to visibility changes it is also responsible for // ensuring the "freshness" of the current frame for programmatic frame // requests; e.g., Canvas.drawImage() requests // // This class is also responsible for detecting frames dropped by the compositor // after rendering and signaling that information to a RenderCallback. It // detects frames not dropped by verifying each GetCurrentFrame() is followed // by a PutCurrentFrame() before the next UpdateCurrentFrame() call. // // VideoRenderSink::RenderCallback implementations must call Start() and Stop() // once new frames are expected or are no longer expected to be ready; this data // is relayed to the compositor to avoid extraneous callbacks. // // VideoFrameCompositor is also responsible for pumping UpdateCurrentFrame() // callbacks in the background when |client_| has decided to suspend them. // // VideoFrameCompositor must live on the same thread as the compositor, though // it may be constructed on any thread. class BLINK_PLATFORM_EXPORT VideoFrameCompositor : public media::VideoRendererSink, public cc::VideoFrameProvider { … }; } // namespace blink #endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MEDIA_VIDEO_FRAME_COMPOSITOR_H_