|
@@ -12,6 +12,8 @@
|
|
|
#include <glad/gl.h>
|
|
#include <glad/gl.h>
|
|
|
#include <GLFW/glfw3.h>
|
|
#include <GLFW/glfw3.h>
|
|
|
|
|
|
|
|
|
|
+#include <boost/process/child.hpp>
|
|
|
|
|
+
|
|
|
#include <spdlog/spdlog.h>
|
|
#include <spdlog/spdlog.h>
|
|
|
|
|
|
|
|
#include <thread>
|
|
#include <thread>
|
|
@@ -25,7 +27,7 @@ GLFWwindow *main_window = nullptr;
|
|
|
// for receiver
|
|
// for receiver
|
|
|
video_decoder decoder;
|
|
video_decoder decoder;
|
|
|
|
|
|
|
|
-void controller_main() {
|
|
|
|
|
|
|
+void controller_main(const char *this_name) {
|
|
|
|
|
|
|
|
// setup imgui context
|
|
// setup imgui context
|
|
|
IMGUI_CHECKVERSION();
|
|
IMGUI_CHECKVERSION();
|
|
@@ -43,6 +45,9 @@ void controller_main() {
|
|
|
free(server_address);
|
|
free(server_address);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ namespace bp = boost::process;
|
|
|
|
|
+ bp::child *worker = nullptr;
|
|
|
|
|
+
|
|
|
// main loop
|
|
// main loop
|
|
|
while (!glfwWindowShouldClose(main_window)) {
|
|
while (!glfwWindowShouldClose(main_window)) {
|
|
|
|
|
|
|
@@ -58,9 +63,24 @@ void controller_main() {
|
|
|
// action
|
|
// action
|
|
|
ImGui::SeparatorText("Actions");
|
|
ImGui::SeparatorText("Actions");
|
|
|
|
|
|
|
|
|
|
+ if (worker == nullptr) {
|
|
|
|
|
+ if (ImGui::Button("Start")) {
|
|
|
|
|
+ worker = new bp::child{this_name, std::to_string(monitor_index),
|
|
|
|
|
+ server_address, std::to_string(server_port)};
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (ImGui::Button("Stop")) {
|
|
|
|
|
+ worker->terminate();
|
|
|
|
|
+ worker = nullptr;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// configs
|
|
// configs
|
|
|
ImGui::SeparatorText("Configs");
|
|
ImGui::SeparatorText("Configs");
|
|
|
ImGui::PushItemWidth(200);
|
|
ImGui::PushItemWidth(200);
|
|
|
|
|
+ if (worker != nullptr) {
|
|
|
|
|
+ ImGui::BeginDisabled();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// monitor
|
|
// monitor
|
|
|
int monitor_count;
|
|
int monitor_count;
|
|
@@ -89,6 +109,9 @@ void controller_main() {
|
|
|
static uint16_t val_one = 1;
|
|
static uint16_t val_one = 1;
|
|
|
ImGui::InputScalar("Server Port", ImGuiDataType_U16, &server_port, &val_one, nullptr, "%u");
|
|
ImGui::InputScalar("Server Port", ImGuiDataType_U16, &server_port, &val_one, nullptr, "%u");
|
|
|
|
|
|
|
|
|
|
+ if (worker != nullptr) {
|
|
|
|
|
+ ImGui::EndDisabled();
|
|
|
|
|
+ }
|
|
|
ImGui::PopItemWidth();
|
|
ImGui::PopItemWidth();
|
|
|
}
|
|
}
|
|
|
ImGui::End();
|
|
ImGui::End();
|
|
@@ -103,6 +126,10 @@ void controller_main() {
|
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
|
glfwSwapBuffers(main_window);
|
|
glfwSwapBuffers(main_window);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (worker != nullptr) {
|
|
|
|
|
+ worker->terminate();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void render_main() {
|
|
void render_main() {
|
|
@@ -197,7 +224,7 @@ int main(int argc, char *argv[]) {
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
if (is_controller) {
|
|
if (is_controller) {
|
|
|
- controller_main();
|
|
|
|
|
|
|
+ controller_main(argv[0]);
|
|
|
} else {
|
|
} else {
|
|
|
render_main();
|
|
render_main();
|
|
|
}
|
|
}
|