refactor(linux): remove leftovers from portalgrab -> pipewire split (#5039)
This commit is contained in:
@@ -3,15 +3,7 @@
|
|||||||
* @brief Shared classes for pipewire-based capture methods.
|
* @brief Shared classes for pipewire-based capture methods.
|
||||||
*/
|
*/
|
||||||
// standard includes
|
// standard includes
|
||||||
#include <array>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <format>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
|
||||||
#include <mutex>
|
|
||||||
#include <string.h>
|
|
||||||
#include <string_view>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
// lib includes
|
// lib includes
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
@@ -32,12 +24,6 @@
|
|||||||
#include "vulkan_encode.h"
|
#include "vulkan_encode.h"
|
||||||
#include "wayland.h"
|
#include "wayland.h"
|
||||||
|
|
||||||
#if !defined(__FreeBSD__)
|
|
||||||
// platform includes
|
|
||||||
#include <sys/capability.h>
|
|
||||||
#include <sys/prctl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Buffer and limit constants
|
// Buffer and limit constants
|
||||||
constexpr int SPA_POD_BUFFER_SIZE = 4096;
|
constexpr int SPA_POD_BUFFER_SIZE = 4096;
|
||||||
@@ -60,12 +46,6 @@ namespace pipewire {
|
|||||||
{0, 0},
|
{0, 0},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
struct dbus_response_t {
|
|
||||||
GMainLoop *loop;
|
|
||||||
GVariant *response;
|
|
||||||
guint subscription_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct shared_state_t {
|
struct shared_state_t {
|
||||||
std::atomic<int> negotiated_width {0};
|
std::atomic<int> negotiated_width {0};
|
||||||
std::atomic<int> negotiated_height {0};
|
std::atomic<int> negotiated_height {0};
|
||||||
@@ -698,13 +678,13 @@ namespace pipewire {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pipewire.init(pipewire_fd, pipewire_node, shared_state) < 0) {
|
if (pipewire.init(pipewire_fd, pipewire_node, shared_state) < 0) {
|
||||||
BOOST_LOG(error) << "[pipewire] Failed to init pipewire. portal_t::init() failed.";
|
BOOST_LOG(error) << "[pipewire] Failed to init pipewire. pipewire_t::init() failed.";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start PipeWire now so format negotiation can proceed before capture start
|
// Start PipeWire now so format negotiation can proceed before capture start
|
||||||
if (pipewire.ensure_stream(mem_type, width, height, framerate, dmabuf_infos.data(), n_dmabuf_infos, display_is_nvidia) < 0) {
|
if (pipewire.ensure_stream(mem_type, width, height, framerate, dmabuf_infos.data(), n_dmabuf_infos, display_is_nvidia) < 0) {
|
||||||
BOOST_LOG(error) << "[pipewire] Failed to ensure pipewire stream. portal_t::init() failed.";
|
BOOST_LOG(error) << "[pipewire] Failed to ensure pipewire stream. pipewire_t::init() failed.";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,36 +2,8 @@
|
|||||||
* @file src/platform/linux/portalgrab.cpp
|
* @file src/platform/linux/portalgrab.cpp
|
||||||
* @brief Definitions for XDG portal grab.
|
* @brief Definitions for XDG portal grab.
|
||||||
*/
|
*/
|
||||||
// standard includes
|
|
||||||
#include <array>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <format>
|
|
||||||
#include <fstream>
|
|
||||||
#include <memory>
|
|
||||||
#include <mutex>
|
|
||||||
#include <string.h>
|
|
||||||
#include <string_view>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
// lib includes
|
|
||||||
#include <gio/gio.h>
|
|
||||||
#include <gio/gunixfdlist.h>
|
|
||||||
#include <libdrm/drm_fourcc.h>
|
|
||||||
#include <pipewire/pipewire.h>
|
|
||||||
#include <spa/param/video/format-utils.h>
|
|
||||||
#include <spa/param/video/type-info.h>
|
|
||||||
#include <spa/pod/builder.h>
|
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "cuda.h"
|
|
||||||
#include "graphics.h"
|
|
||||||
#include "pipewire.cpp"
|
#include "pipewire.cpp"
|
||||||
#include "src/main.h"
|
|
||||||
#include "src/platform/common.h"
|
|
||||||
#include "src/video.h"
|
|
||||||
#include "vaapi.h"
|
|
||||||
#include "vulkan_encode.h"
|
|
||||||
#include "wayland.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Portal configuration constants
|
// Portal configuration constants
|
||||||
@@ -108,59 +80,12 @@ namespace portal {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct format_map_t {
|
|
||||||
uint64_t fourcc;
|
|
||||||
int32_t pw_format;
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr std::array<format_map_t, 3> format_map = {{
|
|
||||||
{DRM_FORMAT_ARGB8888, SPA_VIDEO_FORMAT_BGRA},
|
|
||||||
{DRM_FORMAT_XRGB8888, SPA_VIDEO_FORMAT_BGRx},
|
|
||||||
{0, 0},
|
|
||||||
}};
|
|
||||||
|
|
||||||
struct dbus_response_t {
|
struct dbus_response_t {
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
GVariant *response;
|
GVariant *response;
|
||||||
guint subscription_id;
|
guint subscription_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct shared_state_t {
|
|
||||||
std::atomic<int> negotiated_width {0};
|
|
||||||
std::atomic<int> negotiated_height {0};
|
|
||||||
std::atomic<bool> stream_dead {false};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct stream_data_t {
|
|
||||||
struct pw_stream *stream;
|
|
||||||
struct spa_hook stream_listener;
|
|
||||||
struct spa_video_info format;
|
|
||||||
struct pw_buffer *current_buffer;
|
|
||||||
uint64_t drm_format;
|
|
||||||
std::shared_ptr<shared_state_t> shared;
|
|
||||||
std::mutex frame_mutex;
|
|
||||||
std::condition_variable frame_cv;
|
|
||||||
size_t local_stride = 0;
|
|
||||||
bool frame_ready = false;
|
|
||||||
// Two distinct memory pools
|
|
||||||
std::vector<uint8_t> buffer_a;
|
|
||||||
std::vector<uint8_t> buffer_b;
|
|
||||||
// Points to the buffer currently owned by fill_img
|
|
||||||
std::vector<uint8_t> *front_buffer;
|
|
||||||
// Points to the buffer currently being written by on_process
|
|
||||||
std::vector<uint8_t> *back_buffer;
|
|
||||||
|
|
||||||
stream_data_t():
|
|
||||||
front_buffer(&buffer_a),
|
|
||||||
back_buffer(&buffer_b) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct dmabuf_format_info_t {
|
|
||||||
int32_t format;
|
|
||||||
uint64_t *modifiers;
|
|
||||||
int n_modifiers;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pipewire_streaminfo_t {
|
struct pipewire_streaminfo_t {
|
||||||
int pipewire_node = -1;
|
int pipewire_node = -1;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user