dxgi_frame.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifndef MODULES_DESKTOP_CAPTURE_WIN_DXGI_FRAME_H_
  11. #define MODULES_DESKTOP_CAPTURE_WIN_DXGI_FRAME_H_
  12. #include <memory>
  13. #include <vector>
  14. #include "modules/desktop_capture/desktop_capture_types.h"
  15. #include "modules/desktop_capture/desktop_capturer.h"
  16. #include "modules/desktop_capture/desktop_geometry.h"
  17. #include "modules/desktop_capture/resolution_tracker.h"
  18. #include "modules/desktop_capture/shared_desktop_frame.h"
  19. #include "modules/desktop_capture/shared_memory.h"
  20. #include "modules/desktop_capture/win/dxgi_context.h"
  21. namespace webrtc {
  22. class DxgiDuplicatorController;
  23. // A pair of a SharedDesktopFrame and a DxgiDuplicatorController::Context for
  24. // the client of DxgiDuplicatorController.
  25. class DxgiFrame final {
  26. public:
  27. using Context = DxgiFrameContext;
  28. // DxgiFrame does not take ownership of |factory|, consumers should ensure it
  29. // outlives this instance. nullptr is acceptable.
  30. explicit DxgiFrame(SharedMemoryFactory* factory);
  31. ~DxgiFrame();
  32. // Should not be called if Prepare() is not executed or returns false.
  33. SharedDesktopFrame* frame() const;
  34. private:
  35. // Allows DxgiDuplicatorController to access Prepare() and context() function
  36. // as well as Context class.
  37. friend class DxgiDuplicatorController;
  38. // Prepares current instance with desktop size and source id.
  39. bool Prepare(DesktopSize size, DesktopCapturer::SourceId source_id);
  40. // Should not be called if Prepare() is not executed or returns false.
  41. Context* context();
  42. SharedMemoryFactory* const factory_;
  43. ResolutionTracker resolution_tracker_;
  44. DesktopCapturer::SourceId source_id_ = kFullDesktopScreenId;
  45. std::unique_ptr<SharedDesktopFrame> frame_;
  46. Context context_;
  47. };
  48. } // namespace webrtc
  49. #endif // MODULES_DESKTOP_CAPTURE_WIN_DXGI_FRAME_H_