From 6e63c23463b9289bc56d77f7c7335917f8bf6a6a Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 1 Nov 2018 00:45:17 +0100 Subject: [PATCH] Support changing the HTTP port. --- flags.cpp | 8 +++++++- flags.h | 3 +++ frames/.empty | 0 main.cpp | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) delete mode 100644 frames/.empty diff --git a/flags.cpp b/flags.cpp index 1a4c08e..4c75370 100644 --- a/flags.cpp +++ b/flags.cpp @@ -14,7 +14,8 @@ Flags global_flags; // Long options that have no corresponding short option. enum LongOption { OPTION_HELP = 1000, - OPTION_SLOW_DOWN_INPUT = 1001 + OPTION_SLOW_DOWN_INPUT = 1001, + OPTION_HTTP_PORT = 1002 }; void usage() @@ -29,6 +30,7 @@ void usage() fprintf(stderr, " 3 = good (realtime 720p on GTX 970 or so)\n"); fprintf(stderr, " 4 = best (not realtime on any current GPU)\n"); fprintf(stderr, " -d, --working-directory DIR where to store frames and database\n"); + fprintf(stderr, " --http-port PORT which port to listen on for output\n"); } void parse_flags(int argc, char * const argv[]) @@ -38,6 +40,7 @@ void parse_flags(int argc, char * const argv[]) { "slow-down-input", no_argument, 0, OPTION_SLOW_DOWN_INPUT }, { "interpolation-quality", required_argument, 0, 'q' }, { "working-directory", required_argument, 0, 'd' }, + { "http-port", required_argument, 0, OPTION_HTTP_PORT }, { 0, 0, 0, 0 } }; for ( ;; ) { @@ -57,6 +60,9 @@ void parse_flags(int argc, char * const argv[]) case 'd': global_flags.working_directory = optarg; break; + case OPTION_HTTP_PORT: + global_flags.http_port = atoi(optarg); + break; case OPTION_HELP: usage(); exit(0); diff --git a/flags.h b/flags.h index 8b2563c..5e9d34b 100644 --- a/flags.h +++ b/flags.h @@ -3,11 +3,14 @@ #include +#include "defs.h" + struct Flags { std::string stream_source; std::string working_directory = "."; bool slow_down_input = false; int interpolation_quality = 2; + uint16_t http_port = DEFAULT_HTTPD_PORT; }; extern Flags global_flags; diff --git a/frames/.empty b/frames/.empty deleted file mode 100644 index e69de29..0000000 diff --git a/main.cpp b/main.cpp index 229bbf1..1d29735 100644 --- a/main.cpp +++ b/main.cpp @@ -128,7 +128,7 @@ int main(int argc, char **argv) main_window.show(); global_httpd->add_endpoint("/queue_status", bind(&MainWindow::get_queue_status, &main_window), HTTPD::NO_CORS_POLICY); - global_httpd->start(DEFAULT_HTTPD_PORT); + global_httpd->start(global_flags.http_port); init_jpeg_vaapi(); -- 2.39.2