From b64b589fe4c68957fec1aaebc770fc65602257f7 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 9 Jul 2014 18:34:48 +0530 Subject: main: Add option parsing (port) --- src/main.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index a2430f5..45a281f 100644 --- a/src/main.c +++ b/src/main.c @@ -8,8 +8,13 @@ #include "debug/local-play.h" #endif -#include -#include +static int port = 8000; + +static GOptionEntry entries[] = +{ + { "port", 'p', 0, G_OPTION_ARG_INT, &port, "Port to listen on (default: 8000)", "PORT" }, + { NULL } +}; static SoupServer *server; @@ -535,16 +540,29 @@ main (int argc, char *argv[]) { GHashTable *ctx_table; + GOptionContext *optctx; + GError *error = NULL; gst_init (&argc, &argv); + optctx = g_option_context_new ("- Soup Transcoding Proxy"); + g_option_context_add_main_entries (optctx, entries, NULL); + g_option_context_add_group (optctx, gst_init_get_option_group ()); + if (!g_option_context_parse (optctx, &argc, &argv, &error)) { + g_printerr ("Error parsing options: %s\n", error->message); + return 1; + } + g_option_context_free (optctx); + /* Keys are paths, and values are TranscodeServerCtxs */ ctx_table = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)stp_cleanup_transcode_server_ctx); + + /* TODO: Accept command-line argument for host */ server = soup_server_new (SOUP_SERVER_SERVER_HEADER, "soup-transcode-proxy ", - SOUP_SERVER_PORT, 8000, NULL); + SOUP_SERVER_PORT, port, NULL); soup_server_add_handler (server, NULL, (SoupServerCallback)handle_request_cb, ctx_table, NULL); -- cgit v0.11.2-2-gd1dd