tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

window_capturer_win_gdi.h (2496B)


      1 /*
      2 *  Copyright (c) 2020 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_WINDOW_CAPTURER_WIN_GDI_H_
     12 #define MODULES_DESKTOP_CAPTURE_WIN_WINDOW_CAPTURER_WIN_GDI_H_
     13 
     14 #include <map>
     15 #include <memory>
     16 #include <vector>
     17 
     18 #include "modules/desktop_capture/desktop_capture_options.h"
     19 #include "modules/desktop_capture/desktop_capturer.h"
     20 #include "modules/desktop_capture/desktop_geometry.h"
     21 #include "modules/desktop_capture/win/window_capture_utils.h"
     22 #include "modules/desktop_capture/window_finder_win.h"
     23 
     24 namespace webrtc {
     25 
     26 class WindowCapturerWinGdi : public DesktopCapturer {
     27 public:
     28  explicit WindowCapturerWinGdi(bool enumerate_current_process_windows);
     29 
     30  // Disallow copy and assign
     31  WindowCapturerWinGdi(const WindowCapturerWinGdi&) = delete;
     32  WindowCapturerWinGdi& operator=(const WindowCapturerWinGdi&) = delete;
     33 
     34  ~WindowCapturerWinGdi() override;
     35 
     36  static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
     37      const DesktopCaptureOptions& options);
     38 
     39  // DesktopCapturer interface.
     40  void Start(Callback* callback) override;
     41  void CaptureFrame() override;
     42  bool GetSourceList(SourceList* sources) override;
     43  bool SelectSource(SourceId id) override;
     44  bool FocusOnSelectedSource() override;
     45  bool IsOccluded(const DesktopVector& pos) override;
     46 
     47 private:
     48  struct CaptureResults {
     49    Result result;
     50    std::unique_ptr<DesktopFrame> frame;
     51  };
     52 
     53  CaptureResults CaptureFrame(bool capture_owned_windows);
     54 
     55  Callback* callback_ = nullptr;
     56 
     57  // HWND and HDC for the currently selected window or nullptr if window is not
     58  // selected.
     59  HWND window_ = nullptr;
     60 
     61  DesktopSize previous_size_;
     62 
     63  WindowCaptureHelperWin window_capture_helper_;
     64 
     65  bool enumerate_current_process_windows_;
     66 
     67  // This map is used to avoid flickering for the case when SelectWindow() calls
     68  // are interleaved with Capture() calls.
     69  std::map<HWND, DesktopSize> window_size_map_;
     70 
     71  WindowFinderWin window_finder_;
     72 
     73  std::vector<HWND> owned_windows_;
     74  std::unique_ptr<WindowCapturerWinGdi> owned_window_capturer_;
     75 };
     76 
     77 }  // namespace webrtc
     78 
     79 #endif  // MODULES_DESKTOP_CAPTURE_WIN_WINDOW_CAPTURER_WIN_GDI_H_