#ifndef CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_
#define CC_LAYERS_VIDEO_FRAME_PROVIDER_CLIENT_IMPL_H_
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
#include "cc/cc_export.h"
#include "cc/layers/video_frame_provider.h"
#include "cc/scheduler/video_frame_controller.h"
#include "ui/gfx/geometry/transform.h"
namespace media { class VideoFrame; }
namespace cc {
class VideoLayerImpl;
class CC_EXPORT VideoFrameProviderClientImpl
: public VideoFrameProvider::Client,
public VideoFrameController,
public base::RefCounted<VideoFrameProviderClientImpl> {
public:
static scoped_refptr<VideoFrameProviderClientImpl> Create(
VideoFrameProvider* provider,
VideoFrameControllerClient* client);
VideoFrameProviderClientImpl(const VideoFrameProviderClientImpl&) = delete;
VideoFrameProviderClientImpl& operator=(const VideoFrameProviderClientImpl&) =
delete;
VideoLayerImpl* ActiveVideoLayer() const;
void SetActiveVideoLayer(VideoLayerImpl* video_layer);
bool Stopped() const;
void Stop();
scoped_refptr<media::VideoFrame> AcquireLockAndCurrentFrame()
EXCLUSIVE_LOCK_FUNCTION(provider_lock_);
void PutCurrentFrame() EXCLUSIVE_LOCKS_REQUIRED(provider_lock_);
void ReleaseLock() UNLOCK_FUNCTION(provider_lock_);
void AssertLocked() const ASSERT_EXCLUSIVE_LOCK(provider_lock_) {
provider_lock_.AssertAcquired();
}
bool HasCurrentFrame();
void OnBeginFrame(const viz::BeginFrameArgs& args) override;
void DidDrawFrame() override;
void StopUsingProvider() override;
void StartRendering() override;
void StopRendering() override;
void DidReceiveFrame() override;
bool IsDrivingFrameUpdates() const override;
const VideoFrameProvider* get_provider_for_testing() const {
return provider_;
}
private:
friend class base::RefCounted<VideoFrameProviderClientImpl>;
VideoFrameProviderClientImpl(VideoFrameProvider* provider,
VideoFrameControllerClient* client);
~VideoFrameProviderClientImpl() override;
raw_ptr<VideoFrameProvider> provider_;
raw_ptr<VideoFrameControllerClient> client_;
raw_ptr<VideoLayerImpl> active_video_layer_;
bool stopped_;
bool rendering_;
bool needs_put_current_frame_;
base::Lock provider_lock_;
base::ThreadChecker thread_checker_;
};
}
#endif