rygel r492 - in trunk/src: plugins/dvb plugins/test plugins/tracker rygel
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r492 - in trunk/src: plugins/dvb plugins/test plugins/tracker rygel
- Date: Wed, 28 Jan 2009 12:33:04 +0000 (UTC)
Author: zeeshanak
Date: Wed Jan 28 12:33:04 2009
New Revision: 492
URL: http://svn.gnome.org/viewvc/rygel?rev=492&view=rev
Log:
Free ContentDirectory implementations from DIDL-Lite handling.
Modified:
trunk/src/plugins/dvb/rygel-dvb-content-dir.vala
trunk/src/plugins/test/rygel-test-content-dir.vala
trunk/src/plugins/tracker/rygel-media-tracker.vala
trunk/src/rygel/rygel-content-directory.vala
Modified: trunk/src/plugins/dvb/rygel-dvb-content-dir.vala
==============================================================================
--- trunk/src/plugins/dvb/rygel-dvb-content-dir.vala (original)
+++ trunk/src/plugins/dvb/rygel-dvb-content-dir.vala Wed Jan 28 12:33:04 2009
@@ -31,8 +31,6 @@
* Implementation of DVB ContentDirectory service.
*/
public class Rygel.DVBContentDir : ContentDirectory {
- public static const int MAX_REQUESTED_COUNT = 128;
-
// class-wide constants
private const string DVB_SERVICE = "org.gnome.DVB";
private const string MANAGER_PATH = "/org/gnome/DVB/Manager";
@@ -101,79 +99,8 @@
}
}
- public override void add_children_metadata (DIDLLiteWriter didl_writer,
- BrowseArgs args)
- throws GLib.Error {
- if (args.requested_count == 0)
- args.requested_count = MAX_REQUESTED_COUNT;
-
- ArrayList<MediaItem> children;
-
- children = this.get_children (args.object_id,
- args.index,
- args.requested_count,
- out args.total_matches);
- args.number_returned = children.size;
-
- /* Iterate through all items */
- for (int i = 0; i < children.size; i++) {
- children[i].serialize (didl_writer);
- }
-
- args.update_id = uint32.MAX;
- }
-
- public override void add_metadata (DIDLLiteWriter didl_writer,
- BrowseArgs args) throws GLib.Error {
- MediaObject media_object = find_object_by_id (args.object_id);
- media_object.serialize (didl_writer);
-
- args.update_id = uint32.MAX;
- }
-
- public override void add_root_children_metadata (DIDLLiteWriter didl_writer,
- BrowseArgs args)
- throws GLib.Error {
- var children = get_root_children (args.index,
- args.requested_count,
- out args.total_matches);
- foreach (var child in children) {
- child.serialize (didl_writer);
- }
-
- args.number_returned = children.size;
- args.update_id = uint32.MAX;
- }
-
- // Private methods
- private DVBChannelGroup? find_group_by_id (string id) {
- DVBChannelGroup group = null;
-
- foreach (DVBChannelGroup tmp in this.groups) {
- if (id == tmp.id) {
- group = tmp;
-
- break;
- }
- }
-
- return group;
- }
-
- private DVBChannel find_channel_by_id (string id) throws GLib.Error {
- DVBChannel channel = null;
-
- foreach (DVBChannelGroup group in this.groups) {
- channel = group.find_channel (id);
- if (channel != null) {
- break;
- }
- }
-
- return channel;
- }
-
- private MediaObject find_object_by_id (string object_id) throws GLib.Error {
+ public override MediaObject find_object_by_id (string object_id)
+ throws GLib.Error {
// First try groups
MediaObject media_object = find_group_by_id (object_id);
@@ -188,7 +115,8 @@
return media_object;
}
- private ArrayList<MediaObject> get_children (string container_id,
+ public override ArrayList<MediaObject> get_children (
+ string container_id,
uint offset,
uint max_count,
out uint child_count)
@@ -210,10 +138,11 @@
}
}
- private ArrayList<MediaObject> get_root_children (uint offset,
- uint max_count,
- out uint child_count)
- throws GLib.Error {
+ public override ArrayList<MediaObject> get_root_children (
+ uint offset,
+ uint max_count,
+ out uint child_count)
+ throws GLib.Error {
child_count = this.groups.size;
ArrayList<MediaObject> children;
@@ -231,6 +160,34 @@
return children;
}
+ // Private methods
+ private DVBChannelGroup? find_group_by_id (string id) {
+ DVBChannelGroup group = null;
+
+ foreach (DVBChannelGroup tmp in this.groups) {
+ if (id == tmp.id) {
+ group = tmp;
+
+ break;
+ }
+ }
+
+ return group;
+ }
+
+ private DVBChannel find_channel_by_id (string id) throws GLib.Error {
+ DVBChannel channel = null;
+
+ foreach (DVBChannelGroup group in this.groups) {
+ channel = group.find_channel (id);
+ if (channel != null) {
+ break;
+ }
+ }
+
+ return channel;
+ }
+
private ArrayList<MediaObject> slice_object_list (
ArrayList<MediaObject> list,
uint offset,
Modified: trunk/src/plugins/test/rygel-test-content-dir.vala
==============================================================================
--- trunk/src/plugins/test/rygel-test-content-dir.vala (original)
+++ trunk/src/plugins/test/rygel-test-content-dir.vala Wed Jan 28 12:33:04 2009
@@ -55,32 +55,11 @@
this.root_container.child_count = this.items.size;
}
- public override void add_metadata (DIDLLiteWriter didl_writer,
- BrowseArgs args) throws GLib.Error {
- MediaObject media_object = find_object_by_id (args.object_id);
- media_object.serialize (didl_writer);
-
- args.update_id = uint32.MAX;
- }
-
- public override void add_root_children_metadata (DIDLLiteWriter didl_writer,
- BrowseArgs args)
- throws GLib.Error {
- var children = get_root_children (args.index,
- args.requested_count,
- out args.total_matches);
- foreach (var child in children) {
- child.serialize (didl_writer);
- }
-
- args.number_returned = children.size;
- args.update_id = uint32.MAX;
- }
-
- private ArrayList<MediaObject> get_root_children (uint offset,
- uint max_count,
- out uint child_count)
- throws GLib.Error {
+ public override ArrayList<MediaObject> get_root_children (
+ uint offset,
+ uint max_count,
+ out uint child_count)
+ throws GLib.Error {
child_count = this.items.size;
ArrayList<MediaObject> children;
@@ -98,8 +77,8 @@
return children;
}
- /* Private methods */
- private MediaObject find_object_by_id (string object_id) throws GLib.Error {
+ public override MediaObject find_object_by_id (string object_id)
+ throws GLib.Error {
MediaItem item = null;
foreach (MediaItem tmp in this.items) {
@@ -117,6 +96,7 @@
return item;
}
+ /* Private methods */
private void on_item_requested (HTTPServer http_server,
string item_id,
out MediaItem item) {
Modified: trunk/src/plugins/tracker/rygel-media-tracker.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-media-tracker.vala (original)
+++ trunk/src/plugins/tracker/rygel-media-tracker.vala Wed Jan 28 12:33:04 2009
@@ -30,8 +30,6 @@
* Implementation of Tracker-based ContentDirectory service.
*/
public class Rygel.MediaTracker : ContentDirectory {
- public static const int MAX_REQUESTED_COUNT = 128;
-
/* FIXME: Make this a static if you know how to initize it */
private ArrayList<TrackerContainer> containers;
@@ -73,48 +71,62 @@
this.search_parser = new SearchCriteriaParser ();
}
- public override void add_children_metadata (DIDLLiteWriter didl_writer,
- BrowseArgs args)
- throws GLib.Error {
- if (args.requested_count == 0)
- args.requested_count = MAX_REQUESTED_COUNT;
+ public override ArrayList<MediaObject> get_children (
+ string container_id,
+ uint offset,
+ uint max_count,
+ out uint child_count)
+ throws GLib.Error {
+ var container = this.find_container_by_id (container_id);
+ if (container == null) {
+ throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object");
+ }
- ArrayList<MediaItem> children;
+ return container.get_children_from_db (offset,
+ max_count,
+ out child_count);
+ }
+
+ public override MediaObject find_object_by_id (string object_id)
+ throws GLib.Error {
+ /* First try containers */
+ MediaObject media_object = find_container_by_id (object_id);
- children = this.get_children (args.object_id,
- args.index,
- args.requested_count,
- out args.total_matches);
- args.number_returned = children.size;
+ if (media_object == null) {
+ /* Now try items */
+ var container = get_item_parent (object_id);
+
+ if (container != null)
+ media_object = container.get_item_from_db (object_id);
+ }
- /* Iterate through all items */
- for (int i = 0; i < children.size; i++) {
- children[i].serialize (didl_writer);
+ if (media_object == null) {
+ throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object");
}
- args.update_id = uint32.MAX;
+ return media_object;
}
- public override void add_metadata (DIDLLiteWriter didl_writer,
- BrowseArgs args) throws GLib.Error {
- MediaObject media_object = find_object_by_id (args.object_id);
- media_object.serialize (didl_writer);
+ public override ArrayList<MediaObject> get_root_children (
+ uint offset,
+ uint max_count,
+ out uint child_count)
+ throws GLib.Error {
+ child_count = this.containers.size;
- args.update_id = uint32.MAX;
- }
+ ArrayList<MediaObject> children;
- public override void add_root_children_metadata (DIDLLiteWriter didl_writer,
- BrowseArgs args)
- throws GLib.Error {
- var children = get_root_children (args.index,
- args.requested_count,
- out args.total_matches);
- foreach (var child in children) {
- child.serialize (didl_writer);
+ if (max_count == 0 && offset == 0) {
+ children = this.containers;
+ } else if (offset >= child_count) {
+ throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object");
+ } else {
+ children = slice_object_list (this.containers,
+ offset,
+ max_count);
}
- args.number_returned = children.size;
- args.update_id = uint32.MAX;
+ return children;
}
/* Private methods */
@@ -167,61 +179,6 @@
item = container.get_item_from_db (item_id);
}
- private ArrayList<MediaObject> get_children (string container_id,
- uint offset,
- uint max_count,
- out uint child_count)
- throws GLib.Error {
- var container = this.find_container_by_id (container_id);
- if (container == null) {
- throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object");
- }
-
- return container.get_children_from_db (offset,
- max_count,
- out child_count);
- }
-
- private MediaObject find_object_by_id (string object_id) throws GLib.Error {
- /* First try containers */
- MediaObject media_object = find_container_by_id (object_id);
-
- if (media_object == null) {
- /* Now try items */
- var container = get_item_parent (object_id);
-
- if (container != null)
- media_object = container.get_item_from_db (object_id);
- }
-
- if (media_object == null) {
- throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object");
- }
-
- return media_object;
- }
-
- private ArrayList<MediaObject> get_root_children (uint offset,
- uint max_count,
- out uint child_count)
- throws GLib.Error {
- child_count = this.containers.size;
-
- ArrayList<MediaObject> children;
-
- if (max_count == 0 && offset == 0) {
- children = this.containers;
- } else if (offset >= child_count) {
- throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object");
- } else {
- children = slice_object_list (this.containers,
- offset,
- max_count);
- }
-
- return children;
- }
-
private ArrayList<MediaObject> slice_object_list (
ArrayList<MediaObject> list,
uint offset,
Modified: trunk/src/rygel/rygel-content-directory.vala
==============================================================================
--- trunk/src/rygel/rygel-content-directory.vala (original)
+++ trunk/src/rygel/rygel-content-directory.vala Wed Jan 28 12:33:04 2009
@@ -23,6 +23,7 @@
*/
using GUPnP;
+using Gee;
/**
* Errors used by ContentDirectory and deriving classes.
@@ -58,6 +59,8 @@
"urn:schemas-upnp-org:service:ContentDirectory:2";
public const string DESCRIPTION_PATH = "xml/ContentDirectory.xml";
+ public const int MAX_REQUESTED_COUNT = 128;
+
protected uint32 system_update_id;
protected string feature_list;
protected string search_caps;
@@ -70,20 +73,24 @@
DIDLLiteWriter didl_writer;
// Public abstract methods derived classes need to implement
- public virtual void add_children_metadata (DIDLLiteWriter didl_writer,
- BrowseArgs args)
- throws Error {
+ public virtual ArrayList<MediaObject> get_children (string container_id,
+ uint offset,
+ uint max_count,
+ out uint child_count)
+ throws GLib.Error {
throw new ServerError.NOT_IMPLEMENTED ("Not Implemented\n");
}
- public virtual void add_metadata (DIDLLiteWriter didl_writer,
- BrowseArgs args) throws Error {
+ public virtual MediaObject find_object_by_id (string object_id)
+ throws GLib.Error {
throw new ServerError.NOT_IMPLEMENTED ("Not Implemented\n");
}
- public virtual void add_root_children_metadata
- (DIDLLiteWriter didl_writer,
- BrowseArgs args) throws Error {
+ public virtual ArrayList<MediaObject> get_root_children (
+ uint offset,
+ uint max_count,
+ out uint child_count)
+ throws GLib.Error {
throw new ServerError.NOT_IMPLEMENTED ("Not Implemented\n");
}
@@ -316,5 +323,51 @@
action.return ();
}
+
+ protected virtual void add_children_metadata (DIDLLiteWriter didl_writer,
+ BrowseArgs args)
+ throws GLib.Error {
+ if (args.requested_count == 0)
+ args.requested_count = MAX_REQUESTED_COUNT;
+
+ ArrayList<MediaItem> children;
+
+ children = this.get_children (args.object_id,
+ args.index,
+ args.requested_count,
+ out args.total_matches);
+ args.number_returned = children.size;
+
+ /* Iterate through all items */
+ for (int i = 0; i < children.size; i++) {
+ children[i].serialize (didl_writer);
+ }
+
+ args.update_id = uint32.MAX;
+ }
+
+ protected virtual void add_metadata (DIDLLiteWriter didl_writer,
+ BrowseArgs args)
+ throws GLib.Error {
+ MediaObject media_object = find_object_by_id (args.object_id);
+ media_object.serialize (didl_writer);
+
+ args.update_id = uint32.MAX;
+ }
+
+ protected virtual void add_root_children_metadata (
+ DIDLLiteWriter didl_writer,
+ BrowseArgs args)
+ throws GLib.Error {
+ var children = get_root_children (args.index,
+ args.requested_count,
+ out args.total_matches);
+ foreach (var child in children) {
+ child.serialize (didl_writer);
+ }
+
+ args.number_returned = children.size;
+ args.update_id = uint32.MAX;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]