[rygel] Add example renderer plugin
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] Add example renderer plugin
- Date: Thu, 25 Oct 2012 07:24:38 +0000 (UTC)
commit 8bf5efe310e0da821b748abbd6d538a900eb1d8a
Author: Murray Cumming <murrayc openismus com>
Date: Mon Oct 22 13:52:40 2012 +0200
Add example renderer plugin
This is a fairly stupid example but it does at least show what
needs to be implemented, even if the example does not actually
contain much implementation.
Bug #686632
configure.ac | 2 +
examples/Makefile.am | 2 +-
examples/renderer-plugins/Makefile.am | 2 +
examples/renderer-plugins/vala/Makefile.am | 20 +++
examples/renderer-plugins/vala/example-player.vala | 142 ++++++++++++++++++++
.../vala/example-renderer-plugin.vala | 65 +++++++++
.../rygel-media-renderer-plugin.vala | 2 +-
7 files changed, 233 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 806e91b..30a8bc8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -307,6 +307,8 @@ rygel-server-2.0.pc
rygel-renderer-gst-2.0.pc
tests/Makefile
examples/Makefile
+examples/renderer-plugins/Makefile
+examples/renderer-plugins/vala/Makefile
examples/server-plugins/Makefile
examples/server-plugins/vala/Makefile
])
diff --git a/examples/Makefile.am b/examples/Makefile.am
index c69c70f..4ece7a8 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -2,7 +2,7 @@
# if they are not enabled, to avoid
# installing them.
if BUILD_EXAMPLE_PLUGINS
-EXAMPLE_PLUGINS = server-plugins
+EXAMPLE_PLUGINS = renderer-plugins server-plugins
endif
SUBDIRS = $(EXAMPLE_PLUGINS)
diff --git a/examples/renderer-plugins/Makefile.am b/examples/renderer-plugins/Makefile.am
new file mode 100644
index 0000000..ecd5d25
--- /dev/null
+++ b/examples/renderer-plugins/Makefile.am
@@ -0,0 +1,2 @@
+SUBDIRS = vala
+
diff --git a/examples/renderer-plugins/vala/Makefile.am b/examples/renderer-plugins/vala/Makefile.am
new file mode 100644
index 0000000..27dcc10
--- /dev/null
+++ b/examples/renderer-plugins/vala/Makefile.am
@@ -0,0 +1,20 @@
+include $(top_srcdir)/common.am
+
+plugin_LTLIBRARIES = librygel-example-renderer-plugin.la
+
+AM_CFLAGS += -DG_LOG_DOMAIN='"Example"'
+
+librygel_example_renderer_plugin_la_SOURCES = \
+ example-renderer-plugin.vala \
+ example-player.vala
+
+librygel_example_renderer_plugin_la_VALAFLAGS = \
+ --pkg gstreamer-0.10 \
+ $(RYGEL_COMMON_RENDERER_PLUGIN_VALAFLAGS)
+
+librygel_example_renderer_plugin_la_LIBADD = \
+ $(LIBGSTREAMER_LIBS) \
+ $(RYGEL_COMMON_RENDERER_LIBS)
+
+librygel_example_renderer_plugin_la_LDFLAGS = \
+ $(RYGEL_PLUGIN_LINKER_FLAGS)
diff --git a/examples/renderer-plugins/vala/example-player.vala b/examples/renderer-plugins/vala/example-player.vala
new file mode 100644
index 0000000..77c89d2
--- /dev/null
+++ b/examples/renderer-plugins/vala/example-player.vala
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * 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 GUPnP;
+
+/**
+ * Implementation of RygelMediaPlayer.
+ *
+ * This is an incredibly simple example that does no real rendering,
+ * and does not attempt to support audio or video formats. It just prints out
+ * the URI that is received from the UPnP control point.
+ *
+ * RygelPlaybinPlayer, from librygel-renderer-gst, is a more complete example.
+ */
+public class Rygel.Example.Player : GLib.Object, Rygel.MediaPlayer {
+ private const string[] PROTOCOLS = { "http-get" };
+ private const string[] MIME_TYPES = {"image/jpeg",
+ "image/png" };
+ private static Player player;
+
+ private Player () {
+ }
+
+ public static Player get_default () {
+ if (player == null) {
+ player = new Player ();
+ }
+
+ return player;
+ }
+
+ private string _playback_state = "NO_MEDIA_PRESENT";
+ public string playback_state {
+ owned get {
+ return this._playback_state;
+ }
+
+ set {
+ this._playback_state = value;
+ }
+ }
+
+ private string _uri = "";
+ public string? uri {
+ owned get {
+ return _uri;
+ }
+
+ set {
+ this._uri = value;
+ debug ("URI set to %s.", value);
+ }
+ }
+
+ private string _mime_type = "";
+ public string? mime_type {
+ owned get {
+ return this._mime_type;
+ }
+
+ set {
+ this._mime_type = value;
+ }
+ }
+
+ private string _metadata = "";
+ public string? metadata {
+ owned get {
+ return this._metadata;
+ }
+
+ set {
+ this._metadata = value;
+ }
+ }
+
+ private string _content_features = "";
+ public string? content_features {
+ owned get {
+ return this._content_features;
+ }
+
+ set {
+ this._content_features = value;
+ }
+ }
+
+ private double _volume = 0;
+ public double volume {
+ get {
+ return this._volume;
+ }
+
+ set {
+ this._volume = value;
+ debug ("volume set to %f.", value);
+ }
+ }
+
+ private int64 _duration = 0;
+ public int64 duration {
+ get {
+ return this._duration;
+ }
+ }
+
+ private int64 _position = 0;
+ public int64 position {
+ get {
+ return this._position;
+ }
+ }
+
+ public bool seek (int64 time) {
+ return false;
+ }
+
+ public string[] get_protocols () {
+ return PROTOCOLS;
+ }
+
+ public string[] get_mime_types () {
+ return MIME_TYPES;
+ }
+
diff --git a/examples/renderer-plugins/vala/example-renderer-plugin.vala b/examples/renderer-plugins/vala/example-renderer-plugin.vala
new file mode 100644
index 0000000..ca99f56
--- /dev/null
+++ b/examples/renderer-plugins/vala/example-renderer-plugin.vala
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * 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;
+
+public void module_init (PluginLoader loader) {
+ if (loader.plugin_disabled (Rygel.Example.RendererPlugin.NAME)) {
+ message ("Plugin '%s' disabled by user, ignoring..",
+ Rygel.Example.RendererPlugin.NAME);
+
+ return;
+ }
+
+ var plugin = new Rygel.Example.RendererPlugin ();
+ loader.add_plugin (plugin);
+}
+
+
+/*
+ * Our derived Plugin class.
+ *
+ * To use this plugin, you must enable it in your rygel.conf file like so:
+ * [ExampleRendererPluginVala]
+ * enabled=false
+ */
+public class Rygel.Example.RendererPlugin : Rygel.MediaRendererPlugin {
+ /*
+ * The non-human-readable name for the service:
+ * Note that this should currently not contain spaces.
+ * See https://bugzilla.gnome.org/show_bug.cgi?id=679673
+ */
+ public const string NAME = "ExampleRendererPluginVala";
+
+ /* Optional human-readable name for the service: */
+ public const string TITLE = "Example Renderer Plugin Vala";
+
+ /* Optional human-readable description for the service: */
+ public const string DESCRIPTION = "An example Rygel renderer plugin implemented in vala.";
+
+ public RendererPlugin () {
+ base (NAME, TITLE, DESCRIPTION);
+ }
+
+ public override MediaPlayer? get_player () {
+ return Example.Player.get_default ();
+ }
+}
diff --git a/src/librygel-renderer/rygel-media-renderer-plugin.vala b/src/librygel-renderer/rygel-media-renderer-plugin.vala
index be206aa..e2c4109 100644
--- a/src/librygel-renderer/rygel-media-renderer-plugin.vala
+++ b/src/librygel-renderer/rygel-media-renderer-plugin.vala
@@ -39,7 +39,7 @@ public class Rygel.MediaRendererPlugin : Rygel.Plugin {
* Create an instance of the plugin.
*
* @param name The non-human-readable name for the plugin and its renderer, used in UPnP messages and in the Rygel configuration file.
- * @param title An optional human-readable name (friendlyName) of the UpnP renderer provided by the plugin. If the title is empty then the name will be used.
+ * @param title An optional human-readable name (friendlyName) of the UPnP renderer provided by the plugin. If the title is empty then the name will be used.
* @param description An optional human-readable description (modelDescription) of the UPnP renderer provided by the plugin.
*/
public MediaRendererPlugin (string name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]