wivrn namespace: move all server classes
This commit is contained in:
@@ -30,7 +30,7 @@ static void handle_event_from_main_loop(to_monado::disconnect)
|
||||
// Ignore disconnect request when no headset is connected
|
||||
}
|
||||
|
||||
std::unique_ptr<wivrn::TCP> accept_connection(int watch_fd, std::function<bool()> quit)
|
||||
std::unique_ptr<wivrn::TCP> wivrn::accept_connection(int watch_fd, std::function<bool()> quit)
|
||||
{
|
||||
wivrn_ipc_socket_monado->send(from_monado::headsdet_disconnected{});
|
||||
|
||||
|
||||
@@ -23,4 +23,7 @@
|
||||
#include <memory>
|
||||
#include <wivrn_sockets.h>
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
std::unique_ptr<wivrn::TCP> accept_connection(int watch_fd, std::function<bool()> quit = std::function<bool()>());
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
std::filesystem::path active_runtime::manifest_path()
|
||||
{
|
||||
const std::filesystem::path install_location = "share/openxr/1/openxr_wivrn.json";
|
||||
@@ -84,3 +87,4 @@ active_runtime::~active_runtime()
|
||||
std::cerr << "Cannot unset active OpenXR runtime: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include <filesystem>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
class active_runtime
|
||||
{
|
||||
bool to_be_deleted = false;
|
||||
@@ -35,3 +38,4 @@ public:
|
||||
|
||||
static std::filesystem::path manifest_path();
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -26,8 +26,11 @@
|
||||
#include <pipewire/pipewire.h>
|
||||
#include <spa/param/audio/format-utils.h>
|
||||
|
||||
using namespace wivrn;
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
struct deleter
|
||||
{
|
||||
void operator()(pw_main_loop * loop)
|
||||
@@ -189,6 +192,7 @@ struct pipewire_device : public audio_device
|
||||
[loop = pw_loop.get()]() { pw_main_loop_run(loop); });
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void pipewire_device::mic_process(void * self_v)
|
||||
{
|
||||
@@ -315,3 +319,4 @@ std::shared_ptr<audio_device> create_pipewire_handle(
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "audio_setup.h"
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
std::shared_ptr<audio_device> create_pipewire_handle(
|
||||
const std::string & source_name,
|
||||
const std::string & source_description,
|
||||
@@ -27,3 +30,4 @@ std::shared_ptr<audio_device> create_pipewire_handle(
|
||||
const std::string & sink_description,
|
||||
const wivrn::from_headset::headset_info_packet & info,
|
||||
wivrn::wivrn_session & session);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ static const char * sink_name = "WiVRn";
|
||||
static const char * source_pipe = "wivrn-source";
|
||||
static const char * sink_pipe = "wivrn-sink";
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
struct module_entry
|
||||
{
|
||||
uint32_t module;
|
||||
@@ -466,3 +469,4 @@ void unload_module(uintptr_t id)
|
||||
pa_connection cnx("WiVRn");
|
||||
unload_module(cnx, id);
|
||||
}
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "audio_setup.h"
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
std::shared_ptr<audio_device> create_pulse_handle(
|
||||
const std::string & source_name,
|
||||
const std::string & source_description,
|
||||
@@ -27,3 +30,4 @@ std::shared_ptr<audio_device> create_pulse_handle(
|
||||
const std::string & sink_description,
|
||||
const wivrn::from_headset::headset_info_packet & info,
|
||||
wivrn::wivrn_session & session);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "audio_pipewire.h"
|
||||
#endif
|
||||
|
||||
std::shared_ptr<audio_device> audio_device::create(
|
||||
std::shared_ptr<wivrn::audio_device> wivrn::audio_device::create(
|
||||
const std::string & source_name,
|
||||
const std::string & source_description,
|
||||
const std::string & sink_name,
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
namespace wivrn
|
||||
{
|
||||
class wivrn_session;
|
||||
}
|
||||
|
||||
struct audio_device
|
||||
{
|
||||
@@ -46,3 +45,4 @@ struct audio_device
|
||||
const wivrn::from_headset::headset_info_packet & info,
|
||||
wivrn::wivrn_session & session);
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include <avahi-common/strlst.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
const std::error_category & avahi_error_category()
|
||||
{
|
||||
static struct : std::error_category
|
||||
@@ -173,3 +176,4 @@ void avahi_publisher::watch_free(AvahiWatch * watch)
|
||||
{
|
||||
poll_api->watch_free(watch);
|
||||
}*/
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include <system_error>
|
||||
#include <vector>
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
const std::error_category & avahi_error_category();
|
||||
|
||||
class avahi_publisher
|
||||
@@ -39,3 +42,4 @@ public:
|
||||
avahi_publisher & operator=(const avahi_publisher &) = delete;
|
||||
~avahi_publisher();
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
#include "ffmpeg/video_encoder_va.h"
|
||||
#endif
|
||||
|
||||
using namespace wivrn;
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
// TODO: size independent bitrate
|
||||
static const uint64_t default_bitrate = 50'000'000;
|
||||
|
||||
@@ -258,7 +258,7 @@ static void make_even(uint16_t & value, uint16_t max)
|
||||
value = std::min(value, max);
|
||||
}
|
||||
|
||||
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)
|
||||
std::vector<encoder_settings> get_encoder_settings(wivrn_vk_bundle & bundle, uint32_t & width, uint32_t & height, const from_headset::headset_info_packet & info)
|
||||
{
|
||||
configuration config;
|
||||
try
|
||||
@@ -316,3 +316,4 @@ std::vector<encoder_settings> wivrn::get_encoder_settings(wivrn_vk_bundle & bund
|
||||
split_bitrate(res, bitrate);
|
||||
return res;
|
||||
}
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -25,10 +25,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct wivrn_vk_bundle;
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
struct wivrn_vk_bundle;
|
||||
|
||||
struct encoder_settings : public to_headset::video_stream_description::item
|
||||
{
|
||||
@@ -43,6 +42,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 wivrn
|
||||
|
||||
void print_encoders(const std::vector<wivrn::encoder_settings> & encoders);
|
||||
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -61,6 +61,9 @@ bool set_log_level()
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
bool VideoEncoderFFMPEG::once = set_log_level();
|
||||
|
||||
std::optional<wivrn::VideoEncoder::data> VideoEncoderFFMPEG::encode(bool idr, std::chrono::steady_clock::time_point target_timestamp, uint8_t slot)
|
||||
@@ -94,3 +97,4 @@ VideoEncoderFFMPEG::mute_logs::~mute_logs()
|
||||
{
|
||||
set_log_level();
|
||||
}
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#include "ffmpeg_helper.h"
|
||||
#include <chrono>
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
class VideoEncoderFFMPEG : public wivrn::VideoEncoder
|
||||
{
|
||||
public:
|
||||
@@ -47,3 +50,4 @@ protected:
|
||||
private:
|
||||
static bool once;
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -40,6 +40,9 @@ extern "C"
|
||||
#include <libavutil/pixdesc.h>
|
||||
}
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
const char *
|
||||
@@ -475,3 +478,4 @@ void video_encoder_va::push_frame(bool idr, std::chrono::steady_clock::time_poin
|
||||
throw std::system_error(err, av_error_category(), "avcodec_send_frame failed");
|
||||
}
|
||||
}
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
namespace wivrn
|
||||
{
|
||||
struct encoder_settings;
|
||||
}
|
||||
|
||||
class video_encoder_va : public VideoEncoderFFMPEG
|
||||
{
|
||||
@@ -52,3 +51,4 @@ public:
|
||||
protected:
|
||||
void push_frame(bool idr, std::chrono::steady_clock::time_point pts, uint8_t slot) override;
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -33,11 +33,10 @@
|
||||
#include "encoder_settings.h"
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
struct wivrn_vk_bundle;
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
struct wivrn_vk_bundle;
|
||||
class wivrn_session;
|
||||
|
||||
inline const char * encoder_nvenc = "nvenc";
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ static std::string _hostname()
|
||||
return "no-hostname";
|
||||
}
|
||||
|
||||
std::string hostname()
|
||||
std::string wivrn::hostname()
|
||||
{
|
||||
// Accessing hostname in child process fails with glib
|
||||
static std::string result = _hostname();
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
std::string hostname();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <systemd/sd-bus.h>
|
||||
#include <thread>
|
||||
|
||||
int get_service_pid(const std::string & service_name, pid_t & pid)
|
||||
static int get_service_pid(const std::string & service_name, pid_t & pid)
|
||||
{
|
||||
sd_bus * bus = nullptr;
|
||||
sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
@@ -165,7 +165,7 @@ finish:
|
||||
return is_active;
|
||||
}
|
||||
|
||||
pid_t start_unit_file()
|
||||
pid_t wivrn::start_unit_file()
|
||||
{
|
||||
std::string service_name = "wivrn-application.service";
|
||||
pid_t pid;
|
||||
@@ -200,7 +200,7 @@ pid_t start_unit_file()
|
||||
|
||||
#endif
|
||||
|
||||
pid_t fork_application()
|
||||
pid_t wivrn::fork_application()
|
||||
{
|
||||
auto config = configuration::read_user_configuration();
|
||||
|
||||
@@ -225,7 +225,7 @@ pid_t fork_application()
|
||||
return application_pid;
|
||||
}
|
||||
|
||||
int exec_application(configuration config)
|
||||
int wivrn::exec_application(configuration config)
|
||||
{
|
||||
if (config.application.empty())
|
||||
return 0;
|
||||
|
||||
@@ -4,10 +4,15 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
struct configuration;
|
||||
|
||||
pid_t fork_application();
|
||||
|
||||
#if WIVRN_USE_SYSTEMD
|
||||
pid_t start_unit_file();
|
||||
#endif
|
||||
|
||||
int exec_application(configuration);
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
extern std::unique_ptr<TCP> tcp;
|
||||
extern std::unique_ptr<wivrn::TCP> tcp;
|
||||
|
||||
static xrt_result_t
|
||||
wivrn_instance_create_system(struct xrt_instance * xinst,
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
#include "os/os_threading.h"
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
class scoped_lock
|
||||
{
|
||||
os_mutex & mutex;
|
||||
@@ -36,3 +39,4 @@ public:
|
||||
os_mutex_unlock(&mutex);
|
||||
}
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
wivrn_vk_bundle::wivrn_vk_bundle(vk_bundle & vk, std::span<const char *> requested_instance_extensions, std::span<const char *> requested_device_extensions) :
|
||||
wivrn::wivrn_vk_bundle::wivrn_vk_bundle(vk_bundle & vk, std::span<const char *> requested_instance_extensions, std::span<const char *> requested_device_extensions) :
|
||||
vk(vk),
|
||||
instance(vk_ctx, vk.instance),
|
||||
physical_device(instance, vk.physical_device),
|
||||
@@ -147,7 +147,7 @@ wivrn_vk_bundle::wivrn_vk_bundle(vk_bundle & vk, std::span<const char *> request
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t wivrn_vk_bundle::get_memory_type(uint32_t type_bits, vk::MemoryPropertyFlags memory_props)
|
||||
uint32_t wivrn::wivrn_vk_bundle::get_memory_type(uint32_t type_bits, vk::MemoryPropertyFlags memory_props)
|
||||
{
|
||||
auto mem_prop = physical_device.getMemoryProperties();
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
|
||||
struct vk_bundle;
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
// to use vk::raii we need a vk::raii::{Instance,PhysicalDevice,Device}
|
||||
// however we don't own it, so deactivate the destructor
|
||||
struct raii_instance : public vk::raii::Instance
|
||||
@@ -68,3 +71,4 @@ struct wivrn_vk_bundle
|
||||
|
||||
uint32_t get_memory_type(uint32_t type_bits, vk::MemoryPropertyFlags memory_props);
|
||||
};
|
||||
} // namespace wivrn
|
||||
|
||||
Reference in New Issue
Block a user