dxgi_frame.h (2162B)
1 /* 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_DESKTOP_CAPTURE_WIN_DXGI_FRAME_H_ 12 #define MODULES_DESKTOP_CAPTURE_WIN_DXGI_FRAME_H_ 13 14 #include <memory> 15 16 #include "modules/desktop_capture/desktop_capture_types.h" 17 #include "modules/desktop_capture/desktop_capturer.h" 18 #include "modules/desktop_capture/desktop_geometry.h" 19 #include "modules/desktop_capture/resolution_tracker.h" 20 #include "modules/desktop_capture/shared_desktop_frame.h" 21 #include "modules/desktop_capture/shared_memory.h" 22 #include "modules/desktop_capture/win/dxgi_context.h" 23 24 namespace webrtc { 25 26 class DxgiDuplicatorController; 27 28 // A pair of a SharedDesktopFrame and a DxgiDuplicatorController::Context for 29 // the client of DxgiDuplicatorController. 30 class DxgiFrame final { 31 public: 32 using Context = DxgiFrameContext; 33 34 // DxgiFrame does not take ownership of `factory`, consumers should ensure it 35 // outlives this instance. nullptr is acceptable. 36 explicit DxgiFrame(SharedMemoryFactory* factory); 37 ~DxgiFrame(); 38 39 // Should not be called if Prepare() is not executed or returns false. 40 SharedDesktopFrame* frame() const; 41 42 private: 43 // Allows DxgiDuplicatorController to access Prepare() and context() function 44 // as well as Context class. 45 friend class DxgiDuplicatorController; 46 47 // Prepares current instance with desktop size and source id. 48 bool Prepare(DesktopSize size, DesktopCapturer::SourceId source_id); 49 50 // Should not be called if Prepare() is not executed or returns false. 51 Context* context(); 52 53 SharedMemoryFactory* const factory_; 54 ResolutionTracker resolution_tracker_; 55 DesktopCapturer::SourceId source_id_ = kFullDesktopScreenId; 56 std::unique_ptr<SharedDesktopFrame> frame_; 57 Context context_; 58 }; 59 60 } // namespace webrtc 61 62 #endif // MODULES_DESKTOP_CAPTURE_WIN_DXGI_FRAME_H_