webrtc_m130/modules/desktop_capture/linux/screen_capturer_x11.h
Guido Urdaneta 00d0f178c2 Revert "Reland "Reland "Implemented screen enumeration and selection for desktop capture under X11 using the X Resize and Rotate extension version 1.5."""
This reverts commit af51be7869994a299451e22e6382ae641767b26d.

Reason for revert: Causes failure of Linxu CFI Chromium bot.
See https://crbug.com/1031930

Original change's description:
> Reland "Reland "Implemented screen enumeration and selection for desktop capture under X11 using the X Resize and Rotate extension version 1.5.""
> 
> This is a reland of a0adf3d4409036d095480e9bfa0fc06990362f84
> 
> Original change's description:
> > Reland "Implemented screen enumeration and selection for desktop capture under X11 using the X Resize and Rotate extension version 1.5."
> > 
> > This is a reland of e7153012682ccd3d1eacc18f802cab7820e3bad3
> > 
> > Original change's description:
> > > Implemented screen enumeration and selection for desktop capture under X11 using the X Resize and Rotate entension version 1.5.
> > >
> > > Bug: chromium:396091
> > > Change-Id: Ia1b36c771632c536bb8d15322461b479fabc409e
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/148768
> > > Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
> > > Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
> > > Cr-Commit-Position: refs/heads/master@{#29083}
> > 
> > Bug: chromium:396091
> > Change-Id: I0d9171ae5f340e0489e4b45ce5d97bc52b0a4904
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/156067
> > Commit-Queue: Tommi <tommi@webrtc.org>
> > Reviewed-by: Tommi <tommi@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#29655}
> 
> Bug: chromium:396091
> Change-Id: I47525911095fabc6cee613d03b0d83134b95b084
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158900
> Reviewed-by: Tomas Gunnarsson <tommi@chromium.org>
> Reviewed-by: Tommi <tommi@webrtc.org>
> Commit-Queue: Tommi <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#30032}

TBR=zijiehe@chromium.org,jamiewalch@chromium.org,tommi@webrtc.org,julien.isorce@chromium.org,sergeyu@chromium.org,tommi@chromium.org,trevor.axiom@gmail.com,jonringle@gmail.com,justin.franco@arterys.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: chromium:396091
Change-Id: Ibd7b21ade1547d96f42b3c24860e9f901fc71065
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161458
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Commit-Queue: Guido Urdaneta <guidou@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30039}
2019-12-09 11:26:20 +00:00

129 lines
4.4 KiB
C++

/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_SCREEN_CAPTURER_X11_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_SCREEN_CAPTURER_X11_H_
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xfixes.h>
#include <memory>
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_region.h"
#include "modules/desktop_capture/linux/shared_x_display.h"
#include "modules/desktop_capture/linux/x_atom_cache.h"
#include "modules/desktop_capture/linux/x_server_pixel_buffer.h"
#include "modules/desktop_capture/screen_capture_frame_queue.h"
#include "modules/desktop_capture/screen_capturer_helper.h"
#include "modules/desktop_capture/shared_desktop_frame.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
// A class to perform video frame capturing for Linux on X11.
//
// If XDamage is used, this class sets DesktopFrame::updated_region() according
// to the areas reported by XDamage. Otherwise this class does not detect
// DesktopFrame::updated_region(), the field is always set to the entire frame
// rectangle. ScreenCapturerDifferWrapper should be used if that functionality
// is necessary.
class ScreenCapturerX11 : public DesktopCapturer,
public SharedXDisplay::XEventHandler {
public:
ScreenCapturerX11();
~ScreenCapturerX11() override;
static std::unique_ptr<DesktopCapturer> CreateRawScreenCapturer(
const DesktopCaptureOptions& options);
// TODO(ajwong): Do we really want this to be synchronous?
bool Init(const DesktopCaptureOptions& options);
// DesktopCapturer interface.
void Start(Callback* delegate) override;
void CaptureFrame() override;
bool GetSourceList(SourceList* sources) override;
bool SelectSource(SourceId id) override;
private:
Display* display() { return options_.x_display()->display(); }
// SharedXDisplay::XEventHandler interface.
bool HandleXEvent(const XEvent& event) override;
void InitXDamage();
// Capture screen pixels to the current buffer in the queue. In the DAMAGE
// case, the ScreenCapturerHelper already holds the list of invalid rectangles
// from HandleXEvent(). In the non-DAMAGE case, this captures the
// whole screen, then calculates some invalid rectangles that include any
// differences between this and the previous capture.
std::unique_ptr<DesktopFrame> CaptureScreen();
// Called when the screen configuration is changed.
void ScreenConfigurationChanged();
// Synchronize the current buffer with |last_buffer_|, by copying pixels from
// the area of |last_invalid_rects|.
// Note this only works on the assumption that kNumBuffers == 2, as
// |last_invalid_rects| holds the differences from the previous buffer and
// the one prior to that (which will then be the current buffer).
void SynchronizeFrame();
void DeinitXlib();
DesktopCaptureOptions options_;
Callback* callback_ = nullptr;
// X11 graphics context.
GC gc_ = nullptr;
Window root_window_ = BadValue;
// XFixes.
bool has_xfixes_ = false;
int xfixes_event_base_ = -1;
int xfixes_error_base_ = -1;
// XDamage information.
bool use_damage_ = false;
Damage damage_handle_ = 0;
int damage_event_base_ = -1;
int damage_error_base_ = -1;
XserverRegion damage_region_ = 0;
// Access to the X Server's pixel buffer.
XServerPixelBuffer x_server_pixel_buffer_;
// A thread-safe list of invalid rectangles, and the size of the most
// recently captured screen.
ScreenCapturerHelper helper_;
// Queue of the frames buffers.
ScreenCaptureFrameQueue<SharedDesktopFrame> queue_;
// Invalid region from the previous capture. This is used to synchronize the
// current with the last buffer used.
DesktopRegion last_invalid_region_;
std::unique_ptr<XAtomCache> atom_cache_;
RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerX11);
};
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_SCREEN_CAPTURER_X11_H_