summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-01-17 10:28:13 +0100
committerSebastian Dröge <sebastian@centricular.com>2015-02-06 09:42:50 +0100
commit18d3244fd0a547d40b0791e37da8cfcbb41b9e93 (patch)
tree2fb3a1e37f1461ac0ba3e8fd143074109330512f /examples
parent844add610d1fe9056beddf0f9497ad875751f725 (diff)
test-record: Use GOptionContext to parse the server port and take the pipeline from the commandline
Diffstat (limited to 'examples')
-rw-r--r--examples/test-record.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/examples/test-record.c b/examples/test-record.c
index 676ae98..85d6f83 100644
--- a/examples/test-record.c
+++ b/examples/test-record.c
@@ -23,6 +23,16 @@
#include <gst/rtsp-server/rtsp-server.h>
+#define DEFAULT_RTSP_PORT "8554"
+
+static char *port = (char *) DEFAULT_RTSP_PORT;
+
+static GOptionEntry entries[] = {
+ {"port", 'p', 0, G_OPTION_ARG_STRING, &port,
+ "Port to listen on (default: " DEFAULT_RTSP_PORT ")", "PORT"},
+ {NULL}
+};
+
int
main (int argc, char *argv[])
{
@@ -30,8 +40,18 @@ main (int argc, char *argv[])
GstRTSPServer *server;
GstRTSPMountPoints *mounts;
GstRTSPMediaFactory *factory;
+ GOptionContext *optctx;
+ GError *error = NULL;
- gst_init (&argc, &argv);
+ optctx = g_option_context_new ("<launch line> - Test RTSP Server, Launch\n\n"
+ "Example: \"( decodebin name=depay0 ! autovideosink )\"");
+ 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);
loop = g_main_loop_new (NULL, FALSE);
@@ -48,8 +68,7 @@ main (int argc, char *argv[])
* element with depay%d names will be a stream */
factory = gst_rtsp_media_factory_new ();
gst_rtsp_media_factory_set_record (factory, TRUE);
- gst_rtsp_media_factory_set_launch (factory,
- "( decodebin name=depay0 ! autovideosink decodebin name=depay1 ! autoaudiosink )");
+ gst_rtsp_media_factory_set_launch (factory, argv[1]);
/* attach the test factory to the /test url */
gst_rtsp_mount_points_add_factory (mounts, "/test", factory);
@@ -61,7 +80,7 @@ main (int argc, char *argv[])
gst_rtsp_server_attach (server, NULL);
/* start serving */
- g_print ("stream ready at rtsp://127.0.0.1:8554/test\n");
+ g_print ("stream ready at rtsp://127.0.0.1:%s/test\n", port);
g_main_loop_run (loop);
return 0;