// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SERVICES_VIDEO_CAPTURE_PUBLIC_CPP_VIDEO_FRAME_ACCESS_HANDLER_H_ #define SERVICES_VIDEO_CAPTURE_PUBLIC_CPP_VIDEO_FRAME_ACCESS_HANDLER_H_ #include <map> #include <memory> #include "base/memory/ref_counted.h" #include "media/capture/video/video_capture_device.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/video_capture/public/mojom/video_frame_handler.mojom.h" namespace video_capture { // A referernce counted map of buffer IDs <-> ScopedAccessPermissions. This // lives on the sender side and the reference counting ensures that the map // stays alive until all mojo pipes are disconnected, i.e. until all // VideoFrameAccessHandlerImpl are destroyed. class ScopedAccessPermissionMap : public base::RefCountedThreadSafe<ScopedAccessPermissionMap> { … }; // The implementation of mojom::VideoFrameAccessHandler lives on the sender side // and handles buffers being released through IPC calls. class VideoFrameAccessHandlerImpl : public mojom::VideoFrameAccessHandler { … }; // A reference counted object owning a // mojo::Remote<video_capture::mojom::VideoFrameAccessHandler>. This lives on // the receiver side and keeps the mojo pipe open while being alive. While the // mojo pipe is open, the mojom::VideoFrameAccessHandler implementation (e.g. // VideoFrameAccessHandlerImpl) is also kept alive on the sender side. class VideoFrameAccessHandlerRemote : public base::RefCounted<VideoFrameAccessHandlerRemote> { … }; // Forwards OnFinishedConsumingBuffer() calls to VideoFrameAccessHandlerRemote. // This can be used by adapters that act as the middleman between a producer of // frames and mojom::VideoFrameHandler. class VideoFrameAccessHandlerForwarder : public mojom::VideoFrameAccessHandler { … }; } // namespace video_capture #endif // SERVICES_VIDEO_CAPTURE_PUBLIC_CPP_VIDEO_FRAME_ACCESS_HANDLER_H_