#ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_GPU_CHANNEL_HOST_H_
#define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_GPU_CHANNEL_HOST_H_
#include "base/no_destructor.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "gpu/command_buffer/client/shared_image_interface.h"
#include "media/capture/capture_export.h"
namespace media {
class VideoCaptureGpuContextLostObserver : public base::CheckedObserver {
public:
virtual void OnContextLost() = 0;
protected:
~VideoCaptureGpuContextLostObserver() override = default;
};
class CAPTURE_EXPORT VideoCaptureGpuChannelHost final
: public VideoCaptureGpuContextLostObserver {
public:
static VideoCaptureGpuChannelHost& GetInstance();
VideoCaptureGpuChannelHost(const VideoCaptureGpuChannelHost&) = delete;
VideoCaptureGpuChannelHost& operator=(const VideoCaptureGpuChannelHost&) =
delete;
void SetSharedImageInterface(scoped_refptr<gpu::SharedImageInterface>);
scoped_refptr<gpu::SharedImageInterface> GetSharedImageInterface();
void OnContextLost() override;
void AddObserver(VideoCaptureGpuContextLostObserver*);
void RemoveObserver(VideoCaptureGpuContextLostObserver*);
private:
friend class base::NoDestructor<VideoCaptureGpuChannelHost>;
VideoCaptureGpuChannelHost();
~VideoCaptureGpuChannelHost() override;
mutable base::Lock lock_;
base::ObserverList<VideoCaptureGpuContextLostObserver> observers_
GUARDED_BY(lock_);
scoped_refptr<gpu::SharedImageInterface> shared_image_interface_
GUARDED_BY(lock_);
};
}
#endif