clang-format

This commit is contained in:
Guillaume Meunier
2022-11-28 22:35:10 +01:00
parent b1cb28200d
commit 6dce276889
10 changed files with 30 additions and 25 deletions
+4 -2
View File
@@ -36,7 +36,8 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
wivrn_session::wivrn_session(in6_addr address, int port) : control(address, port), stream() wivrn_session::wivrn_session(in6_addr address, int port) :
control(address, port), stream()
{ {
// TODO: negociate UDP port // TODO: negociate UDP port
stream.bind(stream_client_port); stream.bind(stream_client_port);
@@ -47,7 +48,8 @@ wivrn_session::wivrn_session(in6_addr address, int port) : control(address, port
spdlog::info("Connection to {}:{}", inet_ntop(AF_INET6, &address, buffer, sizeof(buffer)), port); spdlog::info("Connection to {}:{}", inet_ntop(AF_INET6, &address, buffer, sizeof(buffer)), port);
} }
wivrn_session::wivrn_session(in_addr address, int port) : control(address, port), stream() wivrn_session::wivrn_session(in_addr address, int port) :
control(address, port), stream()
{ {
// TODO: negociate UDP port // TODO: negociate UDP port
stream.bind(stream_client_port); stream.bind(stream_client_port);
+10 -8
View File
@@ -345,7 +345,7 @@ public:
log_query(record, service_name); log_query(record, service_name);
std::array<uint8_t, 2048> buffer; std::array<uint8_t, 2048> buffer;
for(size_t i = 1; i < pollfds.size(); i++) for (size_t i = 1; i < pollfds.size(); i++)
{ {
if (mdns_query_send(pollfds[i].fd, record, service_name.data(), service_name.size(), buffer.data(), buffer.size(), 0)) if (mdns_query_send(pollfds[i].fd, record, service_name.data(), service_name.size(), buffer.data(), buffer.size(), 0))
{ {
@@ -368,7 +368,7 @@ public:
::read(pollfds[0].fd, buffer.data(), buffer.size()); ::read(pollfds[0].fd, buffer.data(), buffer.size());
} }
for(size_t i = 1; i < pollfds.size(); i++) for (size_t i = 1; i < pollfds.size(); i++)
{ {
if (pollfds[i].revents & POLLIN) if (pollfds[i].revents & POLLIN)
{ {
@@ -504,7 +504,8 @@ void wivrn_discover::discover(std::string service_name)
} }
} }
wivrn_discover::wivrn_discover(std::string service_name) : cache(std::make_unique<dnssd_cache>()), dnssd_thread(&wivrn_discover::discover, this, service_name) wivrn_discover::wivrn_discover(std::string service_name) :
cache(std::make_unique<dnssd_cache>()), dnssd_thread(&wivrn_discover::discover, this, service_name)
{ {
} }
@@ -534,20 +535,21 @@ int main()
{ {
wivrn_discover wd("_wivrn._tcp.local."); wivrn_discover wd("_wivrn._tcp.local.");
while(true) while (true)
{ {
auto now = steady_clock::now(); auto now = steady_clock::now();
auto services = wd.get_services(); auto services = wd.get_services();
spdlog::info("{} service(s) found", services.size()); spdlog::info("{} service(s) found", services.size());
for(auto& i: services) for (auto & i: services)
{ {
spdlog::info(" {} at {}:{}, expires in {} s", i.name, i.hostname, i.port, duration_cast<seconds>(i.ttl - now).count()); spdlog::info(" {} at {}:{}, expires in {} s", i.name, i.hostname, i.port, duration_cast<seconds>(i.ttl - now).count());
for(auto& j: i.addresses) for (auto & j: i.addresses)
{ {
std::visit([](const auto& addr){ std::visit([](const auto & addr) {
spdlog::info(" {}", ip_address_to_string(addr)); spdlog::info(" {}", ip_address_to_string(addr));
}, j); },
j);
} }
} }
+1 -1
View File
@@ -1,12 +1,12 @@
#pragma once #pragma once
#include <chrono>
#include <memory> #include <memory>
#include <netinet/in.h> #include <netinet/in.h>
#include <string> #include <string>
#include <thread> #include <thread>
#include <variant> #include <variant>
#include <vector> #include <vector>
#include <chrono>
class dnssd_cache; class dnssd_cache;
+4 -4
View File
@@ -187,7 +187,7 @@ struct video_stream_description
uint16_t offset_x; uint16_t offset_x;
uint16_t offset_y; uint16_t offset_y;
video_codec codec; video_codec codec;
std::optional<uint32_t> range; // VkSamplerYcbcrRange std::optional<uint32_t> range; // VkSamplerYcbcrRange
std::optional<uint32_t> color_model; // VkSamplerYcbcrModelConversion std::optional<uint32_t> color_model; // VkSamplerYcbcrModelConversion
}; };
struct foveation_parameter_item struct foveation_parameter_item
@@ -213,8 +213,8 @@ class video_stream_data_shard
{ {
std::shared_ptr<std::vector<uint8_t>> data; std::shared_ptr<std::vector<uint8_t>> data;
friend serialization_traits<video_stream_data_shard, void>; friend serialization_traits<video_stream_data_shard, void>;
public:
public:
inline static const size_t max_payload_size = 1400; inline static const size_t max_payload_size = 1400;
enum flags : uint8_t enum flags : uint8_t
{ {
@@ -289,7 +289,7 @@ struct serialization_traits<to_headset::video_stream_data_shard, void>
} }
template <typename T> template <typename T>
static void serialize(const to_headset::video_stream_data_shard& shard, T& packet) static void serialize(const to_headset::video_stream_data_shard & shard, T & packet)
{ {
packet.serialize(shard.stream_item_idx); packet.serialize(shard.stream_item_idx);
packet.serialize(shard.frame_idx); packet.serialize(shard.frame_idx);
@@ -302,7 +302,7 @@ struct serialization_traits<to_headset::video_stream_data_shard, void>
} }
template <typename T> template <typename T>
static to_headset::video_stream_data_shard deserialize(T& packet) static to_headset::video_stream_data_shard deserialize(T & packet)
{ {
to_headset::video_stream_data_shard shard; to_headset::video_stream_data_shard shard;
packet.deserialize(shard.stream_item_idx); packet.deserialize(shard.stream_item_idx);
+1 -1
View File
@@ -172,7 +172,7 @@ public:
} }
template <typename T> template <typename T>
void deserialize(T& v) void deserialize(T & v)
{ {
v = deserialize<T>(); v = deserialize<T>();
} }
+2 -2
View File
@@ -18,9 +18,9 @@
*/ */
#include "encoder_settings.h" #include "encoder_settings.h"
#include "configuration.h"
#include "video_encoder.h" #include "video_encoder.h"
#include "vk/vk_helpers.h" #include "vk/vk_helpers.h"
#include "configuration.h"
#include <string> #include <string>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@@ -90,7 +90,7 @@ std::vector<encoder_settings> xrt::drivers::wivrn::get_encoder_settings(vk_bundl
return get_encoder_default_settings(vk, width, height); return get_encoder_default_settings(vk, width, height);
std::vector<xrt::drivers::wivrn::encoder_settings> res; std::vector<xrt::drivers::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{}; xrt::drivers::wivrn::encoder_settings settings{};
settings.encoder_name = encoder.name; settings.encoder_name = encoder.name;
+1 -2
View File
@@ -126,8 +126,7 @@ VideoEncoderVA::VideoEncoderVA(vk_bundle * vk, const encoder_settings & settings
int err = av_hwdevice_ctx_create(&tmp, AV_HWDEVICE_TYPE_VAAPI, device ? device->c_str() : NULL, NULL, 0); int err = av_hwdevice_ctx_create(&tmp, AV_HWDEVICE_TYPE_VAAPI, device ? device->c_str() : NULL, NULL, 0);
if (err < 0) if (err < 0)
{ {
throw std::system_error(err, av_error_category(), "Failed create VAAPI device" + throw std::system_error(err, av_error_category(), "Failed create VAAPI device" + (device ? (" " + device->string()) : std::string()));
(device ? (" " + device->string()) : std::string()));
} }
hw_ctx_vaapi.reset(tmp); hw_ctx_vaapi.reset(tmp);
+3 -1
View File
@@ -192,7 +192,9 @@ void VideoEncoder::PushShard(std::vector<uint8_t> && payload, uint8_t flags)
if (not shards.empty()) if (not shards.empty())
{ {
cnx->send_stream(shards.back()); cnx->send_stream(shards.back());
} else { }
else
{
cnx->dump_time("send_start", frame_idx, os_monotonic_get_ns(), stream_idx); cnx->dump_time("send_start", frame_idx, os_monotonic_get_ns(), stream_idx);
} }
to_headset::video_stream_data_shard shard; to_headset::video_stream_data_shard shard;
+3 -3
View File
@@ -46,7 +46,8 @@ xrt_system_devices * xrt::drivers::wivrn::wivrn_session::create_session(xrt::dri
try try
{ {
self = std::shared_ptr<wivrn_session>(new wivrn_session(std::move(tcp), address.sin6_addr)); self = std::shared_ptr<wivrn_session>(new wivrn_session(std::move(tcp), address.sin6_addr));
while (not (control = self->connection.poll_control(-1))) {} while (not(control = self->connection.poll_control(-1)))
{}
} }
catch (std::exception & e) catch (std::exception & e)
{ {
@@ -131,7 +132,6 @@ void wivrn_session::operator()(from_headset::timesync_response && timesync)
void wivrn_session::operator()(from_headset::feedback && feedback) void wivrn_session::operator()(from_headset::feedback && feedback)
{ {
clock_offset o; clock_offset o;
{ {
std::lock_guard lock(mutex); std::lock_guard lock(mutex);
@@ -207,7 +207,7 @@ std::array<to_headset::video_stream_description::foveation_parameter, 2> wivrn_s
return hmd->get_foveation_parameters(); return hmd->get_foveation_parameters();
} }
void wivrn_session::dump_time(const std::string &event, uint64_t frame, uint64_t time, uint8_t stream) void wivrn_session::dump_time(const std::string & event, uint64_t frame, uint64_t time, uint8_t stream)
{ {
if (feedback_csv) if (feedback_csv)
{ {
+1 -1
View File
@@ -91,7 +91,7 @@ public:
std::array<to_headset::video_stream_description::foveation_parameter, 2> get_foveation_parameters(); std::array<to_headset::video_stream_description::foveation_parameter, 2> get_foveation_parameters();
void dump_time(const std::string& event, uint64_t frame, uint64_t time, uint8_t stream = -1); void dump_time(const std::string & event, uint64_t frame, uint64_t time, uint8_t stream = -1);
private: private:
static void run(std::weak_ptr<wivrn_session>); static void run(std::weak_ptr<wivrn_session>);