summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xautogen.sh3
-rw-r--r--configure.ac7
-rw-r--r--data/Makefile.am1
-rw-r--r--data/rygel-gstlaunch.conf15
-rw-r--r--src/plugins/Makefile.am7
-rw-r--r--src/plugins/gstlaunch/Makefile.am31
-rw-r--r--src/plugins/gstlaunch/rygel-gstlaunch-content-dir.vala34
-rw-r--r--src/plugins/gstlaunch/rygel-gstlaunch-item.vala56
-rw-r--r--src/plugins/gstlaunch/rygel-gstlaunch-plugin.vala39
-rw-r--r--src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala150
10 files changed, 341 insertions, 2 deletions
diff --git a/autogen.sh b/autogen.sh
index 816f74c2..a9344e45 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -3,4 +3,5 @@ mkdir -p m4
autoreconf -v --install || exit 1
glib-gettextize --force --copy || exit 1
./configure --enable-vala --enable-maintainer-mode --enable-debug \
- --enable-test-plugin --enable-mediathek-plugin "$@"
+ --enable-test-plugin --enable-mediathek-plugin \
+ --enable-gstlaunch-plugin "$@"
diff --git a/configure.ac b/configure.ac
index 045e8cc4..b06c8502 100644
--- a/configure.ac
+++ b/configure.ac
@@ -195,6 +195,11 @@ AC_ARG_ENABLE(mediathek-plugin,
[ --enable-mediathek-plugin build Mediathek plugin],,
enable_mediathek_plugin=no)
+# Build GstLaunch plugin
+AC_ARG_ENABLE(gstlaunch-plugin,
+ [ --enable-gstlaunch-plugin build Gstreamer launchline plugin],,
+ enable_gstlaunch_plugin=no)
+
AC_SUBST(abs_top_builddir)
@@ -206,6 +211,7 @@ AM_CONDITIONAL([BUILD_TRACKER_PLUGIN],
AM_CONDITIONAL([BUILD_MEDIATHEK_PLUGIN], [test "x$enable_mediathek_plugin" = "xyes"])
AM_CONDITIONAL([BUILD_MEDIA_EXPORT_PLUGIN], [test "x$enable_media_export_plugin" = "xyes"])
AM_CONDITIONAL([BUILD_EXTERNAL_PLUGIN], [test "x$enable_external_plugin" = "xyes"])
+AM_CONDITIONAL([BUILD_GSTLAUNCH_PLUGIN], [test "x$enable_gstlaunch_plugin" = "xyes"])
# Gettext
GETTEXT_PACKAGE=rygel
@@ -228,6 +234,7 @@ src/ui/Makefile
src/plugins/Makefile
src/plugins/media-export/Makefile
src/plugins/external/Makefile
+src/plugins/gstlaunch/Makefile
src/plugins/mediathek/Makefile
src/plugins/tracker/Makefile
src/plugins/test/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 6ff991da..cbb064e7 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -38,6 +38,7 @@ $(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-gstlaunch.conf b/data/rygel-gstlaunch.conf
new file mode 100644
index 00000000..821ca214
--- /dev/null
+++ b/data/rygel-gstlaunch.conf
@@ -0,0 +1,15 @@
+[audiotest]
+title=Audiotestsrc
+mime=audio/x-wav
+launch=audiotestsrc ! wavenc
+
+[videotest]
+title=Videotestsrc
+mime=video/mpeg
+launch=videotestsrc ! ffenc_mpeg2video ! mpegtsmux
+
+[videotestoverlay]
+title=Videotestsrc with timeoverlay
+mime=video/mpeg
+launch=videotestsrc ! timeoverlay ! ffenc_mpeg2video ! mpegtsmux
+
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index d445987e..707d77f6 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -18,10 +18,15 @@ if BUILD_EXTERNAL_PLUGIN
EXTERNAL_PLUGIN = external
endif
+if BUILD_GSTLAUNCH_PLUGIN
+GSTLAUNCH_PLUGIN = gstlaunch
+endif
+
SUBDIRS = $(TEST_PLUGIN) \
$(TRACKER_PLUGIN) \
$(MEDIATHEK_PLUGIN) \
$(MEDIA_EXPORT_PLUGIN) \
- $(EXTERNAL_PLUGIN)
+ $(EXTERNAL_PLUGIN) \
+ $(GSTLAUNCH_PLUGIN)
MAINTAINERCLEANFILES = Makefile.in
diff --git a/src/plugins/gstlaunch/Makefile.am b/src/plugins/gstlaunch/Makefile.am
new file mode 100644
index 00000000..95eea5d1
--- /dev/null
+++ b/src/plugins/gstlaunch/Makefile.am
@@ -0,0 +1,31 @@
+plugindir = $(libdir)/rygel-1.0
+
+plugin_LTLIBRARIES = librygel-gstlaunch.la
+
+AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
+ $(LIBGUPNP_AV_CFLAGS) \
+ $(LIBDBUS_GLIB_CFLAGS) \
+ $(GEE_CFLAGS) \
+ $(LIBGSTREAMER_CFLAGS) \
+ $(top_srcdir)/src/rygel -DDATA_DIR='"$(datadir)"' \
+ -DSYS_CONFIG_DIR='"$(sysconfdir)"'
+
+librygel_gstlaunch_la_SOURCES = rygel-gstlaunch-plugin.vala \
+ rygel-gstlaunch-root-container.vala \
+ rygel-gstlaunch-content-dir.vala \
+ rygel-gstlaunch-item.vala
+
+librygel_gstlaunch_la_VALAFLAGS = --vapidir=$(top_srcdir)/src/rygel \
+ --pkg rygel-1.0 --pkg cstuff --pkg gconf-2.0 \
+ --pkg gupnp-1.0 --pkg gupnp-av-1.0 \
+ --pkg dbus-glib-1 --pkg gee-1.0 --pkg gstreamer-0.10
+
+librygel_gstlaunch_la_LIBADD = $(LIBGUPNP_LIBS) \
+ $(LIBGUPNP_AV_LIBS) \
+ $(LIBDBUS_GLIB_LIBS) \
+ $(LIBGSTREAMER_LIBS) \
+ $(GEE_LIBS)
+
+librygel_gstlaunch_la_LDFLAGS = -shared -fPIC -module -avoid-version
+
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/src/plugins/gstlaunch/rygel-gstlaunch-content-dir.vala b/src/plugins/gstlaunch/rygel-gstlaunch-content-dir.vala
new file mode 100644
index 00000000..015f1add
--- /dev/null
+++ b/src/plugins/gstlaunch/rygel-gstlaunch-content-dir.vala
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+public class Rygel.GstLaunchContentDir : ContentDirectory {
+ /* Pubic methods */
+ public override MediaContainer? create_root_container () {
+ string friendly_name = this.root_device.get_friendly_name ();
+ return new GstLaunchRootContainer (friendly_name);
+ }
+}
+
diff --git a/src/plugins/gstlaunch/rygel-gstlaunch-item.vala b/src/plugins/gstlaunch/rygel-gstlaunch-item.vala
new file mode 100644
index 00000000..ba515c68
--- /dev/null
+++ b/src/plugins/gstlaunch/rygel-gstlaunch-item.vala
@@ -0,0 +1,56 @@
+/*
+ * 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;
+using Gst;
+
+/**
+ * Represents Test audio item.
+ */
+public class Rygel.GstLaunchItem : Rygel.MediaItem {
+ string launch_line;
+
+ public GstLaunchItem (string id,
+ MediaContainer parent,
+ string title,
+ string mime_type,
+ string launch_line) {
+ base (id,
+ parent,
+ title,
+ (mime_type.has_prefix ("audio") ? MediaItem.AUDIO_CLASS : MediaItem.VIDEO_CLASS));
+ this.mime_type = mime_type;
+ this.launch_line = launch_line;
+ }
+
+ public override Element? create_stream_source () {
+ try {
+ return Gst.parse_bin_from_description (this.launch_line, true);
+ } catch (Error err) {
+ warning ("parse launchline failed: %s", err.message);
+ return null;
+ }
+ }
+}
+
diff --git a/src/plugins/gstlaunch/rygel-gstlaunch-plugin.vala b/src/plugins/gstlaunch/rygel-gstlaunch-plugin.vala
new file mode 100644
index 00000000..cd118054
--- /dev/null
+++ b/src/plugins/gstlaunch/rygel-gstlaunch-plugin.vala
@@ -0,0 +1,39 @@
+/*
+ * 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 Gee;
+using CStuff;
+
+[ModuleInit]
+public void module_init (PluginLoader loader) {
+ Plugin plugin = new Plugin.MediaServer ("GstLaunch", "Gst Launch");
+
+ var resource_info = new ResourceInfo (ContentDirectory.UPNP_ID,
+ ContentDirectory.UPNP_TYPE,
+ ContentDirectory.DESCRIPTION_PATH,
+ typeof (GstLaunchContentDir));
+
+ plugin.add_resource (resource_info);
+ loader.add_plugin (plugin);
+}
+
diff --git a/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala b/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala
new file mode 100644
index 00000000..1a9c9f87
--- /dev/null
+++ b/src/plugins/gstlaunch/rygel-gstlaunch-root-container.vala
@@ -0,0 +1,150 @@
+/*
+ * 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.
+ */
+
+/*
+ * 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;
+using Gst;
+using CStuff;
+
+/**
+ * Represents the root container for GstLaunch content hierarchy.
+ */
+public class Rygel.GstLaunchRootContainer : MediaContainer {
+ static const string GSTLAUNCH_FILE = "rygel-gstlaunch.conf";
+ ArrayList<MediaItem> items;
+ KeyFile key_file;
+
+ public GstLaunchRootContainer (string title) {
+ base.root (title, 0);
+
+ this.items = new ArrayList<MediaItem> ();
+
+ try {
+ load_key_file ();
+ parse_key_file ();
+ } catch (Error err) {
+ debug ("GstLaunch init failed: %s", err.message);
+ }
+
+ 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));
+ }
+ }
+
+ public override void get_children (uint offset,
+ uint max_count,
+ Cancellable? cancellable,
+ AsyncReadyCallback callback) {
+ uint stop = offset + max_count;
+
+ stop = stop.clamp (0, this.child_count);
+ var children = this.items.slice ((int) offset, (int) stop);
+
+ var res = new Rygel.SimpleAsyncResult<Gee.List<MediaObject>>
+ (this,
+ callback);
+ res.data = children;
+ res.complete_in_idle ();
+ }
+
+ public override Gee.List<MediaObject>? get_children_finish (
+ AsyncResult res)
+ throws GLib.Error {
+ var simple_res = (Rygel.SimpleAsyncResult<Gee.List<MediaObject>>) res;
+ return simple_res.data;
+ }
+
+ public override void find_object (string id,
+ Cancellable? cancellable,
+ AsyncReadyCallback callback) {
+ var res = new Rygel.SimpleAsyncResult<string> (this, callback);
+
+ res.data = id;
+ res.complete_in_idle ();
+ }
+
+ public override MediaObject? find_object_finish (AsyncResult res)
+ throws Error {
+ MediaItem item = null;
+ var id = ((Rygel.SimpleAsyncResult<string>) res).data;
+
+ foreach (MediaItem tmp in this.items) {
+ if (id == tmp.id) {
+ item = tmp;
+
+ break;
+ }
+ }
+
+ return item;
+ }
+}
+