[rygel] core: List the resources according to compatiblity
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] core: List the resources according to compatiblity
- Date: Wed, 26 Aug 2009 11:46:12 +0000 (UTC)
commit 3654eb0c4ac400e0ce4681a22e36e06f3b63df49
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Aug 25 18:14:54 2009 +0300
core: List the resources according to compatiblity
Transcoding formats that are further from the format of the item in
question, should be listed at the end and viceversa. Not making sense?
Read the code, Luke!
src/rygel/rygel-media-item.vala | 8 ++++++++
src/rygel/rygel-transcode-manager.vala | 19 ++++++-------------
2 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/src/rygel/rygel-media-item.vala b/src/rygel/rygel-media-item.vala
index 1caac3f..e7fca70 100644
--- a/src/rygel/rygel-media-item.vala
+++ b/src/rygel/rygel-media-item.vala
@@ -78,6 +78,14 @@ public class Rygel.MediaItem : MediaObject {
return null;
}
+ internal int compare_transcoders (void *a, void *b) {
+ var transcoder1 = (Transcoder) a;
+ var transcoder2 = (Transcoder) b;
+
+ return (int) transcoder1.get_distance (this) -
+ (int) transcoder2.get_distance (this);
+ }
+
internal void add_resources (DIDLLiteItem didl_item) throws Error {
foreach (var uri in this.uris) {
this.add_resource (didl_item, uri, null);
diff --git a/src/rygel/rygel-transcode-manager.vala b/src/rygel/rygel-transcode-manager.vala
index a29f474..9b1200c 100644
--- a/src/rygel/rygel-transcode-manager.vala
+++ b/src/rygel/rygel-transcode-manager.vala
@@ -60,24 +60,17 @@ internal abstract class Rygel.TranscodeManager : GLib.Object {
public virtual void add_resources (DIDLLiteItem didl_item,
MediaItem item)
throws Error {
- if (item.upnp_class.has_prefix (MediaItem.IMAGE_CLASS)) {
- // No transcoding for images yet :(
- return;
- }
+ var list = new GLib.List<Transcoder> ();
- // First add resource of the transcoders that are primarily meant for
- // the UPnP class of the item concerned
foreach (var transcoder in this.transcoders) {
- if (item.upnp_class.has_prefix (transcoder.upnp_class)) {
- transcoder.add_resource (didl_item, item, this);
+ if (transcoder.get_distance (item) != uint.MAX) {
+ list.append (transcoder);
}
}
- // Then add resources from other transcoders
- foreach (var transcoder in this.transcoders) {
- if (!item.upnp_class.has_prefix (transcoder.upnp_class)) {
- transcoder.add_resource (didl_item, item, this);
- }
+ list.sort_with_data (item.compare_transcoders);
+ foreach (var transcoder in list) {
+ transcoder.add_resource (didl_item, item, this);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]