rygel r332 - in trunk: . src/plugins src/plugins/test



Author: zeeshanak
Date: Sun Dec 14 20:21:18 2008
New Revision: 332
URL: http://svn.gnome.org/viewvc/rygel?rev=332&view=rev

Log:
Basic skeleton for test plugin.

A test plugin that is supposed to host test media, mainly meant for
testing the new Streaming API and hopefully the transcoding API
that will follow soon.

Added:
   trunk/src/plugins/test/
   trunk/src/plugins/test/Makefile.am
   trunk/src/plugins/test/rygel-test-audio-item.vala
   trunk/src/plugins/test/rygel-test-content-dir.vala
   trunk/src/plugins/test/rygel-test-item.vala
   trunk/src/plugins/test/rygel-test-plugin.vala
Modified:
   trunk/configure.ac
   trunk/src/plugins/Makefile.am

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sun Dec 14 20:21:18 2008
@@ -120,6 +120,7 @@
 src/rygel/Makefile
 src/plugins/Makefile
 src/plugins/tracker/Makefile
+src/plugins/test/Makefile
 data/Makefile
 data/xml/Makefile
 ])

Modified: trunk/src/plugins/Makefile.am
==============================================================================
--- trunk/src/plugins/Makefile.am	(original)
+++ trunk/src/plugins/Makefile.am	Sun Dec 14 20:21:18 2008
@@ -1,3 +1,3 @@
-SUBDIRS = tracker
+SUBDIRS = tracker test
 
 MAINTAINERCLEANFILES = Makefile.in

Added: trunk/src/plugins/test/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/src/plugins/test/Makefile.am	Sun Dec 14 20:21:18 2008
@@ -0,0 +1,43 @@
+plugindir = $(libdir)/rygel-1.0
+
+plugin_LTLIBRARIES = librygel-test.la
+
+AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
+	    $(LIBGUPNP_AV_CFLAGS) \
+	    $(LIBDBUS_GLIB_CFLAGS) \
+	    $(GEE_CFLAGS) \
+	    -I$(top_srcdir)/src/rygel -DDATA_DIR='"$(datadir)"'
+
+BUILT_SOURCES = rygel-test.stamp \
+		rygel-test-content-dir.h \
+		rygel-test-content-dir.c \
+		rygel-test-audio-item.h \
+		rygel-test-audio-item.c \
+		rygel-test-plugin.h \
+		rygel-test-plugin.c
+
+librygel_test_la_SOURCES = rygel-test-content-dir.h \
+			   rygel-test-content-dir.c \
+                           rygel-test-content-dir.vala \
+                           rygel-test-audio-item.h \
+                           rygel-test-audio-item.c \
+                           rygel-test-audio-item.vala \
+                           rygel-test-plugin.h \
+                           rygel-test-plugin.c \
+                           rygel-test-plugin.vala
+
+rygel-test.stamp: $(filter %.vala,$(librygel_test_la_SOURCES))
+	$(VALAC) -C --vapidir=$(top_srcdir)/src/rygel \
+	--pkg rygel-1.0 --pkg cstuff \
+	--pkg gupnp-1.0 --pkg gupnp-av-1.0 --pkg dbus-glib-1 --pkg gee-1.0 $^
+	touch $@
+
+librygel_test_la_LIBADD = $(LIBGUPNP_LIBS) \
+			  $(LIBGUPNP_AV_LIBS) \
+                          $(LIBDBUS_GLIB_LIBS) \
+                          $(GEE_LIBS)
+librygel_test_la_LDFLAGS = -shared -fPIC -module -avoid-version
+
+CLEANFILES = $(BUILT_SOURCES)
+MAINTAINERCLEANFILES = Makefile.in
+

