[rygel] examples: Add a C version of the example renderer plugin
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] examples: Add a C version of the example renderer plugin
- Date: Thu, 22 Nov 2012 13:27:57 +0000 (UTC)
commit 0f5b21538b1dbfe17c24ac467073cd452f721ff2
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Nov 22 14:26:48 2012 +0100
examples: Add a C version of the example renderer plugin
configure.ac | 1 +
data/rygel.conf | 3 +
examples/renderer-plugins/C/Makefile.am | 32 ++
examples/renderer-plugins/C/example-player.c | 486 ++++++++++++++++++++
examples/renderer-plugins/C/example-player.h | 57 +++
.../renderer-plugins/C/example-renderer-plugin.c | 84 ++++
.../renderer-plugins/C/example-renderer-plugin.h | 59 +++
examples/renderer-plugins/Makefile.am | 2 +-
examples/server-plugins/C/example-server-plugin.c | 4 +-
9 files changed, 725 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 04f4679..701c60e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -314,6 +314,7 @@ tests/Makefile
examples/Makefile
examples/renderer-plugins/Makefile
examples/renderer-plugins/vala/Makefile
+examples/renderer-plugins/C/Makefile
examples/server-plugins/Makefile
examples/server-plugins/vala/Makefile
examples/server-plugins/C/Makefile
diff --git a/data/rygel.conf b/data/rygel.conf
index 848b25c..5d831bf 100644
--- a/data/rygel.conf
+++ b/data/rygel.conf
@@ -143,6 +143,9 @@ enabled=false
[ExampleRendererPluginVala]
enabled=false
+[ExampleRendererPluginC]
+enabled=false
+
[MPRIS]
enabled=false
diff --git a/examples/renderer-plugins/C/Makefile.am b/examples/renderer-plugins/C/Makefile.am
new file mode 100644
index 0000000..ae34783
--- /dev/null
+++ b/examples/renderer-plugins/C/Makefile.am
@@ -0,0 +1,32 @@
+include $(top_srcdir)/common.am
+
+plugin_LTLIBRARIES = librygel-example-renderer-plugin-c.la
+
+AM_CFLAGS += -DG_LOG_DOMAIN='"ExampleRendererPluginC"'
+
+librygel_example_renderer_plugin_c_la_SOURCES = \
+ example-renderer-plugin.h \
+ example-renderer-plugin.h \
+ example-player.h \
+ example-player.c
+
+# You would ususally just use pkg-config:
+librygel_core_includes = -I$(top_builddir)/src/librygel-core $(if $(srcdir:.=),-I$(top_srcdir)/src/librygel-core)
+librygel_renderer_includes = -I$(top_builddir)/src/librygel-renderer $(if $(srcdir:.=),-I$(top_srcdir)/src/librygel-renderer)
+
+# TODO: Do we need all these?
+librygel_example_renderer_plugin_c_la_CFLAGS = \
+ $(LIBGSTREAMER_CFLAGS) \
+ $(LIBGUPNP_CFLAGS) \
+ $(LIBGUPNP_AV_CFLAGS) \
+ $(GEE_CFLAGS) \
+ $(librygel_core_includes) \
+ $(librygel_renderer_includes)
+
+librygel_example_renderer_plugin_c_la_LIBADD = \
+ $(LIBGSTREAMER_LIBS) \
+ $(RYGEL_COMMON_RENDERER_LIBS)
+
+librygel_example_renderer_plugin_c_la_LDFLAGS = \
+ $(RYGEL_PLUGIN_LINKER_FLAGS)
+
diff --git a/examples/renderer-plugins/C/example-player.c b/examples/renderer-plugins/C/example-player.c
new file mode 100644
index 0000000..25c4cfb
--- /dev/null
+++ b/examples/renderer-plugins/C/example-player.c
@@ -0,0 +1,486 @@
+/*
+ * 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.
+ */
+
+#include "example-player.h"
+
+enum {
+ RYGEL_EXAMPLE_PLAYER_DUMMY_PROPERTY,
+ RYGEL_EXAMPLE_PLAYER_PLAYBACK_STATE,
+ RYGEL_EXAMPLE_PLAYER_URI,
+ RYGEL_EXAMPLE_PLAYER_MIME_TYPE,
+ RYGEL_EXAMPLE_PLAYER_METADATA,
+ RYGEL_EXAMPLE_PLAYER_CONTENT_FEATURES,
+ RYGEL_EXAMPLE_PLAYER_VOLUME,
+ RYGEL_EXAMPLE_PLAYER_DURATION,
+ RYGEL_EXAMPLE_PLAYER_POSITION
+};
+
+static void rygel_example_player_rygel_media_player_interface_init (RygelMediaPlayerIface *iface);
+
+static gboolean
+rygel_example_player_real_seek (RygelMediaPlayer *base, gint64 time);
+
+static gchar**
+rygel_example_player_real_get_protocols (RygelMediaPlayer *base, int *result_length1);
+
+static gchar**
+rygel_example_player_real_get_mime_types (RygelMediaPlayer *base, int *result_length1);
+
+static gchar*
+rygel_example_player_real_get_playback_state (RygelMediaPlayer *base);
+
+static void
+rygel_example_player_real_set_playback_state (RygelMediaPlayer *base, const gchar *value);
+
+static gchar*
+rygel_example_player_real_get_uri (RygelMediaPlayer *base);
+
+static void
+rygel_example_player_real_set_uri (RygelMediaPlayer *base, const gchar *value);
+
+static gchar*
+rygel_example_player_real_get_mime_type (RygelMediaPlayer *base);
+
+static void
+rygel_example_player_real_set_mime_type (RygelMediaPlayer *base, const gchar *value);
+
+static gchar*
+rygel_example_player_real_get_metadata (RygelMediaPlayer *base);
+
+static void
+rygel_example_player_real_set_metadata (RygelMediaPlayer *base, const gchar *value);
+
+static gchar*
+rygel_example_player_real_get_content_features (RygelMediaPlayer *base);
+
+static void
+rygel_example_player_real_set_content_features (RygelMediaPlayer *base, const gchar *value);
+
+static gdouble
+rygel_example_player_real_get_volume (RygelMediaPlayer *base);
+
+static void
+rygel_example_player_real_set_volume (RygelMediaPlayer *base, gdouble value);
+
+static gint64
+rygel_example_player_real_get_duration (RygelMediaPlayer *base);
+
+static gint64
+rygel_example_player_real_get_position (RygelMediaPlayer *base);
+
+static void
+_rygel_example_player_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+
+static void
+_rygel_example_player_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
+
+static void
+rygel_example_player_finalize (GObject *obj);
+
+
+G_DEFINE_TYPE_WITH_CODE (RygelExamplePlayer, rygel_example_player, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (RYGEL_TYPE_MEDIA_PLAYER,
+ rygel_example_player_rygel_media_player_interface_init))
+
+struct _RygelExamplePlayerPrivate {
+ gchar *_playback_state;
+ gchar *_uri;
+ gchar *_mime_type;
+ gchar *_metadata;
+ gchar *_content_features;
+ gdouble _volume;
+ gint64 _duration;
+ gint64 _position;
+};
+
+static const gchar* RYGEL_EXAMPLE_PLAYER_PROTOCOLS[] = {"http-get", NULL};
+static const gchar* RYGEL_EXAMPLE_PLAYER_MIME_TYPES[] = {"image/jpeg", "image/png", NULL};
+
+RygelExamplePlayer*
+rygel_example_player_construct (GType object_type) {
+ RygelExamplePlayer *self;
+
+
+ return self;
+}
+
+
+RygelExamplePlayer*
+rygel_example_player_new (void) {
+ return rygel_example_player_construct (RYGEL_EXAMPLE_TYPE_PLAYER);
+}
+
+
+static void
+rygel_example_player_rygel_media_player_interface_init (RygelMediaPlayerIface *iface) {
+ iface->seek = (gboolean (*)(RygelMediaPlayer*, gint64)) rygel_example_player_real_seek;
+ iface->get_protocols = (gchar **(*)(RygelMediaPlayer*, int*)) rygel_example_player_real_get_protocols;
+ iface->get_mime_types = (gchar **(*)(RygelMediaPlayer*, int*)) rygel_example_player_real_get_mime_types;
+ iface->get_playback_state = rygel_example_player_real_get_playback_state;
+ iface->set_playback_state = rygel_example_player_real_set_playback_state;
+ iface->get_uri = rygel_example_player_real_get_uri;
+ iface->set_uri = rygel_example_player_real_set_uri;
+ iface->get_mime_type = rygel_example_player_real_get_mime_type;
+ iface->set_mime_type = rygel_example_player_real_set_mime_type;
+ iface->get_metadata = rygel_example_player_real_get_metadata;
+ iface->set_metadata = rygel_example_player_real_set_metadata;
+ iface->get_content_features = rygel_example_player_real_get_content_features;
+ iface->set_content_features = rygel_example_player_real_set_content_features;
+ iface->get_volume = rygel_example_player_real_get_volume;
+ iface->set_volume = rygel_example_player_real_set_volume;
+ iface->get_duration = rygel_example_player_real_get_duration;
+ iface->get_position = rygel_example_player_real_get_position;
+}
+
+static void
+rygel_example_player_class_init (RygelExamplePlayerClass *klass) {
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (gobject_class, sizeof (RygelExamplePlayerPrivate));
+
+ gobject_class->get_property = _rygel_example_player_get_property;
+ gobject_class->set_property = _rygel_example_player_set_property;
+ gobject_class->finalize = rygel_example_player_finalize;
+
+ g_object_class_install_property (gobject_class,
+ RYGEL_EXAMPLE_PLAYER_PLAYBACK_STATE,
+ g_param_spec_string ("playback-state",
+ "playback-state",
+ "playback-state",
+ NULL,
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+
+ g_object_class_install_property (gobject_class,
+ RYGEL_EXAMPLE_PLAYER_URI,
+ g_param_spec_string ("uri",
+ "uri",
+ "uri",
+ NULL,
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+
+ g_object_class_install_property (gobject_class,
+ RYGEL_EXAMPLE_PLAYER_MIME_TYPE,
+ g_param_spec_string ("mime-type",
+ "mime-type",
+ "mime-type",
+ NULL,
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+
+ g_object_class_install_property (gobject_class,
+ RYGEL_EXAMPLE_PLAYER_METADATA,
+ g_param_spec_string ("metadata",
+ "metadata",
+ "metadata",
+ NULL,
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+
+ g_object_class_install_property (gobject_class,
+ RYGEL_EXAMPLE_PLAYER_CONTENT_FEATURES,
+ g_param_spec_string ("content-features",
+ "content-features",
+ "content-features",
+ NULL,
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+
+ g_object_class_install_property (gobject_class,
+ RYGEL_EXAMPLE_PLAYER_VOLUME,
+ g_param_spec_double ("volume",
+ "volume",
+ "volume",
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+
+ g_object_class_install_property (gobject_class,
+ RYGEL_EXAMPLE_PLAYER_DURATION,
+ g_param_spec_int64 ("duration",
+ "duration",
+ "duration",
+ G_MININT64,
+ G_MAXINT64,
+ 0,
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
+
+ g_object_class_install_property (gobject_class,
+ RYGEL_EXAMPLE_PLAYER_POSITION,
+ g_param_spec_int64 ("position",
+ "position",
+ "position",
+ G_MININT64,
+ G_MAXINT64,
+ 0,
+ G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
+}
+
+static void
+rygel_example_player_init (RygelExamplePlayer *self) {
+ self->priv = RYGEL_EXAMPLE_PLAYER_GET_PRIVATE (self);
+
+ self->priv->_playback_state = g_strdup ("NO_MEDIA_PRESENT");
+ self->priv->_uri = NULL;
+ self->priv->_mime_type = NULL;
+ self->priv->_metadata = NULL;
+ self->priv->_content_features = NULL;
+ self->priv->_volume = 0;
+ self->priv->_duration = 0;
+ self->priv->_position = 0;
+}
+
+
+static gboolean
+rygel_example_player_real_seek (RygelMediaPlayer *base, gint64 time) {
+ /* RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base); */
+ return FALSE;
+}
+
+static gchar**
+rygel_example_player_real_get_protocols (RygelMediaPlayer *base, int *result_length) {
+ /* RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base); */
+
+ if (result_length) {
+ *result_length = g_strv_length (RYGEL_EXAMPLE_PLAYER_PROTOCOLS);
+ }
+
+ return g_strdupv (RYGEL_EXAMPLE_PLAYER_PROTOCOLS);
+}
+
+
+static gchar**
+rygel_example_player_real_get_mime_types (RygelMediaPlayer *base, int *result_length) {
+ /* RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base); */
+
+ if (result_length) {
+ *result_length = g_strv_length (RYGEL_EXAMPLE_PLAYER_MIME_TYPES);
+ }
+
+ return g_strdupv (RYGEL_EXAMPLE_PLAYER_MIME_TYPES);
+}
+
+
+static gchar*
+rygel_example_player_real_get_playback_state (RygelMediaPlayer *base) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ return g_strdup (self->priv->_playback_state);
+}
+
+
+static void
+rygel_example_player_real_set_playback_state (RygelMediaPlayer *base, const gchar *value) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ g_free (self->priv->_playback_state);
+ self->priv->_playback_state = g_strdup (value);
+
+ g_object_notify (G_OBJECT (self), "playback-state");
+}
+
+
+static gchar*
+rygel_example_player_real_get_uri (RygelMediaPlayer *base) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ return g_strdup (self->priv->_uri);
+}
+
+
+static void
+rygel_example_player_real_set_uri (RygelMediaPlayer *base, const gchar *value) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ g_free (self->priv->_uri);
+ self->priv->_uri = g_strdup (value);
+
+ g_debug ("URI set to %s.", value);
+ g_object_notify (G_OBJECT (self), "uri");
+}
+
+
+static gchar*
+rygel_example_player_real_get_mime_type (RygelMediaPlayer *base) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ return g_strdup (self->priv->_mime_type);
+}
+
+
+static void
+rygel_example_player_real_set_mime_type (RygelMediaPlayer *base, const gchar *value) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ g_free (self->priv->_mime_type);
+ self->priv->_mime_type = g_strdup (value);
+
+ g_object_notify (G_OBJECT (self), "mime-type");
+}
+
+
+static gchar*
+rygel_example_player_real_get_metadata (RygelMediaPlayer *base) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ return g_strdup (self->priv->_metadata);
+}
+
+
+static void
+rygel_example_player_real_set_metadata (RygelMediaPlayer *base, const gchar *value) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ g_free (self->priv->_mime_type);
+ self->priv->_mime_type = g_strdup (value);
+
+ g_object_notify (G_OBJECT (self), "metadata");
+}
+
+
+static gchar*
+rygel_example_player_real_get_content_features (RygelMediaPlayer *base) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ return g_strdup (self->priv->_content_features);
+}
+
+
+static void
+rygel_example_player_real_set_content_features (RygelMediaPlayer *base, const gchar *value) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ g_free (self->priv->_content_features);
+ self->priv->_content_features = g_strdup (value);
+
+ g_object_notify (G_OBJECT (self), "content-features");
+}
+
+
+static gdouble
+rygel_example_player_real_get_volume (RygelMediaPlayer *base) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ return self->priv->_volume;
+}
+
+
+static void
+rygel_example_player_real_set_volume (RygelMediaPlayer *base, gdouble value) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ self->priv->_volume = value;
+
+ g_debug ("volume set to %f.", value);
+ g_object_notify (G_OBJECT (self), "volume");
+}
+
+
+static gint64
+rygel_example_player_real_get_duration (RygelMediaPlayer *base) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ return self->priv->_duration;
+}
+
+
+static gint64
+rygel_example_player_real_get_position (RygelMediaPlayer *base) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (base);
+
+ return self->priv->_position;
+}
+
+static void
+_rygel_example_player_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) {
+ RygelMediaPlayer *base = RYGEL_MEDIA_PLAYER (object);
+
+ switch (property_id) {
+ case RYGEL_EXAMPLE_PLAYER_PLAYBACK_STATE:
+ g_value_take_string (value, rygel_media_player_get_playback_state (base));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_URI:
+ g_value_take_string (value, rygel_media_player_get_uri (base));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_MIME_TYPE:
+ g_value_take_string (value, rygel_media_player_get_mime_type (base));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_METADATA:
+ g_value_take_string (value, rygel_media_player_get_metadata (base));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_CONTENT_FEATURES:
+ g_value_take_string (value, rygel_media_player_get_content_features (base));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_VOLUME:
+ g_value_set_double (value, rygel_media_player_get_volume (base));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_DURATION:
+ g_value_set_int64 (value, rygel_media_player_get_duration (base));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_POSITION:
+ g_value_set_int64 (value, rygel_media_player_get_position (base));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static void
+_rygel_example_player_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) {
+ RygelMediaPlayer *base = RYGEL_MEDIA_PLAYER (object);
+
+ switch (property_id) {
+ case RYGEL_EXAMPLE_PLAYER_PLAYBACK_STATE:
+ rygel_media_player_set_playback_state (base, g_value_get_string (value));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_URI:
+ rygel_media_player_set_uri (base, g_value_get_string (value));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_MIME_TYPE:
+ rygel_media_player_set_mime_type (base, g_value_get_string (value));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_METADATA:
+ rygel_media_player_set_metadata (base, g_value_get_string (value));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_CONTENT_FEATURES:
+ rygel_media_player_set_content_features (base, g_value_get_string (value));
+ break;
+ case RYGEL_EXAMPLE_PLAYER_VOLUME:
+ rygel_media_player_set_volume (base, g_value_get_double (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+rygel_example_player_finalize (GObject *obj) {
+ RygelExamplePlayer *self = RYGEL_EXAMPLE_PLAYER (obj);
+
+ g_free (self->priv->_playback_state);
+ g_free (self->priv->_uri);
+ g_free (self->priv->_mime_type);
+ g_free (self->priv->_metadata);
+ g_free (self->priv->_content_features);
+
+ G_OBJECT_CLASS (rygel_example_player_parent_class)->finalize (obj);
+}
+
+
diff --git a/examples/renderer-plugins/C/example-player.h b/examples/renderer-plugins/C/example-player.h
new file mode 100644
index 0000000..ee20881
--- /dev/null
+++ b/examples/renderer-plugins/C/example-player.h
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+#ifndef __RYGEL_EXAMPLE_PLAYER_H__
+#define __RYGEL_EXAMPLE_PLAYER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <rygel-renderer.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_EXAMPLE_TYPE_PLAYER (rygel_example_player_get_type ())
+#define RYGEL_EXAMPLE_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_EXAMPLE_TYPE_PLAYER, RygelExamplePlayer))
+#define RYGEL_EXAMPLE_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_EXAMPLE_TYPE_PLAYER, RygelExamplePlayerClass))
+#define RYGEL_EXAMPLE_IS_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_EXAMPLE_TYPE_PLAYER))
+#define RYGEL_EXAMPLE_IS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_EXAMPLE_TYPE_PLAYER))
+#define RYGEL_EXAMPLE_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_EXAMPLE_TYPE_PLAYER, RygelExamplePlayerClass))
+
+typedef struct _RygelExamplePlayer RygelExamplePlayer;
+typedef struct _RygelExamplePlayerClass RygelExamplePlayerClass;
+typedef struct _RygelExamplePlayerPrivate RygelExamplePlayerPrivate;
+
+struct _RygelExamplePlayer {
+ GObject parent_instance;
+ RygelExamplePlayerPrivate * priv;
+};
+
+struct _RygelExamplePlayerClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_example_player_get_type (void) G_GNUC_CONST;
+
+RygelExamplePlayer* rygel_example_player_new (void);
+
+G_END_DECLS
+
+#endif /* __RYGEL_EXAMPLE_PLAYER_H__ */
+
diff --git a/examples/renderer-plugins/C/example-renderer-plugin.c b/examples/renderer-plugins/C/example-renderer-plugin.c
new file mode 100644
index 0000000..eeaa0c7
--- /dev/null
+++ b/examples/renderer-plugins/C/example-renderer-plugin.c
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+#include "example-renderer-plugin.h"
+#include "example-player.h"
+
+#define RYGEL_EXAMPLE_RENDERER_PLUGIN_NAME "ExampleRenderPluginC"
+
+enum {
+ RYGEL_EXAMPLE_RENDERER_PLUGIN_DUMMY_PROPERTY
+};
+
+#define RYGEL_EXAMPLE_RENDERER_PLUGIN_TITLE "Example Render Plugin C"
+#define RYGEL_EXAMPLE_RENDERER_PLUGIN_DESCRIPTION "An example Rygel renderer plugin implemented in C."
+
+G_DEFINE_TYPE (RygelExampleRenderPlugin, rygel_example_renderer_plugin, RYGEL_TYPE_MEDIA_RENDERER_PLUGIN)
+
+void
+module_init (RygelPluginLoader* loader) {
+ RygelExampleRenderPlugin* plugin;
+
+ g_return_if_fail (loader != NULL);
+
+ if (rygel_plugin_loader_plugin_disabled (loader, RYGEL_EXAMPLE_RENDERER_PLUGIN_NAME)) {
+ g_message ("Plugin '%s' disabled by user. Ignoring.",
+ RYGEL_EXAMPLE_RENDERER_PLUGIN_NAME);
+ return;
+ }
+
+ plugin = rygel_example_renderer_plugin_new ();
+ rygel_plugin_loader_add_plugin (loader, RYGEL_PLUGIN (plugin));
+ g_object_unref (plugin);
+}
+
+
+RygelExampleRenderPlugin*
+rygel_example_renderer_plugin_construct (GType object_type) {
+ RygelExampleRenderPlugin *self;
+ RygelExampleRootContainer *root_container;
+
+ root_container =
+ rygel_example_root_container_new (RYGEL_EXAMPLE_RENDERER_PLUGIN_TITLE);
+ self = (RygelExampleRenderPlugin*) rygel_media_renderer_plugin_construct (object_type,
+ (RygelMediaContainer*) root_container, RYGEL_EXAMPLE_RENDERER_PLUGIN_NAME,
+ RYGEL_EXAMPLE_RENDERER_PLUGIN_DESCRIPTION, RYGEL_PLUGIN_CAPABILITIES_NONE);
+ g_object_unref (root_container);
+
+ return self;
+}
+
+
+RygelExampleRenderPlugin*
+rygel_example_renderer_plugin_new (void) {
+ return rygel_example_renderer_plugin_construct (RYGEL_EXAMPLE_TYPE_RENDERER_PLUGIN);
+}
+
+
+static void
+rygel_example_renderer_plugin_class_init (RygelExampleRenderPluginClass *klass) {
+}
+
+
+static void
+rygel_example_renderer_plugin_init (RygelExampleRenderPlugin *self) {
+}
+
+
diff --git a/examples/renderer-plugins/C/example-renderer-plugin.h b/examples/renderer-plugins/C/example-renderer-plugin.h
new file mode 100644
index 0000000..d8ed707
--- /dev/null
+++ b/examples/renderer-plugins/C/example-renderer-plugin.h
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+#ifndef __RYGEL_EXAMPLE_RENDERER_PLUGIN_H__
+#define __RYGEL_EXAMPLE_RENDERER_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <rygel-renderer.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_EXAMPLE_TYPE_RENDERER_PLUGIN (rygel_example_renderer_plugin_get_type ())
+#define RYGEL_EXAMPLE_RENDERER_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_EXAMPLE_TYPE_RENDERER_PLUGIN, RygelExampleRendererPlugin))
+#define RYGEL_EXAMPLE_RENDERER_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_EXAMPLE_TYPE_RENDERER_PLUGIN, RygelExampleRendererPluginClass))
+#define RYGEL_EXAMPLE_IS_RENDERER_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_EXAMPLE_TYPE_RENDERER_PLUGIN))
+#define RYGEL_EXAMPLE_IS_RENDERER_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_EXAMPLE_TYPE_RENDERER_PLUGIN))
+#define RYGEL_EXAMPLE_RENDERER_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_EXAMPLE_TYPE_RENDERER_PLUGIN, RygelExampleRendererPluginClass))
+
+typedef struct _RygelExampleRendererPlugin RygelExampleRendererPlugin;
+typedef struct _RygelExampleRendererPluginClass RygelExampleRendererPluginClass;
+typedef struct _RygelExampleRendererPluginPrivate RygelExampleRendererPluginPrivate;
+
+struct _RygelExampleRendererPlugin {
+ RygelMediaRendererPlugin parent_instance;
+ RygelExampleRendererPluginPrivate * priv;
+};
+
+struct _RygelExampleRendererPluginClass {
+ RygelMediaRendererPluginClass parent_class;
+};
+
+GType rygel_example_renderer_plugin_get_type (void) G_GNUC_CONST;
+
+RygelExampleRendererPlugin* rygel_example_renderer_plugin_new (void);
+
+void module_init (RygelPluginLoader* loader);
+
+G_END_DECLS
+
+#endif /* __RYGEL_EXAMPLE_RENDERER_PLUGIN_H__ */
+
diff --git a/examples/renderer-plugins/Makefile.am b/examples/renderer-plugins/Makefile.am
index ecd5d25..3557251 100644
--- a/examples/renderer-plugins/Makefile.am
+++ b/examples/renderer-plugins/Makefile.am
@@ -1,2 +1,2 @@
-SUBDIRS = vala
+SUBDIRS = vala C
diff --git a/examples/server-plugins/C/example-server-plugin.c b/examples/server-plugins/C/example-server-plugin.c
index 41c8802..cc396eb 100644
--- a/examples/server-plugins/C/example-server-plugin.c
+++ b/examples/server-plugins/C/example-server-plugin.c
@@ -28,7 +28,7 @@ enum {
};
#define RYGEL_EXAMPLE_SERVER_PLUGIN_TITLE "Example Server Plugin C"
-#define RYGEL_EXAMPLE_SERVER_PLUGIN_DESCRIPTION "An example Rygel server plugin implemented in vala."
+#define RYGEL_EXAMPLE_SERVER_PLUGIN_DESCRIPTION "An example Rygel server plugin implemented in C."
G_DEFINE_TYPE (RygelExampleServerPlugin, rygel_example_server_plugin, RYGEL_TYPE_MEDIA_SERVER_PLUGIN)
@@ -39,7 +39,7 @@ module_init (RygelPluginLoader* loader) {
g_return_if_fail (loader != NULL);
if (rygel_plugin_loader_plugin_disabled (loader, RYGEL_EXAMPLE_SERVER_PLUGIN_NAME)) {
- g_message ("example-server-plugin.vala:26: Plugin '%s' disabled by user. Ignoring.",
+ g_message ("Plugin '%s' disabled by user. Ignoring.",
RYGEL_EXAMPLE_SERVER_PLUGIN_NAME);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]