// Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef REMOTING_HOST_VIDEO_MEMORY_UTILS_H_ #define REMOTING_HOST_VIDEO_MEMORY_UTILS_H_ #include <memory> #include "base/functional/callback.h" #include "base/memory/read_only_shared_memory_region.h" #include "base/memory/ref_counted.h" #include "base/memory/shared_memory_mapping.h" #include "third_party/webrtc/modules/desktop_capture/shared_memory.h" #if BUILDFLAG(IS_WIN) #include "base/win/scoped_handle.h" #endif // BUILDFLAG(IS_WIN) // Helper classes to implement sharing of captured video frames over an IPC // channel. namespace remoting { // webrtc::SharedMemory implementation that creates a // base::ReadOnlySharedMemoryRegion along with a writable mapping. // The writable mapping is used by the real video-capturer in the Desktop // process, and the read-only region is sent over the IPC channel. class SharedVideoMemory : public webrtc::SharedMemory { … }; // A webrtc::SharedMemoryFactory implementation which creates // SharedVideoMemory objects for the real video-capturer in the Desktop // process. It notifies callbacks when memory is created and released. class SharedVideoMemoryFactory : public webrtc::SharedMemoryFactory { … }; // A wrapper for read-only memory received over IPC. This creates and stores a // ReadOnlySharedMemoryMapping for the received memory-region. class IpcSharedBufferCore : public base::RefCountedThreadSafe<IpcSharedBufferCore> { … }; // A webrtc::SharedMemory implementation which wraps an IpcSharedBufferCore. // This is used for the `shared_memory` field of a webrtc::DesktopFrame in the // Network process. class IpcSharedBuffer : public webrtc::SharedMemory { … }; } // namespace remoting #endif // REMOTING_HOST_VIDEO_MEMORY_UTILS_H_