Added: trunk/src/plugins/test/rygel-test-audio-item.vala
==============================================================================
--- (empty file)
+++ trunk/src/plugins/test/rygel-test-audio-item.vala	Sun Dec 14 20:21:18 2008
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ */
+
+using Rygel;
+using GUPnP;
+using DBus;
+
+/**
+ * Represents Test audio item.
+ */
+public class Rygel.TestAudioItem : Rygel.MediaItem {
+    public TestAudioItem (string   id,
+                          string   parent_id,
+                          string   title,
+                          Streamer streamer) {
+        base (id, parent_id, title, MediaItem.AUDIO_CLASS);
+    }
+
+    public override void serialize (DIDLLiteWriter didl_writer) {
+        this.mime = "audio/wav";
+        this.author = "Zeeshan Ali (Khattak)";
+        //this.uri = this.uri_from_path (path);
+
+        base.serialize (didl_writer);
+    }
+}
+

Added: trunk/src/plugins/test/rygel-test-content-dir.vala
==============================================================================
--- (empty file)
+++ trunk/src/plugins/test/rygel-test-content-dir.vala	Sun Dec 14 20:21:18 2008
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ */
+
+using Rygel;
+using GUPnP;
+using DBus;
+
+/**
+ * Implementation of ContentDirectory service, meant for testing purposes only.
+ */
+public class Rygel.TestContentDir : ContentDirectory {
+    private List<MediaItem> items;
+
+    /* Pubic methods */
+    public override void constructed () {
+        // Chain-up to base first
+        base.constructed ();
+
+        Streamer streamer = new Streamer (context);
+
+        this.items = new List<MediaItem> ();
+        this.items.append (new TestAudioItem ("testaudio",
+                                              this.root_container.id,
+                                              "testaudio",
+                                              streamer));
+
+        // Now we know how many top-level items we have
+        this.root_container.child_count = this.items.length ();
+    }
+
+    public override void add_metadata (DIDLLiteWriter didl_writer,
+                                       BrowseArgs     args) throws GLib.Error {
+        MediaItem item = find_item_by_id (args.object_id);
+        if (item == null) {
+            throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object");
+        }
+
+        item.serialize (didl_writer);
+        args.update_id = uint32.MAX;
+    }
+
+    public override void add_root_children_metadata (DIDLLiteWriter didl_writer,
+                                                     BrowseArgs     args)
+                                                     throws GLib.Error {
+        foreach (MediaItem item in this.items)
+            item.serialize (didl_writer);
+
+        args.total_matches = args.number_returned = this.items.length ();
+        args.update_id = uint32.MAX;
+    }
+
+    /* Private methods */
+    private MediaItem? find_item_by_id (string item_id) {
+        MediaItem item = null;
+
+        foreach (MediaItem tmp in this.items) {
+            if (item_id == tmp.id) {
+                item = tmp;
+
+                break;
+            }
+        }
+
+        return item;
+    }
+}
+

Added: trunk/src/plugins/test/rygel-test-item.vala
==============================================================================
--- (empty file)
+++ trunk/src/plugins/test/rygel-test-item.vala	Sun Dec 14 20:21:18 2008
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ */
+
+using Rygel;
+using GUPnP;
+using DBus;
+
+/**
+ * Represents Test item.
+ */
+public abstract class Rygel.TestItem : MediaItem {
+    protected string parent_id;
+
+    public TestItem (string id,
+                     string parent_id,
+                     string title) {
+        this.id = id;
+        this.parent_id = parent_id;
+        this.title = title;
+    }
+}
+

Added: trunk/src/plugins/test/rygel-test-plugin.vala
==============================================================================
--- (empty file)
+++ trunk/src/plugins/test/rygel-test-plugin.vala	Sun Dec 14 20:21:18 2008
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ */
+
+using Rygel;
+using Gee;
+using CStuff;
+
+[ModuleInit]
+public Plugin load_plugin () {
+    Plugin plugin = new Plugin ("Test");
+
+    // We only implement a ContentDirectory service
+    var resource_info = new ResourceInfo (ContentDirectory.UPNP_ID,
+                                          ContentDirectory.UPNP_TYPE,
+                                          ContentDirectory.DESCRIPTION_PATH,
+                                          typeof (TestContentDir));
+
+    plugin.add_resource (resource_info);
+
+    return plugin;
+}
+



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