From: Zeeshan Ali (Khattak) Date: Sun, 14 Dec 2008 20:21:18 +0000 (+0000) Subject: Basic skeleton for test plugin. X-Git-Tag: RYGEL_0_2~141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=817691beb60b0c3ce94e390f979839d9110c1d2f;p=profile%2Fivi%2Frygel.git 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. svn path=/trunk/; revision=332 --- diff --git a/configure.ac b/configure.ac index 3beaada..a4768f0 100644 --- a/configure.ac +++ b/configure.ac @@ -120,6 +120,7 @@ src/Makefile src/rygel/Makefile src/plugins/Makefile src/plugins/tracker/Makefile +src/plugins/test/Makefile data/Makefile data/xml/Makefile ]) diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index a603d78..1eba5b9 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -1,3 +1,3 @@ -SUBDIRS = tracker +SUBDIRS = tracker test MAINTAINERCLEANFILES = Makefile.in diff --git a/src/plugins/test/Makefile.am b/src/plugins/test/Makefile.am new file mode 100644 index 0000000..f79cc24 --- /dev/null +++ b/src/plugins/test/Makefile.am @@ -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 + diff --git a/src/plugins/test/rygel-test-audio-item.vala b/src/plugins/test/rygel-test-audio-item.vala new file mode 100644 index 0000000..f9bbbee --- /dev/null +++ b/src/plugins/test/rygel-test-audio-item.vala @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2008 Zeeshan Ali (Khattak) . + * Copyright (C) 2008 Nokia Corporation, all rights reserved. + * + * Author: Zeeshan Ali (Khattak) + * + * + * 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); + } +} + diff --git a/src/plugins/test/rygel-test-content-dir.vala b/src/plugins/test/rygel-test-content-dir.vala new file mode 100644 index 0000000..319b525 --- /dev/null +++ b/src/plugins/test/rygel-test-content-dir.vala @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2008 Zeeshan Ali (Khattak) . + * Copyright (C) 2008 Nokia Corporation, all rights reserved. + * + * Author: Zeeshan Ali (Khattak) + * + * + * 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 items; + + /* Pubic methods */ + public override void constructed () { + // Chain-up to base first + base.constructed (); + + Streamer streamer = new Streamer (context); + + this.items = new List (); + 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; + } +} + diff --git a/src/plugins/test/rygel-test-item.vala b/src/plugins/test/rygel-test-item.vala new file mode 100644 index 0000000..2e2707b --- /dev/null +++ b/src/plugins/test/rygel-test-item.vala @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2008 Zeeshan Ali (Khattak) . + * Copyright (C) 2008 Nokia Corporation, all rights reserved. + * + * Author: Zeeshan Ali (Khattak) + * + * + * 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; + } +} + diff --git a/src/plugins/test/rygel-test-plugin.vala b/src/plugins/test/rygel-test-plugin.vala new file mode 100644 index 0000000..7dcc05f --- /dev/null +++ b/src/plugins/test/rygel-test-plugin.vala @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2008 Zeeshan Ali (Khattak) . + * Copyright (C) 2008 Nokia Corporation, all rights reserved. + * + * Author: Zeeshan Ali (Khattak) + * + * + * 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; +} +