|
@@ -57,6 +57,25 @@ using boost::iostreams::mapped_file;
|
|
|
|
|
|
|
|
log_timer global_timer;
|
|
log_timer global_timer;
|
|
|
|
|
|
|
|
|
|
+// utility
|
|
|
|
|
+struct imgui_disable_guard {
|
|
|
|
|
+ explicit imgui_disable_guard(bool enable = true) {
|
|
|
|
|
+ is_disabled = enable;
|
|
|
|
|
+ if (is_disabled) {
|
|
|
|
|
+ ImGui::BeginDisabled();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ~imgui_disable_guard() {
|
|
|
|
|
+ if (is_disabled) {
|
|
|
|
|
+ ImGui::EndDisabled();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+private:
|
|
|
|
|
+ bool is_disabled;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
// global variable definition
|
|
// global variable definition
|
|
|
CUcontext cuda_ctx = nullptr;
|
|
CUcontext cuda_ctx = nullptr;
|
|
|
int main_window_width = -1, main_window_height = -1;
|
|
int main_window_width = -1, main_window_height = -1;
|
|
@@ -759,9 +778,10 @@ void prepare_imgui_frame() {
|
|
|
ImGui::RadioButton("Right", &preview_camera_index, 1);
|
|
ImGui::RadioButton("Right", &preview_camera_index, 1);
|
|
|
|
|
|
|
|
ImGui::SeparatorText("Infos");
|
|
ImGui::SeparatorText("Infos");
|
|
|
- ImGui::BeginDisabled();
|
|
|
|
|
- ImGui::DragFloat("Process Frame Rate (fps)", &process_frame_rate, 0, 0, 60, "%.01f");
|
|
|
|
|
- ImGui::EndDisabled();
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ auto guard = imgui_disable_guard{};
|
|
|
|
|
+ ImGui::DragFloat("Process Frame Rate (fps)", &process_frame_rate, 0, 0, 60, "%.01f");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// auto save raw config
|
|
// auto save raw config
|
|
|
// ImGui::SeparatorText("Auto Shoot");
|
|
// ImGui::SeparatorText("Auto Shoot");
|
|
@@ -858,18 +878,20 @@ void prepare_imgui_frame() {
|
|
|
ImGui::PushID("Encoder");
|
|
ImGui::PushID("Encoder");
|
|
|
|
|
|
|
|
ImGui::SeparatorText("Method");
|
|
ImGui::SeparatorText("Method");
|
|
|
- if (is_encoding()) {
|
|
|
|
|
- ImGui::BeginDisabled();
|
|
|
|
|
- }
|
|
|
|
|
- if (ImGui::RadioButton("NvEnc", chosen_encoder == ENCODER_NVENC)) {
|
|
|
|
|
- simple_eq.emplace([] { chosen_encoder = ENCODER_NVENC; });
|
|
|
|
|
- }
|
|
|
|
|
- ImGui::SameLine();
|
|
|
|
|
- if (ImGui::RadioButton("nvJPEG", chosen_encoder == ENCODER_JPEG)) {
|
|
|
|
|
- simple_eq.emplace([] { chosen_encoder = ENCODER_JPEG; });
|
|
|
|
|
- }
|
|
|
|
|
- if (is_encoding()) {
|
|
|
|
|
- ImGui::EndDisabled();
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ auto guard = imgui_disable_guard{is_encoding()};
|
|
|
|
|
+ if (ImGui::RadioButton("NvEnc", chosen_encoder == ENCODER_NVENC)) {
|
|
|
|
|
+ simple_eq.emplace([] {
|
|
|
|
|
+ chosen_encoder = ENCODER_NVENC;
|
|
|
|
|
+ if (chosen_sender == SENDER_UDP) { // NvEnc cannot be used with UDP
|
|
|
|
|
+ chosen_sender = SENDER_TCP;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ ImGui::SameLine();
|
|
|
|
|
+ if (ImGui::RadioButton("nvJPEG", chosen_encoder == ENCODER_JPEG)) {
|
|
|
|
|
+ simple_eq.emplace([] { chosen_encoder = ENCODER_JPEG; });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ImGui::SeparatorText("Actions");
|
|
ImGui::SeparatorText("Actions");
|
|
@@ -902,18 +924,15 @@ void prepare_imgui_frame() {
|
|
|
RET_ERROR;
|
|
RET_ERROR;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (is_encoding()) {
|
|
|
|
|
- ImGui::BeginDisabled();
|
|
|
|
|
- }
|
|
|
|
|
- ImGui::Checkbox("Full Resolution", &output_full_frame);
|
|
|
|
|
- ImGui::SameLine();
|
|
|
|
|
- ImGui::Checkbox("Save Video", &encoder_save_file);
|
|
|
|
|
- if (encoder_save_file) {
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ auto guard = imgui_disable_guard{is_encoding()};
|
|
|
|
|
+ ImGui::Checkbox("Full Resolution", &output_full_frame);
|
|
|
ImGui::SameLine();
|
|
ImGui::SameLine();
|
|
|
- ImGui::Checkbox("Save Frame Length", &encoder_save_length);
|
|
|
|
|
- }
|
|
|
|
|
- if (is_encoding()) {
|
|
|
|
|
- ImGui::EndDisabled();
|
|
|
|
|
|
|
+ ImGui::Checkbox("Save Video", &encoder_save_file);
|
|
|
|
|
+ if (encoder_save_file) {
|
|
|
|
|
+ ImGui::SameLine();
|
|
|
|
|
+ ImGui::Checkbox("Save Frame Length", &encoder_save_length);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ImGui::PopID();
|
|
ImGui::PopID();
|
|
@@ -923,6 +942,24 @@ void prepare_imgui_frame() {
|
|
|
if (ImGui::CollapsingHeader("Frame Sender")) {
|
|
if (ImGui::CollapsingHeader("Frame Sender")) {
|
|
|
ImGui::PushID("Sender");
|
|
ImGui::PushID("Sender");
|
|
|
|
|
|
|
|
|
|
+ ImGui::SeparatorText("Method");
|
|
|
|
|
+ {
|
|
|
|
|
+ auto guard = imgui_disable_guard{is_sending()};
|
|
|
|
|
+ if (ImGui::RadioButton("TCP", chosen_sender == SENDER_TCP)) {
|
|
|
|
|
+ simple_eq.emplace([] { chosen_sender = SENDER_TCP; });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (chosen_encoder != ENCODER_NVENC) {
|
|
|
|
|
+ ImGui::SameLine();
|
|
|
|
|
+ if (ImGui::RadioButton("UDP", chosen_sender == SENDER_UDP)) {
|
|
|
|
|
+ simple_eq.emplace([] { chosen_sender = SENDER_UDP; });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ImGui::SameLine();
|
|
|
|
|
+ if (ImGui::RadioButton("UDP (FEC)", chosen_sender == SENDER_UDP_FEC)) {
|
|
|
|
|
+ simple_eq.emplace([] { chosen_sender = SENDER_UDP_FEC; });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
ImGui::SeparatorText("Actions");
|
|
ImGui::SeparatorText("Actions");
|
|
|
if (!is_sending()) {
|
|
if (!is_sending()) {
|
|
|
if (ImGui::Button("Start")) {
|
|
if (ImGui::Button("Start")) {
|
|
@@ -935,13 +972,12 @@ void prepare_imgui_frame() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ImGui::SeparatorText("Configs");
|
|
ImGui::SeparatorText("Configs");
|
|
|
- if (is_sending()) {
|
|
|
|
|
- ImGui::BeginDisabled();
|
|
|
|
|
- }
|
|
|
|
|
- ImGui::InputInt("Listen Port", &sender_listen_port);
|
|
|
|
|
- ImGui::DragFloat("Parity Rate", &sender_parity_rate, 0.01, 0, 2, "%.02f");
|
|
|
|
|
- if (is_sending()) {
|
|
|
|
|
- ImGui::EndDisabled();
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ auto guard = imgui_disable_guard{is_sending()};
|
|
|
|
|
+ ImGui::InputInt("Listen Port", &sender_listen_port);
|
|
|
|
|
+ if (chosen_sender == SENDER_UDP_FEC) {
|
|
|
|
|
+ ImGui::DragFloat("Parity Rate", &sender_parity_rate, 0.01, 0, 2, "%.02f");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ImGui::PopID();
|
|
ImGui::PopID();
|