This reverts commit dd20c9c1e3f681f6c33d1879c76f588bd4b095bd. Reason for revert: Speculative revert; looks like it causes crashes on official builders. See crbug.com/901319. Original change's description: > Add support for screen sharing with PipeWire on Wayland > > Currently, when users want to use the screen sharing and are using the > Wayland display server (the default on Fedora distribution), then it > doesn't work, because the WebRTC only includes the X11 implementation. > This change adds the support by using the PipeWire multimedia server. > > The PipeWire implementation in WebRTC stays in > screen-capturer-pipewire.c and is guarded by the rtc_use_pipewire build > flag that is automatically enabled on Linux. > > More information are included in the relevant commit messages. > > Tested on the current Chromium master and Firefox. > > The sysroot changes are requested in: > https://chromium-review.googlesource.com/c/chromium/src/+/1258174 > > Co-authored-by: Jan Grulich <grulja@gmail.com> > Co-authored-by: Eike Rathke <erathke@redhat.com> > Change-Id: I212074a4bc437b99a77bf383266026c5bfae7c4a > > BUG=chromium:682122 > > Change-Id: I212074a4bc437b99a77bf383266026c5bfae7c4a > Reviewed-on: https://webrtc-review.googlesource.com/c/103504 > Commit-Queue: Patrik Höglund <phoglund@webrtc.org> > Reviewed-by: Patrik Höglund <phoglund@webrtc.org> > Reviewed-by: Brave Yao <braveyao@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#25461} TBR=phoglund@webrtc.org,jamiewalch@chromium.org,niklas.enbom@webrtc.org,braveyao@webrtc.org,tomas.popela@gmail.com # Not skipping CQ checks because original CL landed > 1 day ago. NOPRESUBMIT=true Bug: chromium:682122, chromium:901319 Change-Id: I4ca5da77daea73cae1232953a0d633900a85a93d Reviewed-on: https://webrtc-review.googlesource.com/c/109584 Commit-Queue: Patrik Höglund <phoglund@webrtc.org> Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25522}
90 lines
2.6 KiB
C++
90 lines
2.6 KiB
C++
/*
|
|
* Copyright (c) 2013 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.
|
|
*/
|
|
|
|
#include "modules/desktop_capture/x11/shared_x_display.h"
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <algorithm>
|
|
|
|
#include "rtc_base/checks.h"
|
|
#include "rtc_base/logging.h"
|
|
|
|
namespace webrtc {
|
|
|
|
SharedXDisplay::SharedXDisplay(Display* display) : display_(display) {
|
|
RTC_DCHECK(display_);
|
|
}
|
|
|
|
SharedXDisplay::~SharedXDisplay() {
|
|
RTC_DCHECK(event_handlers_.empty());
|
|
XCloseDisplay(display_);
|
|
}
|
|
|
|
// static
|
|
rtc::scoped_refptr<SharedXDisplay> SharedXDisplay::Create(
|
|
const std::string& display_name) {
|
|
Display* display =
|
|
XOpenDisplay(display_name.empty() ? NULL : display_name.c_str());
|
|
if (!display) {
|
|
RTC_LOG(LS_ERROR) << "Unable to open display";
|
|
return NULL;
|
|
}
|
|
return new SharedXDisplay(display);
|
|
}
|
|
|
|
// static
|
|
rtc::scoped_refptr<SharedXDisplay> SharedXDisplay::CreateDefault() {
|
|
return Create(std::string());
|
|
}
|
|
|
|
void SharedXDisplay::AddEventHandler(int type, XEventHandler* handler) {
|
|
event_handlers_[type].push_back(handler);
|
|
}
|
|
|
|
void SharedXDisplay::RemoveEventHandler(int type, XEventHandler* handler) {
|
|
EventHandlersMap::iterator handlers = event_handlers_.find(type);
|
|
if (handlers == event_handlers_.end())
|
|
return;
|
|
|
|
std::vector<XEventHandler*>::iterator new_end =
|
|
std::remove(handlers->second.begin(), handlers->second.end(), handler);
|
|
handlers->second.erase(new_end, handlers->second.end());
|
|
|
|
// Check if no handlers left for this event.
|
|
if (handlers->second.empty())
|
|
event_handlers_.erase(handlers);
|
|
}
|
|
|
|
void SharedXDisplay::ProcessPendingXEvents() {
|
|
// Hold reference to |this| to prevent it from being destroyed while
|
|
// processing events.
|
|
rtc::scoped_refptr<SharedXDisplay> self(this);
|
|
|
|
// Find the number of events that are outstanding "now." We don't just loop
|
|
// on XPending because we want to guarantee this terminates.
|
|
int events_to_process = XPending(display());
|
|
XEvent e;
|
|
|
|
for (int i = 0; i < events_to_process; i++) {
|
|
XNextEvent(display(), &e);
|
|
EventHandlersMap::iterator handlers = event_handlers_.find(e.type);
|
|
if (handlers == event_handlers_.end())
|
|
continue;
|
|
for (std::vector<XEventHandler*>::iterator it = handlers->second.begin();
|
|
it != handlers->second.end(); ++it) {
|
|
if ((*it)->HandleXEvent(e))
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace webrtc
|