[maemo-commits] [maemo-commits] r17507 - in projects/haf/trunk/hildon-welcome: . debian src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Feb 24 16:44:13 EET 2009
Author: schulhof
Date: 2009-02-24 16:44:02 +0200 (Tue, 24 Feb 2009)
New Revision: 17507

Modified:
   projects/haf/trunk/hildon-welcome/configure.ac
   projects/haf/trunk/hildon-welcome/debian/changelog
   projects/haf/trunk/hildon-welcome/src/main.c
Log:
Added GOptionEntry for -a, -v, and -s

Modified: projects/haf/trunk/hildon-welcome/configure.ac
===================================================================
--- projects/haf/trunk/hildon-welcome/configure.ac	2009-02-24 14:41:46 UTC (rev 17506)
+++ projects/haf/trunk/hildon-welcome/configure.ac	2009-02-24 14:44:02 UTC (rev 17507)
@@ -1,5 +1,5 @@
 # Mandatory, inits autoconf
-AC_INIT(hildon-welcome, 0.11)
+AC_INIT(hildon-welcome, 0.13)
 
 # Tests that source dir exists
 AC_CONFIG_SRCDIR([src/main.c])

Modified: projects/haf/trunk/hildon-welcome/debian/changelog
===================================================================
--- projects/haf/trunk/hildon-welcome/debian/changelog	2009-02-24 14:41:46 UTC (rev 17506)
+++ projects/haf/trunk/hildon-welcome/debian/changelog	2009-02-24 14:44:02 UTC (rev 17507)
@@ -1,3 +1,10 @@
+hildon-welcome (0.13-1unreleased) unstable; urgency=low
+
+  * Added command line parsing for 3 options: -a for audio pipeline, -v for video pipeline,
+    and -s for silence pipeline
+
+ -- Gabriel Schulhof <gabriel.schulhof at nokia.com>  Tue, 24 Feb 2009 16:38:56 +0200
+
 hildon-welcome (0.12-1) unstable; urgency=low
 
   [ Gabriel Schulhof ]

Modified: projects/haf/trunk/hildon-welcome/src/main.c
===================================================================
--- projects/haf/trunk/hildon-welcome/src/main.c	2009-02-24 14:41:46 UTC (rev 17506)
+++ projects/haf/trunk/hildon-welcome/src/main.c	2009-02-24 14:44:02 UTC (rev 17507)
@@ -36,6 +36,14 @@
 
 #define KILL_TO_LENGTH_MS 30000
 
+#define DEFAULT_VIDEO_PIPELINE_STR " playbin2 uri=file://%s flags=99 " 
+#define DEFAULT_AUDIO_PIPELINE_STR " filesrc location=%s ! decodebin2 ! autoaudiosink "
+#define DEFAULT_SHUSH_PIPELINE_STR " audiotestsrc ! volume volume=0 ! autoaudiosink "
+
+static char *video_pipeline_str = DEFAULT_VIDEO_PIPELINE_STR;
+static char *audio_pipeline_str = DEFAULT_AUDIO_PIPELINE_STR;
+static char *shush_pipeline_str = DEFAULT_SHUSH_PIPELINE_STR;
+
 typedef struct
 {
   GstElement *pipeline;
@@ -132,13 +140,13 @@
    *
    */
   if (video && video[0])
-    g_string_append_printf(pipeline_str, " playbin2 uri=file://%s flags=99", video);
+    g_string_append_printf(pipeline_str, video_pipeline_str, video);
 
   if (audio && audio[0]) {
     if ('s' == audio[0] && 0 == audio[1])
-      g_string_append_printf(pipeline_str, " audiotestsrc ! volume volume=0 ! autoaudiosink ");
+      g_string_append_printf(pipeline_str, shush_pipeline_str);
     else
-      g_string_append_printf(pipeline_str, " filesrc location=%s ! decodebin2 ! autoaudiosink ", audio);
+      g_string_append_printf(pipeline_str, audio_pipeline_str, audio);
   }
 
   pipeline = gst_parse_launch(pipeline_str->str, NULL);
@@ -185,6 +193,39 @@
 int
 main(int argc, char **argv)
 {
+  GOptionEntry options[] = {
+    { 
+      .long_name = "audio", 
+      .short_name = 'a',
+      .flags = G_OPTION_FLAG_OPTIONAL_ARG, 
+      .arg = G_OPTION_ARG_STRING,
+      .arg_data = &audio_pipeline_str,
+      .description = "Audio pipeline string. May contain %s for the filename.",
+      .arg_description = "'" DEFAULT_AUDIO_PIPELINE_STR "'"
+    },
+    {
+      .long_name = "video", 
+      .short_name = 'v',
+      .flags = G_OPTION_FLAG_OPTIONAL_ARG, 
+      .arg = G_OPTION_ARG_STRING,
+      .arg_data = &video_pipeline_str,
+      .description = "Video pipeline string. May contain %s for the filename.",
+      .arg_description = "'" DEFAULT_VIDEO_PIPELINE_STR "'"
+    },
+    {
+      .long_name = "silence", 
+      .short_name = 's',
+      .flags = G_OPTION_FLAG_OPTIONAL_ARG, 
+      .arg = G_OPTION_ARG_STRING,
+      .arg_data = &shush_pipeline_str,
+      .description = "Silence pipeline string.",
+      .arg_description = "'" DEFAULT_SHUSH_PIPELINE_STR "'"
+    },
+    { NULL }
+  };
+
+  GOptionContext *ctx;
+  GError *err;
   Display *display = NULL;
   char *video = NULL, *audio = NULL;
   int duration;
@@ -192,6 +233,17 @@
   Window dst_window = 0, xcomposite_window = 0;
   GstElement *new_pipeline = NULL, *old_pipeline = NULL;
 
+  if (!g_thread_supported ()) g_thread_init(NULL);
+
+  ctx = g_option_context_new(NULL);
+  g_option_context_add_main_entries (ctx, options, NULL);
+  g_option_context_add_group (ctx, gst_init_get_option_group());
+  if (!g_option_context_parse (ctx, &argc, &argv, &err))
+    g_error ("Error parsing command line: %s\n", err ? err->message : "Unknown error\n");
+  g_option_context_free (ctx);
+
+  gst_init(&argc, &argv);
+
   if (!(display = XOpenDisplay(NULL)))
     g_error("Failed to open display\n");
   if ((dst_window = DefaultRootWindow(display)) == 0)
@@ -200,8 +252,6 @@
   if ((xcomposite_window = XCompositeGetOverlayWindow(display, dst_window)) != 0)
     dst_window = xcomposite_window;
 
-  gst_init(&argc, &argv);
-
   if ((itr = conf_file_iterator_new())) {
     while (conf_file_iterator_get(itr, &video, &audio, &duration)) {
       new_pipeline = play_logo(dst_window, video, audio, duration);


More information about the maemo-commits mailing list