From 6a2c9af316e7780b17a96eae6352166914da9452 Mon Sep 17 00:00:00 2001 From: dijunkun Date: Sun, 1 Dec 2024 17:00:59 +0800 Subject: [PATCH] [feat] loss rate display supported --- src/localization/localization.h | 1 + src/single_window/control_bar.cpp | 22 +++++++++++++++++++++- thirdparty/projectx | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/localization/localization.h b/src/localization/localization.h index cafd8bc..04a6a1d 100644 --- a/src/localization/localization.h +++ b/src/localization/localization.h @@ -36,6 +36,7 @@ static std::vector data = {u8"数据", "Data"}; static std::vector total = {u8"总计", "Total"}; static std::vector in = {u8"输入", "In"}; static std::vector out = {u8"输出", "Out"}; +static std::vector loss_rate = {u8"丢包率", "Loss Rate"}; static std::vector exit_fullscreen = {u8"退出全屏", "Exit fullscreen"}; static std::vector control_mouse = {u8"控制", "Control"}; diff --git a/src/single_window/control_bar.cpp b/src/single_window/control_bar.cpp index ed81474..f59a79d 100644 --- a/src/single_window/control_bar.cpp +++ b/src/single_window/control_bar.cpp @@ -20,6 +20,15 @@ int BitrateDisplay(int bitrate) { return 0; } +int LossRateDisplay(float loss_rate) { + if (loss_rate < 0.01f) { + ImGui::Text("0%%"); + } else { + ImGui::Text("%.2f%", loss_rate); + } + return 0; +} + int Render::ControlBar() { ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); @@ -204,7 +213,7 @@ int Render::NetTrafficStats() { ImGui::SetCursorPos(ImVec2( is_control_bar_in_left_ ? (control_window_width_ + 5.0f) : 5.0f, 40.0f)); - if (ImGui::BeginTable("split", 3, ImGuiTableFlags_BordersH, + if (ImGui::BeginTable("split", 4, ImGuiTableFlags_BordersH, ImVec2(control_window_max_width_ - 10.0f, control_window_max_height_ - 40.0f))) { ImGui::TableNextColumn(); @@ -213,6 +222,9 @@ int Render::NetTrafficStats() { ImGui::Text("%s", localization::in[localization_language_index_].c_str()); ImGui::TableNextColumn(); ImGui::Text("%s", localization::out[localization_language_index_].c_str()); + ImGui::TableNextColumn(); + ImGui::Text("%s", + localization::loss_rate[localization_language_index_].c_str()); ImGui::TableNextRow(); ImGui::TableNextColumn(); @@ -222,6 +234,8 @@ int Render::NetTrafficStats() { BitrateDisplay((int)net_traffic_stats_.video_inbound_stats.bitrate); ImGui::TableNextColumn(); BitrateDisplay((int)net_traffic_stats_.video_outbound_stats.bitrate); + ImGui::TableNextColumn(); + LossRateDisplay(net_traffic_stats_.video_inbound_stats.loss_rate); ImGui::TableNextRow(); ImGui::TableNextColumn(); @@ -231,6 +245,8 @@ int Render::NetTrafficStats() { BitrateDisplay((int)net_traffic_stats_.audio_inbound_stats.bitrate); ImGui::TableNextColumn(); BitrateDisplay((int)net_traffic_stats_.audio_outbound_stats.bitrate); + ImGui::TableNextColumn(); + LossRateDisplay(net_traffic_stats_.audio_inbound_stats.loss_rate); ImGui::TableNextRow(); ImGui::TableNextColumn(); @@ -239,6 +255,8 @@ int Render::NetTrafficStats() { BitrateDisplay((int)net_traffic_stats_.data_inbound_stats.bitrate); ImGui::TableNextColumn(); BitrateDisplay((int)net_traffic_stats_.data_outbound_stats.bitrate); + ImGui::TableNextColumn(); + LossRateDisplay(net_traffic_stats_.data_inbound_stats.loss_rate); ImGui::TableNextRow(); ImGui::TableNextColumn(); @@ -248,6 +266,8 @@ int Render::NetTrafficStats() { BitrateDisplay((int)net_traffic_stats_.total_inbound_stats.bitrate); ImGui::TableNextColumn(); BitrateDisplay((int)net_traffic_stats_.total_outbound_stats.bitrate); + ImGui::TableNextColumn(); + LossRateDisplay(net_traffic_stats_.total_inbound_stats.loss_rate); ImGui::EndTable(); } diff --git a/thirdparty/projectx b/thirdparty/projectx index daef6f1..49d6307 160000 --- a/thirdparty/projectx +++ b/thirdparty/projectx @@ -1 +1 @@ -Subproject commit daef6f19dc24db59f144efdacbfcaa7ecd049568 +Subproject commit 49d63071544421ad45f7b764eb9cabd8290fe42c