diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-09 13:04:48 (GMT) |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2014-07-09 13:04:48 (GMT) |
commit | b64b589fe4c68957fec1aaebc770fc65602257f7 (patch) | |
tree | 61591c6986919f637aeccb8f6b25d25623a8d762 /src/main.c | |
parent | 686302576f714176c771121fc13f3c492ff9bb93 (diff) | |
download | soup-transcoding-proxy-b64b589fe4c68957fec1aaebc770fc65602257f7.zip soup-transcoding-proxy-b64b589fe4c68957fec1aaebc770fc65602257f7.tar.gz |
main: Add option parsing (port)
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -8,8 +8,13 @@ #include "debug/local-play.h" #endif -#include <fcntl.h> -#include <string.h> +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); |