Skip to content

Commit c4b3065

Browse files
authored
refactor(linux): remove leftovers from portalgrab -> pipewire split (#5039)
1 parent 1ba440e commit c4b3065

2 files changed

Lines changed: 2 additions & 97 deletions

File tree

src/platform/linux/pipewire.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33
* @brief Shared classes for pipewire-based capture methods.
44
*/
55
// standard includes
6-
#include <array>
7-
#include <fcntl.h>
8-
#include <format>
96
#include <fstream>
10-
#include <memory>
11-
#include <mutex>
12-
#include <string.h>
13-
#include <string_view>
14-
#include <thread>
157

168
// lib includes
179
#include <gio/gio.h>
@@ -32,12 +24,6 @@
3224
#include "vulkan_encode.h"
3325
#include "wayland.h"
3426

35-
#if !defined(__FreeBSD__)
36-
// platform includes
37-
#include <sys/capability.h>
38-
#include <sys/prctl.h>
39-
#endif
40-
4127
namespace {
4228
// Buffer and limit constants
4329
constexpr int SPA_POD_BUFFER_SIZE = 4096;
@@ -60,12 +46,6 @@ namespace pipewire {
6046
{0, 0},
6147
}};
6248

63-
struct dbus_response_t {
64-
GMainLoop *loop;
65-
GVariant *response;
66-
guint subscription_id;
67-
};
68-
6949
struct shared_state_t {
7050
std::atomic<int> negotiated_width {0};
7151
std::atomic<int> negotiated_height {0};
@@ -698,13 +678,13 @@ namespace pipewire {
698678
}
699679

700680
if (pipewire.init(pipewire_fd, pipewire_node, shared_state) < 0) {
701-
BOOST_LOG(error) << "[pipewire] Failed to init pipewire. portal_t::init() failed.";
681+
BOOST_LOG(error) << "[pipewire] Failed to init pipewire. pipewire_t::init() failed.";
702682
return -1;
703683
}
704684

705685
// Start PipeWire now so format negotiation can proceed before capture start
706686
if (pipewire.ensure_stream(mem_type, width, height, framerate, dmabuf_infos.data(), n_dmabuf_infos, display_is_nvidia) < 0) {
707-
BOOST_LOG(error) << "[pipewire] Failed to ensure pipewire stream. portal_t::init() failed.";
687+
BOOST_LOG(error) << "[pipewire] Failed to ensure pipewire stream. pipewire_t::init() failed.";
708688
return -1;
709689
}
710690

src/platform/linux/portalgrab.cpp

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,8 @@
22
* @file src/platform/linux/portalgrab.cpp
33
* @brief Definitions for XDG portal grab.
44
*/
5-
// standard includes
6-
#include <array>
7-
#include <fcntl.h>
8-
#include <format>
9-
#include <fstream>
10-
#include <memory>
11-
#include <mutex>
12-
#include <string.h>
13-
#include <string_view>
14-
#include <thread>
15-
16-
// lib includes
17-
#include <gio/gio.h>
18-
#include <gio/gunixfdlist.h>
19-
#include <libdrm/drm_fourcc.h>
20-
#include <pipewire/pipewire.h>
21-
#include <spa/param/video/format-utils.h>
22-
#include <spa/param/video/type-info.h>
23-
#include <spa/pod/builder.h>
24-
255
// local includes
26-
#include "cuda.h"
27-
#include "graphics.h"
286
#include "pipewire.cpp"
29-
#include "src/main.h"
30-
#include "src/platform/common.h"
31-
#include "src/video.h"
32-
#include "vaapi.h"
33-
#include "vulkan_encode.h"
34-
#include "wayland.h"
357

368
namespace {
379
// Portal configuration constants
@@ -108,59 +80,12 @@ namespace portal {
10880
}
10981
};
11082

111-
struct format_map_t {
112-
uint64_t fourcc;
113-
int32_t pw_format;
114-
};
115-
116-
static constexpr std::array<format_map_t, 3> format_map = {{
117-
{DRM_FORMAT_ARGB8888, SPA_VIDEO_FORMAT_BGRA},
118-
{DRM_FORMAT_XRGB8888, SPA_VIDEO_FORMAT_BGRx},
119-
{0, 0},
120-
}};
121-
12283
struct dbus_response_t {
12384
GMainLoop *loop;
12485
GVariant *response;
12586
guint subscription_id;
12687
};
12788

128-
struct shared_state_t {
129-
std::atomic<int> negotiated_width {0};
130-
std::atomic<int> negotiated_height {0};
131-
std::atomic<bool> stream_dead {false};
132-
};
133-
134-
struct stream_data_t {
135-
struct pw_stream *stream;
136-
struct spa_hook stream_listener;
137-
struct spa_video_info format;
138-
struct pw_buffer *current_buffer;
139-
uint64_t drm_format;
140-
std::shared_ptr<shared_state_t> shared;
141-
std::mutex frame_mutex;
142-
std::condition_variable frame_cv;
143-
size_t local_stride = 0;
144-
bool frame_ready = false;
145-
// Two distinct memory pools
146-
std::vector<uint8_t> buffer_a;
147-
std::vector<uint8_t> buffer_b;
148-
// Points to the buffer currently owned by fill_img
149-
std::vector<uint8_t> *front_buffer;
150-
// Points to the buffer currently being written by on_process
151-
std::vector<uint8_t> *back_buffer;
152-
153-
stream_data_t():
154-
front_buffer(&buffer_a),
155-
back_buffer(&buffer_b) {}
156-
};
157-
158-
struct dmabuf_format_info_t {
159-
int32_t format;
160-
uint64_t *modifiers;
161-
int n_modifiers;
162-
};
163-
16489
struct pipewire_streaminfo_t {
16590
int pipewire_node = -1;
16691
int width = 0;

0 commit comments

Comments
 (0)