[rygel] examples: Add a C version of the example server plugin



commit b5d5d002966dd6ae301ecc8b49b726f0f65d9392
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Nov 19 11:53:32 2012 +0100

    examples: Add a C version of the example server plugin

 configure.ac                                       |    1 +
 examples/server-plugins/C/Makefile.am              |   30 +++++++
 examples/server-plugins/C/example-root-container.c |   81 +++++++++++++++++++
 examples/server-plugins/C/example-root-container.h |   57 +++++++++++++
 examples/server-plugins/C/example-server-plugin.c  |   84 ++++++++++++++++++++
 examples/server-plugins/C/example-server-plugin.h  |   59 ++++++++++++++
 examples/server-plugins/Makefile.am                |    2 +-
 7 files changed, 313 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0457848..59b2286 100644
--- a/configure.ac
+++ b/configure.ac
@@ -313,6 +313,7 @@ examples/renderer-plugins/Makefile
 examples/renderer-plugins/vala/Makefile
 examples/server-plugins/Makefile
 examples/server-plugins/vala/Makefile
+examples/server-plugins/C/Makefile
 ])
 AC_OUTPUT
 
diff --git a/examples/server-plugins/C/Makefile.am b/examples/server-plugins/C/Makefile.am
new file mode 100644
index 0000000..2424f55
--- /dev/null
+++ b/examples/server-plugins/C/Makefile.am
@@ -0,0 +1,30 @@
+include $(top_srcdir)/common.am
+
+plugin_LTLIBRARIES = librygel-example-server-plugin-c.la
+
+AM_CFLAGS += -DG_LOG_DOMAIN='"ExampleServerPluginC"'
+
+librygel_example_server_plugin_c_la_SOURCES = \
+	example-server-plugin.h \
+	example-server-plugin.c \
+	example-root-container.h \
+	example-root-container.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_server_includes = -I$(top_builddir)/src/librygel-server $(if $(srcdir:.=),-I$(top_srcdir)/src/librygel-server)
+
+librygel_example_server_plugin_c_la_CFLAGS = \
+	$(LIBGSTREAMER_CFLAGS) \
+	$(LIBGUPNP_CFLAGS) \
+	$(LIBGUPNP_AV_CFLAGS) \
+	$(GEE_CFLAGS) \
+	$(librygel_core_includes) \
+	$(librygel_server_includes)
+
+librygel_example_server_plugin_c_la_LIBADD = \
+	$(LIBGSTREAMER_LIBS) \
+	$(RYGEL_COMMON_SERVER_LIBS)
+	
+librygel_example_server_plugin_c_la_LDFLAGS = \
+	$(RYGEL_PLUGIN_LINKER_FLAGS)
diff --git a/examples/server-plugins/C/example-root-container.c b/examples/server-plugins/C/example-root-container.c
new file mode 100644
index 0000000..725fc01
--- /dev/null
+++ b/examples/server-plugins/C/example-root-container.c
@@ -0,0 +1,81 @@
+/* example-root-container.c generated by valac 0.17.2.16-90889, the Vala compiler
+ * generated from example-root-container.vala, do not modify */
+
+/*
+ * 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-root-container.h"
+
+/**
+ * Our derived MediaContainer.
+ * In this example, we just derive from the SimpleContainer,
+ * but a real-world server plugin might need something more sophisticated.
+ */
+
+enum  {
+  RYGEL_EXAMPLE_ROOT_CONTAINER_DUMMY_PROPERTY
+};
+
+G_DEFINE_TYPE (RygelExampleRootContainer, rygel_example_root_container, RYGEL_TYPE_SIMPLE_CONTAINER)
+
+RygelExampleRootContainer* rygel_example_root_container_new (const gchar *title);
+
+static RygelExampleRootContainer*
+rygel_example_root_container_construct (GType object_type, const gchar *title) {
+  RygelExampleRootContainer *self;
+  RygelMediaItem *item;
+
+  g_return_val_if_fail (title != NULL, NULL);
+  
+  self = (RygelExampleRootContainer*) rygel_simple_container_construct_root (object_type, title);
+
+  item = rygel_music_item_new ("test 1", (RygelMediaContainer*) self, "Test 1", RYGEL_MUSIC_ITEM_UPNP_CLASS);
+  rygel_media_item_add_uri (item, "file:///home/murrayc/Music/Madness/05_Baggy_Trousers.mp3");
+  rygel_media_item_set_mime_type (item, "audio/mpeg");
+  rygel_simple_container_add_child_item ((RygelSimpleContainer*) self, item);
+  g_object_unref (item);
+  
+  item = rygel_music_item_new ("test 2", (RygelMediaContainer*) self, "Test 1", RYGEL_MUSIC_ITEM_UPNP_CLASS);
+  rygel_media_item_add_uri (item, "file:///home/murrayc/Music/08%20Busload%20of%20Faith.mp3");
+  rygel_media_item_set_mime_type (item, "audio/mpeg");
+  rygel_simple_container_add_child_item ((RygelSimpleContainer*) self, item);
+  g_object_unref (item);
+
+  return self;
+}
+
+
+RygelExampleRootContainer*
+rygel_example_root_container_new (const gchar *title) {
+  return rygel_example_root_container_construct (RYGEL_EXAMPLE_TYPE_ROOT_CONTAINER, title);
+}
+
+
+static void
+rygel_example_root_container_class_init (RygelExampleRootContainerClass *klass) {
+}
+
+
+static void
+rygel_example_root_container_init (RygelExampleRootContainer *self) {
+}
+
+
+
diff --git a/examples/server-plugins/C/example-root-container.h b/examples/server-plugins/C/example-root-container.h
new file mode 100644
index 0000000..ad5f56b
--- /dev/null
+++ b/examples/server-plugins/C/example-root-container.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_ROOT_CONTAINER_H__
+#define __RYGEL_EXAMPLE_ROOT_CONTAINER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <rygel-server.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_EXAMPLE_TYPE_ROOT_CONTAINER (rygel_example_root_container_get_type ())
+#define RYGEL_EXAMPLE_ROOT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_EXAMPLE_TYPE_ROOT_CONTAINER, RygelExampleRootContainer))
+#define RYGEL_EXAMPLE_ROOT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_EXAMPLE_TYPE_ROOT_CONTAINER, RygelExampleRootContainerClass))
+#define RYGEL_EXAMPLE_IS_ROOT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_EXAMPLE_TYPE_ROOT_CONTAINER))
+#define RYGEL_EXAMPLE_IS_ROOT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_EXAMPLE_TYPE_ROOT_CONTAINER))
+#define RYGEL_EXAMPLE_ROOT_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_EXAMPLE_TYPE_ROOT_CONTAINER, RygelExampleRootContainerClass))
+
+typedef struct _RygelExampleRootContainer RygelExampleRootContainer;
+typedef struct _RygelExampleRootContainerClass RygelExampleRootContainerClass;
+
+typedef struct _RygelExampleRootContainerPrivate RygelExampleRootContainerPrivate;
+
+struct _RygelExampleRootContainer {
+  RygelSimpleContainer parent_instance;
+  RygelExampleRootContainerPrivate * priv;
+};
+
+struct _RygelExampleRootContainerClass {
+  RygelSimpleContainerClass parent_class;
+};
+
+RygelExampleRootContainer* rygel_example_root_container_new (const gchar* title);
+
+GType rygel_example_root_container_get_type (void);
+
+G_END_DECLS
+
+#endif /* __RYGEL_EXAMPLE_ROOT_CONTAINER_H__ */
diff --git a/examples/server-plugins/C/example-server-plugin.c b/examples/server-plugins/C/example-server-plugin.c
new file mode 100644
index 0000000..41c8802
--- /dev/null
+++ b/examples/server-plugins/C/example-server-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-server-plugin.h"
+#include "example-root-container.h"
+
+#define RYGEL_EXAMPLE_SERVER_PLUGIN_NAME "ExampleServerPluginC"
+
+enum  {
+  RYGEL_EXAMPLE_SERVER_PLUGIN_DUMMY_PROPERTY
+};
+
+#define RYGEL_EXAMPLE_SERVER_PLUGIN_TITLE "Example Server Plugin C"
+#define RYGEL_EXAMPLE_SERVER_PLUGIN_DESCRIPTION "An example Rygel server plugin implemented in vala."
+
+G_DEFINE_TYPE (RygelExampleServerPlugin, rygel_example_server_plugin, RYGEL_TYPE_MEDIA_SERVER_PLUGIN)
+
+void
+module_init (RygelPluginLoader* loader) {
+  RygelExampleServerPlugin* plugin;
+
+  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.",
+      RYGEL_EXAMPLE_SERVER_PLUGIN_NAME);
+    return;
+  }
+
+  plugin = rygel_example_server_plugin_new ();
+  rygel_plugin_loader_add_plugin (loader, RYGEL_PLUGIN (plugin));
+  g_object_unref (plugin);
+}
+
+
+RygelExampleServerPlugin*
+rygel_example_server_plugin_construct (GType object_type) {
+  RygelExampleServerPlugin *self;
+  RygelExampleRootContainer *root_container;
+
+  root_container =
+    rygel_example_root_container_new (RYGEL_EXAMPLE_SERVER_PLUGIN_TITLE);
+  self = (RygelExampleServerPlugin*) rygel_media_server_plugin_construct (object_type,
+    (RygelMediaContainer*) root_container, RYGEL_EXAMPLE_SERVER_PLUGIN_NAME,
+    RYGEL_EXAMPLE_SERVER_PLUGIN_DESCRIPTION, RYGEL_PLUGIN_CAPABILITIES_NONE);
+  g_object_unref (root_container);
+
+  return self;
+}
+
+
+RygelExampleServerPlugin*
+rygel_example_server_plugin_new (void) {
+  return rygel_example_server_plugin_construct (RYGEL_EXAMPLE_TYPE_SERVER_PLUGIN);
+}
+
+
+static void
+rygel_example_server_plugin_class_init (RygelExampleServerPluginClass *klass) {
+}
+
+
+static void
+rygel_example_server_plugin_init (RygelExampleServerPlugin *self) {
+}
+
+
diff --git a/examples/server-plugins/C/example-server-plugin.h b/examples/server-plugins/C/example-server-plugin.h
new file mode 100644
index 0000000..0b552ae
--- /dev/null
+++ b/examples/server-plugins/C/example-server-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_SERVER_PLUGIN_H__
+#define __RYGEL_EXAMPLE_SERVER_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <rygel-server.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_EXAMPLE_TYPE_SERVER_PLUGIN (rygel_example_server_plugin_get_type ())
+#define RYGEL_EXAMPLE_SERVER_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_EXAMPLE_TYPE_SERVER_PLUGIN, RygelExampleServerPlugin))
+#define RYGEL_EXAMPLE_SERVER_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_EXAMPLE_TYPE_SERVER_PLUGIN, RygelExampleServerPluginClass))
+#define RYGEL_EXAMPLE_IS_SERVER_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_EXAMPLE_TYPE_SERVER_PLUGIN))
+#define RYGEL_EXAMPLE_IS_SERVER_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_EXAMPLE_TYPE_SERVER_PLUGIN))
+#define RYGEL_EXAMPLE_SERVER_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_EXAMPLE_TYPE_SERVER_PLUGIN, RygelExampleServerPluginClass))
+
+typedef struct _RygelExampleServerPlugin RygelExampleServerPlugin;
+typedef struct _RygelExampleServerPluginClass RygelExampleServerPluginClass;
+typedef struct _RygelExampleServerPluginPrivate RygelExampleServerPluginPrivate;
+
+struct _RygelExampleServerPlugin {
+  RygelMediaServerPlugin parent_instance;
+  RygelExampleServerPluginPrivate * priv;
+};
+
+struct _RygelExampleServerPluginClass {
+  RygelMediaServerPluginClass parent_class;
+};
+
+GType rygel_example_server_plugin_get_type (void) G_GNUC_CONST;
+
+RygelExampleServerPlugin* rygel_example_server_plugin_new (void);
+
+void module_init (RygelPluginLoader* loader);
+
+G_END_DECLS
+
+#endif /* __RYGEL_EXAMPLE_SERVER_PLUGIN_H__ */
+
diff --git a/examples/server-plugins/Makefile.am b/examples/server-plugins/Makefile.am
index ecd5d25..3557251 100644
--- a/examples/server-plugins/Makefile.am
+++ b/examples/server-plugins/Makefile.am
@@ -1,2 +1,2 @@
-SUBDIRS = vala
+SUBDIRS = vala C
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]