[rygel] gstlaunch: use the default rygel configuration file



commit 70ccca68813c4df16a1cae917c41b1d4ec25a359
Author: Thijs Vermeir <thijsvermeir gmail com>
Date:   Wed Aug 19 02:04:18 2009 +0200

    gstlaunch: use the default rygel configuration file

 data/Makefile.am                                   |    1 -
 data/rygel-default.conf                            |   13 ++++
 data/rygel-gstlaunch.conf                          |   15 -----
 src/plugins/gstlaunch/Makefile.am                  |    2 +-
 .../gstlaunch/rygel-gstlaunch-root-container.vala  |   67 +++++---------------
 5 files changed, 30 insertions(+), 68 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index cbb064e..6ff991d 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -38,7 +38,6 @@ $(desktop_DATA): $(desktop_in_files) Makefile
 CLEANFILES = $(dbusservice_DATA) $(desktop_DATA) rygel.conf
 EXTRA_DIST = rygel-maemo.conf \
 	     rygel-default.conf \
-	     rygel-gstlaunch.conf \
 	     $(dbusservice_in_files) \
 	     $(desktop_in_files)
 
diff --git a/data/rygel-default.conf b/data/rygel-default.conf
index 4de5fd8..55cc03e 100644
--- a/data/rygel-default.conf
+++ b/data/rygel-default.conf
@@ -65,3 +65,16 @@ rss=508
 [DVB]
 enabled=true
 title=Digital\sTV
+
+[GstLaunch]
+launch_items=audiotestsrc;videotestsrc;videotestoverlay
+audiotestsrc_title=Audiotestsrc
+audiotestsrc_mime=audio/x-wav
+audiotestsrc_launch=audiotestsrc ! wavenc
+videotestsrc_title=Videotestsrc
+videotestsrc_mime=video/mpeg
+videotestsrc_launch=videotestsrc ! ffenc_mpeg2video ! mpegtsmux
+videotestoverlay_title=Videotestsrc with timeoverlay 2
+videotestoverlay_mime=video/mpeg
+videotestoverlay_launch=videotestsrc ! timeoverlay ! ffenc_mpeg2video ! mpegtsmux
+
diff --git a/src/plugins/gstlaunch/Makefile.am b/src/plugins/gstlaunch/Makefile.am
index 95eea5d..8060e63 100644
--- a/src/plugins/gstlaunch/Makefile.am
+++ b/src/plugins/gstlaunch/Makefile.am
@@ -7,7 +7,7 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
 		$(LIBDBUS_GLIB_CFLAGS) \
 		$(GEE_CFLAGS) \
 		$(LIBGSTREAMER_CFLAGS) \
-		$(top_srcdir)/src/rygel -DDATA_DIR='"$(datadir)"' \
+		-I$(top_srcdir)/src/rygel -DDATA_DIR='"$(datadir)"' \
 		-DSYS_CONFIG_DIR='"$(sysconfdir)"'
 
 librygel_gstlaunch_la_SOURCES = rygel-gstlaunch-plugin.vala \
diff --git a/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala b/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala
index 1a9c9f8..da0299e 100644
--- a/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala
+++ b/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala
@@ -20,28 +20,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-/*
- * Copyright (C) 2009 Thijs Vermeir <thijsvermeir gmail com>
- *
- * Author: Thijs Vermeir <thijsvermeir gmail com>
- *
- * This file is part of Rygel.
- *
- * Rygel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Rygel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
 using Rygel;
 using GUPnP;
 using Gee;
@@ -52,9 +30,11 @@ using CStuff;
  * Represents the root container for GstLaunch content hierarchy.
  */
 public class Rygel.GstLaunchRootContainer : MediaContainer {
-    static const string GSTLAUNCH_FILE = "rygel-gstlaunch.conf";
+    const string CONFIG_GROUP = "GstLaunch";
+    const string ITEM_NAMES = "launch_items";
+
     ArrayList<MediaItem> items;
-    KeyFile key_file;
+    MetaConfig config;
 
     public GstLaunchRootContainer (string title) {
         base.root (title, 0);
@@ -62,8 +42,10 @@ public class Rygel.GstLaunchRootContainer : MediaContainer {
         this.items = new ArrayList<MediaItem> ();
 
         try {
-          load_key_file ();
-          parse_key_file ();
+          config = MetaConfig.get_default ();
+          var item_names = config.get_string_list (CONFIG_GROUP, ITEM_NAMES);
+          foreach (string name in item_names)
+            add_launch_item (name);
         } catch (Error err) {
           debug ("GstLaunch init failed: %s", err.message);
         }
@@ -71,31 +53,14 @@ public class Rygel.GstLaunchRootContainer : MediaContainer {
         this.child_count = this.items.size;
     }
 
-    void load_key_file () throws Error {
-      this.key_file = new KeyFile ();
-
-      var dirs = new string[2];
-      dirs[0] = Environment.get_user_config_dir ();
-      dirs[1] = BuildConfig.SYS_CONFIG_DIR;
-
-      string path;
-      this.key_file.load_from_dirs (GSTLAUNCH_FILE,
-                                    dirs,
-                                    out path,
-                                    KeyFileFlags.KEEP_COMMENTS |
-                                    KeyFileFlags.KEEP_TRANSLATIONS);
-      debug ("Loaded gstlaunch configuration from file '%s'", path);
-    }
-
-    void parse_key_file () throws Error {
-      var items = this.key_file.get_groups ();
-      foreach (string item in items) {
-        debug ("found item: %s", item);
-        string title = this.key_file.get_string (item, "title");
-        string mime_type = this.key_file.get_string (item, "mime");
-        string launch_line = this.key_file.get_string (item, "launch");
-
-        this.items.add (new GstLaunchItem (item, this, title, mime_type, launch_line));
+    void add_launch_item (string name) {
+      try {
+        string title = config.get_string (CONFIG_GROUP, "%s_title".printf (name));
+        string mime_type = config.get_string (CONFIG_GROUP, "%s_mime".printf (name));
+        string launch_line = config.get_string (CONFIG_GROUP, "%s_launch".printf (name));
+        this.items.add (new GstLaunchItem (name, this, title, mime_type, launch_line));
+      } catch (GLib.Error err) {
+        debug ("GstLaunch failed item '%s': %s", name, err.message);
       }
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]