examples: Fix C renderer example
authorJens Georg <jensg@openismus.com>
Wed, 12 Dec 2012 20:03:25 +0000 (21:03 +0100)
committerJens Georg <jensg@openismus.com>
Wed, 12 Dec 2012 20:03:25 +0000 (21:03 +0100)
examples/renderer-plugins/C/Makefile.am
examples/renderer-plugins/C/example-player.c
examples/renderer-plugins/C/example-renderer-plugin.c

index be7685c..f77c225 100644 (file)
@@ -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
 
index 430fae8..ea833fc 100644 (file)
@@ -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);
index eeaa0c7..26a72d5 100644 (file)
@@ -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) {
 }