webrtc/modules/desktop_capture/linux/shared_x_display.h
Tomas Popela dd20c9c1e3 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}
2018-11-01 08:46:38 +00:00

81 lines
2.5 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.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_SHARED_X_DISPLAY_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_SHARED_X_DISPLAY_H_
#include <map>
#include <vector>
#include <string>
#include "api/refcountedbase.h"
#include "rtc_base/constructormagic.h"
#include "rtc_base/scoped_ref_ptr.h"
// Including Xlib.h will involve evil defines (Bool, Status, True, False), which
// easily conflict with other headers.
typedef struct _XDisplay Display;
typedef union _XEvent XEvent;
namespace webrtc {
// A ref-counted object to store XDisplay connection.
class SharedXDisplay : public rtc::RefCountedBase {
public:
class XEventHandler {
public:
virtual ~XEventHandler() {}
// Processes XEvent. Returns true if the event has been handled.
virtual bool HandleXEvent(const XEvent& event) = 0;
};
// Takes ownership of |display|.
explicit SharedXDisplay(Display* display);
// Creates a new X11 Display for the |display_name|. NULL is returned if X11
// connection failed. Equivalent to CreateDefault() when |display_name| is
// empty.
static rtc::scoped_refptr<SharedXDisplay> Create(
const std::string& display_name);
// Creates X11 Display connection for the default display (e.g. specified in
// DISPLAY). NULL is returned if X11 connection failed.
static rtc::scoped_refptr<SharedXDisplay> CreateDefault();
Display* display() { return display_; }
// Adds a new event |handler| for XEvent's of |type|.
void AddEventHandler(int type, XEventHandler* handler);
// Removes event |handler| added using |AddEventHandler|. Doesn't do anything
// if |handler| is not registered.
void RemoveEventHandler(int type, XEventHandler* handler);
// Processes pending XEvents, calling corresponding event handlers.
void ProcessPendingXEvents();
protected:
~SharedXDisplay() override;
private:
typedef std::map<int, std::vector<XEventHandler*> > EventHandlersMap;
Display* display_;
EventHandlersMap event_handlers_;
RTC_DISALLOW_COPY_AND_ASSIGN(SharedXDisplay);
};
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_SHARED_X_DISPLAY_H_