window_capturer_x11.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2018 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_LINUX_WINDOW_CAPTURER_X11_H_
  11. #define MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_CAPTURER_X11_H_
  12. #include <X11/X.h>
  13. #include <X11/Xlib.h>
  14. #include <memory>
  15. #include <string>
  16. #include "api/scoped_refptr.h"
  17. #include "modules/desktop_capture/desktop_capture_options.h"
  18. #include "modules/desktop_capture/desktop_capturer.h"
  19. #include "modules/desktop_capture/desktop_geometry.h"
  20. #include "modules/desktop_capture/linux/shared_x_display.h"
  21. #include "modules/desktop_capture/linux/window_finder_x11.h"
  22. #include "modules/desktop_capture/linux/x_atom_cache.h"
  23. #include "modules/desktop_capture/linux/x_server_pixel_buffer.h"
  24. #include "rtc_base/constructor_magic.h"
  25. namespace webrtc {
  26. class WindowCapturerX11 : public DesktopCapturer,
  27. public SharedXDisplay::XEventHandler {
  28. public:
  29. explicit WindowCapturerX11(const DesktopCaptureOptions& options);
  30. ~WindowCapturerX11() override;
  31. static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
  32. const DesktopCaptureOptions& options);
  33. // DesktopCapturer interface.
  34. void Start(Callback* callback) override;
  35. void CaptureFrame() override;
  36. bool GetSourceList(SourceList* sources) override;
  37. bool SelectSource(SourceId id) override;
  38. bool FocusOnSelectedSource() override;
  39. bool IsOccluded(const DesktopVector& pos) override;
  40. // SharedXDisplay::XEventHandler interface.
  41. bool HandleXEvent(const XEvent& event) override;
  42. private:
  43. Display* display() { return x_display_->display(); }
  44. // Returns window title for the specified X |window|.
  45. bool GetWindowTitle(::Window window, std::string* title);
  46. Callback* callback_ = nullptr;
  47. rtc::scoped_refptr<SharedXDisplay> x_display_;
  48. bool has_composite_extension_ = false;
  49. ::Window selected_window_ = 0;
  50. XServerPixelBuffer x_server_pixel_buffer_;
  51. XAtomCache atom_cache_;
  52. WindowFinderX11 window_finder_;
  53. RTC_DISALLOW_COPY_AND_ASSIGN(WindowCapturerX11);
  54. };
  55. } // namespace webrtc
  56. #endif // MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_CAPTURER_X11_H_