This reverts commit a0adf3d4409036d095480e9bfa0fc06990362f84. Reason for revert: Suspected of breaking chromium trybots, blocking webrtc from rolling into chromium. - First failed roll: https://chromium-review.googlesource.com/c/chromium/src/+/1889997 - Second failed roll: https://chromium-review.googlesource.com/c/chromium/src/+/1890837 Example failure: https://ci.chromium.org/p/chromium/builders/try/linux-rel/230122 Log: https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8898155661969383856/+/steps/browser_tests__with_patch_/0/logs/Deterministic_failure:_DesktopCaptureApiTest.ChooseDesktopMedia__status_FAILURE_/0 Including lines like: [12413:12413:1030/102514.183135:INFO:CONSOLE(0)] "[FAIL] screenShareWithAudioPermissionGetStream: NotReadableError: Could not start video source Error", source: chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/_generated_background_page.html (0) 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} TBR=zijiehe@chromium.org,tommi@webrtc.org,julien.isorce@chromium.org,sergeyu@chromium.org,trevor.axiom@gmail.com,jonringle@gmail.com Change-Id: I2af6a0d5eaf74a0ee536d1c5440049a21d6f7dbf No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:396091 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158740 Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29658}
129 lines
4.4 KiB
C++
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_
|