Drop xrt::drivers namespace
This commit is contained in:
@@ -127,7 +127,7 @@ int32_t wivrn::android::audio::microphone_data_cb(AAudioStream * stream, void *
|
|||||||
|
|
||||||
size_t frame_size = AAudioStream_getChannelCount(stream) * sizeof(uint16_t);
|
size_t frame_size = AAudioStream_getChannelCount(stream) * sizeof(uint16_t);
|
||||||
|
|
||||||
xrt::drivers::wivrn::audio_data packet{
|
wivrn::audio_data packet{
|
||||||
.timestamp = self->instance.now(),
|
.timestamp = self->instance.now(),
|
||||||
.payload = std::span(audio_data, frame_size * num_frames),
|
.payload = std::span(audio_data, frame_size * num_frames),
|
||||||
};
|
};
|
||||||
@@ -237,7 +237,7 @@ void wivrn::android::audio::microphone_error_cb(AAudioStream * stream, void * us
|
|||||||
recreate_thread.detach();
|
recreate_thread.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
wivrn::android::audio::audio(const xrt::drivers::wivrn::to_headset::audio_stream_description & desc, wivrn_session & session, xr::instance & instance) :
|
wivrn::android::audio::audio(const wivrn::to_headset::audio_stream_description & desc, wivrn_session & session, xr::instance & instance) :
|
||||||
session(session), instance(instance)
|
session(session), instance(instance)
|
||||||
{
|
{
|
||||||
AAudioStreamBuilder * builder;
|
AAudioStreamBuilder * builder;
|
||||||
@@ -265,14 +265,14 @@ wivrn::android::audio::~audio()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wivrn::android::audio::operator()(xrt::drivers::wivrn::audio_data && data)
|
void wivrn::android::audio::operator()(wivrn::audio_data && data)
|
||||||
{
|
{
|
||||||
auto size = data.payload.size_bytes();
|
auto size = data.payload.size_bytes();
|
||||||
if (output_buffer.write(std::move(data)))
|
if (output_buffer.write(std::move(data)))
|
||||||
buffer_size_bytes.fetch_add(size);
|
buffer_size_bytes.fetch_add(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wivrn::android::audio::get_audio_description(xrt::drivers::wivrn::from_headset::headset_info_packet & info)
|
void wivrn::android::audio::get_audio_description(wivrn::from_headset::headset_info_packet & info)
|
||||||
{
|
{
|
||||||
AAudioStreamBuilder * builder;
|
AAudioStreamBuilder * builder;
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ class audio
|
|||||||
void build_microphone(AAudioStreamBuilderStruct *, int32_t, int32_t);
|
void build_microphone(AAudioStreamBuilderStruct *, int32_t, int32_t);
|
||||||
void build_speaker(AAudioStreamBuilderStruct *, int32_t, int32_t);
|
void build_speaker(AAudioStreamBuilderStruct *, int32_t, int32_t);
|
||||||
|
|
||||||
utils::ring_buffer<xrt::drivers::wivrn::audio_data, 100> output_buffer;
|
utils::ring_buffer<wivrn::audio_data, 100> output_buffer;
|
||||||
std::atomic<size_t> buffer_size_bytes;
|
std::atomic<size_t> buffer_size_bytes;
|
||||||
|
|
||||||
xrt::drivers::wivrn::audio_data speaker_tmp;
|
wivrn::audio_data speaker_tmp;
|
||||||
AAudioStreamStruct * speaker = nullptr;
|
AAudioStreamStruct * speaker = nullptr;
|
||||||
std::atomic<bool> speaker_stop_ack = false;
|
std::atomic<bool> speaker_stop_ack = false;
|
||||||
AAudioStreamStruct * microphone = nullptr;
|
AAudioStreamStruct * microphone = nullptr;
|
||||||
@@ -67,11 +67,11 @@ class audio
|
|||||||
public:
|
public:
|
||||||
audio(const audio &) = delete;
|
audio(const audio &) = delete;
|
||||||
audio & operator=(const audio &) = delete;
|
audio & operator=(const audio &) = delete;
|
||||||
audio(const xrt::drivers::wivrn::to_headset::audio_stream_description &, wivrn_session &, xr::instance &);
|
audio(const wivrn::to_headset::audio_stream_description &, wivrn_session &, xr::instance &);
|
||||||
~audio();
|
~audio();
|
||||||
|
|
||||||
void operator()(xrt::drivers::wivrn::audio_data &&);
|
void operator()(wivrn::audio_data &&);
|
||||||
|
|
||||||
static void get_audio_description(xrt::drivers::wivrn::from_headset::headset_info_packet & info);
|
static void get_audio_description(wivrn::from_headset::headset_info_packet & info);
|
||||||
};
|
};
|
||||||
} // namespace wivrn::android
|
} // namespace wivrn::android
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ class audio
|
|||||||
public:
|
public:
|
||||||
audio(const audio &) = delete;
|
audio(const audio &) = delete;
|
||||||
audio & operator=(const audio &) = delete;
|
audio & operator=(const audio &) = delete;
|
||||||
audio(const xrt::drivers::wivrn::to_headset::audio_stream_description &, wivrn_session &, xr::instance &) {}
|
audio(const wivrn::to_headset::audio_stream_description &, wivrn_session &, xr::instance &) {}
|
||||||
~audio() = default;
|
~audio() = default;
|
||||||
|
|
||||||
void operator()(xrt::drivers::wivrn::audio_data &&) {}
|
void operator()(wivrn::audio_data &&) {}
|
||||||
|
|
||||||
static void get_audio_description(xrt::drivers::wivrn::from_headset::headset_info_packet & info) {}
|
static void get_audio_description(wivrn::from_headset::headset_info_packet & info) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ struct wivrn::android::decoder::mapped_hardware_buffer
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const char * mime(xrt::drivers::wivrn::video_codec codec)
|
const char * mime(wivrn::video_codec codec)
|
||||||
{
|
{
|
||||||
using c = xrt::drivers::wivrn::video_codec;
|
using c = wivrn::video_codec;
|
||||||
switch (codec)
|
switch (codec)
|
||||||
{
|
{
|
||||||
case c::h264:
|
case c::h264:
|
||||||
@@ -80,7 +80,7 @@ namespace wivrn::android
|
|||||||
decoder::decoder(
|
decoder::decoder(
|
||||||
vk::raii::Device & device,
|
vk::raii::Device & device,
|
||||||
vk::raii::PhysicalDevice & physical_device,
|
vk::raii::PhysicalDevice & physical_device,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
const wivrn::to_headset::video_stream_description::item & description,
|
||||||
float fps,
|
float fps,
|
||||||
uint8_t stream_index,
|
uint8_t stream_index,
|
||||||
std::weak_ptr<scenes::stream> weak_scene,
|
std::weak_ptr<scenes::stream> weak_scene,
|
||||||
@@ -219,7 +219,7 @@ void decoder::push_data(std::span<std::span<const uint8_t>> data, uint64_t frame
|
|||||||
current_input_buffer = input_buffer{};
|
current_input_buffer = input_buffer{};
|
||||||
}
|
}
|
||||||
|
|
||||||
void decoder::frame_completed(xrt::drivers::wivrn::from_headset::feedback & feedback, const xrt::drivers::wivrn::to_headset::video_stream_data_shard::timing_info_t & timing_info, const xrt::drivers::wivrn::to_headset::video_stream_data_shard::view_info_t & view_info)
|
void decoder::frame_completed(wivrn::from_headset::feedback & feedback, const wivrn::to_headset::video_stream_data_shard::timing_info_t & timing_info, const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info)
|
||||||
{
|
{
|
||||||
if (not media_codec)
|
if (not media_codec)
|
||||||
{
|
{
|
||||||
@@ -532,11 +532,11 @@ static bool hardware_accelerated(AMediaCodec * media_codec)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<xrt::drivers::wivrn::video_codec> decoder::supported_codecs()
|
std::vector<wivrn::video_codec> decoder::supported_codecs()
|
||||||
{
|
{
|
||||||
std::vector<xrt::drivers::wivrn::video_codec> result;
|
std::vector<wivrn::video_codec> result;
|
||||||
|
|
||||||
for (auto codec: std::ranges::reverse_view(magic_enum::enum_values<xrt::drivers::wivrn::video_codec>()))
|
for (auto codec: std::ranges::reverse_view(magic_enum::enum_values<wivrn::video_codec>()))
|
||||||
{
|
{
|
||||||
AMediaCodec_ptr media_codec(AMediaCodec_createDecoderByType(mime(codec)));
|
AMediaCodec_ptr media_codec(AMediaCodec_createDecoderByType(mime(codec)));
|
||||||
|
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ public:
|
|||||||
{
|
{
|
||||||
void operator()(AImage *);
|
void operator()(AImage *);
|
||||||
};
|
};
|
||||||
xrt::drivers::wivrn::from_headset::feedback feedback;
|
wivrn::from_headset::feedback feedback;
|
||||||
xrt::drivers::wivrn::to_headset::video_stream_data_shard::timing_info_t timing_info;
|
wivrn::to_headset::video_stream_data_shard::timing_info_t timing_info;
|
||||||
xrt::drivers::wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
|
wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
|
||||||
vk::raii::ImageView & image_view;
|
vk::raii::ImageView & image_view;
|
||||||
vk::Image image = nullptr;
|
vk::Image image = nullptr;
|
||||||
vk::ImageLayout * current_layout = nullptr;
|
vk::ImageLayout * current_layout = nullptr;
|
||||||
@@ -80,7 +80,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
xrt::drivers::wivrn::to_headset::video_stream_description::item description;
|
wivrn::to_headset::video_stream_description::item description;
|
||||||
float fps;
|
float fps;
|
||||||
|
|
||||||
vk::raii::Device & device;
|
vk::raii::Device & device;
|
||||||
@@ -117,9 +117,9 @@ private:
|
|||||||
|
|
||||||
struct frame_info
|
struct frame_info
|
||||||
{
|
{
|
||||||
xrt::drivers::wivrn::from_headset::feedback feedback;
|
wivrn::from_headset::feedback feedback;
|
||||||
xrt::drivers::wivrn::to_headset::video_stream_data_shard::timing_info_t timing_info;
|
wivrn::to_headset::video_stream_data_shard::timing_info_t timing_info;
|
||||||
xrt::drivers::wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
|
wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
|
||||||
};
|
};
|
||||||
utils::sync_queue<frame_info> frame_infos;
|
utils::sync_queue<frame_info> frame_infos;
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
decoder(vk::raii::Device & device,
|
decoder(vk::raii::Device & device,
|
||||||
vk::raii::PhysicalDevice & physical_device,
|
vk::raii::PhysicalDevice & physical_device,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
const wivrn::to_headset::video_stream_description::item & description,
|
||||||
float fps,
|
float fps,
|
||||||
uint8_t stream_index,
|
uint8_t stream_index,
|
||||||
std::weak_ptr<scenes::stream> scene,
|
std::weak_ptr<scenes::stream> scene,
|
||||||
@@ -151,9 +151,9 @@ public:
|
|||||||
void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial);
|
void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial);
|
||||||
|
|
||||||
void frame_completed(
|
void frame_completed(
|
||||||
xrt::drivers::wivrn::from_headset::feedback & feedback,
|
wivrn::from_headset::feedback & feedback,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_data_shard::timing_info_t & timing_info,
|
const wivrn::to_headset::video_stream_data_shard::timing_info_t & timing_info,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_data_shard::view_info_t & view_info);
|
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info);
|
||||||
|
|
||||||
const auto & desc() const
|
const auto & desc() const
|
||||||
{
|
{
|
||||||
@@ -170,7 +170,7 @@ public:
|
|||||||
return extent;
|
return extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<xrt::drivers::wivrn::video_codec> supported_codecs();
|
static std::vector<wivrn::video_codec> supported_codecs();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace wivrn::android
|
} // namespace wivrn::android
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ static void free_frame(AVFrame * frame)
|
|||||||
av_frame_free(&frame);
|
av_frame_free(&frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
static AVCodecID codec_id(xrt::drivers::wivrn::video_codec codec)
|
static AVCodecID codec_id(wivrn::video_codec codec)
|
||||||
{
|
{
|
||||||
using c = xrt::drivers::wivrn::video_codec;
|
using c = wivrn::video_codec;
|
||||||
switch (codec)
|
switch (codec)
|
||||||
{
|
{
|
||||||
case c::h264:
|
case c::h264:
|
||||||
@@ -73,7 +73,7 @@ decoder::blit_handle::~blit_handle()
|
|||||||
decoder::decoder(
|
decoder::decoder(
|
||||||
vk::raii::Device & device,
|
vk::raii::Device & device,
|
||||||
vk::raii::PhysicalDevice & physical_device,
|
vk::raii::PhysicalDevice & physical_device,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
const wivrn::to_headset::video_stream_description::item & description,
|
||||||
float fps,
|
float fps,
|
||||||
uint8_t stream_index,
|
uint8_t stream_index,
|
||||||
std::weak_ptr<scenes::stream> scene,
|
std::weak_ptr<scenes::stream> scene,
|
||||||
@@ -166,7 +166,7 @@ void decoder::push_data(std::span<std::span<const uint8_t>> data, uint64_t frame
|
|||||||
this->frame_index = frame_index;
|
this->frame_index = frame_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void decoder::frame_completed(const xrt::drivers::wivrn::from_headset::feedback & feedback, const xrt::drivers::wivrn::to_headset::video_stream_data_shard::timing_info_t & timing_info, const xrt::drivers::wivrn::to_headset::video_stream_data_shard::view_info_t & view_info)
|
void decoder::frame_completed(const wivrn::from_headset::feedback & feedback, const wivrn::to_headset::video_stream_data_shard::timing_info_t & timing_info, const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info)
|
||||||
{
|
{
|
||||||
spdlog::trace("ffmpeg decoder:frame_completed {}", frame_index);
|
spdlog::trace("ffmpeg decoder:frame_completed {}", frame_index);
|
||||||
AVPacket packet{};
|
AVPacket packet{};
|
||||||
@@ -235,12 +235,12 @@ void decoder::frame_completed(const xrt::drivers::wivrn::from_headset::feedback
|
|||||||
scene->push_blit_handle(accumulator, std::move(handle));
|
scene->push_blit_handle(accumulator, std::move(handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<xrt::drivers::wivrn::video_codec> decoder::supported_codecs()
|
std::vector<wivrn::video_codec> decoder::supported_codecs()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
xrt::drivers::wivrn::video_codec::h264,
|
wivrn::video_codec::h264,
|
||||||
xrt::drivers::wivrn::video_codec::h265,
|
wivrn::video_codec::h265,
|
||||||
xrt::drivers::wivrn::video_codec::av1,
|
wivrn::video_codec::av1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ class decoder
|
|||||||
public:
|
public:
|
||||||
struct blit_handle
|
struct blit_handle
|
||||||
{
|
{
|
||||||
xrt::drivers::wivrn::from_headset::feedback feedback;
|
wivrn::from_headset::feedback feedback;
|
||||||
xrt::drivers::wivrn::to_headset::video_stream_data_shard::timing_info_t timing_info;
|
wivrn::to_headset::video_stream_data_shard::timing_info_t timing_info;
|
||||||
xrt::drivers::wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
|
wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
|
||||||
vk::raii::ImageView & image_view;
|
vk::raii::ImageView & image_view;
|
||||||
vk::Image image = nullptr;
|
vk::Image image = nullptr;
|
||||||
vk::ImageLayout * current_layout = nullptr;
|
vk::ImageLayout * current_layout = nullptr;
|
||||||
@@ -79,7 +79,7 @@ private:
|
|||||||
vk::Extent2D extent{};
|
vk::Extent2D extent{};
|
||||||
std::vector<int> free_images;
|
std::vector<int> free_images;
|
||||||
|
|
||||||
xrt::drivers::wivrn::to_headset::video_stream_description::item description;
|
wivrn::to_headset::video_stream_description::item description;
|
||||||
|
|
||||||
std::unique_ptr<AVCodecContext, void (*)(AVCodecContext *)> codec;
|
std::unique_ptr<AVCodecContext, void (*)(AVCodecContext *)> codec;
|
||||||
std::unique_ptr<SwsContext, void (*)(SwsContext *)> sws;
|
std::unique_ptr<SwsContext, void (*)(SwsContext *)> sws;
|
||||||
@@ -93,7 +93,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
decoder(vk::raii::Device & device,
|
decoder(vk::raii::Device & device,
|
||||||
vk::raii::PhysicalDevice & physical_device,
|
vk::raii::PhysicalDevice & physical_device,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
const wivrn::to_headset::video_stream_description::item & description,
|
||||||
float fps,
|
float fps,
|
||||||
uint8_t stream_index,
|
uint8_t stream_index,
|
||||||
std::weak_ptr<scenes::stream> scene,
|
std::weak_ptr<scenes::stream> scene,
|
||||||
@@ -105,9 +105,9 @@ public:
|
|||||||
void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial);
|
void push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial);
|
||||||
|
|
||||||
void frame_completed(
|
void frame_completed(
|
||||||
const xrt::drivers::wivrn::from_headset::feedback & feedback,
|
const wivrn::from_headset::feedback & feedback,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_data_shard::timing_info_t & timing_info,
|
const wivrn::to_headset::video_stream_data_shard::timing_info_t & timing_info,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_data_shard::view_info_t & view_info);
|
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info);
|
||||||
|
|
||||||
const auto & desc() const
|
const auto & desc() const
|
||||||
{
|
{
|
||||||
@@ -124,6 +124,6 @@ public:
|
|||||||
return extent;
|
return extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<xrt::drivers::wivrn::video_codec> supported_codecs();
|
static std::vector<wivrn::video_codec> supported_codecs();
|
||||||
};
|
};
|
||||||
} // namespace ffmpeg
|
} // namespace ffmpeg
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "scenes/stream.h"
|
#include "scenes/stream.h"
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn::to_headset;
|
using namespace wivrn::to_headset;
|
||||||
using shard_set = shard_accumulator::shard_set;
|
using shard_set = shard_accumulator::shard_set;
|
||||||
using data_shard = shard_accumulator::data_shard;
|
using data_shard = shard_accumulator::data_shard;
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ void shard_accumulator::try_submit_frame(uint16_t shard_idx)
|
|||||||
advance();
|
advance();
|
||||||
}
|
}
|
||||||
|
|
||||||
void shard_accumulator::send_feedback(xrt::drivers::wivrn::from_headset::feedback & feedback)
|
void shard_accumulator::send_feedback(wivrn::from_headset::feedback & feedback)
|
||||||
{
|
{
|
||||||
if (not feedback.received_last_packet)
|
if (not feedback.received_last_packet)
|
||||||
feedback.received_first_packet = application::now();
|
feedback.received_first_packet = application::now();
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class shard_accumulator
|
|||||||
std::shared_ptr<decoder_impl> decoder;
|
std::shared_ptr<decoder_impl> decoder;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using data_shard = xrt::drivers::wivrn::to_headset::video_stream_data_shard;
|
using data_shard = wivrn::to_headset::video_stream_data_shard;
|
||||||
struct shard_set
|
struct shard_set
|
||||||
{
|
{
|
||||||
size_t min_for_reconstruction = -1;
|
size_t min_for_reconstruction = -1;
|
||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
|
|
||||||
std::optional<uint16_t> insert(data_shard &&);
|
std::optional<uint16_t> insert(data_shard &&);
|
||||||
|
|
||||||
xrt::drivers::wivrn::from_headset::feedback feedback{};
|
wivrn::from_headset::feedback feedback{};
|
||||||
|
|
||||||
explicit shard_set(uint8_t stream_index);
|
explicit shard_set(uint8_t stream_index);
|
||||||
shard_set(const shard_set &) = default;
|
shard_set(const shard_set &) = default;
|
||||||
@@ -72,7 +72,7 @@ public:
|
|||||||
explicit shard_accumulator(
|
explicit shard_accumulator(
|
||||||
vk::raii::Device & device,
|
vk::raii::Device & device,
|
||||||
vk::raii::PhysicalDevice & physical_device,
|
vk::raii::PhysicalDevice & physical_device,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
const wivrn::to_headset::video_stream_description::item & description,
|
||||||
float fps,
|
float fps,
|
||||||
std::weak_ptr<scenes::stream> scene,
|
std::weak_ptr<scenes::stream> scene,
|
||||||
uint8_t stream_index) :
|
uint8_t stream_index) :
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
next.reset(1);
|
next.reset(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_shard(xrt::drivers::wivrn::to_headset::video_stream_data_shard &&);
|
void push_shard(wivrn::to_headset::video_stream_data_shard &&);
|
||||||
|
|
||||||
auto & desc() const
|
auto & desc() const
|
||||||
{
|
{
|
||||||
@@ -106,6 +106,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void try_submit_frame(std::optional<uint16_t> shard_idx);
|
void try_submit_frame(std::optional<uint16_t> shard_idx);
|
||||||
void try_submit_frame(uint16_t shard_idx);
|
void try_submit_frame(uint16_t shard_idx);
|
||||||
void send_feedback(xrt::drivers::wivrn::from_headset::feedback & feedback);
|
void send_feedback(wivrn::from_headset::feedback & feedback);
|
||||||
void advance();
|
void advance();
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ void real_main()
|
|||||||
if (not server_address.empty())
|
if (not server_address.empty())
|
||||||
{
|
{
|
||||||
auto colon = server_address.rfind(":");
|
auto colon = server_address.rfind(":");
|
||||||
int port = xrt::drivers::wivrn::default_port;
|
int port = wivrn::default_port;
|
||||||
if (colon != std::string::npos)
|
if (colon != std::string::npos)
|
||||||
{
|
{
|
||||||
port = std::stoi(server_address.substr(colon + 1));
|
port = std::stoi(server_address.substr(colon + 1));
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ std::unique_ptr<wivrn_session> connect_to_session(wivrn_discover::service servic
|
|||||||
if (!manual_connection)
|
if (!manual_connection)
|
||||||
{
|
{
|
||||||
char protocol_string[17];
|
char protocol_string[17];
|
||||||
sprintf(protocol_string, "%016lx", xrt::drivers::wivrn::protocol_version);
|
sprintf(protocol_string, "%016lx", wivrn::protocol_version);
|
||||||
|
|
||||||
spdlog::debug("Client protocol version: {}", protocol_string);
|
spdlog::debug("Client protocol version: {}", protocol_string);
|
||||||
spdlog::debug("Server TXT:");
|
spdlog::debug("Server TXT:");
|
||||||
@@ -290,7 +290,7 @@ void scenes::lobby::update_server_list()
|
|||||||
}
|
}
|
||||||
|
|
||||||
char protocol_string[17];
|
char protocol_string[17];
|
||||||
sprintf(protocol_string, "%016lx", xrt::drivers::wivrn::protocol_version);
|
sprintf(protocol_string, "%016lx", wivrn::protocol_version);
|
||||||
|
|
||||||
for (auto & service: discovered_services)
|
for (auto & service: discovered_services)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ void scenes::lobby::gui_settings()
|
|||||||
void scenes::lobby::gui_about()
|
void scenes::lobby::gui_about()
|
||||||
{
|
{
|
||||||
ImGui::PushFont(imgui_ctx->large_font);
|
ImGui::PushFont(imgui_ctx->large_font);
|
||||||
CenterTextH(std::string("WiVRn ") + xrt::drivers::wivrn::git_version);
|
CenterTextH(std::string("WiVRn ") + wivrn::git_version);
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
ImGui::Dummy(ImVec2(0, 60));
|
ImGui::Dummy(ImVec2(0, 60));
|
||||||
@@ -611,7 +611,7 @@ static void ScrollWhenDraggingOnVoid(ImVec2 delta)
|
|||||||
|
|
||||||
static auto face_weights()
|
static auto face_weights()
|
||||||
{
|
{
|
||||||
using weights = decltype(xrt::drivers::wivrn::from_headset::tracking::fb_face2{}.weights);
|
using weights = decltype(wivrn::from_headset::tracking::fb_face2{}.weights);
|
||||||
using item = std::pair<const char *, std::array<float, XR_FACE_EXPRESSION2_COUNT_FB>>;
|
using item = std::pair<const char *, std::array<float, XR_FACE_EXPRESSION2_COUNT_FB>>;
|
||||||
std::vector<item> res;
|
std::vector<item> res;
|
||||||
|
|
||||||
@@ -794,7 +794,7 @@ static auto face_weights()
|
|||||||
static const char * get_face_icon(XrTime predicted_display_time)
|
static const char * get_face_icon(XrTime predicted_display_time)
|
||||||
{
|
{
|
||||||
static const auto w = face_weights();
|
static const auto w = face_weights();
|
||||||
xrt::drivers::wivrn::from_headset::tracking::fb_face2 expression;
|
wivrn::from_headset::tracking::fb_face2 expression;
|
||||||
application::get_fb_face_tracker2().get_weights(predicted_display_time, expression);
|
application::get_fb_face_tracker2().get_weights(predicted_display_time, expression);
|
||||||
|
|
||||||
if (not expression.is_valid)
|
if (not expression.is_valid)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vulkan/vulkan_raii.hpp>
|
#include <vulkan/vulkan_raii.hpp>
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn;
|
using namespace wivrn;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const std::unordered_map<std::string, device_id> device_ids = {
|
static const std::unordered_map<std::string, device_id> device_ids = {
|
||||||
@@ -568,7 +568,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
|||||||
|
|
||||||
std::array<XrPosef, 2> pose{};
|
std::array<XrPosef, 2> pose{};
|
||||||
std::array<XrFovf, 2> fov{};
|
std::array<XrFovf, 2> fov{};
|
||||||
std::array<xrt::drivers::wivrn::to_headset::foveation_parameter, 2> foveation{};
|
std::array<wivrn::to_headset::foveation_parameter, 2> foveation{};
|
||||||
{
|
{
|
||||||
// Search for frame with desired display time on all decoders
|
// Search for frame with desired display time on all decoders
|
||||||
// If no such frame exists, use the latest frame for each decoder
|
// If no such frame exists, use the latest frame for each decoder
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
static const size_t view_count = 2;
|
static const size_t view_count = 2;
|
||||||
|
|
||||||
using stream_description = xrt::drivers::wivrn::to_headset::video_stream_description::item;
|
using stream_description = wivrn::to_headset::video_stream_description::item;
|
||||||
|
|
||||||
struct accumulator_images
|
struct accumulator_images
|
||||||
{
|
{
|
||||||
@@ -149,7 +149,7 @@ public:
|
|||||||
|
|
||||||
void push_blit_handle(shard_accumulator * decoder, std::shared_ptr<shard_accumulator::blit_handle> handle);
|
void push_blit_handle(shard_accumulator * decoder, std::shared_ptr<shard_accumulator::blit_handle> handle);
|
||||||
|
|
||||||
void send_feedback(const xrt::drivers::wivrn::from_headset::feedback & feedback);
|
void send_feedback(const wivrn::from_headset::feedback & feedback);
|
||||||
|
|
||||||
state current_state() const
|
state current_state() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ void scenes::stream::operator()(audio_data && data)
|
|||||||
(*audio_handle)(std::move(data));
|
(*audio_handle)(std::move(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void scenes::stream::send_feedback(const xrt::drivers::wivrn::from_headset::feedback & feedback)
|
void scenes::stream::send_feedback(const wivrn::from_headset::feedback & feedback)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ stream_reprojection::stream_reprojection(
|
|||||||
std::vector<vk::Image> output_images_,
|
std::vector<vk::Image> output_images_,
|
||||||
vk::Extent2D extent,
|
vk::Extent2D extent,
|
||||||
vk::Format format,
|
vk::Format format,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_description & description) :
|
const wivrn::to_headset::video_stream_description & description) :
|
||||||
input_images(std::move(input_images_)),
|
input_images(std::move(input_images_)),
|
||||||
output_images(std::move(output_images_)),
|
output_images(std::move(output_images_)),
|
||||||
extent(extent)
|
extent(extent)
|
||||||
@@ -434,7 +434,7 @@ void stream_reprojection::reproject(vk::raii::CommandBuffer & command_buffer, in
|
|||||||
command_buffer.endRenderPass();
|
command_buffer.endRenderPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void stream_reprojection::set_foveation(std::array<xrt::drivers::wivrn::to_headset::foveation_parameter, 2> foveation)
|
void stream_reprojection::set_foveation(std::array<wivrn::to_headset::foveation_parameter, 2> foveation)
|
||||||
{
|
{
|
||||||
foveation_parameters = foveation;
|
foveation_parameters = foveation;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class stream_reprojection
|
|||||||
vk::Extent2D extent;
|
vk::Extent2D extent;
|
||||||
|
|
||||||
// Foveation
|
// Foveation
|
||||||
std::array<xrt::drivers::wivrn::to_headset::foveation_parameter, 2> foveation_parameters;
|
std::array<wivrn::to_headset::foveation_parameter, 2> foveation_parameters;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
stream_reprojection(
|
stream_reprojection(
|
||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
std::vector<vk::Image> output_images,
|
std::vector<vk::Image> output_images,
|
||||||
vk::Extent2D extent,
|
vk::Extent2D extent,
|
||||||
vk::Format format,
|
vk::Format format,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_description & description);
|
const wivrn::to_headset::video_stream_description & description);
|
||||||
|
|
||||||
stream_reprojection(const stream_reprojection &) = delete;
|
stream_reprojection(const stream_reprojection &) = delete;
|
||||||
|
|
||||||
@@ -71,5 +71,5 @@ public:
|
|||||||
int source,
|
int source,
|
||||||
int destination);
|
int destination);
|
||||||
|
|
||||||
void set_foveation(std::array<xrt::drivers::wivrn::to_headset::foveation_parameter, 2> foveation);
|
void set_foveation(std::array<wivrn::to_headset::foveation_parameter, 2> foveation);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ void scenes::stream::tracking()
|
|||||||
|
|
||||||
packet.state_flags = 0;
|
packet.state_flags = 0;
|
||||||
if (local_dirty.exchange(false))
|
if (local_dirty.exchange(false))
|
||||||
packet.state_flags = xrt::drivers::wivrn::from_headset::tracking::recentered;
|
packet.state_flags = wivrn::from_headset::tracking::recentered;
|
||||||
|
|
||||||
packet.device_poses.clear();
|
packet.device_poses.clear();
|
||||||
for (auto [device, space]: spaces)
|
for (auto [device, space]: spaces)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "wivrn_sockets.h"
|
#include "wivrn_sockets.h"
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn;
|
using namespace wivrn;
|
||||||
|
|
||||||
class wivrn_session
|
class wivrn_session
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ xr::fb_face_tracker2::fb_face_tracker2(instance & inst, XrFaceTracker2FB h)
|
|||||||
xrDestroyFaceTracker2FB = inst.get_proc<PFN_xrDestroyFaceTracker2FB>("xrDestroyFaceTracker2FB");
|
xrDestroyFaceTracker2FB = inst.get_proc<PFN_xrDestroyFaceTracker2FB>("xrDestroyFaceTracker2FB");
|
||||||
}
|
}
|
||||||
|
|
||||||
void xr::fb_face_tracker2::get_weights(XrTime time, xrt::drivers::wivrn::from_headset::tracking::fb_face2 & out_expressions)
|
void xr::fb_face_tracker2::get_weights(XrTime time, wivrn::from_headset::tracking::fb_face2 & out_expressions)
|
||||||
{
|
{
|
||||||
if (!id || !xrGetFaceExpressionWeights2FB)
|
if (!id || !xrGetFaceExpressionWeights2FB)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -37,6 +37,6 @@ public:
|
|||||||
fb_face_tracker2() = default;
|
fb_face_tracker2() = default;
|
||||||
fb_face_tracker2(instance & inst, XrFaceTracker2FB h);
|
fb_face_tracker2(instance & inst, XrFaceTracker2FB h);
|
||||||
|
|
||||||
void get_weights(XrTime time, struct xrt::drivers::wivrn::from_headset::tracking::fb_face2 & out_expressions);
|
void get_weights(XrTime time, struct wivrn::from_headset::tracking::fb_face2 & out_expressions);
|
||||||
};
|
};
|
||||||
} // namespace xr
|
} // namespace xr
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
extern const char git_version[];
|
extern const char git_version[];
|
||||||
const char git_version[] = "@GIT_DESC@";
|
const char git_version[] = "@GIT_DESC@";
|
||||||
|
|||||||
+2
-2
@@ -3,10 +3,10 @@
|
|||||||
#include "wivrn_packets.h"
|
#include "wivrn_packets.h"
|
||||||
#include "wivrn_serialization.h"
|
#include "wivrn_serialization.h"
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
using protocol = std::variant<from_headset::packets, to_headset::packets>;
|
using protocol = std::variant<from_headset::packets, to_headset::packets>;
|
||||||
|
|
||||||
extern const char git_version[];
|
extern const char git_version[];
|
||||||
static inline const constinit auto protocol_version = serialization_type_hash<protocol>();
|
static inline const constinit auto protocol_version = serialization_type_hash<protocol>();
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "wivrn_serialization_types.h"
|
#include "wivrn_serialization_types.h"
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
// Default port for server to listen, both TCP and UDP
|
// Default port for server to listen, both TCP and UDP
|
||||||
@@ -390,4 +390,4 @@ using packets = std::variant<handshake, audio_stream_description, video_stream_d
|
|||||||
|
|
||||||
} // namespace to_headset
|
} // namespace to_headset
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include "wivrn_serialization_types.h"
|
#include "wivrn_serialization_types.h"
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace details
|
namespace details
|
||||||
@@ -889,4 +889,4 @@ constexpr uint64_t serialization_type_hash()
|
|||||||
return h.hash;
|
return h.hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
// Intended to be the last element of a serializable type
|
// Intended to be the last element of a serializable type
|
||||||
@@ -37,4 +37,4 @@ struct data_holder
|
|||||||
std::shared_ptr<uint8_t[]> c;
|
std::shared_ptr<uint8_t[]> c;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "wivrn_serialization.h"
|
#include "wivrn_serialization.h"
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn;
|
using namespace wivrn;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|||||||
+31
-31
@@ -32,35 +32,35 @@
|
|||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
const char * xrt::drivers::wivrn::invalid_packet::what() const noexcept
|
const char * wivrn::invalid_packet::what() const noexcept
|
||||||
{
|
{
|
||||||
return "Invalid packet";
|
return "Invalid packet";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * xrt::drivers::wivrn::socket_shutdown::what() const noexcept
|
const char * wivrn::socket_shutdown::what() const noexcept
|
||||||
{
|
{
|
||||||
return "Socket shutdown";
|
return "Socket shutdown";
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::fd_base::fd_base(xrt::drivers::wivrn::fd_base && other) :
|
wivrn::fd_base::fd_base(wivrn::fd_base && other) :
|
||||||
fd(other.fd)
|
fd(other.fd)
|
||||||
{
|
{
|
||||||
other.fd = -1;
|
other.fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::fd_base & xrt::drivers::wivrn::fd_base::operator=(xrt::drivers::wivrn::fd_base && other)
|
wivrn::fd_base & wivrn::fd_base::operator=(wivrn::fd_base && other)
|
||||||
{
|
{
|
||||||
std::swap(fd, other.fd);
|
std::swap(fd, other.fd);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::fd_base::~fd_base()
|
wivrn::fd_base::~fd_base()
|
||||||
{
|
{
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
::close(fd);
|
::close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::UDP::UDP()
|
wivrn::UDP::UDP()
|
||||||
{
|
{
|
||||||
fd = socket(AF_INET6, SOCK_DGRAM, 0);
|
fd = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||||
|
|
||||||
@@ -68,12 +68,12 @@ xrt::drivers::wivrn::UDP::UDP()
|
|||||||
throw std::system_error{errno, std::generic_category()};
|
throw std::system_error{errno, std::generic_category()};
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::UDP::UDP(int fd)
|
wivrn::UDP::UDP(int fd)
|
||||||
{
|
{
|
||||||
this->fd = fd;
|
this->fd = fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::bind(int port)
|
void wivrn::UDP::bind(int port)
|
||||||
{
|
{
|
||||||
sockaddr_in6 bind_addr{};
|
sockaddr_in6 bind_addr{};
|
||||||
bind_addr.sin6_family = AF_INET6;
|
bind_addr.sin6_family = AF_INET6;
|
||||||
@@ -84,7 +84,7 @@ void xrt::drivers::wivrn::UDP::bind(int port)
|
|||||||
throw std::system_error{errno, std::generic_category()};
|
throw std::system_error{errno, std::generic_category()};
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::connect(in6_addr address, int port)
|
void wivrn::UDP::connect(in6_addr address, int port)
|
||||||
{
|
{
|
||||||
sockaddr_in6 sa;
|
sockaddr_in6 sa;
|
||||||
sa.sin6_family = AF_INET6;
|
sa.sin6_family = AF_INET6;
|
||||||
@@ -95,7 +95,7 @@ void xrt::drivers::wivrn::UDP::connect(in6_addr address, int port)
|
|||||||
throw std::system_error{errno, std::generic_category()};
|
throw std::system_error{errno, std::generic_category()};
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::connect(in_addr address, int port)
|
void wivrn::UDP::connect(in_addr address, int port)
|
||||||
{
|
{
|
||||||
sockaddr_in sa;
|
sockaddr_in sa;
|
||||||
sa.sin_family = AF_INET;
|
sa.sin_family = AF_INET;
|
||||||
@@ -106,7 +106,7 @@ void xrt::drivers::wivrn::UDP::connect(in_addr address, int port)
|
|||||||
throw std::system_error{errno, std::generic_category()};
|
throw std::system_error{errno, std::generic_category()};
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::subscribe_multicast(in6_addr address)
|
void wivrn::UDP::subscribe_multicast(in6_addr address)
|
||||||
{
|
{
|
||||||
assert(IN6_IS_ADDR_MULTICAST(&address));
|
assert(IN6_IS_ADDR_MULTICAST(&address));
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ void xrt::drivers::wivrn::UDP::subscribe_multicast(in6_addr address)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::unsubscribe_multicast(in6_addr address)
|
void wivrn::UDP::unsubscribe_multicast(in6_addr address)
|
||||||
{
|
{
|
||||||
assert(IN6_IS_ADDR_MULTICAST(&address));
|
assert(IN6_IS_ADDR_MULTICAST(&address));
|
||||||
|
|
||||||
@@ -134,17 +134,17 @@ void xrt::drivers::wivrn::UDP::unsubscribe_multicast(in6_addr address)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::set_receive_buffer_size(int size)
|
void wivrn::UDP::set_receive_buffer_size(int size)
|
||||||
{
|
{
|
||||||
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
|
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::set_send_buffer_size(int size)
|
void wivrn::UDP::set_send_buffer_size(int size)
|
||||||
{
|
{
|
||||||
setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
|
setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::set_tos(int tos)
|
void wivrn::UDP::set_tos(int tos)
|
||||||
{
|
{
|
||||||
int err = setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
|
int err = setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
|
||||||
if (err == -1)
|
if (err == -1)
|
||||||
@@ -153,7 +153,7 @@ void xrt::drivers::wivrn::UDP::set_tos(int tos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::TCP::init()
|
void wivrn::TCP::init()
|
||||||
{
|
{
|
||||||
int nodelay = 1;
|
int nodelay = 1;
|
||||||
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay)) < 0)
|
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay)) < 0)
|
||||||
@@ -165,14 +165,14 @@ void xrt::drivers::wivrn::TCP::init()
|
|||||||
mutex = std::make_unique<std::mutex>();
|
mutex = std::make_unique<std::mutex>();
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::TCP::TCP(int fd)
|
wivrn::TCP::TCP(int fd)
|
||||||
{
|
{
|
||||||
this->fd = fd;
|
this->fd = fd;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::TCP::TCP(in6_addr address, int port)
|
wivrn::TCP::TCP(in6_addr address, int port)
|
||||||
{
|
{
|
||||||
fd = socket(AF_INET6, SOCK_STREAM, 0);
|
fd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ xrt::drivers::wivrn::TCP::TCP(in6_addr address, int port)
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::TCP::TCP(in_addr address, int port)
|
wivrn::TCP::TCP(in_addr address, int port)
|
||||||
{
|
{
|
||||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
|
||||||
@@ -214,11 +214,11 @@ xrt::drivers::wivrn::TCP::TCP(in_addr address, int port)
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::TCPListener::TCPListener()
|
wivrn::TCPListener::TCPListener()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::TCPListener::TCPListener(int port)
|
wivrn::TCPListener::TCPListener(int port)
|
||||||
{
|
{
|
||||||
fd = socket(AF_INET6, SOCK_STREAM, 0);
|
fd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ xrt::drivers::wivrn::TCPListener::TCPListener(int port)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<xrt::drivers::wivrn::deserialization_packet, sockaddr_in6> xrt::drivers::wivrn::UDP::receive_from_raw()
|
std::pair<wivrn::deserialization_packet, sockaddr_in6> wivrn::UDP::receive_from_raw()
|
||||||
{
|
{
|
||||||
sockaddr_in6 addr;
|
sockaddr_in6 addr;
|
||||||
socklen_t addrlen = sizeof(addr);
|
socklen_t addrlen = sizeof(addr);
|
||||||
@@ -275,7 +275,7 @@ std::pair<xrt::drivers::wivrn::deserialization_packet, sockaddr_in6> xrt::driver
|
|||||||
return {deserialization_packet{std::move(buffer), std::span(tmp, received)}, addr};
|
return {deserialization_packet{std::move(buffer), std::span(tmp, received)}, addr};
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::UDP::receive_pending()
|
wivrn::deserialization_packet wivrn::UDP::receive_pending()
|
||||||
{
|
{
|
||||||
if (messages.empty())
|
if (messages.empty())
|
||||||
return {};
|
return {};
|
||||||
@@ -285,7 +285,7 @@ xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::UDP::receive_pe
|
|||||||
return deserialization_packet{buffer, span};
|
return deserialization_packet{buffer, span};
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::UDP::receive_raw()
|
wivrn::deserialization_packet wivrn::UDP::receive_raw()
|
||||||
{
|
{
|
||||||
if (not messages.empty())
|
if (not messages.empty())
|
||||||
{
|
{
|
||||||
@@ -339,7 +339,7 @@ xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::UDP::receive_ra
|
|||||||
return deserialization_packet{buffer, std::span(buffer.get(), mmsgs[0].msg_len)};
|
return deserialization_packet{buffer, std::span(buffer.get(), mmsgs[0].msg_len)};
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::send_raw(const std::vector<uint8_t> & data)
|
void wivrn::UDP::send_raw(const std::vector<uint8_t> & data)
|
||||||
{
|
{
|
||||||
ssize_t sent = ::send(fd, data.data(), data.size(), 0);
|
ssize_t sent = ::send(fd, data.data(), data.size(), 0);
|
||||||
if (sent < 0)
|
if (sent < 0)
|
||||||
@@ -348,7 +348,7 @@ void xrt::drivers::wivrn::UDP::send_raw(const std::vector<uint8_t> & data)
|
|||||||
bytes_sent_ += sent;
|
bytes_sent_ += sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::send_raw(const std::vector<std::span<uint8_t>> & data)
|
void wivrn::UDP::send_raw(const std::vector<std::span<uint8_t>> & data)
|
||||||
{
|
{
|
||||||
thread_local std::vector<iovec> spans;
|
thread_local std::vector<iovec> spans;
|
||||||
spans.clear();
|
spans.clear();
|
||||||
@@ -359,7 +359,7 @@ void xrt::drivers::wivrn::UDP::send_raw(const std::vector<std::span<uint8_t>> &
|
|||||||
throw std::system_error{errno, std::generic_category()};
|
throw std::system_error{errno, std::generic_category()};
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::UDP::send_many_raw(std::span<const std::vector<std::span<uint8_t>> *> data)
|
void wivrn::UDP::send_many_raw(std::span<const std::vector<std::span<uint8_t>> *> data)
|
||||||
{
|
{
|
||||||
thread_local std::vector<iovec> iovecs;
|
thread_local std::vector<iovec> iovecs;
|
||||||
thread_local std::vector<mmsghdr> mmsgs;
|
thread_local std::vector<mmsghdr> mmsgs;
|
||||||
@@ -393,7 +393,7 @@ void xrt::drivers::wivrn::UDP::send_many_raw(std::span<const std::vector<std::sp
|
|||||||
throw std::system_error{errno, std::generic_category()};
|
throw std::system_error{errno, std::generic_category()};
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::TCP::receive_raw()
|
wivrn::deserialization_packet wivrn::TCP::receive_raw()
|
||||||
{
|
{
|
||||||
ssize_t expected_size;
|
ssize_t expected_size;
|
||||||
|
|
||||||
@@ -449,7 +449,7 @@ xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::TCP::receive_ra
|
|||||||
return deserialization_packet{buffer, span};
|
return deserialization_packet{buffer, span};
|
||||||
}
|
}
|
||||||
|
|
||||||
xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::TCP::receive_pending()
|
wivrn::deserialization_packet wivrn::TCP::receive_pending()
|
||||||
{
|
{
|
||||||
if (data.size_bytes() < sizeof(uint16_t))
|
if (data.size_bytes() < sizeof(uint16_t))
|
||||||
return {};
|
return {};
|
||||||
@@ -466,7 +466,7 @@ xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::TCP::receive_pe
|
|||||||
return deserialization_packet{buffer, span};
|
return deserialization_packet{buffer, span};
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::TCP::send_raw(const std::vector<std::span<uint8_t>> & spans)
|
void wivrn::TCP::send_raw(const std::vector<std::span<uint8_t>> & spans)
|
||||||
{
|
{
|
||||||
thread_local std::vector<iovec> iovecs;
|
thread_local std::vector<iovec> iovecs;
|
||||||
iovecs.clear();
|
iovecs.clear();
|
||||||
@@ -517,7 +517,7 @@ void xrt::drivers::wivrn::TCP::send_raw(const std::vector<std::span<uint8_t>> &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void xrt::drivers::wivrn::TCP::send_many_raw(std::span<const std::vector<std::span<uint8_t>> *> data)
|
void wivrn::TCP::send_many_raw(std::span<const std::vector<std::span<uint8_t>> *> data)
|
||||||
{
|
{
|
||||||
thread_local std::vector<iovec> iovecs;
|
thread_local std::vector<iovec> iovecs;
|
||||||
thread_local std::vector<uint16_t> sizes;
|
thread_local std::vector<uint16_t> sizes;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
class socket_shutdown : public std::exception
|
class socket_shutdown : public std::exception
|
||||||
{
|
{
|
||||||
@@ -109,7 +109,7 @@ public:
|
|||||||
|
|
||||||
deserialization_packet receive_raw();
|
deserialization_packet receive_raw();
|
||||||
deserialization_packet receive_pending();
|
deserialization_packet receive_pending();
|
||||||
std::pair<xrt::drivers::wivrn::deserialization_packet, sockaddr_in6> receive_from_raw();
|
std::pair<wivrn::deserialization_packet, sockaddr_in6> receive_from_raw();
|
||||||
void send_raw(const std::vector<uint8_t> & data);
|
void send_raw(const std::vector<uint8_t> & data);
|
||||||
void send_raw(const std::vector<std::span<uint8_t>> & data);
|
void send_raw(const std::vector<std::span<uint8_t>> & data);
|
||||||
void send_many_raw(std::span<const std::vector<std::span<uint8_t>> *> data);
|
void send_many_raw(std::span<const std::vector<std::span<uint8_t>> *> data);
|
||||||
@@ -242,4 +242,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
+2
-2
@@ -27,7 +27,7 @@
|
|||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
#include "wizard.h"
|
#include "wizard.h"
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
extern const char git_version[];
|
extern const char git_version[];
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
app.setApplicationName("wivrn-dashboard");
|
app.setApplicationName("wivrn-dashboard");
|
||||||
app.setOrganizationName("wivrn");
|
app.setOrganizationName("wivrn");
|
||||||
app.setApplicationVersion(xrt::drivers::wivrn::git_version);
|
app.setApplicationVersion(wivrn::git_version);
|
||||||
app.setDesktopFileName("io.github.wivrn.wivrn");
|
app.setDesktopFileName("io.github.wivrn.wivrn");
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ static void handle_event_from_main_loop(to_monado::disconnect)
|
|||||||
// Ignore disconnect request when no headset is connected
|
// 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{});
|
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]{
|
pollfd fds[3]{
|
||||||
{.fd = watch_fd, .events = POLLIN},
|
{.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)
|
if (fds[1].revents & POLLIN)
|
||||||
{
|
{
|
||||||
wivrn_ipc_socket_monado->send(from_monado::headsdet_connected{});
|
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)
|
if (fds[2].revents & POLLIN)
|
||||||
|
|||||||
@@ -23,4 +23,4 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <wivrn_sockets.h>
|
#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()>());
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/pipewire.h>
|
||||||
#include <spa/param/audio/format-utils.h>
|
#include <spa/param/audio/format-utils.h>
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn;
|
using namespace wivrn;
|
||||||
|
|
||||||
struct deleter
|
struct deleter
|
||||||
{
|
{
|
||||||
@@ -73,7 +73,7 @@ struct pipewire_device : public audio_device
|
|||||||
static void speaker_process(void * self_v);
|
static void speaker_process(void * self_v);
|
||||||
static void mic_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;
|
~pipewire_device() = default;
|
||||||
|
|
||||||
@@ -82,8 +82,8 @@ struct pipewire_device : public audio_device
|
|||||||
const std::string & source_description,
|
const std::string & source_description,
|
||||||
const std::string & sink_name,
|
const std::string & sink_name,
|
||||||
const std::string & sink_description,
|
const std::string & sink_description,
|
||||||
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
|
const wivrn::from_headset::headset_info_packet & info,
|
||||||
xrt::drivers::wivrn::wivrn_session & session) :
|
wivrn::wivrn_session & session) :
|
||||||
session(session)
|
session(session)
|
||||||
{
|
{
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
@@ -289,7 +289,7 @@ void pipewire_device::speaker_process(void * self_v)
|
|||||||
pw_stream_queue_buffer(self->speaker.get(), buffer);
|
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();
|
auto size = sample.payload.size_bytes();
|
||||||
if (mic_samples.write(std::move(sample)))
|
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 & source_description,
|
||||||
const std::string & sink_name,
|
const std::string & sink_name,
|
||||||
const std::string & sink_description,
|
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)
|
wivrn_session & session)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -25,5 +25,5 @@ std::shared_ptr<audio_device> create_pipewire_handle(
|
|||||||
const std::string & source_description,
|
const std::string & source_description,
|
||||||
const std::string & sink_name,
|
const std::string & sink_name,
|
||||||
const std::string & sink_description,
|
const std::string & sink_description,
|
||||||
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
|
const wivrn::from_headset::headset_info_packet & info,
|
||||||
xrt::drivers::wivrn::wivrn_session & session);
|
wivrn::wivrn_session & session);
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ public:
|
|||||||
|
|
||||||
struct pulse_device : public audio_device
|
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 mic_thread;
|
||||||
std::thread speaker_thread;
|
std::thread speaker_thread;
|
||||||
@@ -251,10 +251,10 @@ struct pulse_device : public audio_device
|
|||||||
|
|
||||||
utils::sync_queue<audio_data> mic_buffer;
|
utils::sync_queue<audio_data> mic_buffer;
|
||||||
|
|
||||||
xrt::drivers::wivrn::fd_base speaker_pipe;
|
wivrn::fd_base speaker_pipe;
|
||||||
xrt::drivers::wivrn::fd_base mic_pipe;
|
wivrn::fd_base mic_pipe;
|
||||||
|
|
||||||
xrt::drivers::wivrn::wivrn_session & session;
|
wivrn::wivrn_session & session;
|
||||||
|
|
||||||
~pulse_device()
|
~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;
|
return desc;
|
||||||
};
|
};
|
||||||
@@ -298,7 +298,7 @@ struct pulse_device : public audio_device
|
|||||||
// use buffers of up to 2ms
|
// use buffers of up to 2ms
|
||||||
// read buffers must be smaller than buffer size on client or we will discard chunks often
|
// 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;
|
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);
|
std::vector<uint8_t> buffer(buffer_size, 0);
|
||||||
size_t remainder = 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));
|
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 & source_description,
|
||||||
const std::string & sink_name,
|
const std::string & sink_name,
|
||||||
const std::string & sink_description,
|
const std::string & sink_description,
|
||||||
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
|
const wivrn::from_headset::headset_info_packet & info,
|
||||||
xrt::drivers::wivrn::wivrn_session & session) :
|
wivrn::wivrn_session & session) :
|
||||||
session(session)
|
session(session)
|
||||||
{
|
{
|
||||||
pa_connection cnx("WiVRn");
|
pa_connection cnx("WiVRn");
|
||||||
@@ -446,7 +446,7 @@ std::shared_ptr<audio_device> create_pulse_handle(
|
|||||||
const std::string & source_description,
|
const std::string & source_description,
|
||||||
const std::string & sink_name,
|
const std::string & sink_name,
|
||||||
const std::string & sink_description,
|
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)
|
wivrn_session & session)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -25,5 +25,5 @@ std::shared_ptr<audio_device> create_pulse_handle(
|
|||||||
const std::string & source_description,
|
const std::string & source_description,
|
||||||
const std::string & sink_name,
|
const std::string & sink_name,
|
||||||
const std::string & sink_description,
|
const std::string & sink_description,
|
||||||
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
|
const wivrn::from_headset::headset_info_packet & info,
|
||||||
xrt::drivers::wivrn::wivrn_session & session);
|
wivrn::wivrn_session & session);
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ std::shared_ptr<audio_device> audio_device::create(
|
|||||||
const std::string & source_description,
|
const std::string & source_description,
|
||||||
const std::string & sink_name,
|
const std::string & sink_name,
|
||||||
const std::string & sink_description,
|
const std::string & sink_description,
|
||||||
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
|
const wivrn::from_headset::headset_info_packet & info,
|
||||||
xrt::drivers::wivrn::wivrn_session & session)
|
wivrn::wivrn_session & session)
|
||||||
{
|
{
|
||||||
#if WIVRN_USE_PIPEWIRE
|
#if WIVRN_USE_PIPEWIRE
|
||||||
if (auto res = create_pipewire_handle(source_name, source_description, sink_name, sink_description, info, session))
|
if (auto res = create_pipewire_handle(source_name, source_description, sink_name, sink_description, info, session))
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "wivrn_packets.h"
|
#include "wivrn_packets.h"
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
class wivrn_session;
|
class wivrn_session;
|
||||||
}
|
}
|
||||||
@@ -34,15 +34,15 @@ struct audio_device
|
|||||||
// unpublishes the device
|
// unpublishes the device
|
||||||
virtual ~audio_device() = default;
|
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(
|
static std::shared_ptr<audio_device> create(
|
||||||
const std::string & source_name,
|
const std::string & source_name,
|
||||||
const std::string & source_description,
|
const std::string & source_description,
|
||||||
const std::string & sink_name,
|
const std::string & sink_name,
|
||||||
const std::string & sink_description,
|
const std::string & sink_description,
|
||||||
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
|
const wivrn::from_headset::headset_info_packet & info,
|
||||||
xrt::drivers::wivrn::wivrn_session & session);
|
wivrn::wivrn_session & session);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ void clock_offset_estimator::request_sample(wivrn_connection & connection)
|
|||||||
|
|
||||||
next_sample = std::chrono::steady_clock::now() + sample_interval.load();
|
next_sample = std::chrono::steady_clock::now() + sample_interval.load();
|
||||||
connection.send_stream(
|
connection.send_stream(
|
||||||
xrt::drivers::wivrn::to_headset::timesync_query{
|
wivrn::to_headset::timesync_query{
|
||||||
.query = XrTime(os_monotonic_get_ns()),
|
.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();
|
XrTime now = os_monotonic_get_ns();
|
||||||
clock_offset_estimator::sample sample{base_sample, now};
|
clock_offset_estimator::sample sample{base_sample, now};
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ struct clock_offset
|
|||||||
|
|
||||||
class clock_offset_estimator
|
class clock_offset_estimator
|
||||||
{
|
{
|
||||||
struct sample : public xrt::drivers::wivrn::from_headset::timesync_response
|
struct sample : public wivrn::from_headset::timesync_response
|
||||||
{
|
{
|
||||||
XrTime received;
|
XrTime received;
|
||||||
};
|
};
|
||||||
@@ -64,7 +64,7 @@ class clock_offset_estimator
|
|||||||
public:
|
public:
|
||||||
void reset();
|
void reset();
|
||||||
void request_sample(wivrn_connection & connection);
|
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();
|
clock_offset get_offset();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
static std::filesystem::path config_file = xdg_config_home() / "wivrn" / "config.json";
|
static std::filesystem::path config_file = xdg_config_home() / "wivrn" / "config.json";
|
||||||
static std::filesystem::path cookie_file = xdg_config_home() / "wivrn" / "cookie";
|
static std::filesystem::path cookie_file = xdg_config_home() / "wivrn" / "cookie";
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
NLOHMANN_JSON_SERIALIZE_ENUM(
|
NLOHMANN_JSON_SERIALIZE_ENUM(
|
||||||
video_codec,
|
video_codec,
|
||||||
@@ -102,7 +102,7 @@ configuration configuration::read_user_configuration()
|
|||||||
SET_IF(offset_y);
|
SET_IF(offset_y);
|
||||||
SET_IF(group);
|
SET_IF(group);
|
||||||
SET_IF(codec);
|
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>());
|
throw std::runtime_error("invalid codec value " + encoder["codec"].get<std::string>());
|
||||||
SET_IF(options);
|
SET_IF(options);
|
||||||
SET_IF(device);
|
SET_IF(device);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ struct configuration
|
|||||||
std::optional<double> offset_x;
|
std::optional<double> offset_x;
|
||||||
std::optional<double> offset_y;
|
std::optional<double> offset_y;
|
||||||
std::optional<int> group;
|
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::map<std::string, std::string> options;
|
||||||
std::optional<std::string> device;
|
std::optional<std::string> device;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "pose_list.h"
|
#include "pose_list.h"
|
||||||
#include "xrt_cast.h"
|
#include "xrt_cast.h"
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn;
|
using namespace wivrn;
|
||||||
|
|
||||||
static_assert(XRT_HAND_JOINT_COUNT == XR_HAND_JOINT_COUNT_EXT);
|
static_assert(XRT_HAND_JOINT_COUNT == XR_HAND_JOINT_COUNT_EXT);
|
||||||
|
|
||||||
|
|||||||
@@ -33,5 +33,5 @@ public:
|
|||||||
hand_joints_list(int hand_id) :
|
hand_joints_list(int hand_id) :
|
||||||
hand_id(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);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "xrt/xrt_defines.h"
|
#include "xrt/xrt_defines.h"
|
||||||
#include "xrt_cast.h"
|
#include "xrt_cast.h"
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn;
|
using namespace wivrn;
|
||||||
using namespace xrt::auxiliary::math;
|
using namespace xrt::auxiliary::math;
|
||||||
|
|
||||||
xrt_space_relation pose_list::interpolate(const xrt_space_relation & a, const xrt_space_relation & b, float t)
|
xrt_space_relation pose_list::interpolate(const xrt_space_relation & a, const xrt_space_relation & b, float t)
|
||||||
|
|||||||
@@ -27,15 +27,15 @@
|
|||||||
class pose_list : public history<pose_list, xrt_space_relation>
|
class pose_list : public history<pose_list, xrt_space_relation>
|
||||||
{
|
{
|
||||||
public:
|
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 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);
|
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) {}
|
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 &);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
#include <vulkan/vulkan_handles.hpp>
|
#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_instance_extensions = {};
|
||||||
std::vector<const char *> wivrn_comp_target::wanted_device_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{},
|
comp_target{},
|
||||||
pacer(U_TIME_1S_IN_NS / fps),
|
pacer(U_TIME_1S_IN_NS / fps),
|
||||||
cnx(cnx)
|
cnx(cnx)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <vulkan/vulkan_raii.hpp>
|
#include <vulkan/vulkan_raii.hpp>
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
class VideoEncoder;
|
class VideoEncoder;
|
||||||
@@ -97,10 +97,10 @@ struct wivrn_comp_target : public comp_target
|
|||||||
std::list<std::jthread> encoder_threads;
|
std::list<std::jthread> encoder_threads;
|
||||||
std::vector<std::shared_ptr<VideoEncoder>> encoders;
|
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;
|
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();
|
~wivrn_comp_target();
|
||||||
|
|
||||||
void on_feedback(const from_headset::feedback &, const clock_offset &);
|
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);
|
void render_dynamic_foveation(std::array<to_headset::foveation_parameter, 2> foveation);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn;
|
using namespace wivrn;
|
||||||
|
|
||||||
class wivrn_connection
|
class wivrn_connection
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ static void wivrn_controller_update_inputs(xrt_device * xdev);
|
|||||||
|
|
||||||
wivrn_controller::wivrn_controller(int hand_id,
|
wivrn_controller::wivrn_controller(int hand_id,
|
||||||
xrt_device * hmd,
|
xrt_device * hmd,
|
||||||
xrt::drivers::wivrn::wivrn_session * cnx) :
|
wivrn::wivrn_session * cnx) :
|
||||||
xrt_device{},
|
xrt_device{},
|
||||||
grip(hand_id == 0 ? device_id::LEFT_GRIP : device_id::RIGHT_GRIP),
|
grip(hand_id == 0 ? device_id::LEFT_GRIP : device_id::RIGHT_GRIP),
|
||||||
aim(hand_id == 0 ? device_id::LEFT_AIM : device_id::RIGHT_AIM),
|
aim(hand_id == 0 ? device_id::LEFT_AIM : device_id::RIGHT_AIM),
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
class wivrn_session;
|
class wivrn_session;
|
||||||
}
|
}
|
||||||
@@ -46,10 +46,10 @@ class wivrn_controller : public xrt_device
|
|||||||
std::vector<xrt_input> inputs_array;
|
std::vector<xrt_input> inputs_array;
|
||||||
xrt_output haptic_output;
|
xrt_output haptic_output;
|
||||||
|
|
||||||
xrt::drivers::wivrn::wivrn_session * cnx;
|
wivrn::wivrn_session * cnx;
|
||||||
|
|
||||||
public:
|
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()
|
void unregister()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ static void wivrn_eye_tracker_get_tracked_pose(xrt_device * xdev,
|
|||||||
xrt_space_relation * out_relation);
|
xrt_space_relation * out_relation);
|
||||||
|
|
||||||
wivrn_eye_tracker::wivrn_eye_tracker(xrt_device * hmd,
|
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{}, gaze(device_id::EYE_GAZE), cnx(cnx)
|
||||||
{
|
{
|
||||||
xrt_device * base = this;
|
xrt_device * base = this;
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ class wivrn_eye_tracker : public xrt_device
|
|||||||
xrt_input gaze_input;
|
xrt_input gaze_input;
|
||||||
pose_list gaze;
|
pose_list gaze;
|
||||||
|
|
||||||
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx;
|
std::shared_ptr<wivrn::wivrn_session> cnx;
|
||||||
|
|
||||||
public:
|
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()
|
void unregister()
|
||||||
{
|
{
|
||||||
cnx = nullptr;
|
cnx = nullptr;
|
||||||
|
|||||||
@@ -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);
|
struct xrt_facial_expression_set * out_value);
|
||||||
|
|
||||||
wivrn_fb_face2_tracker::wivrn_fb_face2_tracker(xrt_device * hmd,
|
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{}, cnx(cnx)
|
||||||
{
|
{
|
||||||
xrt_device * base = this;
|
xrt_device * base = this;
|
||||||
|
|||||||
@@ -86,10 +86,10 @@ class wivrn_fb_face2_tracker : public xrt_device
|
|||||||
fb_face2_list face_list;
|
fb_face2_list face_list;
|
||||||
xrt_input face_input;
|
xrt_input face_input;
|
||||||
|
|
||||||
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx;
|
std::shared_ptr<wivrn::wivrn_session> cnx;
|
||||||
|
|
||||||
public:
|
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()
|
void unregister()
|
||||||
{
|
{
|
||||||
cnx = nullptr;
|
cnx = nullptr;
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ bool wivrn_hmd::wivrn_hmd_compute_distortion(xrt_device * xdev, uint32_t view_in
|
|||||||
return true;
|
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) :
|
const from_headset::headset_info_packet & info) :
|
||||||
xrt_device{}, cnx(cnx)
|
xrt_device{}, cnx(cnx)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
struct comp_target;
|
struct comp_target;
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
class wivrn_session;
|
class wivrn_session;
|
||||||
}
|
}
|
||||||
@@ -55,12 +55,12 @@ class wivrn_hmd : public xrt_device
|
|||||||
std::array<to_headset::foveation_parameter, 2> foveation_parameters{};
|
std::array<to_headset::foveation_parameter, 2> foveation_parameters{};
|
||||||
from_headset::battery battery{};
|
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);
|
static bool wivrn_hmd_compute_distortion(xrt_device * xdev, uint32_t view_index, float u, float v, xrt_uv_triplet * result);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wivrn_hmd(xrt::drivers::wivrn::wivrn_session * cnx,
|
wivrn_hmd(wivrn::wivrn_session * cnx,
|
||||||
const from_headset::headset_info_packet & info);
|
const from_headset::headset_info_packet & info);
|
||||||
void unregister()
|
void unregister()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void wivrn_pacer::predict(
|
|||||||
out_present_slop_ns = 0;
|
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);
|
std::lock_guard lock(mutex);
|
||||||
if (feedback.stream_index >= streams.size() or feedback.times_displayed > 1)
|
if (feedback.stream_index >= streams.size() or feedback.times_displayed > 1)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ private:
|
|||||||
struct stream_data
|
struct stream_data
|
||||||
{
|
{
|
||||||
// Last feedback for each encoder
|
// Last feedback for each encoder
|
||||||
xrt::drivers::wivrn::from_headset::feedback last_feedback;
|
wivrn::from_headset::feedback last_feedback;
|
||||||
std::vector<int64_t> times;
|
std::vector<int64_t> times;
|
||||||
size_t next_times_index = 0;
|
size_t next_times_index = 0;
|
||||||
};
|
};
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
int64_t & out_present_slop_ns,
|
int64_t & out_present_slop_ns,
|
||||||
int64_t & out_predicted_display_time_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(
|
void mark_timing_point(
|
||||||
comp_target_timing_point point,
|
comp_target_timing_point point,
|
||||||
|
|||||||
@@ -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)
|
if (std::chrono::steady_clock::now() < next_sample)
|
||||||
return;
|
return;
|
||||||
@@ -102,7 +102,7 @@ void xrt::drivers::wivrn::tracking_control_t::send(wivrn_connection & connection
|
|||||||
next_sample += std::chrono::seconds(1);
|
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);
|
std::lock_guard lock(mutex);
|
||||||
if (enabled != this->enabled[size_t(id)])
|
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;
|
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)),
|
connection(std::move(tcp)),
|
||||||
info([](wivrn_connection & connection) {
|
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)))
|
while (not(control = connection.poll_control(-1)))
|
||||||
{
|
{
|
||||||
// FIXME: timeout
|
// 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,
|
xrt_result_t wivrn::wivrn_session::create_session(wivrn::TCP && tcp,
|
||||||
u_system & system,
|
u_system & system,
|
||||||
xrt_system_devices ** out_xsysd,
|
xrt_system_devices ** out_xsysd,
|
||||||
xrt_space_overseer ** out_xspovrs,
|
xrt_space_overseer ** out_xspovrs,
|
||||||
xrt_system_compositor ** out_xsysc)
|
xrt_system_compositor ** out_xsysc)
|
||||||
{
|
{
|
||||||
std::shared_ptr<wivrn_session> self;
|
std::shared_ptr<wivrn_session> self;
|
||||||
try
|
try
|
||||||
@@ -519,7 +519,7 @@ void wivrn_session::reconnect()
|
|||||||
{
|
{
|
||||||
offset_est.reset();
|
offset_est.reset();
|
||||||
connection.reset(std::move(*tcp));
|
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)))
|
while (not(control = connection.poll_control(100)))
|
||||||
{
|
{
|
||||||
// FIXME: timeout
|
// FIXME: timeout
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ struct xrt_space_overseer;
|
|||||||
struct xrt_system_compositor;
|
struct xrt_system_compositor;
|
||||||
struct wivrn_comp_target_factory;
|
struct wivrn_comp_target_factory;
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
struct wivrn_comp_target;
|
struct wivrn_comp_target;
|
||||||
|
|
||||||
@@ -175,4 +175,4 @@ private:
|
|||||||
void reconnect();
|
void reconnect();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
#include "ffmpeg/video_encoder_va.h"
|
#include "ffmpeg/video_encoder_va.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn;
|
using namespace wivrn;
|
||||||
|
|
||||||
// TODO: size independent bitrate
|
// TODO: size independent bitrate
|
||||||
static const uint64_t default_bitrate = 50'000'000;
|
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;
|
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;
|
double total_weight = 0;
|
||||||
for (auto & encoder: encoders)
|
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;
|
double w = encoder.width * encoder.height;
|
||||||
switch (encoder.codec)
|
switch (encoder.codec)
|
||||||
{
|
{
|
||||||
case xrt::drivers::wivrn::h264:
|
case wivrn::h264:
|
||||||
w *= 2;
|
w *= 2;
|
||||||
break;
|
break;
|
||||||
case xrt::drivers::wivrn::h265:
|
case wivrn::h265:
|
||||||
case xrt::drivers::wivrn::av1:
|
case wivrn::av1:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
encoder.bitrate = w;
|
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;
|
int group = -1;
|
||||||
for (auto & encoder: encoders)
|
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
|
#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;
|
VideoEncoderFFMPEG::mute_logs mute;
|
||||||
encoder_settings s{
|
encoder_settings s{
|
||||||
@@ -148,7 +148,7 @@ static std::optional<xrt::drivers::wivrn::video_codec> filter_codecs_vaapi(wivrn
|
|||||||
}
|
}
|
||||||
#endif
|
#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())
|
if (config.name.empty())
|
||||||
{
|
{
|
||||||
@@ -200,7 +200,7 @@ static void fill_defaults(wivrn_vk_bundle & bundle, const std::vector<xrt::drive
|
|||||||
config.codec = h265;
|
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;
|
configuration::encoder base;
|
||||||
fill_defaults(bundle, headset_codecs, 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);
|
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;
|
configuration config;
|
||||||
try
|
try
|
||||||
@@ -291,11 +291,11 @@ std::vector<encoder_settings> xrt::drivers::wivrn::get_encoder_settings(wivrn_vk
|
|||||||
height *= scale[1];
|
height *= scale[1];
|
||||||
height += height % 2;
|
height += height % 2;
|
||||||
|
|
||||||
std::vector<xrt::drivers::wivrn::encoder_settings> res;
|
std::vector<wivrn::encoder_settings> res;
|
||||||
int next_group = 0;
|
int next_group = 0;
|
||||||
for (const auto & encoder: config.encoders)
|
for (const auto & encoder: config.encoders)
|
||||||
{
|
{
|
||||||
xrt::drivers::wivrn::encoder_settings settings{};
|
wivrn::encoder_settings settings{};
|
||||||
settings.encoder_name = encoder.name;
|
settings.encoder_name = encoder.name;
|
||||||
settings.width = std::ceil(encoder.width.value_or(1) * width);
|
settings.width = std::ceil(encoder.width.value_or(1) * width);
|
||||||
settings.height = std::ceil(encoder.height.value_or(1) * height);
|
settings.height = std::ceil(encoder.height.value_or(1) * height);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
struct wivrn_vk_bundle;
|
struct wivrn_vk_bundle;
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
struct encoder_settings : public to_headset::video_stream_description::item
|
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);
|
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();
|
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);
|
push_frame(idr, target_timestamp, slot);
|
||||||
std::shared_ptr<AVPacket> enc_pkt(av_packet_alloc(), [](AVPacket * d) { av_packet_free(&d); });
|
std::shared_ptr<AVPacket> enc_pkt(av_packet_alloc(), [](AVPacket * d) { av_packet_free(&d); });
|
||||||
|
|||||||
@@ -23,10 +23,10 @@
|
|||||||
#include "ffmpeg_helper.h"
|
#include "ffmpeg_helper.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
class VideoEncoderFFMPEG : public xrt::drivers::wivrn::VideoEncoder
|
class VideoEncoderFFMPEG : public wivrn::VideoEncoder
|
||||||
{
|
{
|
||||||
public:
|
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;
|
std::optional<data> encode(bool idr, std::chrono::steady_clock::time_point target_timestamp, uint8_t slot) override;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
VideoEncoderFFMPEG() :
|
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;
|
virtual void push_frame(bool idr, std::chrono::steady_clock::time_point pts, uint8_t slot) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ vk::Format drm_to_vulkan_fmt(uint32_t drm_fourcc)
|
|||||||
|
|
||||||
} // namespace
|
} // 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)
|
synchronization2(vk.vk.features.synchronization_2)
|
||||||
{
|
{
|
||||||
auto drm_hw_ctx = make_drm_hw_ctx(vk.physical_device, settings.device);
|
auto drm_hw_ctx = make_drm_hw_ctx(vk.physical_device, settings.device);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "video_encoder_ffmpeg.h"
|
#include "video_encoder_ffmpeg.h"
|
||||||
#include <vulkan/vulkan_raii.hpp>
|
#include <vulkan/vulkan_raii.hpp>
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
struct encoder_settings;
|
struct encoder_settings;
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ class video_encoder_va : public VideoEncoderFFMPEG
|
|||||||
bool synchronization2 = false;
|
bool synchronization2 = false;
|
||||||
|
|
||||||
public:
|
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;
|
void present_image(vk::Image y_cbcr, vk::raii::CommandBuffer & cmd_buf, uint8_t slot) override;
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
#include "video_encoder_x264.h"
|
#include "video_encoder_x264.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
VideoEncoder::sender::sender() :
|
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);
|
cnx->dump_time("send_end", shard.frame_idx, os_monotonic_get_ns(), stream_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
struct wivrn_vk_bundle;
|
struct wivrn_vk_bundle;
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
class wivrn_session;
|
class wivrn_session;
|
||||||
@@ -126,4 +126,4 @@ protected:
|
|||||||
void SendData(std::span<uint8_t> data, bool end_of_frame);
|
void SendData(std::span<uint8_t> data, bool end_of_frame);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
void VideoEncoderNvenc::deleter::operator()(CudaFunctions * fn)
|
void VideoEncoderNvenc::deleter::operator()(CudaFunctions * fn)
|
||||||
@@ -445,4 +445,4 @@ std::array<int, 2> VideoEncoderNvenc::get_max_size(video_codec codec)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <ffnvcodec/nvEncodeAPI.h>
|
#include <ffnvcodec/nvEncodeAPI.h>
|
||||||
#include <vulkan/vulkan_raii.hpp>
|
#include <vulkan/vulkan_raii.hpp>
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
class VideoEncoderNvenc : public VideoEncoder
|
class VideoEncoderNvenc : public VideoEncoder
|
||||||
@@ -73,4 +73,4 @@ public:
|
|||||||
static std::array<int, 2> get_max_size(video_codec);
|
static std::array<int, 2> get_max_size(video_codec);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "utils/wivrn_vk_bundle.h"
|
#include "utils/wivrn_vk_bundle.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
void VideoEncoderX264::ProcessCb(x264_t * h, x264_nal_t * nal, void * opaque)
|
void VideoEncoderX264::ProcessCb(x264_t * h, x264_nal_t * nal, void * opaque)
|
||||||
@@ -249,4 +249,4 @@ VideoEncoderX264::~VideoEncoderX264()
|
|||||||
x264_encoder_close(enc);
|
x264_encoder_close(enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vulkan/vulkan_raii.hpp>
|
#include <vulkan/vulkan_raii.hpp>
|
||||||
|
|
||||||
namespace xrt::drivers::wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
class VideoEncoderX264 : public VideoEncoder
|
class VideoEncoderX264 : public VideoEncoder
|
||||||
@@ -77,4 +77,4 @@ private:
|
|||||||
void InsertInPendingNal(pending_nal && nal);
|
void InsertInPendingNal(pending_nal && nal);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xrt::drivers::wivrn
|
} // namespace wivrn
|
||||||
|
|||||||
+15
-15
@@ -50,11 +50,11 @@ extern "C"
|
|||||||
ipc_server_main(int argc, char * argv[]);
|
ipc_server_main(int argc, char * argv[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn;
|
using namespace wivrn;
|
||||||
|
|
||||||
static std::unique_ptr<TCPListener> listener;
|
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<wivrn::typed_socket<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, to_monado::packets, from_monado::packets>> wivrn_ipc_socket_monado;
|
||||||
|
|
||||||
std::filesystem::path socket_path()
|
std::filesystem::path socket_path()
|
||||||
{
|
{
|
||||||
@@ -205,7 +205,7 @@ std::optional<avahi_publisher> publisher;
|
|||||||
|
|
||||||
gboolean headset_connected(gint fd, GIOCondition condition, gpointer user_data);
|
gboolean headset_connected(gint fd, GIOCondition condition, gpointer user_data);
|
||||||
void stop_listening();
|
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 start_publishing();
|
||||||
void stop_publishing();
|
void stop_publishing();
|
||||||
@@ -339,7 +339,7 @@ void start_listening()
|
|||||||
|
|
||||||
assert(listener_watch == 0);
|
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);
|
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);
|
g_source_set_callback(source_listener, G_SOURCE_FUNC(&headset_connected), nullptr, nullptr);
|
||||||
listener_watch = g_source_attach(source_listener, nullptr);
|
listener_watch = g_source_attach(source_listener, nullptr);
|
||||||
@@ -364,13 +364,13 @@ void start_publishing()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
char protocol_string[17];
|
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 = {
|
std::map<std::string, std::string> TXT = {
|
||||||
{"protocol", protocol_string},
|
{"protocol", protocol_string},
|
||||||
{"version", xrt::drivers::wivrn::git_version},
|
{"version", wivrn::git_version},
|
||||||
{"cookie", server_cookie()},
|
{"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()
|
void stop_publishing()
|
||||||
@@ -428,7 +428,7 @@ gboolean headset_connected(gint fd, GIOCondition condition, gpointer user_data)
|
|||||||
|
|
||||||
assert(listener);
|
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();
|
init_cleanup_functions();
|
||||||
|
|
||||||
std::cout << "Client connected" << std::endl;
|
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();
|
auto packet = wivrn_ipc_socket_main_loop->receive();
|
||||||
if (packet)
|
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);
|
wivrn_server_set_headset_connected(dbus_server, true);
|
||||||
}
|
}
|
||||||
else if (std::holds_alternative<from_monado::headsdet_connected>(*packet))
|
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;
|
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;
|
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);
|
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_channels(dbus_server, speaker.num_channels);
|
||||||
wivrn_server_set_speaker_sample_rate(dbus_server, speaker.sample_rate);
|
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_channels(dbus_server, mic.num_channels);
|
||||||
wivrn_server_set_mic_sample_rate(dbus_server, mic.sample_rate);
|
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)
|
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;
|
std::cerr << "For Steam games, set command to " << steam_command() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ wivrn_instance_create_system(struct xrt_instance * xinst,
|
|||||||
*out_xsys = &u_sys->base;
|
*out_xsys = &u_sys->base;
|
||||||
|
|
||||||
struct xrt_system_compositor * xsysc = NULL;
|
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),
|
std::move(*tcp),
|
||||||
*u_sys,
|
*u_sys,
|
||||||
out_xsysd,
|
out_xsysd,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
std::unique_ptr<xrt::drivers::wivrn::TCP> tcp;
|
std::unique_ptr<wivrn::TCP> tcp;
|
||||||
|
|
||||||
struct cleanup_function
|
struct cleanup_function
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-3
@@ -23,7 +23,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <wivrn_sockets.h>
|
#include <wivrn_sockets.h>
|
||||||
|
|
||||||
extern std::unique_ptr<xrt::drivers::wivrn::TCP> tcp;
|
extern std::unique_ptr<wivrn::TCP> tcp;
|
||||||
|
|
||||||
namespace from_monado
|
namespace from_monado
|
||||||
{
|
{
|
||||||
@@ -32,7 +32,7 @@ struct headsdet_connected
|
|||||||
struct headsdet_disconnected
|
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 from_monado
|
||||||
|
|
||||||
namespace to_monado
|
namespace to_monado
|
||||||
@@ -43,7 +43,7 @@ struct disconnect
|
|||||||
using packets = std::variant<disconnect>;
|
using packets = std::variant<disconnect>;
|
||||||
} // namespace to_monado
|
} // 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();
|
std::optional<to_monado::packets> receive_from_main();
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ static inline uint16_t get_uint8(tvbuff_t * tvb, const int offset)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace xrt::drivers::wivrn;
|
using namespace wivrn;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -716,7 +716,7 @@ int dissect_wivrn(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree _U_, vo
|
|||||||
if (tcp)
|
if (tcp)
|
||||||
start += sizeof(uint16_t);
|
start += sizeof(uint16_t);
|
||||||
|
|
||||||
if (pinfo->destport == xrt::drivers::wivrn::default_port)
|
if (pinfo->destport == wivrn::default_port)
|
||||||
tree_traits<"wivrn.from_headset", from_headset::packets>::dissect(subtree, tvb, start);
|
tree_traits<"wivrn.from_headset", from_headset::packets>::dissect(subtree, tvb, start);
|
||||||
else
|
else
|
||||||
tree_traits<"wivrn.to_headset", to_headset::packets>::dissect(subtree, tvb, start);
|
tree_traits<"wivrn.to_headset", to_headset::packets>::dissect(subtree, tvb, start);
|
||||||
@@ -760,8 +760,8 @@ void proto_reg_handoff_wivrn()
|
|||||||
{
|
{
|
||||||
static dissector_handle_t handle_tcp = create_dissector_handle(dissect_wivrn_tcp, proto);
|
static dissector_handle_t handle_tcp = create_dissector_handle(dissect_wivrn_tcp, proto);
|
||||||
static dissector_handle_t handle_udp = create_dissector_handle(dissect_wivrn_udp, proto);
|
static dissector_handle_t handle_udp = create_dissector_handle(dissect_wivrn_udp, proto);
|
||||||
dissector_add_uint("udp.port", xrt::drivers::wivrn::default_port, handle_udp);
|
dissector_add_uint("udp.port", wivrn::default_port, handle_udp);
|
||||||
dissector_add_uint("tcp.port", xrt::drivers::wivrn::default_port, handle_tcp);
|
dissector_add_uint("tcp.port", wivrn::default_port, handle_tcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user