268ae0028c
The content of this branch was automatically imported from Fedora ELN with the following as its source: https://src.fedoraproject.org/rpms/firefox#c8daf71be4963daab37d810024e0a6e7f04cf2dd
527 lines
22 KiB
Diff
527 lines
22 KiB
Diff
diff -up firefox-79.0/config/system-headers.mozbuild.firefox-pipewire-0-2 firefox-79.0/config/system-headers.mozbuild
|
|
--- firefox-79.0/config/system-headers.mozbuild.firefox-pipewire-0-2 2020-07-21 00:49:36.000000000 +0200
|
|
+++ firefox-79.0/config/system-headers.mozbuild 2020-07-29 11:03:51.455284187 +0200
|
|
@@ -314,6 +314,7 @@ system_headers = [
|
|
'Gestalt.h',
|
|
'getopt.h',
|
|
'gio/gio.h',
|
|
+ 'gio/gunixfdlist.h',
|
|
'glibconfig.h',
|
|
'glib.h',
|
|
'glib-object.h',
|
|
@@ -607,6 +608,7 @@ system_headers = [
|
|
'Pgenerr.h',
|
|
'PGenErr.h',
|
|
'Ph.h',
|
|
+ 'pipewire/pipewire.h',
|
|
'pixman.h',
|
|
'pk11func.h',
|
|
'pk11pqg.h',
|
|
diff -up firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build.firefox-pipewire-0-2 firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build
|
|
--- firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build.firefox-pipewire-0-2 2020-07-29 11:03:51.455284187 +0200
|
|
+++ firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build 2020-07-29 11:04:40.898017241 +0200
|
|
@@ -231,6 +231,27 @@ if CONFIG["OS_TARGET"] == "OpenBSD":
|
|
"/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc"
|
|
]
|
|
|
|
+# PipeWire specific files
|
|
+if CONFIG["OS_TARGET"] == "Linux":
|
|
+
|
|
+ DEFINES["WEBRTC_USE_PIPEWIRE"] = "1"
|
|
+
|
|
+ OS_LIBS += [
|
|
+ "rt",
|
|
+ "pipewire-0.2",
|
|
+ "glib-2.0",
|
|
+ "gio-2.0",
|
|
+ "gobject-2.0"
|
|
+ ]
|
|
+
|
|
+ CXXFLAGS += CONFIG['TK_CFLAGS']
|
|
+
|
|
+ UNIFIED_SOURCES += [
|
|
+ "/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc",
|
|
+ "/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc",
|
|
+ "/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc"
|
|
+ ]
|
|
+
|
|
if CONFIG["OS_TARGET"] == "WINNT":
|
|
|
|
DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
|
|
diff -up firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h.firefox-pipewire-0-2 firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h
|
|
--- firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h.firefox-pipewire-0-2 2020-07-20 22:54:16.000000000 +0200
|
|
+++ firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h 2020-07-29 11:03:51.456284181 +0200
|
|
@@ -141,7 +141,7 @@ class DesktopCaptureOptions {
|
|
bool disable_effects_ = true;
|
|
bool detect_updated_region_ = false;
|
|
#if defined(WEBRTC_USE_PIPEWIRE)
|
|
- bool allow_pipewire_ = false;
|
|
+ bool allow_pipewire_ = true;
|
|
#endif
|
|
};
|
|
|
|
diff -up firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc.firefox-pipewire-0-2 firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc
|
|
--- firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc.firefox-pipewire-0-2 2020-07-20 22:54:27.000000000 +0200
|
|
+++ firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc 2020-07-29 11:03:51.618283306 +0200
|
|
@@ -18,6 +18,11 @@
|
|
#include <spa/param/video/raw-utils.h>
|
|
#include <spa/support/type-map.h>
|
|
|
|
+#include <linux/dma-buf.h>
|
|
+#include <sys/mman.h>
|
|
+#include <sys/ioctl.h>
|
|
+#include <sys/syscall.h>
|
|
+
|
|
#include <memory>
|
|
#include <utility>
|
|
|
|
@@ -36,6 +41,27 @@ const char kSessionInterfaceName[] = "or
|
|
const char kRequestInterfaceName[] = "org.freedesktop.portal.Request";
|
|
const char kScreenCastInterfaceName[] = "org.freedesktop.portal.ScreenCast";
|
|
|
|
+
|
|
+// static
|
|
+void BaseCapturerPipeWire::SyncDmaBuf(int fd, uint64_t start_or_end) {
|
|
+ struct dma_buf_sync sync = { 0 };
|
|
+
|
|
+ sync.flags = start_or_end | DMA_BUF_SYNC_READ;
|
|
+
|
|
+ while(true) {
|
|
+ int ret;
|
|
+ ret = ioctl (fd, DMA_BUF_IOCTL_SYNC, &sync);
|
|
+ if (ret == -1 && errno == EINTR) {
|
|
+ continue;
|
|
+ } else if (ret == -1) {
|
|
+ RTC_LOG(LS_ERROR) << "Failed to synchronize DMA buffer: " << g_strerror(errno);
|
|
+ break;
|
|
+ } else {
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
// static
|
|
void BaseCapturerPipeWire::OnStateChanged(void* data,
|
|
pw_remote_state old_state,
|
|
@@ -108,11 +134,13 @@ void BaseCapturerPipeWire::OnStreamForma
|
|
auto stride = SPA_ROUND_UP_N(width * kBytesPerPixel, 4);
|
|
auto size = height * stride;
|
|
|
|
+ that->desktop_size_ = DesktopSize(width, height);
|
|
+
|
|
uint8_t buffer[1024] = {};
|
|
auto builder = spa_pod_builder{buffer, sizeof(buffer)};
|
|
|
|
// Setup buffers and meta header for new format.
|
|
- const struct spa_pod* params[2];
|
|
+ const struct spa_pod* params[3];
|
|
params[0] = reinterpret_cast<spa_pod*>(spa_pod_builder_object(
|
|
&builder,
|
|
// id to enumerate buffer requirements
|
|
@@ -141,8 +169,14 @@ void BaseCapturerPipeWire::OnStreamForma
|
|
// Size: size of the metadata, specified as integer (i)
|
|
":", that->pw_core_type_->param_meta.size, "i",
|
|
sizeof(struct spa_meta_header)));
|
|
-
|
|
- pw_stream_finish_format(that->pw_stream_, /*res=*/0, params, /*n_params=*/2);
|
|
+ params[2] = reinterpret_cast<spa_pod*>(
|
|
+ spa_pod_builder_object(&builder, that->pw_core_type_->param.idMeta,
|
|
+ that->pw_core_type_->param_meta.Meta, ":",
|
|
+ that->pw_core_type_->param_meta.type, "I",
|
|
+ that->pw_core_type_->meta.VideoCrop, ":",
|
|
+ that->pw_core_type_->param_meta.size, "i",
|
|
+ sizeof(struct spa_meta_video_crop)));
|
|
+ pw_stream_finish_format(that->pw_stream_, /*res=*/0, params, /*n_params=*/3);
|
|
}
|
|
|
|
// static
|
|
@@ -150,15 +184,25 @@ void BaseCapturerPipeWire::OnStreamProce
|
|
BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(data);
|
|
RTC_DCHECK(that);
|
|
|
|
- pw_buffer* buf = nullptr;
|
|
+ struct pw_buffer *next_buffer;
|
|
+ struct pw_buffer *buffer = nullptr;
|
|
|
|
- if (!(buf = pw_stream_dequeue_buffer(that->pw_stream_))) {
|
|
+ next_buffer = pw_stream_dequeue_buffer(that->pw_stream_);
|
|
+ while (next_buffer) {
|
|
+ buffer = next_buffer;
|
|
+ next_buffer = pw_stream_dequeue_buffer(that->pw_stream_);
|
|
+
|
|
+ if (next_buffer)
|
|
+ pw_stream_queue_buffer (that->pw_stream_, buffer);
|
|
+ }
|
|
+
|
|
+ if (!buffer) {
|
|
return;
|
|
}
|
|
|
|
- that->HandleBuffer(buf);
|
|
+ that->HandleBuffer(buffer);
|
|
|
|
- pw_stream_queue_buffer(that->pw_stream_, buf);
|
|
+ pw_stream_queue_buffer(that->pw_stream_, buffer);
|
|
}
|
|
|
|
BaseCapturerPipeWire::BaseCapturerPipeWire(CaptureSourceType source_type)
|
|
@@ -197,10 +241,6 @@ BaseCapturerPipeWire::~BaseCapturerPipeW
|
|
pw_loop_destroy(pw_loop_);
|
|
}
|
|
|
|
- if (current_frame_) {
|
|
- free(current_frame_);
|
|
- }
|
|
-
|
|
if (start_request_signal_id_) {
|
|
g_dbus_connection_signal_unsubscribe(connection_, start_request_signal_id_);
|
|
}
|
|
@@ -290,12 +330,7 @@ void BaseCapturerPipeWire::InitPipeWireT
|
|
|
|
void BaseCapturerPipeWire::CreateReceivingStream() {
|
|
spa_rectangle pwMinScreenBounds = spa_rectangle{1, 1};
|
|
- spa_rectangle pwScreenBounds =
|
|
- spa_rectangle{static_cast<uint32_t>(desktop_size_.width()),
|
|
- static_cast<uint32_t>(desktop_size_.height())};
|
|
-
|
|
- spa_fraction pwFrameRateMin = spa_fraction{0, 1};
|
|
- spa_fraction pwFrameRateMax = spa_fraction{60, 1};
|
|
+ spa_rectangle pwMaxScreenBounds = spa_rectangle{INT32_MAX, INT32_MAX};
|
|
|
|
pw_properties* reuseProps = pw_properties_new("pipewire.client.reuse", "1",
|
|
/*end of varargs*/ nullptr);
|
|
@@ -313,27 +348,19 @@ void BaseCapturerPipeWire::CreateReceivi
|
|
// then allowed formats are enumerated (e) and the format is undecided (u)
|
|
// to allow negotiation
|
|
":", pw_type_->format_video.format, "Ieu", pw_type_->video_format.BGRx,
|
|
- SPA_POD_PROP_ENUM(2, pw_type_->video_format.RGBx,
|
|
- pw_type_->video_format.BGRx),
|
|
+ SPA_POD_PROP_ENUM(
|
|
+ 4, pw_type_->video_format.RGBx, pw_type_->video_format.BGRx,
|
|
+ pw_type_->video_format.RGBA, pw_type_->video_format.BGRA),
|
|
// Video size: specified as rectangle (R), preferred size is specified as
|
|
// first parameter, then allowed size is defined as range (r) from min and
|
|
// max values and the format is undecided (u) to allow negotiation
|
|
- ":", pw_type_->format_video.size, "Rru", &pwScreenBounds, 2,
|
|
- &pwMinScreenBounds, &pwScreenBounds,
|
|
- // Frame rate: specified as fraction (F) and set to minimum frame rate
|
|
- // value
|
|
- ":", pw_type_->format_video.framerate, "F", &pwFrameRateMin,
|
|
- // Max frame rate: specified as fraction (F), preferred frame rate is set
|
|
- // to maximum value, then allowed frame rate is defined as range (r) from
|
|
- // min and max values and it is undecided (u) to allow negotiation
|
|
- ":", pw_type_->format_video.max_framerate, "Fru", &pwFrameRateMax, 2,
|
|
- &pwFrameRateMin, &pwFrameRateMax));
|
|
+ ":", pw_type_->format_video.size, "Rru", &pwMinScreenBounds,
|
|
+ SPA_POD_PROP_MIN_MAX(&pwMinScreenBounds, &pwMaxScreenBounds)));
|
|
|
|
pw_stream_add_listener(pw_stream_, &spa_stream_listener_, &pw_stream_events_,
|
|
this);
|
|
pw_stream_flags flags = static_cast<pw_stream_flags>(
|
|
- PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_INACTIVE |
|
|
- PW_STREAM_FLAG_MAP_BUFFERS);
|
|
+ PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_INACTIVE);
|
|
if (pw_stream_connect(pw_stream_, PW_DIRECTION_INPUT, /*port_path=*/nullptr,
|
|
flags, params,
|
|
/*n_params=*/1) != 0) {
|
|
@@ -344,15 +371,81 @@ void BaseCapturerPipeWire::CreateReceivi
|
|
}
|
|
|
|
void BaseCapturerPipeWire::HandleBuffer(pw_buffer* buffer) {
|
|
+ struct spa_meta_video_crop* video_crop;
|
|
spa_buffer* spaBuffer = buffer->buffer;
|
|
- void* src = nullptr;
|
|
+ uint8_t *map = nullptr;
|
|
+ uint8_t* src = nullptr;
|
|
+ uint8_t* dst = nullptr;
|
|
+
|
|
+ if (spaBuffer->datas[0].chunk->size == 0) {
|
|
+ map = nullptr;
|
|
+ src = nullptr;
|
|
+ } else if (spaBuffer->datas[0].type == pw_core_type_->data.MemFd) {
|
|
+ map = static_cast<uint8_t*>(mmap(
|
|
+ nullptr, spaBuffer->datas[0].maxsize + spaBuffer->datas[0].mapoffset,
|
|
+ PROT_READ, MAP_PRIVATE, spaBuffer->datas[0].fd, 0));
|
|
+ src = SPA_MEMBER(map, spaBuffer->datas[0].mapoffset, uint8_t);
|
|
+ } else if (spaBuffer->datas[0].type == pw_core_type_->data.DmaBuf) {
|
|
+ int fd;
|
|
+ fd = spaBuffer->datas[0].fd;
|
|
+
|
|
+ map = static_cast<uint8_t*>(mmap(
|
|
+ nullptr, spaBuffer->datas[0].maxsize + spaBuffer->datas[0].mapoffset,
|
|
+ PROT_READ, MAP_PRIVATE, fd, 0));
|
|
+ SyncDmaBuf(fd, DMA_BUF_SYNC_START);
|
|
+
|
|
+ src = SPA_MEMBER(map, spaBuffer->datas[0].mapoffset, uint8_t);
|
|
+ } else if (spaBuffer->datas[0].type == pw_core_type_->data.MemPtr) {
|
|
+ map = nullptr;
|
|
+ src = static_cast<uint8_t*>(spaBuffer->datas[0].data);
|
|
+ } else {
|
|
+ return;
|
|
+ }
|
|
|
|
- if (!(src = spaBuffer->datas[0].data)) {
|
|
+ if (!src) {
|
|
return;
|
|
}
|
|
|
|
- uint32_t maxSize = spaBuffer->datas[0].maxsize;
|
|
- int32_t srcStride = spaBuffer->datas[0].chunk->stride;
|
|
+ DesktopSize prev_crop_size = DesktopSize(0, 0);
|
|
+ if (video_crop_size_initialized_) {
|
|
+ prev_crop_size = video_crop_size_;
|
|
+ }
|
|
+
|
|
+ if ((video_crop = static_cast<struct spa_meta_video_crop*>(
|
|
+ spa_buffer_find_meta(spaBuffer, pw_core_type_->meta.VideoCrop)))) {
|
|
+ RTC_DCHECK(video_crop->width <= desktop_size_.width() &&
|
|
+ video_crop->height <= desktop_size_.height());
|
|
+ if ((video_crop->width != desktop_size_.width() ||
|
|
+ video_crop->height != desktop_size_.height()) && video_crop->width && video_crop->height) {
|
|
+ video_crop_size_ = DesktopSize(video_crop->width, video_crop->height);
|
|
+ video_crop_size_initialized_ = true;
|
|
+ } else {
|
|
+ video_crop_size_initialized_ = false;
|
|
+ }
|
|
+ } else {
|
|
+ video_crop_size_initialized_ = false;
|
|
+ }
|
|
+
|
|
+ size_t frame_size;
|
|
+ if (video_crop_size_initialized_) {
|
|
+ frame_size =
|
|
+ video_crop_size_.width() * video_crop_size_.height() * kBytesPerPixel;
|
|
+ } else {
|
|
+ frame_size =
|
|
+ desktop_size_.width() * desktop_size_.height() * kBytesPerPixel;
|
|
+ }
|
|
+
|
|
+ if (!current_frame_ ||
|
|
+ (video_crop_size_initialized_ && !video_crop_size_.equals(prev_crop_size))) {
|
|
+ current_frame_ = std::make_unique<uint8_t[]>(frame_size);
|
|
+ }
|
|
+ RTC_DCHECK(current_frame_ != nullptr);
|
|
+
|
|
+ const int32_t dstStride = video_crop_size_initialized_
|
|
+ ? video_crop_size_.width() * kBytesPerPixel
|
|
+ : desktop_size_.width() * kBytesPerPixel;
|
|
+ const int32_t srcStride = spaBuffer->datas[0].chunk->stride;
|
|
+
|
|
if (srcStride != (desktop_size_.width() * kBytesPerPixel)) {
|
|
RTC_LOG(LS_ERROR) << "Got buffer with stride different from screen stride: "
|
|
<< srcStride
|
|
@@ -361,21 +454,39 @@ void BaseCapturerPipeWire::HandleBuffer(
|
|
return;
|
|
}
|
|
|
|
- if (!current_frame_) {
|
|
- current_frame_ = static_cast<uint8_t*>(malloc(maxSize));
|
|
+ dst = current_frame_.get();
|
|
+
|
|
+ // Adjust source content based on crop video position
|
|
+ if (video_crop_size_initialized_ &&
|
|
+ (video_crop->y + video_crop_size_.height() <= desktop_size_.height())) {
|
|
+ for (int i = 0; i < video_crop->y; ++i) {
|
|
+ src += srcStride;
|
|
+ }
|
|
+ }
|
|
+ const int xOffset =
|
|
+ video_crop_size_initialized_ && (video_crop->x + video_crop_size_.width() <=
|
|
+ desktop_size_.width())
|
|
+ ? video_crop->x * kBytesPerPixel
|
|
+ : 0;
|
|
+ const int height = video_crop_size_initialized_ ? video_crop_size_.height() : desktop_size_.height();
|
|
+ for (int i = 0; i < height; ++i) {
|
|
+ // Adjust source content based on crop video position if needed
|
|
+ src += xOffset;
|
|
+ std::memcpy(dst, src, dstStride);
|
|
+ // If both sides decided to go with the RGBx format we need to convert it to
|
|
+ // BGRx to match color format expected by WebRTC.
|
|
+ if (spa_video_format_->format == pw_type_->video_format.RGBx) {
|
|
+ ConvertRGBxToBGRx(dst, dstStride);
|
|
+ }
|
|
+ src += srcStride - xOffset;
|
|
+ dst += dstStride;
|
|
}
|
|
- RTC_DCHECK(current_frame_ != nullptr);
|
|
|
|
- // If both sides decided to go with the RGBx format we need to convert it to
|
|
- // BGRx to match color format expected by WebRTC.
|
|
- if (spa_video_format_->format == pw_type_->video_format.RGBx) {
|
|
- uint8_t* tempFrame = static_cast<uint8_t*>(malloc(maxSize));
|
|
- std::memcpy(tempFrame, src, maxSize);
|
|
- ConvertRGBxToBGRx(tempFrame, maxSize);
|
|
- std::memcpy(current_frame_, tempFrame, maxSize);
|
|
- free(tempFrame);
|
|
- } else {
|
|
- std::memcpy(current_frame_, src, maxSize);
|
|
+ if (map) {
|
|
+ if (spaBuffer->datas[0].type == pw_core_type_->data.DmaBuf) {
|
|
+ SyncDmaBuf(spaBuffer->datas[0].fd, DMA_BUF_SYNC_END);
|
|
+ }
|
|
+ munmap(map, spaBuffer->datas[0].maxsize + spaBuffer->datas[0].mapoffset);
|
|
}
|
|
}
|
|
|
|
@@ -725,10 +836,6 @@ void BaseCapturerPipeWire::OnStartReques
|
|
g_variant_get(variant, "(u@a{sv})", &stream_id, &options);
|
|
RTC_DCHECK(options != nullptr);
|
|
|
|
- g_variant_lookup(options, "size", "(ii)", &width, &height);
|
|
-
|
|
- that->desktop_size_.set(width, height);
|
|
-
|
|
g_variant_unref(options);
|
|
g_variant_unref(variant);
|
|
}
|
|
@@ -813,10 +920,15 @@ void BaseCapturerPipeWire::CaptureFrame(
|
|
return;
|
|
}
|
|
|
|
- std::unique_ptr<DesktopFrame> result(new BasicDesktopFrame(desktop_size_));
|
|
+ DesktopSize frame_size = desktop_size_;
|
|
+ if (video_crop_size_initialized_) {
|
|
+ frame_size = video_crop_size_;
|
|
+ }
|
|
+
|
|
+ std::unique_ptr<DesktopFrame> result(new BasicDesktopFrame(frame_size));
|
|
result->CopyPixelsFrom(
|
|
- current_frame_, (desktop_size_.width() * kBytesPerPixel),
|
|
- DesktopRect::MakeWH(desktop_size_.width(), desktop_size_.height()));
|
|
+ current_frame_.get(), (frame_size.width() * kBytesPerPixel),
|
|
+ DesktopRect::MakeWH(frame_size.width(), frame_size.height()));
|
|
if (!result) {
|
|
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
|
|
return;
|
|
@@ -837,4 +949,22 @@ bool BaseCapturerPipeWire::SelectSource(
|
|
return true;
|
|
}
|
|
|
|
+// static
|
|
+std::unique_ptr<DesktopCapturer>
|
|
+BaseCapturerPipeWire::CreateRawScreenCapturer(
|
|
+ const DesktopCaptureOptions& options) {
|
|
+ std::unique_ptr<BaseCapturerPipeWire> capturer =
|
|
+ std::make_unique<BaseCapturerPipeWire>(BaseCapturerPipeWire::CaptureSourceType::kAny);
|
|
+ return std::move(capturer);}
|
|
+
|
|
+// static
|
|
+std::unique_ptr<DesktopCapturer>
|
|
+BaseCapturerPipeWire::CreateRawWindowCapturer(
|
|
+ const DesktopCaptureOptions& options) {
|
|
+
|
|
+ std::unique_ptr<BaseCapturerPipeWire> capturer =
|
|
+ std::make_unique<BaseCapturerPipeWire>(BaseCapturerPipeWire::CaptureSourceType::kAny);
|
|
+ return std::move(capturer);
|
|
+}
|
|
+
|
|
} // namespace webrtc
|
|
diff -up firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h.firefox-pipewire-0-2 firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h
|
|
--- firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h.firefox-pipewire-0-2 2020-07-20 22:54:40.000000000 +0200
|
|
+++ firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h 2020-07-29 11:03:51.619283301 +0200
|
|
@@ -32,7 +32,11 @@ class PipeWireType {
|
|
|
|
class BaseCapturerPipeWire : public DesktopCapturer {
|
|
public:
|
|
- enum CaptureSourceType { Screen = 1, Window };
|
|
+ enum CaptureSourceType : uint32_t {
|
|
+ kScreen = 0b01,
|
|
+ kWindow = 0b10,
|
|
+ kAny = 0b11
|
|
+ };
|
|
|
|
explicit BaseCapturerPipeWire(CaptureSourceType source_type);
|
|
~BaseCapturerPipeWire() override;
|
|
@@ -43,6 +47,12 @@ class BaseCapturerPipeWire : public Desk
|
|
bool GetSourceList(SourceList* sources) override;
|
|
bool SelectSource(SourceId id) override;
|
|
|
|
+ static std::unique_ptr<DesktopCapturer> CreateRawScreenCapturer(
|
|
+ const DesktopCaptureOptions& options);
|
|
+
|
|
+ static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
|
|
+ const DesktopCaptureOptions& options);
|
|
+
|
|
private:
|
|
// PipeWire types -->
|
|
pw_core* pw_core_ = nullptr;
|
|
@@ -64,7 +74,7 @@ class BaseCapturerPipeWire : public Desk
|
|
gint32 pw_fd_ = -1;
|
|
|
|
CaptureSourceType capture_source_type_ =
|
|
- BaseCapturerPipeWire::CaptureSourceType::Screen;
|
|
+ BaseCapturerPipeWire::CaptureSourceType::kAny;
|
|
|
|
// <-- end of PipeWire types
|
|
|
|
@@ -78,10 +88,12 @@ class BaseCapturerPipeWire : public Desk
|
|
guint sources_request_signal_id_ = 0;
|
|
guint start_request_signal_id_ = 0;
|
|
|
|
+ bool video_crop_size_initialized_ = false;
|
|
+ DesktopSize video_crop_size_;;
|
|
DesktopSize desktop_size_ = {};
|
|
DesktopCaptureOptions options_ = {};
|
|
|
|
- uint8_t* current_frame_ = nullptr;
|
|
+ std::unique_ptr<uint8_t[]> current_frame_;
|
|
Callback* callback_ = nullptr;
|
|
|
|
bool portal_init_failed_ = false;
|
|
@@ -95,6 +107,7 @@ class BaseCapturerPipeWire : public Desk
|
|
|
|
void ConvertRGBxToBGRx(uint8_t* frame, uint32_t size);
|
|
|
|
+ static void SyncDmaBuf(int fd, uint64_t start_or_end);
|
|
static void OnStateChanged(void* data,
|
|
pw_remote_state old_state,
|
|
pw_remote_state state,
|
|
diff -up firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc.firefox-pipewire-0-2 firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc
|
|
--- firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc.firefox-pipewire-0-2 2020-07-20 22:53:57.000000000 +0200
|
|
+++ firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/screen_capturer_pipewire.cc 2020-07-29 11:03:51.619283301 +0200
|
|
@@ -15,7 +15,7 @@
|
|
namespace webrtc {
|
|
|
|
ScreenCapturerPipeWire::ScreenCapturerPipeWire()
|
|
- : BaseCapturerPipeWire(BaseCapturerPipeWire::CaptureSourceType::Screen) {}
|
|
+ : BaseCapturerPipeWire(BaseCapturerPipeWire::CaptureSourceType::kScreen) {}
|
|
ScreenCapturerPipeWire::~ScreenCapturerPipeWire() {}
|
|
|
|
// static
|
|
diff -up firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc.firefox-pipewire-0-2 firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc
|
|
--- firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc.firefox-pipewire-0-2 2020-07-20 22:54:18.000000000 +0200
|
|
+++ firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/linux/window_capturer_pipewire.cc 2020-07-29 11:03:51.619283301 +0200
|
|
@@ -15,7 +15,7 @@
|
|
namespace webrtc {
|
|
|
|
WindowCapturerPipeWire::WindowCapturerPipeWire()
|
|
- : BaseCapturerPipeWire(BaseCapturerPipeWire::CaptureSourceType::Window) {}
|
|
+ : BaseCapturerPipeWire(BaseCapturerPipeWire::CaptureSourceType::kWindow) {}
|
|
WindowCapturerPipeWire::~WindowCapturerPipeWire() {}
|
|
|
|
// static
|
|
diff -up firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc.firefox-pipewire-0-2 firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc
|
|
--- firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc.firefox-pipewire-0-2 2020-07-20 22:54:40.000000000 +0200
|
|
+++ firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc 2020-07-29 11:03:51.620283296 +0200
|
|
@@ -26,7 +26,7 @@ std::unique_ptr<DesktopCapturer> Desktop
|
|
const DesktopCaptureOptions& options) {
|
|
#if defined(WEBRTC_USE_PIPEWIRE)
|
|
if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland()) {
|
|
- return ScreenCapturerPipeWire::CreateRawScreenCapturer(options);
|
|
+ return BaseCapturerPipeWire::CreateRawScreenCapturer(options);
|
|
}
|
|
#endif // defined(WEBRTC_USE_PIPEWIRE)
|
|
|
|
diff -up firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc.firefox-pipewire-0-2 firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc
|
|
--- firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc.firefox-pipewire-0-2 2020-07-20 22:53:32.000000000 +0200
|
|
+++ firefox-79.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc 2020-07-29 11:03:51.620283296 +0200
|
|
@@ -26,7 +26,7 @@ std::unique_ptr<DesktopCapturer> Desktop
|
|
const DesktopCaptureOptions& options) {
|
|
#if defined(WEBRTC_USE_PIPEWIRE)
|
|
if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland()) {
|
|
- return WindowCapturerPipeWire::CreateRawWindowCapturer(options);
|
|
+ return BaseCapturerPipeWire::CreateRawWindowCapturer(options);
|
|
}
|
|
#endif // defined(WEBRTC_USE_PIPEWIRE)
|
|
|