wivrn namespace: move all server classes

This commit is contained in:
Patrick Nicolas
2024-10-03 23:39:32 +02:00
parent efbcef2861
commit 28284a9694
55 changed files with 195 additions and 73 deletions
+4
View File
@@ -23,6 +23,9 @@
#include "os/os_time.h"
#include "util/u_logging.h"
namespace wivrn
{
static const size_t num_samples = 100;
void clock_offset_estimator::reset()
@@ -144,3 +147,4 @@ XrTime clock_offset::to_headset(XrTime timestamp_ns) const
{
return timestamp_ns + b;
}
} // namespace wivrn
+4
View File
@@ -26,6 +26,9 @@
#include <cstdint>
#include <mutex>
namespace wivrn
{
class wivrn_connection;
struct clock_offset
@@ -68,3 +71,4 @@ public:
clock_offset get_offset();
};
} // namespace wivrn
+1 -1
View File
@@ -49,7 +49,6 @@ NLOHMANN_JSON_SERIALIZE_ENUM(
{av1, "av1"},
{av1, "AV1"},
})
}
void configuration::set_config_file(const std::filesystem::path & path)
{
@@ -176,3 +175,4 @@ std::string server_cookie()
return buffer;
}
}
} // namespace wivrn
+4
View File
@@ -27,6 +27,9 @@
#include "wivrn_packets.h"
namespace wivrn
{
struct configuration
{
struct encoder
@@ -54,3 +57,4 @@ struct configuration
};
std::string server_cookie();
} // namespace wivrn
+7 -7
View File
@@ -22,26 +22,25 @@
#include "pose_list.h"
#include "xrt_cast.h"
using namespace wivrn;
static_assert(XRT_HAND_JOINT_COUNT == XR_HAND_JOINT_COUNT_EXT);
namespace
namespace wivrn
{
xrt_hand_joint_value interpolate(const xrt_hand_joint_value & a, const xrt_hand_joint_value & b, float t)
static xrt_hand_joint_value interpolate(const xrt_hand_joint_value & a, const xrt_hand_joint_value & b, float t)
{
return {
.relation = pose_list::interpolate(a.relation, b.relation, t),
.radius = a.radius * (1 - t) + b.radius * t};
.radius = a.radius * (1 - t) + b.radius * t,
};
}
} // namespace
xrt_hand_joint_set hand_joints_list::interpolate(const xrt_hand_joint_set & a, const xrt_hand_joint_set & b, float t)
{
xrt_hand_joint_set j = a;
for (int i = 0; i < XRT_HAND_JOINT_COUNT; i++)
{
j.values.hand_joint_set_default[i] = ::interpolate(a.values.hand_joint_set_default[i], b.values.hand_joint_set_default[i], t);
j.values.hand_joint_set_default[i] = ::wivrn::interpolate(a.values.hand_joint_set_default[i], b.values.hand_joint_set_default[i], t);
}
return j;
}
@@ -128,3 +127,4 @@ bool hand_joints_list::update_tracking(const from_headset::hand_tracking & track
offset);
return true;
}
} // namespace wivrn
+4
View File
@@ -22,6 +22,9 @@
#include "history.h"
#include "xrt/xrt_defines.h"
namespace wivrn
{
class hand_joints_list : public history<hand_joints_list, xrt_hand_joint_set>
{
public:
@@ -35,3 +38,4 @@ public:
bool update_tracking(const wivrn::from_headset::hand_tracking & tracking, const clock_offset & offset);
};
} // namespace wivrn
+4
View File
@@ -27,6 +27,9 @@
#include <list>
#include <mutex>
namespace wivrn
{
template <typename Derived, typename Data, XrDuration extrapolation = 0, size_t MaxSamples = 10>
class history
{
@@ -161,3 +164,4 @@ public:
}
}
};
} // namespace wivrn
+4 -1
View File
@@ -24,9 +24,11 @@
#include "xrt/xrt_defines.h"
#include "xrt_cast.h"
using namespace wivrn;
using namespace xrt::auxiliary::math;
namespace wivrn
{
xrt_space_relation pose_list::interpolate(const xrt_space_relation & a, const xrt_space_relation & b, float t)
{
xrt_space_relation result;
@@ -103,3 +105,4 @@ xrt_space_relation pose_list::convert_pose(const from_headset::tracking::pose &
return res;
}
} // namespace wivrn
+4
View File
@@ -24,6 +24,9 @@
#include "wivrn_packets.h"
#include "xrt/xrt_defines.h"
namespace wivrn
{
class pose_list : public history<pose_list, xrt_space_relation>
{
public:
@@ -39,3 +42,4 @@ public:
static xrt_space_relation convert_pose(const wivrn::from_headset::tracking::pose &);
};
} // namespace wivrn
+4
View File
@@ -21,6 +21,9 @@
#include "pose_list.h"
#include "xrt_cast.h"
namespace wivrn
{
tracked_views view_list::interpolate(const tracked_views & a, const tracked_views & b, float t)
{
tracked_views result = a;
@@ -57,3 +60,4 @@ bool view_list::update_tracking(const from_headset::tracking & tracking, const c
}
return true;
}
} // namespace wivrn
+4
View File
@@ -22,6 +22,9 @@
#include "pose_list.h"
#include "wivrn_connection.h"
namespace wivrn
{
struct tracked_views
{
XrViewStateFlags flags;
@@ -38,3 +41,4 @@ public:
bool update_tracking(const from_headset::tracking & tracking, const clock_offset & offset);
};
} // namespace wivrn
+3 -1
View File
@@ -29,7 +29,8 @@
#include <vulkan/vulkan_core.h>
#include <vulkan/vulkan_handles.hpp>
using namespace wivrn;
namespace wivrn
{
std::vector<const char *> wivrn_comp_target::wanted_instance_extensions = {};
std::vector<const char *> wivrn_comp_target::wanted_device_extensions = {
@@ -673,3 +674,4 @@ wivrn_comp_target::wivrn_comp_target(std::shared_ptr<wivrn::wivrn_session> cnx,
desc.fps = fps;
this->c = c;
}
} // namespace wivrn
+4 -4
View File
@@ -31,13 +31,13 @@ static void handle_event_from_main_loop(to_monado::disconnect)
// Ignore disconnect request when no headset is connected
}
wivrn_connection::wivrn_connection(TCP && tcp) :
wivrn::wivrn_connection::wivrn_connection(TCP && tcp) :
control(std::move(tcp)), stream(-1)
{
init();
}
void wivrn_connection::init()
void wivrn::wivrn_connection::init()
{
active = false;
stream = -1;
@@ -144,13 +144,13 @@ void wivrn_connection::init()
active = true;
}
void wivrn_connection::reset(TCP && tcp)
void wivrn::wivrn_connection::reset(TCP && tcp)
{
control = std::move(tcp);
init();
}
std::optional<from_headset::packets> wivrn_connection::poll_control(int timeout)
std::optional<wivrn::from_headset::packets> wivrn::wivrn_connection::poll_control(int timeout)
{
pollfd fds{};
fds.events = POLLIN;
+3 -1
View File
@@ -25,7 +25,8 @@
#include <optional>
#include <poll.h>
using namespace wivrn;
namespace wivrn
{
class wivrn_connection
{
@@ -131,3 +132,4 @@ public:
return r;
}
};
} // namespace wivrn
+3 -5
View File
@@ -25,11 +25,8 @@
#include "xrt/xrt_defines.h"
/*
*
* Defines & structs.
*
*/
namespace wivrn
{
enum wivrn_controller_input_index
{
@@ -418,3 +415,4 @@ static void wivrn_controller_set_output(struct xrt_device * xdev, enum xrt_outpu
{
static_cast<wivrn_controller *>(xdev)->set_output(name, value);
}
} // namespace wivrn
+1 -1
View File
@@ -32,7 +32,6 @@
namespace wivrn
{
class wivrn_session;
}
class wivrn_controller : public xrt_device
{
@@ -70,3 +69,4 @@ public:
private:
void set_inputs(device_id input_id, float value, int64_t last_change_time);
};
} // namespace wivrn
+4
View File
@@ -30,6 +30,9 @@
#include <cstdint>
#include <openxr/openxr.h>
namespace wivrn
{
static void wivrn_eye_tracker_destroy(xrt_device * xdev);
static void wivrn_eye_tracker_update_inputs(xrt_device * xdev);
@@ -110,3 +113,4 @@ static void wivrn_eye_tracker_get_tracked_pose(xrt_device * xdev,
{
*out_relation = static_cast<wivrn_eye_tracker *>(xdev)->get_tracked_pose(name, at_timestamp_ns);
}
} // namespace wivrn
+4
View File
@@ -32,6 +32,9 @@
#include <memory>
#include <mutex>
namespace wivrn
{
class wivrn_eye_tracker : public xrt_device
{
std::mutex mutex;
@@ -51,3 +54,4 @@ public:
void update_tracking(const from_headset::tracking &, const clock_offset &);
xrt_space_relation get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns);
};
} // namespace wivrn
+4
View File
@@ -32,6 +32,9 @@
#include <cstring>
#include <openxr/openxr.h>
namespace wivrn
{
static void wivrn_fb_face2_tracker_destroy(xrt_device * xdev);
static void wivrn_fb_face2_tracker_update_inputs(xrt_device * xdev);
@@ -135,3 +138,4 @@ static xrt_result_t wivrn_fb_face2_tracker_get_face_tracking(struct xrt_device *
{
return static_cast<wivrn_fb_face2_tracker *>(xdev)->get_face_tracking(facial_expression_type, at_timestamp_ns, inout_value);
}
} // namespace wivrn
+4
View File
@@ -33,6 +33,9 @@
#include <memory>
#include <openxr/openxr.h>
namespace wivrn
{
struct wivrn_fb_face2_data
{
std::array<float, XRT_FACE_EXPRESSION2_COUNT_FB> weights;
@@ -99,3 +102,4 @@ public:
void update_tracking(const from_headset::tracking &, const clock_offset &);
xrt_result_t get_face_tracking(enum xrt_input_name facial_expression_type, int64_t at_timestamp_ns, struct xrt_facial_expression_set * out_value);
};
} // namespace wivrn
+4
View File
@@ -35,6 +35,9 @@
extern const std::map<std::string, std::vector<uint32_t>> shaders;
namespace wivrn
{
const uint32_t dispatch_group_count = RENDER_DISTORTION_IMAGE_DIMENSIONS / 8;
struct FoveationParamsPcs
@@ -317,3 +320,4 @@ void wivrn_foveation::set_initial_parameters(std::array<to_headset::foveation_pa
center_offset[0] = {p[0].x.center, p[0].y.center};
center_offset[1] = {p[1].x.center, p[1].y.center};
}
} // namespace wivrn
+4
View File
@@ -22,6 +22,9 @@
#include "wivrn_session.h"
namespace wivrn
{
struct wivrn_vk_bundle;
// Calculates the center parameter from the received eye tracking data.
@@ -59,3 +62,4 @@ public:
void render_distortion_images(std::array<to_headset::foveation_parameter, 2> foveation_arr, const VkImage * images, const VkImageView * image_views);
};
} // namespace wivrn
+3 -17
View File
@@ -35,23 +35,8 @@
#include "configuration.h"
/*
*
* Structs and defines.
*
*/
/*!
* A wivrn HMD device.
*
* @implements xrt_device
*/
/*
*
* Functions
*
*/
namespace wivrn
{
static void wivrn_hmd_destroy(xrt_device * xdev);
@@ -456,3 +441,4 @@ static xrt_result_t wivrn_hmd_get_battery_status(struct xrt_device * xdev,
{
return static_cast<wivrn_hmd *>(xdev)->get_battery_status(xdev, out_present, out_charging, out_charge);
}
} // namespace wivrn
+3 -2
View File
@@ -31,11 +31,11 @@
#include <mutex>
struct comp_target;
struct comp_compositor;
namespace wivrn
{
class wivrn_session;
}
class wivrn_hmd : public xrt_device
{
@@ -69,7 +69,7 @@ public:
void update_inputs();
xrt_space_relation get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns);
comp_target * create_compositor_target(struct comp_compositor * comp);
comp_target * create_compositor_target(comp_compositor * comp);
void get_view_poses(const xrt_vec3 * default_eye_relation,
int64_t at_timestamp_ns,
uint32_t view_count,
@@ -92,3 +92,4 @@ public:
return foveation_parameters;
}
};
} // namespace wivrn
+6 -2
View File
@@ -22,10 +22,13 @@
#include "os/os_time.h"
#include <cmath>
namespace wivrn
{
// How many samples of wait time to store per decoder
const size_t num_wait_times = 100;
static const size_t num_wait_times = 100;
// How many samples of wait time are required to use them
const size_t min_wait_times = 50;
static const size_t min_wait_times = 50;
void wivrn_pacer::set_stream_count(size_t count)
{
@@ -171,3 +174,4 @@ void wivrn_pacer::reset()
}
in_flight_frames = {};
}
} // namespace wivrn
+4
View File
@@ -26,6 +26,9 @@
#include <mutex>
#include <vector>
namespace wivrn
{
struct clock_offset;
class wivrn_pacer
@@ -89,3 +92,4 @@ public:
void reset();
};
} // namespace wivrn
+4
View File
@@ -53,6 +53,9 @@
#include "solarxr_device.h"
#endif
namespace wivrn
{
struct wivrn_comp_target_factory : public comp_target_factory
{
std::shared_ptr<wivrn_session> session;
@@ -545,3 +548,4 @@ void wivrn_session::reconnect()
U_LOG_E("Reconnection failed: %s", e.what());
}
}
} // namespace wivrn
+8 -9
View File
@@ -33,21 +33,20 @@
#include <mutex>
#include <thread>
struct u_system;
struct xrt_system_devices;
struct xrt_space_overseer;
struct xrt_system_compositor;
namespace wivrn
{
class wivrn_eye_tracker;
class wivrn_fb_face2_tracker;
class wivrn_foveation;
class wivrn_foveation_renderer;
struct audio_device;
struct u_system;
struct xrt_system_devices;
struct xrt_space_overseer;
struct xrt_system_compositor;
struct wivrn_comp_target_factory;
namespace wivrn
{
struct wivrn_comp_target;
struct wivrn_comp_target_factory;
class tracking_control_t
{