configure bitrate on client only
This commit is contained in:
@@ -32,12 +32,14 @@
|
||||
#include "utils/i18n.h"
|
||||
#include "utils/mapped_file.h"
|
||||
#include "utils/overloaded.h"
|
||||
#if WIVRN_CLIENT_DEBUG_MENU
|
||||
#include "utils/ranges.h"
|
||||
#endif
|
||||
#include "version.h"
|
||||
#include "xr/body_tracker.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <chrono> // IWYU pragma: keep
|
||||
#include <entt/entity/fwd.hpp>
|
||||
#include <fastgltf/math.hpp>
|
||||
#include <fastgltf/types.hpp>
|
||||
@@ -689,6 +691,25 @@ void scenes::lobby::gui_settings()
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
}
|
||||
|
||||
// Bitrate
|
||||
{
|
||||
const int mb = 1'000'000;
|
||||
const auto current = config.bitrate_bps;
|
||||
auto val = int(current / mb);
|
||||
const auto slider = ImGui::SliderInt(
|
||||
_("Bitrate").append("##bitrate").c_str(),
|
||||
&val,
|
||||
1,
|
||||
200,
|
||||
fmt::format(_F("{}Mbit/s"), val).c_str());
|
||||
if (slider)
|
||||
{
|
||||
config.bitrate_bps = val * mb;
|
||||
config.save();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
}
|
||||
|
||||
if (instance.has_extension(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME))
|
||||
{
|
||||
if (ImGui::Checkbox(_S("High power mode"), &config.high_power_mode))
|
||||
|
||||
@@ -233,13 +233,13 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
{
|
||||
if (config.preferred_refresh_rate and (config.preferred_refresh_rate == 0 or utils::contains(info.available_refresh_rates, *config.preferred_refresh_rate)))
|
||||
{
|
||||
info.preferred_refresh_rate = *config.preferred_refresh_rate;
|
||||
info.minimum_refresh_rate = config.minimum_refresh_rate.value_or(0);
|
||||
info.settings.preferred_refresh_rate = *config.preferred_refresh_rate;
|
||||
info.settings.minimum_refresh_rate = config.minimum_refresh_rate.value_or(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default to highest refresh rate
|
||||
info.preferred_refresh_rate = info.available_refresh_rates.back();
|
||||
info.settings.preferred_refresh_rate = info.available_refresh_rates.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,9 +248,11 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
{
|
||||
spdlog::warn("Unable to detect refresh rates");
|
||||
info.available_refresh_rates = {guessed_fps};
|
||||
info.preferred_refresh_rate = guessed_fps;
|
||||
info.settings.preferred_refresh_rate = guessed_fps;
|
||||
}
|
||||
|
||||
info.settings.bitrate_bps = config.bitrate_bps;
|
||||
|
||||
info.hand_tracking = config.check_feature(feature::hand_tracking);
|
||||
info.eye_gaze = config.check_feature(feature::eye_gaze);
|
||||
|
||||
|
||||
@@ -167,8 +167,6 @@ private:
|
||||
XrTime running_application_req = 0;
|
||||
thread_safe<to_headset::running_applications> running_applications;
|
||||
|
||||
std::atomic_uint32_t bitrate = 0;
|
||||
|
||||
stream(std::string server_name, scene & parent_scene);
|
||||
|
||||
bool forward_hid_input(from_headset::hid::input_t);
|
||||
@@ -204,7 +202,6 @@ public:
|
||||
void operator()(to_headset::tracking_control &&);
|
||||
void operator()(to_headset::audio_stream_description &&);
|
||||
void operator()(to_headset::video_stream_description &&);
|
||||
void operator()(to_headset::settings &&);
|
||||
void operator()(to_headset::refresh_rate_change &&);
|
||||
void operator()(to_headset::application_list &&);
|
||||
void operator()(to_headset::application_icon &&);
|
||||
|
||||
@@ -382,11 +382,11 @@ void scenes::stream::gui_compact_view()
|
||||
}
|
||||
}
|
||||
|
||||
static void send_settings_changed_packet(xr::session & session, wivrn_session * network, const configuration & config, uint32_t bitrate, float predicted_display_period)
|
||||
static void send_settings_changed_packet(xr::session & session, wivrn_session * network, const configuration & config, float predicted_display_period)
|
||||
{
|
||||
const auto & refresh_rates = session.get_refresh_rates();
|
||||
from_headset::settings_changed packet{
|
||||
.bitrate_bps = bitrate,
|
||||
.bitrate_bps = config.bitrate_bps,
|
||||
};
|
||||
if (config.preferred_refresh_rate and (config.preferred_refresh_rate == 0 or utils::contains(refresh_rates, *config.preferred_refresh_rate)))
|
||||
{
|
||||
@@ -420,7 +420,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
|
||||
{
|
||||
session.set_refresh_rate(0);
|
||||
config.preferred_refresh_rate = 0;
|
||||
send_settings_changed_packet(session, network_session.get(), config, bitrate, predicted_display_period);
|
||||
send_settings_changed_packet(session, network_session.get(), config, predicted_display_period);
|
||||
config.save();
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
@@ -431,7 +431,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
|
||||
{
|
||||
session.set_refresh_rate(rate);
|
||||
config.preferred_refresh_rate = rate;
|
||||
send_settings_changed_packet(session, network_session.get(), config, bitrate, predicted_display_period);
|
||||
send_settings_changed_packet(session, network_session.get(), config, predicted_display_period);
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
@@ -449,7 +449,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
|
||||
if (ImGui::Selectable(fmt::format("{}", rate).c_str(), rate == config.minimum_refresh_rate, ImGuiSelectableFlags_SelectOnRelease))
|
||||
{
|
||||
config.minimum_refresh_rate = rate;
|
||||
send_settings_changed_packet(session, network_session.get(), config, bitrate, predicted_display_period);
|
||||
send_settings_changed_packet(session, network_session.get(), config, predicted_display_period);
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
@@ -467,7 +467,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
|
||||
|
||||
ImGui::SameLine(0.f, 10.f);
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (size.y / 4.f) - style.FramePadding.y * 3.f);
|
||||
if (ImGui::Button(fmt::format("{}Mbit/s", bitrate / 1'000'000).c_str()))
|
||||
if (ImGui::Button(fmt::format("{}Mbit/s", config.bitrate_bps / 1'000'000).c_str()))
|
||||
gui_status = gui_status::bitrate_settings;
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
@@ -589,23 +589,27 @@ void scenes::stream::gui_settings(float predicted_display_period)
|
||||
|
||||
void scenes::stream::gui_bitrate_settings(float predicted_display_period)
|
||||
{
|
||||
auto & config = application::get_config();
|
||||
ImGui::PushFont(nullptr, constants::gui::font_size_large);
|
||||
ImGui::Text("%s", _S("Use the right thumbstick to adjust the bitrate"));
|
||||
ImGui::Text("%s", _S("Press A to go back"));
|
||||
ImGui::Text("%s", fmt::format(_F("Bitrate: {}Mbit/s"), bitrate / 1'000'000).c_str());
|
||||
ImGui::Text("%s", fmt::format(_F("Bitrate: {}Mbit/s"), config.bitrate_bps / 1'000'000).c_str());
|
||||
ImGui::PopFont();
|
||||
|
||||
// Maximum speed of 20Mbit/s
|
||||
float delta = application::read_action_float(settings_adjust).value_or(std::pair{0, 0}).second * 20'000'000.f * predicted_display_period;
|
||||
|
||||
bitrate = std::clamp(bitrate + static_cast<int32_t>(delta), 1'000'000u, 200'000'000u);
|
||||
config.bitrate_bps = std::clamp(config.bitrate_bps + static_cast<int32_t>(delta), 1'000'000u, 200'000'000u);
|
||||
|
||||
bool ok = application::read_action_bool(foveation_ok).value_or(std::pair{0, false}).second;
|
||||
|
||||
if (ok)
|
||||
{
|
||||
config.save();
|
||||
gui_status = gui_status::settings;
|
||||
}
|
||||
|
||||
send_settings_changed_packet(session, network_session.get(), application::get_config(), bitrate, predicted_display_period);
|
||||
send_settings_changed_packet(session, network_session.get(), application::get_config(), predicted_display_period);
|
||||
}
|
||||
|
||||
void scenes::stream::gui_foveation_settings(float predicted_display_period)
|
||||
|
||||
@@ -74,11 +74,6 @@ void scenes::stream::operator()(to_headset::video_stream_description && desc)
|
||||
}
|
||||
}
|
||||
|
||||
void scenes::stream::operator()(to_headset::settings && settings)
|
||||
{
|
||||
bitrate = settings.bitrate_bps;
|
||||
}
|
||||
|
||||
void scenes::stream::operator()(to_headset::refresh_rate_change && rate)
|
||||
{
|
||||
session.set_refresh_rate(rate.fps);
|
||||
|
||||
Reference in New Issue
Block a user