[rygel] examples: Fix C renderer example
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] examples: Fix C renderer example
- Date: Wed, 12 Dec 2012 20:13:13 +0000 (UTC)
commit 9015a2eef0cdd528aba2b4aa19e33dcd09107079
Author: Jens Georg <jensg openismus com>
Date: Wed Dec 12 21:03:25 2012 +0100
examples: Fix C renderer example
examples/renderer-plugins/C/Makefile.am | 2 +-
examples/renderer-plugins/C/example-player.c | 27 +++++++------
.../renderer-plugins/C/example-renderer-plugin.c | 42 +++++++++++++-------
3 files changed, 43 insertions(+), 28 deletions(-)
---
diff --git a/examples/renderer-plugins/C/Makefile.am b/examples/renderer-plugins/C/Makefile.am
index be7685c..f77c225 100644
--- a/examples/renderer-plugins/C/Makefile.am
+++ b/examples/renderer-plugins/C/Makefile.am
@@ -4,7 +4,7 @@ plugin_LTLIBRARIES = librygel-example-renderer-plugin-c.la
librygel_example_renderer_plugin_c_la_SOURCES = \
example-renderer-plugin.h \
- example-renderer-plugin.h \
+ example-renderer-plugin.c \
example-player.h \
example-player.c
diff --git a/examples/renderer-plugins/C/example-player.c b/examples/renderer-plugins/C/example-player.c
index 430fae8..ea833fc 100644
--- a/examples/renderer-plugins/C/example-player.c
+++ b/examples/renderer-plugins/C/example-player.c
@@ -86,6 +86,9 @@ rygel_example_player_real_get_duration (RygelMediaPlayer *base);
static gint64
rygel_example_player_real_get_position (RygelMediaPlayer *base);
+static gboolean
+rygel_example_player_real_get_can_seek (RygelMediaPlayer *base);
+
static void
_rygel_example_player_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
@@ -115,17 +118,8 @@ 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);
+ return g_object_new (RYGEL_EXAMPLE_TYPE_PLAYER, NULL);
}
@@ -148,6 +142,7 @@ rygel_example_player_rygel_media_player_interface_init (RygelMediaPlayerIface *i
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;
+ iface->get_can_seek = rygel_example_player_real_get_can_seek;
}
static void
@@ -241,7 +236,9 @@ rygel_example_player_class_init (RygelExamplePlayerClass *klass) {
static void
rygel_example_player_init (RygelExamplePlayer *self) {
- self->priv = RYGEL_EXAMPLE_PLAYER_GET_PRIVATE (self);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ RYGEL_EXAMPLE_TYPE_PLAYER,
+ RygelExamplePlayerPrivate);
self->priv->_playback_state = g_strdup ("NO_MEDIA_PRESENT");
self->priv->_uri = NULL;
@@ -414,6 +411,12 @@ rygel_example_player_real_get_position (RygelMediaPlayer *base) {
return self->priv->_position;
}
+static gboolean
+rygel_example_player_real_get_can_seek (RygelMediaPlayer *base) {
+ return FALSE;
+}
+
+
static void
_rygel_example_player_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) {
RygelMediaPlayer *base = RYGEL_MEDIA_PLAYER (object);
@@ -444,7 +447,7 @@ _rygel_example_player_get_property (GObject *object, guint property_id, GValue *
g_value_set_int64 (value, rygel_media_player_get_position (base));
break;
case RYGEL_EXAMPLE_PLAYER_CAN_SEEK:
- g_value_set_boolean (value, FALSE);
+ g_value_set_boolean (value, rygel_media_player_get_can_seek (base));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
diff --git a/examples/renderer-plugins/C/example-renderer-plugin.c b/examples/renderer-plugins/C/example-renderer-plugin.c
index eeaa0c7..26a72d5 100644
--- a/examples/renderer-plugins/C/example-renderer-plugin.c
+++ b/examples/renderer-plugins/C/example-renderer-plugin.c
@@ -21,7 +21,7 @@
#include "example-renderer-plugin.h"
#include "example-player.h"
-#define RYGEL_EXAMPLE_RENDERER_PLUGIN_NAME "ExampleRenderPluginC"
+#define RYGEL_EXAMPLE_RENDERER_PLUGIN_NAME "ExampleRendererPluginC"
enum {
RYGEL_EXAMPLE_RENDERER_PLUGIN_DUMMY_PROPERTY
@@ -30,11 +30,13 @@ enum {
#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)
+G_DEFINE_TYPE (RygelExampleRendererPlugin, rygel_example_renderer_plugin, RYGEL_TYPE_MEDIA_RENDERER_PLUGIN)
+
+static RygelExamplePlayer *player;
void
module_init (RygelPluginLoader* loader) {
- RygelExampleRenderPlugin* plugin;
+ RygelExampleRendererPlugin* plugin;
g_return_if_fail (loader != NULL);
@@ -50,35 +52,45 @@ module_init (RygelPluginLoader* loader) {
}
-RygelExampleRenderPlugin*
+RygelExampleRendererPlugin*
rygel_example_renderer_plugin_construct (GType object_type) {
- RygelExampleRenderPlugin *self;
- RygelExampleRootContainer *root_container;
+ RygelExampleRendererPlugin *self;
- 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);
+ self = (RygelExampleRendererPlugin*) rygel_media_renderer_plugin_construct (object_type,
+ RYGEL_EXAMPLE_RENDERER_PLUGIN_NAME, NULL, RYGEL_EXAMPLE_RENDERER_PLUGIN_DESCRIPTION,
+ RYGEL_PLUGIN_CAPABILITIES_NONE);
return self;
}
-RygelExampleRenderPlugin*
+RygelExampleRendererPlugin*
rygel_example_renderer_plugin_new (void) {
return rygel_example_renderer_plugin_construct (RYGEL_EXAMPLE_TYPE_RENDERER_PLUGIN);
}
+static RygelMediaPlayer *
+rygel_example_renderer_plugin_get_player (RygelMediaRendererPlugin* plugin)
+{
+ if (player == NULL) {
+ player = rygel_example_player_new ();
+ }
+
+ return RYGEL_EXAMPLE_PLAYER (g_object_ref (player));
+}
+
static void
-rygel_example_renderer_plugin_class_init (RygelExampleRenderPluginClass *klass) {
+rygel_example_renderer_plugin_class_init (RygelExampleRendererPluginClass *klass) {
+ RygelMediaRendererPluginClass *plugin_class;
+
+ plugin_class = RYGEL_EXAMPLE_RENDERER_PLUGIN_CLASS (klass);
+ plugin_class->get_player = rygel_example_renderer_plugin_get_player;
}
static void
-rygel_example_renderer_plugin_init (RygelExampleRenderPlugin *self) {
+rygel_example_renderer_plugin_init (RygelExampleRendererPlugin *self) {
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]