Drop xrt::drivers namespace

This commit is contained in:
Patrick Nicolas
2024-10-03 23:39:32 +02:00
parent 6946d5144a
commit fdb79b1939
78 changed files with 260 additions and 260 deletions
+3 -3
View File
@@ -30,11 +30,11 @@ static void handle_event_from_main_loop(to_monado::disconnect)
// Ignore disconnect request when no headset is connected
}
std::unique_ptr<xrt::drivers::wivrn::TCP> accept_connection(int watch_fd, std::function<bool()> quit)
std::unique_ptr<wivrn::TCP> accept_connection(int watch_fd, std::function<bool()> quit)
{
wivrn_ipc_socket_monado->send(from_monado::headsdet_disconnected{});
xrt::drivers::wivrn::TCPListener listener(xrt::drivers::wivrn::default_port);
wivrn::TCPListener listener(wivrn::default_port);
pollfd fds[3]{
{.fd = watch_fd, .events = POLLIN},
@@ -56,7 +56,7 @@ std::unique_ptr<xrt::drivers::wivrn::TCP> accept_connection(int watch_fd, std::f
if (fds[1].revents & POLLIN)
{
wivrn_ipc_socket_monado->send(from_monado::headsdet_connected{});
return std::make_unique<xrt::drivers::wivrn::TCP>(listener.accept().first);
return std::make_unique<wivrn::TCP>(listener.accept().first);
}
if (fds[2].revents & POLLIN)
+1 -1
View File
@@ -23,4 +23,4 @@
#include <memory>
#include <wivrn_sockets.h>
std::unique_ptr<xrt::drivers::wivrn::TCP> accept_connection(int watch_fd, std::function<bool()> quit = std::function<bool()>());
std::unique_ptr<wivrn::TCP> accept_connection(int watch_fd, std::function<bool()> quit = std::function<bool()>());
+6 -6
View File
@@ -26,7 +26,7 @@
#include <pipewire/pipewire.h>
#include <spa/param/audio/format-utils.h>
using namespace xrt::drivers::wivrn;
using namespace wivrn;
struct deleter
{
@@ -73,7 +73,7 @@ struct pipewire_device : public audio_device
static void speaker_process(void * self_v);
static void mic_process(void * self_v);
void process_mic_data(xrt::drivers::wivrn::audio_data &&) override;
void process_mic_data(wivrn::audio_data &&) override;
~pipewire_device() = default;
@@ -82,8 +82,8 @@ struct pipewire_device : public audio_device
const std::string & source_description,
const std::string & sink_name,
const std::string & sink_description,
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
xrt::drivers::wivrn::wivrn_session & session) :
const wivrn::from_headset::headset_info_packet & info,
wivrn::wivrn_session & session) :
session(session)
{
int argc = 0;
@@ -289,7 +289,7 @@ void pipewire_device::speaker_process(void * self_v)
pw_stream_queue_buffer(self->speaker.get(), buffer);
}
void pipewire_device::process_mic_data(xrt::drivers::wivrn::audio_data && sample)
void pipewire_device::process_mic_data(wivrn::audio_data && sample)
{
auto size = sample.payload.size_bytes();
if (mic_samples.write(std::move(sample)))
@@ -301,7 +301,7 @@ std::shared_ptr<audio_device> create_pipewire_handle(
const std::string & source_description,
const std::string & sink_name,
const std::string & sink_description,
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
const wivrn::from_headset::headset_info_packet & info,
wivrn_session & session)
{
try
+2 -2
View File
@@ -25,5 +25,5 @@ std::shared_ptr<audio_device> create_pipewire_handle(
const std::string & source_description,
const std::string & sink_name,
const std::string & sink_description,
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
xrt::drivers::wivrn::wivrn_session & session);
const wivrn::from_headset::headset_info_packet & info,
wivrn::wivrn_session & session);
+10 -10
View File
@@ -240,7 +240,7 @@ public:
struct pulse_device : public audio_device
{
xrt::drivers::wivrn::to_headset::audio_stream_description desc;
wivrn::to_headset::audio_stream_description desc;
std::thread mic_thread;
std::thread speaker_thread;
@@ -251,10 +251,10 @@ struct pulse_device : public audio_device
utils::sync_queue<audio_data> mic_buffer;
xrt::drivers::wivrn::fd_base speaker_pipe;
xrt::drivers::wivrn::fd_base mic_pipe;
wivrn::fd_base speaker_pipe;
wivrn::fd_base mic_pipe;
xrt::drivers::wivrn::wivrn_session & session;
wivrn::wivrn_session & session;
~pulse_device()
{
@@ -282,7 +282,7 @@ struct pulse_device : public audio_device
}
}
xrt::drivers::wivrn::to_headset::audio_stream_description description() const override
wivrn::to_headset::audio_stream_description description() const override
{
return desc;
};
@@ -298,7 +298,7 @@ struct pulse_device : public audio_device
// use buffers of up to 2ms
// read buffers must be smaller than buffer size on client or we will discard chunks often
const size_t buffer_size = (desc.speaker->sample_rate * sample_size * 2) / 1000;
xrt::drivers::wivrn::audio_data packet;
wivrn::audio_data packet;
std::vector<uint8_t> buffer(buffer_size, 0);
size_t remainder = 0;
@@ -396,7 +396,7 @@ struct pulse_device : public audio_device
}
}
void process_mic_data(xrt::drivers::wivrn::audio_data && mic_data) override
void process_mic_data(wivrn::audio_data && mic_data) override
{
mic_buffer.push(std::move(mic_data));
}
@@ -406,8 +406,8 @@ struct pulse_device : public audio_device
const std::string & source_description,
const std::string & sink_name,
const std::string & sink_description,
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
xrt::drivers::wivrn::wivrn_session & session) :
const wivrn::from_headset::headset_info_packet & info,
wivrn::wivrn_session & session) :
session(session)
{
pa_connection cnx("WiVRn");
@@ -446,7 +446,7 @@ std::shared_ptr<audio_device> create_pulse_handle(
const std::string & source_description,
const std::string & sink_name,
const std::string & sink_description,
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
const wivrn::from_headset::headset_info_packet & info,
wivrn_session & session)
{
try
+2 -2
View File
@@ -25,5 +25,5 @@ std::shared_ptr<audio_device> create_pulse_handle(
const std::string & source_description,
const std::string & sink_name,
const std::string & sink_description,
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
xrt::drivers::wivrn::wivrn_session & session);
const wivrn::from_headset::headset_info_packet & info,
wivrn::wivrn_session & session);
+2 -2
View File
@@ -35,8 +35,8 @@ std::shared_ptr<audio_device> audio_device::create(
const std::string & source_description,
const std::string & sink_name,
const std::string & sink_description,
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
xrt::drivers::wivrn::wivrn_session & session)
const wivrn::from_headset::headset_info_packet & info,
wivrn::wivrn_session & session)
{
#if WIVRN_USE_PIPEWIRE
if (auto res = create_pipewire_handle(source_name, source_description, sink_name, sink_description, info, session))
+5 -5
View File
@@ -24,7 +24,7 @@
#include "wivrn_packets.h"
namespace xrt::drivers::wivrn
namespace wivrn
{
class wivrn_session;
}
@@ -34,15 +34,15 @@ struct audio_device
// unpublishes the device
virtual ~audio_device() = default;
virtual xrt::drivers::wivrn::to_headset::audio_stream_description description() const = 0;
virtual wivrn::to_headset::audio_stream_description description() const = 0;
virtual void process_mic_data(xrt::drivers::wivrn::audio_data &&) = 0;
virtual void process_mic_data(wivrn::audio_data &&) = 0;
static std::shared_ptr<audio_device> create(
const std::string & source_name,
const std::string & source_description,
const std::string & sink_name,
const std::string & sink_description,
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
xrt::drivers::wivrn::wivrn_session & session);
const wivrn::from_headset::headset_info_packet & info,
wivrn::wivrn_session & session);
};
+2 -2
View File
@@ -42,12 +42,12 @@ void clock_offset_estimator::request_sample(wivrn_connection & connection)
next_sample = std::chrono::steady_clock::now() + sample_interval.load();
connection.send_stream(
xrt::drivers::wivrn::to_headset::timesync_query{
wivrn::to_headset::timesync_query{
.query = XrTime(os_monotonic_get_ns()),
});
}
void clock_offset_estimator::add_sample(const xrt::drivers::wivrn::from_headset::timesync_response & base_sample)
void clock_offset_estimator::add_sample(const wivrn::from_headset::timesync_response & base_sample)
{
XrTime now = os_monotonic_get_ns();
clock_offset_estimator::sample sample{base_sample, now};
+2 -2
View File
@@ -48,7 +48,7 @@ struct clock_offset
class clock_offset_estimator
{
struct sample : public xrt::drivers::wivrn::from_headset::timesync_response
struct sample : public wivrn::from_headset::timesync_response
{
XrTime received;
};
@@ -64,7 +64,7 @@ class clock_offset_estimator
public:
void reset();
void request_sample(wivrn_connection & connection);
void add_sample(const xrt::drivers::wivrn::from_headset::timesync_response & sample);
void add_sample(const wivrn::from_headset::timesync_response & sample);
clock_offset get_offset();
};
+2 -2
View File
@@ -36,7 +36,7 @@
static std::filesystem::path config_file = xdg_config_home() / "wivrn" / "config.json";
static std::filesystem::path cookie_file = xdg_config_home() / "wivrn" / "cookie";
namespace xrt::drivers::wivrn
namespace wivrn
{
NLOHMANN_JSON_SERIALIZE_ENUM(
video_codec,
@@ -102,7 +102,7 @@ configuration configuration::read_user_configuration()
SET_IF(offset_y);
SET_IF(group);
SET_IF(codec);
if (e.codec == xrt::drivers::wivrn::video_codec(-1))
if (e.codec == wivrn::video_codec(-1))
throw std::runtime_error("invalid codec value " + encoder["codec"].get<std::string>());
SET_IF(options);
SET_IF(device);
+1 -1
View File
@@ -37,7 +37,7 @@ struct configuration
std::optional<double> offset_x;
std::optional<double> offset_y;
std::optional<int> group;
std::optional<xrt::drivers::wivrn::video_codec> codec;
std::optional<wivrn::video_codec> codec;
std::map<std::string, std::string> options;
std::optional<std::string> device;
};
+1 -1
View File
@@ -22,7 +22,7 @@
#include "pose_list.h"
#include "xrt_cast.h"
using namespace xrt::drivers::wivrn;
using namespace wivrn;
static_assert(XRT_HAND_JOINT_COUNT == XR_HAND_JOINT_COUNT_EXT);
+1 -1
View File
@@ -33,5 +33,5 @@ public:
hand_joints_list(int hand_id) :
hand_id(hand_id) {}
bool update_tracking(const xrt::drivers::wivrn::from_headset::hand_tracking & tracking, const clock_offset & offset);
bool update_tracking(const wivrn::from_headset::hand_tracking & tracking, const clock_offset & offset);
};
+1 -1
View File
@@ -24,7 +24,7 @@
#include "xrt/xrt_defines.h"
#include "xrt_cast.h"
using namespace xrt::drivers::wivrn;
using namespace wivrn;
using namespace xrt::auxiliary::math;
xrt_space_relation pose_list::interpolate(const xrt_space_relation & a, const xrt_space_relation & b, float t)
+4 -4
View File
@@ -27,15 +27,15 @@
class pose_list : public history<pose_list, xrt_space_relation>
{
public:
const xrt::drivers::wivrn::device_id device;
const wivrn::device_id device;
static xrt_space_relation interpolate(const xrt_space_relation & a, const xrt_space_relation & b, float t);
static xrt_space_relation extrapolate(const xrt_space_relation & a, const xrt_space_relation & b, int64_t ta, int64_t tb, int64_t t);
pose_list(xrt::drivers::wivrn::device_id id) :
pose_list(wivrn::device_id id) :
device(id) {}
bool update_tracking(const xrt::drivers::wivrn::from_headset::tracking &, const clock_offset & offset);
bool update_tracking(const wivrn::from_headset::tracking &, const clock_offset & offset);
static xrt_space_relation convert_pose(const xrt::drivers::wivrn::from_headset::tracking::pose &);
static xrt_space_relation convert_pose(const wivrn::from_headset::tracking::pose &);
};
+2 -2
View File
@@ -29,7 +29,7 @@
#include <vulkan/vulkan_core.h>
#include <vulkan/vulkan_handles.hpp>
using namespace xrt::drivers::wivrn;
using namespace wivrn;
std::vector<const char *> wivrn_comp_target::wanted_instance_extensions = {};
std::vector<const char *> wivrn_comp_target::wanted_device_extensions = {
@@ -650,7 +650,7 @@ void wivrn_comp_target::render_dynamic_foveation(std::array<to_headset::foveatio
}
}
wivrn_comp_target::wivrn_comp_target(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx, struct comp_compositor * c, float fps) :
wivrn_comp_target::wivrn_comp_target(std::shared_ptr<wivrn::wivrn_session> cnx, struct comp_compositor * c, float fps) :
comp_target{},
pacer(U_TIME_1S_IN_NS / fps),
cnx(cnx)
+4 -4
View File
@@ -35,7 +35,7 @@
#include <vector>
#include <vulkan/vulkan_raii.hpp>
namespace xrt::drivers::wivrn
namespace wivrn
{
class VideoEncoder;
@@ -97,10 +97,10 @@ struct wivrn_comp_target : public comp_target
std::list<std::jthread> encoder_threads;
std::vector<std::shared_ptr<VideoEncoder>> encoders;
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx;
std::shared_ptr<wivrn::wivrn_session> cnx;
std::unique_ptr<wivrn_foveation_renderer> foveation_renderer = nullptr;
wivrn_comp_target(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx, struct comp_compositor * c, float fps);
wivrn_comp_target(std::shared_ptr<wivrn::wivrn_session> cnx, struct comp_compositor * c, float fps);
~wivrn_comp_target();
void on_feedback(const from_headset::feedback &, const clock_offset &);
@@ -109,4 +109,4 @@ struct wivrn_comp_target : public comp_target
void render_dynamic_foveation(std::array<to_headset::foveation_parameter, 2> foveation);
};
} // namespace xrt::drivers::wivrn
} // namespace wivrn
+1 -1
View File
@@ -25,7 +25,7 @@
#include <optional>
#include <poll.h>
using namespace xrt::drivers::wivrn;
using namespace wivrn;
class wivrn_connection
{
+1 -1
View File
@@ -151,7 +151,7 @@ static void wivrn_controller_update_inputs(xrt_device * xdev);
wivrn_controller::wivrn_controller(int hand_id,
xrt_device * hmd,
xrt::drivers::wivrn::wivrn_session * cnx) :
wivrn::wivrn_session * cnx) :
xrt_device{},
grip(hand_id == 0 ? device_id::LEFT_GRIP : device_id::RIGHT_GRIP),
aim(hand_id == 0 ? device_id::LEFT_AIM : device_id::RIGHT_AIM),
+3 -3
View File
@@ -29,7 +29,7 @@
#include <mutex>
#include <vector>
namespace xrt::drivers::wivrn
namespace wivrn
{
class wivrn_session;
}
@@ -46,10 +46,10 @@ class wivrn_controller : public xrt_device
std::vector<xrt_input> inputs_array;
xrt_output haptic_output;
xrt::drivers::wivrn::wivrn_session * cnx;
wivrn::wivrn_session * cnx;
public:
wivrn_controller(int hand_id, xrt_device * hmd, xrt::drivers::wivrn::wivrn_session * cnx);
wivrn_controller(int hand_id, xrt_device * hmd, wivrn::wivrn_session * cnx);
void unregister()
{
+1 -1
View File
@@ -40,7 +40,7 @@ static void wivrn_eye_tracker_get_tracked_pose(xrt_device * xdev,
xrt_space_relation * out_relation);
wivrn_eye_tracker::wivrn_eye_tracker(xrt_device * hmd,
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx) :
std::shared_ptr<wivrn::wivrn_session> cnx) :
xrt_device{}, gaze(device_id::EYE_GAZE), cnx(cnx)
{
xrt_device * base = this;
+2 -2
View File
@@ -38,10 +38,10 @@ class wivrn_eye_tracker : public xrt_device
xrt_input gaze_input;
pose_list gaze;
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx;
std::shared_ptr<wivrn::wivrn_session> cnx;
public:
wivrn_eye_tracker(xrt_device * hmd, std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx);
wivrn_eye_tracker(xrt_device * hmd, std::shared_ptr<wivrn::wivrn_session> cnx);
void unregister()
{
cnx = nullptr;
+1 -1
View File
@@ -42,7 +42,7 @@ static xrt_result_t wivrn_fb_face2_tracker_get_face_tracking(struct xrt_device *
struct xrt_facial_expression_set * out_value);
wivrn_fb_face2_tracker::wivrn_fb_face2_tracker(xrt_device * hmd,
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx) :
std::shared_ptr<wivrn::wivrn_session> cnx) :
xrt_device{}, cnx(cnx)
{
xrt_device * base = this;
+2 -2
View File
@@ -86,10 +86,10 @@ class wivrn_fb_face2_tracker : public xrt_device
fb_face2_list face_list;
xrt_input face_input;
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx;
std::shared_ptr<wivrn::wivrn_session> cnx;
public:
wivrn_fb_face2_tracker(xrt_device * hmd, std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx);
wivrn_fb_face2_tracker(xrt_device * hmd, std::shared_ptr<wivrn::wivrn_session> cnx);
void unregister()
{
cnx = nullptr;
+1 -1
View File
@@ -197,7 +197,7 @@ bool wivrn_hmd::wivrn_hmd_compute_distortion(xrt_device * xdev, uint32_t view_in
return true;
}
wivrn_hmd::wivrn_hmd(xrt::drivers::wivrn::wivrn_session * cnx,
wivrn_hmd::wivrn_hmd(wivrn::wivrn_session * cnx,
const from_headset::headset_info_packet & info) :
xrt_device{}, cnx(cnx)
{
+3 -3
View File
@@ -32,7 +32,7 @@
struct comp_target;
namespace xrt::drivers::wivrn
namespace wivrn
{
class wivrn_session;
}
@@ -55,12 +55,12 @@ class wivrn_hmd : public xrt_device
std::array<to_headset::foveation_parameter, 2> foveation_parameters{};
from_headset::battery battery{};
xrt::drivers::wivrn::wivrn_session * cnx;
wivrn::wivrn_session * cnx;
static bool wivrn_hmd_compute_distortion(xrt_device * xdev, uint32_t view_index, float u, float v, xrt_uv_triplet * result);
public:
wivrn_hmd(xrt::drivers::wivrn::wivrn_session * cnx,
wivrn_hmd(wivrn::wivrn_session * cnx,
const from_headset::headset_info_packet & info);
void unregister()
{
+1 -1
View File
@@ -68,7 +68,7 @@ void wivrn_pacer::predict(
out_present_slop_ns = 0;
}
void wivrn_pacer::on_feedback(const xrt::drivers::wivrn::from_headset::feedback & feedback, const clock_offset & offset)
void wivrn_pacer::on_feedback(const wivrn::from_headset::feedback & feedback, const clock_offset & offset)
{
std::lock_guard lock(mutex);
if (feedback.stream_index >= streams.size() or feedback.times_displayed > 1)
+2 -2
View File
@@ -56,7 +56,7 @@ private:
struct stream_data
{
// Last feedback for each encoder
xrt::drivers::wivrn::from_headset::feedback last_feedback;
wivrn::from_headset::feedback last_feedback;
std::vector<int64_t> times;
size_t next_times_index = 0;
};
@@ -78,7 +78,7 @@ public:
int64_t & out_present_slop_ns,
int64_t & out_predicted_display_time_ns);
void on_feedback(const xrt::drivers::wivrn::from_headset::feedback &, const clock_offset &);
void on_feedback(const wivrn::from_headset::feedback &, const clock_offset &);
void mark_timing_point(
comp_target_timing_point point,
+10 -10
View File
@@ -90,7 +90,7 @@ struct wivrn_comp_target_factory : public comp_target_factory
}
};
void xrt::drivers::wivrn::tracking_control_t::send(wivrn_connection & connection)
void wivrn::tracking_control_t::send(wivrn_connection & connection)
{
if (std::chrono::steady_clock::now() < next_sample)
return;
@@ -102,7 +102,7 @@ void xrt::drivers::wivrn::tracking_control_t::send(wivrn_connection & connection
next_sample += std::chrono::seconds(1);
}
void xrt::drivers::wivrn::tracking_control_t::set_enabled(to_headset::tracking_control::id id, bool enabled)
void wivrn::tracking_control_t::set_enabled(to_headset::tracking_control::id id, bool enabled)
{
std::lock_guard lock(mutex);
if (enabled != this->enabled[size_t(id)])
@@ -110,10 +110,10 @@ void xrt::drivers::wivrn::tracking_control_t::set_enabled(to_headset::tracking_c
this->enabled[size_t(id)] = enabled;
}
xrt::drivers::wivrn::wivrn_session::wivrn_session(xrt::drivers::wivrn::TCP && tcp, u_system & system) :
wivrn::wivrn_session::wivrn_session(wivrn::TCP && tcp, u_system & system) :
connection(std::move(tcp)),
info([](wivrn_connection & connection) {
std::optional<xrt::drivers::wivrn::from_headset::packets> control;
std::optional<wivrn::from_headset::packets> control;
while (not(control = connection.poll_control(-1)))
{
// FIXME: timeout
@@ -127,11 +127,11 @@ xrt::drivers::wivrn::wivrn_session::wivrn_session(xrt::drivers::wivrn::TCP && tc
{
}
xrt_result_t xrt::drivers::wivrn::wivrn_session::create_session(xrt::drivers::wivrn::TCP && tcp,
u_system & system,
xrt_system_devices ** out_xsysd,
xrt_space_overseer ** out_xspovrs,
xrt_system_compositor ** out_xsysc)
xrt_result_t wivrn::wivrn_session::create_session(wivrn::TCP && tcp,
u_system & system,
xrt_system_devices ** out_xsysd,
xrt_space_overseer ** out_xspovrs,
xrt_system_compositor ** out_xsysc)
{
std::shared_ptr<wivrn_session> self;
try
@@ -519,7 +519,7 @@ void wivrn_session::reconnect()
{
offset_est.reset();
connection.reset(std::move(*tcp));
std::optional<xrt::drivers::wivrn::from_headset::packets> control;
std::optional<wivrn::from_headset::packets> control;
while (not(control = connection.poll_control(100)))
{
// FIXME: timeout
+2 -2
View File
@@ -45,7 +45,7 @@ struct xrt_space_overseer;
struct xrt_system_compositor;
struct wivrn_comp_target_factory;
namespace xrt::drivers::wivrn
namespace wivrn
{
struct wivrn_comp_target;
@@ -175,4 +175,4 @@ private:
void reconnect();
};
} // namespace xrt::drivers::wivrn
} // namespace wivrn
+12 -12
View File
@@ -37,7 +37,7 @@
#include "ffmpeg/video_encoder_va.h"
#endif
using namespace xrt::drivers::wivrn;
using namespace wivrn;
// TODO: size independent bitrate
static const uint64_t default_bitrate = 50'000'000;
@@ -50,7 +50,7 @@ static bool is_nvidia(vk::PhysicalDevice physical_device)
return props.vendorID == 0x10DE;
}
static void split_bitrate(std::vector<xrt::drivers::wivrn::encoder_settings> & encoders, uint64_t bitrate)
static void split_bitrate(std::vector<wivrn::encoder_settings> & encoders, uint64_t bitrate)
{
double total_weight = 0;
for (auto & encoder: encoders)
@@ -58,11 +58,11 @@ static void split_bitrate(std::vector<xrt::drivers::wivrn::encoder_settings> & e
double w = encoder.width * encoder.height;
switch (encoder.codec)
{
case xrt::drivers::wivrn::h264:
case wivrn::h264:
w *= 2;
break;
case xrt::drivers::wivrn::h265:
case xrt::drivers::wivrn::av1:
case wivrn::h265:
case wivrn::av1:
break;
}
encoder.bitrate = w;
@@ -75,7 +75,7 @@ static void split_bitrate(std::vector<xrt::drivers::wivrn::encoder_settings> & e
}
}
void print_encoders(const std::vector<xrt::drivers::wivrn::encoder_settings> & encoders)
void print_encoders(const std::vector<wivrn::encoder_settings> & encoders)
{
int group = -1;
for (auto & encoder: encoders)
@@ -117,7 +117,7 @@ static void check_scale(std::string_view encoder_name, video_codec codec, uint16
}
#if WIVRN_USE_VAAPI
static std::optional<xrt::drivers::wivrn::video_codec> filter_codecs_vaapi(wivrn_vk_bundle & bundle, const std::vector<xrt::drivers::wivrn::video_codec> & codecs)
static std::optional<wivrn::video_codec> filter_codecs_vaapi(wivrn_vk_bundle & bundle, const std::vector<wivrn::video_codec> & codecs)
{
VideoEncoderFFMPEG::mute_logs mute;
encoder_settings s{
@@ -148,7 +148,7 @@ static std::optional<xrt::drivers::wivrn::video_codec> filter_codecs_vaapi(wivrn
}
#endif
static void fill_defaults(wivrn_vk_bundle & bundle, const std::vector<xrt::drivers::wivrn::video_codec> & headset_codecs, configuration::encoder & config)
static void fill_defaults(wivrn_vk_bundle & bundle, const std::vector<wivrn::video_codec> & headset_codecs, configuration::encoder & config)
{
if (config.name.empty())
{
@@ -200,7 +200,7 @@ static void fill_defaults(wivrn_vk_bundle & bundle, const std::vector<xrt::drive
config.codec = h265;
}
static std::vector<configuration::encoder> get_encoder_default_settings(wivrn_vk_bundle & bundle, const std::vector<xrt::drivers::wivrn::video_codec> & headset_codecs)
static std::vector<configuration::encoder> get_encoder_default_settings(wivrn_vk_bundle & bundle, const std::vector<wivrn::video_codec> & headset_codecs)
{
configuration::encoder base;
fill_defaults(bundle, headset_codecs, base);
@@ -258,7 +258,7 @@ static void make_even(uint16_t & value, uint16_t max)
value = std::min(value, max);
}
std::vector<encoder_settings> xrt::drivers::wivrn::get_encoder_settings(wivrn_vk_bundle & bundle, uint32_t & width, uint32_t & height, const from_headset::headset_info_packet & info)
std::vector<encoder_settings> wivrn::get_encoder_settings(wivrn_vk_bundle & bundle, uint32_t & width, uint32_t & height, const from_headset::headset_info_packet & info)
{
configuration config;
try
@@ -291,11 +291,11 @@ std::vector<encoder_settings> xrt::drivers::wivrn::get_encoder_settings(wivrn_vk
height *= scale[1];
height += height % 2;
std::vector<xrt::drivers::wivrn::encoder_settings> res;
std::vector<wivrn::encoder_settings> res;
int next_group = 0;
for (const auto & encoder: config.encoders)
{
xrt::drivers::wivrn::encoder_settings settings{};
wivrn::encoder_settings settings{};
settings.encoder_name = encoder.name;
settings.width = std::ceil(encoder.width.value_or(1) * width);
settings.height = std::ceil(encoder.height.value_or(1) * height);
+3 -3
View File
@@ -27,7 +27,7 @@
struct wivrn_vk_bundle;
namespace xrt::drivers::wivrn
namespace wivrn
{
struct encoder_settings : public to_headset::video_stream_description::item
@@ -43,6 +43,6 @@ struct encoder_settings : public to_headset::video_stream_description::item
std::vector<encoder_settings> get_encoder_settings(wivrn_vk_bundle &, uint32_t & width, uint32_t & height, const from_headset::headset_info_packet & info);
} // namespace xrt::drivers::wivrn
} // namespace wivrn
void print_encoders(const std::vector<xrt::drivers::wivrn::encoder_settings> & encoders);
void print_encoders(const std::vector<wivrn::encoder_settings> & encoders);
@@ -63,7 +63,7 @@ bool set_log_level()
bool VideoEncoderFFMPEG::once = set_log_level();
std::optional<xrt::drivers::wivrn::VideoEncoder::data> VideoEncoderFFMPEG::encode(bool idr, std::chrono::steady_clock::time_point target_timestamp, uint8_t slot)
std::optional<wivrn::VideoEncoder::data> VideoEncoderFFMPEG::encode(bool idr, std::chrono::steady_clock::time_point target_timestamp, uint8_t slot)
{
push_frame(idr, target_timestamp, slot);
std::shared_ptr<AVPacket> enc_pkt(av_packet_alloc(), [](AVPacket * d) { av_packet_free(&d); });
+3 -3
View File
@@ -23,10 +23,10 @@
#include "ffmpeg_helper.h"
#include <chrono>
class VideoEncoderFFMPEG : public xrt::drivers::wivrn::VideoEncoder
class VideoEncoderFFMPEG : public wivrn::VideoEncoder
{
public:
using Codec = xrt::drivers::wivrn::video_codec;
using Codec = wivrn::video_codec;
std::optional<data> encode(bool idr, std::chrono::steady_clock::time_point target_timestamp, uint8_t slot) override;
@@ -38,7 +38,7 @@ public:
protected:
VideoEncoderFFMPEG() :
xrt::drivers::wivrn::VideoEncoder(true) {}
wivrn::VideoEncoder(true) {}
virtual void push_frame(bool idr, std::chrono::steady_clock::time_point pts, uint8_t slot) = 0;
+1 -1
View File
@@ -127,7 +127,7 @@ vk::Format drm_to_vulkan_fmt(uint32_t drm_fourcc)
} // namespace
video_encoder_va::video_encoder_va(wivrn_vk_bundle & vk, xrt::drivers::wivrn::encoder_settings & settings, float fps) :
video_encoder_va::video_encoder_va(wivrn_vk_bundle & vk, wivrn::encoder_settings & settings, float fps) :
synchronization2(vk.vk.features.synchronization_2)
{
auto drm_hw_ctx = make_drm_hw_ctx(vk.physical_device, settings.device);
+2 -2
View File
@@ -24,7 +24,7 @@
#include "video_encoder_ffmpeg.h"
#include <vulkan/vulkan_raii.hpp>
namespace xrt::drivers::wivrn
namespace wivrn
{
struct encoder_settings;
}
@@ -45,7 +45,7 @@ class video_encoder_va : public VideoEncoderFFMPEG
bool synchronization2 = false;
public:
video_encoder_va(wivrn_vk_bundle &, xrt::drivers::wivrn::encoder_settings & settings, float fps);
video_encoder_va(wivrn_vk_bundle &, wivrn::encoder_settings & settings, float fps);
void present_image(vk::Image y_cbcr, vk::raii::CommandBuffer & cmd_buf, uint8_t slot) override;
+2 -2
View File
@@ -39,7 +39,7 @@
#include "video_encoder_x264.h"
#endif
namespace xrt::drivers::wivrn
namespace wivrn
{
VideoEncoder::sender::sender() :
@@ -293,4 +293,4 @@ void VideoEncoder::SendData(std::span<uint8_t> data, bool end_of_frame)
cnx->dump_time("send_end", shard.frame_idx, os_monotonic_get_ns(), stream_idx);
}
} // namespace xrt::drivers::wivrn
} // namespace wivrn
+2 -2
View File
@@ -35,7 +35,7 @@
struct wivrn_vk_bundle;
namespace xrt::drivers::wivrn
namespace wivrn
{
class wivrn_session;
@@ -126,4 +126,4 @@ protected:
void SendData(std::span<uint8_t> data, bool end_of_frame);
};
} // namespace xrt::drivers::wivrn
} // namespace wivrn
+2 -2
View File
@@ -60,7 +60,7 @@
} \
} while (0)
namespace xrt::drivers::wivrn
namespace wivrn
{
void VideoEncoderNvenc::deleter::operator()(CudaFunctions * fn)
@@ -445,4 +445,4 @@ std::array<int, 2> VideoEncoderNvenc::get_max_size(video_codec codec)
return result;
}
} // namespace xrt::drivers::wivrn
} // namespace wivrn
+2 -2
View File
@@ -26,7 +26,7 @@
#include <ffnvcodec/nvEncodeAPI.h>
#include <vulkan/vulkan_raii.hpp>
namespace xrt::drivers::wivrn
namespace wivrn
{
class VideoEncoderNvenc : public VideoEncoder
@@ -73,4 +73,4 @@ public:
static std::array<int, 2> get_max_size(video_codec);
};
} // namespace xrt::drivers::wivrn
} // namespace wivrn
+2 -2
View File
@@ -23,7 +23,7 @@
#include "utils/wivrn_vk_bundle.h"
#include <stdexcept>
namespace xrt::drivers::wivrn
namespace wivrn
{
void VideoEncoderX264::ProcessCb(x264_t * h, x264_nal_t * nal, void * opaque)
@@ -249,4 +249,4 @@ VideoEncoderX264::~VideoEncoderX264()
x264_encoder_close(enc);
}
} // namespace xrt::drivers::wivrn
} // namespace wivrn
+2 -2
View File
@@ -27,7 +27,7 @@
#include <mutex>
#include <vulkan/vulkan_raii.hpp>
namespace xrt::drivers::wivrn
namespace wivrn
{
class VideoEncoderX264 : public VideoEncoder
@@ -77,4 +77,4 @@ private:
void InsertInPendingNal(pending_nal && nal);
};
} // namespace xrt::drivers::wivrn
} // namespace wivrn
+15 -15
View File
@@ -50,11 +50,11 @@ extern "C"
ipc_server_main(int argc, char * argv[]);
}
using namespace xrt::drivers::wivrn;
using namespace wivrn;
static std::unique_ptr<TCPListener> listener;
std::optional<xrt::drivers::wivrn::typed_socket<xrt::drivers::wivrn::UnixDatagram, from_monado::packets, to_monado::packets>> wivrn_ipc_socket_main_loop;
std::optional<xrt::drivers::wivrn::typed_socket<xrt::drivers::wivrn::UnixDatagram, to_monado::packets, from_monado::packets>> wivrn_ipc_socket_monado;
std::optional<wivrn::typed_socket<wivrn::UnixDatagram, from_monado::packets, to_monado::packets>> wivrn_ipc_socket_main_loop;
std::optional<wivrn::typed_socket<wivrn::UnixDatagram, to_monado::packets, from_monado::packets>> wivrn_ipc_socket_monado;
std::filesystem::path socket_path()
{
@@ -205,7 +205,7 @@ std::optional<avahi_publisher> publisher;
gboolean headset_connected(gint fd, GIOCondition condition, gpointer user_data);
void stop_listening();
void on_headset_info_packet(const xrt::drivers::wivrn::from_headset::headset_info_packet & info);
void on_headset_info_packet(const wivrn::from_headset::headset_info_packet & info);
void start_publishing();
void stop_publishing();
@@ -339,7 +339,7 @@ void start_listening()
assert(listener_watch == 0);
listener = std::make_unique<TCPListener>(xrt::drivers::wivrn::default_port);
listener = std::make_unique<TCPListener>(wivrn::default_port);
auto source_listener = g_unix_fd_source_new(listener->get_fd(), GIOCondition::G_IO_IN);
g_source_set_callback(source_listener, G_SOURCE_FUNC(&headset_connected), nullptr, nullptr);
listener_watch = g_source_attach(source_listener, nullptr);
@@ -364,13 +364,13 @@ void start_publishing()
return;
char protocol_string[17];
sprintf(protocol_string, "%016lx", xrt::drivers::wivrn::protocol_version);
sprintf(protocol_string, "%016lx", wivrn::protocol_version);
std::map<std::string, std::string> TXT = {
{"protocol", protocol_string},
{"version", xrt::drivers::wivrn::git_version},
{"version", wivrn::git_version},
{"cookie", server_cookie()},
};
publisher.emplace(poll_api, hostname(), "_wivrn._tcp", xrt::drivers::wivrn::default_port, TXT);
publisher.emplace(poll_api, hostname(), "_wivrn._tcp", wivrn::default_port, TXT);
}
void stop_publishing()
@@ -428,7 +428,7 @@ gboolean headset_connected(gint fd, GIOCondition condition, gpointer user_data)
assert(listener);
tcp = std::make_unique<xrt::drivers::wivrn::TCP>(listener->accept().first);
tcp = std::make_unique<wivrn::TCP>(listener->accept().first);
init_cleanup_functions();
std::cout << "Client connected" << std::endl;
@@ -444,9 +444,9 @@ gboolean control_received(gint fd, GIOCondition condition, gpointer user_data)
auto packet = wivrn_ipc_socket_main_loop->receive();
if (packet)
{
if (std::holds_alternative<xrt::drivers::wivrn::from_headset::headset_info_packet>(*packet))
if (std::holds_alternative<wivrn::from_headset::headset_info_packet>(*packet))
{
on_headset_info_packet(std::get<xrt::drivers::wivrn::from_headset::headset_info_packet>(*packet));
on_headset_info_packet(std::get<wivrn::from_headset::headset_info_packet>(*packet));
wivrn_server_set_headset_connected(dbus_server, true);
}
else if (std::holds_alternative<from_monado::headsdet_connected>(*packet))
@@ -503,7 +503,7 @@ void on_json_configuration(WivrnServer * server, const GParamSpec * pspec, gpoin
std::cerr << "Failed to save configuration: " << ec.message() << std::endl;
}
void on_headset_info_packet(const xrt::drivers::wivrn::from_headset::headset_info_packet & info)
void on_headset_info_packet(const wivrn::from_headset::headset_info_packet & info)
{
GVariantBuilder * builder;
@@ -521,11 +521,11 @@ void on_headset_info_packet(const xrt::drivers::wivrn::from_headset::headset_inf
wivrn_server_set_preferred_refresh_rate(dbus_server, info.preferred_refresh_rate);
auto speaker = info.speaker.value_or(xrt::drivers::wivrn::from_headset::headset_info_packet::audio_description{});
auto speaker = info.speaker.value_or(wivrn::from_headset::headset_info_packet::audio_description{});
wivrn_server_set_speaker_channels(dbus_server, speaker.num_channels);
wivrn_server_set_speaker_sample_rate(dbus_server, speaker.sample_rate);
auto mic = info.microphone.value_or(xrt::drivers::wivrn::from_headset::headset_info_packet::audio_description{});
auto mic = info.microphone.value_or(wivrn::from_headset::headset_info_packet::audio_description{});
wivrn_server_set_mic_channels(dbus_server, mic.num_channels);
wivrn_server_set_mic_sample_rate(dbus_server, mic.sample_rate);
@@ -594,7 +594,7 @@ int inner_main(int argc, char * argv[], bool show_instructions)
{
if (show_instructions)
{
std::cerr << "WiVRn " << xrt::drivers::wivrn::git_version << " starting" << std::endl;
std::cerr << "WiVRn " << wivrn::git_version << " starting" << std::endl;
std::cerr << "For Steam games, set command to " << steam_command() << std::endl;
}
+1 -1
View File
@@ -40,7 +40,7 @@ wivrn_instance_create_system(struct xrt_instance * xinst,
*out_xsys = &u_sys->base;
struct xrt_system_compositor * xsysc = NULL;
auto res = xrt::drivers::wivrn::wivrn_session::create_session(
auto res = wivrn::wivrn_session::create_session(
std::move(*tcp),
*u_sys,
out_xsysd,
+1 -1
View File
@@ -23,7 +23,7 @@
#include <sys/mman.h>
#include <sys/wait.h>
std::unique_ptr<xrt::drivers::wivrn::TCP> tcp;
std::unique_ptr<wivrn::TCP> tcp;
struct cleanup_function
{
+3 -3
View File
@@ -23,7 +23,7 @@
#include <memory>
#include <wivrn_sockets.h>
extern std::unique_ptr<xrt::drivers::wivrn::TCP> tcp;
extern std::unique_ptr<wivrn::TCP> tcp;
namespace from_monado
{
@@ -32,7 +32,7 @@ struct headsdet_connected
struct headsdet_disconnected
{};
using packets = std::variant<xrt::drivers::wivrn::from_headset::headset_info_packet, headsdet_connected, headsdet_disconnected>;
using packets = std::variant<wivrn::from_headset::headset_info_packet, headsdet_connected, headsdet_disconnected>;
} // namespace from_monado
namespace to_monado
@@ -43,7 +43,7 @@ struct disconnect
using packets = std::variant<disconnect>;
} // namespace to_monado
extern std::optional<xrt::drivers::wivrn::typed_socket<xrt::drivers::wivrn::UnixDatagram, to_monado::packets, from_monado::packets>> wivrn_ipc_socket_monado;
extern std::optional<wivrn::typed_socket<wivrn::UnixDatagram, to_monado::packets, from_monado::packets>> wivrn_ipc_socket_monado;
std::optional<to_monado::packets> receive_from_main();
template <typename T>