* 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";
}
}
- 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);
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)
}
}
- 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;
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,
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;
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) {
return item;
}
+ /* Private methods */
private void on_item_requested (HTTPServer http_server,
string item_id,
out MediaItem item) {
* 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;
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 */
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,
*/
using GUPnP;
+using Gee;
/**
* Errors used by ContentDirectory and deriving classes.
"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;
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");
}
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;
+ }
}