[rygel] all: Move common code to MediaFileItem
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] all: Move common code to MediaFileItem
- Date: Mon, 2 Nov 2015 21:04:26 +0000 (UTC)
commit 97a1597523a0204c991e0a1bb3c2a1ca56eb5b79
Author: Jens Georg <mail jensge org>
Date: Tue Oct 27 07:05:58 2015 +0100
all: Move common code to MediaFileItem
Signed-off-by: Jens Georg <mail jensge org>
src/librygel-server/rygel-media-file-item.vala | 16 ++++++++++++++++
.../external/rygel-external-item-factory.vala | 4 +---
.../gst-launch/rygel-gst-launch-audio-item.vala | 15 +--------------
.../gst-launch/rygel-gst-launch-video-item.vala | 15 +--------------
.../rygel-media-export-media-cache.vala | 17 ++---------------
.../rygel-mediathek-video-item-factory.vala | 15 +--------------
.../tracker/rygel-tracker-item-factory.vala | 16 +++-------------
7 files changed, 25 insertions(+), 73 deletions(-)
---
diff --git a/src/librygel-server/rygel-media-file-item.vala b/src/librygel-server/rygel-media-file-item.vala
index fdd3d6f..f32e576 100644
--- a/src/librygel-server/rygel-media-file-item.vala
+++ b/src/librygel-server/rygel-media-file-item.vala
@@ -249,6 +249,22 @@ public abstract class Rygel.MediaFileItem : MediaItem {
return "";
}
+ /**
+ * Request the media engine for the resources it can provide for this
+ * item. Typically these are the transcoded resources.
+ */
+ public virtual async void add_engine_resources () {
+ var media_engine = MediaEngine.get_default ( );
+ var added_resources = yield media_engine.get_resources_for_item (this);
+ debug ("Adding %d resources to item source %s:",
+ added_resources.size,
+ this.get_primary_uri ());
+
+ foreach (var resource in added_resources) {
+ debug (" %s", resource.get_name ());
+ }
+ this.get_resource_list ().add_all (added_resources);
+ }
/**
* Subclasses can override this method to augment the MediaObject MediaResource
diff --git a/src/plugins/external/rygel-external-item-factory.vala
b/src/plugins/external/rygel-external-item-factory.vala
index b5a93cb..1f865b8 100644
--- a/src/plugins/external/rygel-external-item-factory.vala
+++ b/src/plugins/external/rygel-external-item-factory.vala
@@ -68,9 +68,7 @@ public class Rygel.External.ItemFactory {
item.parent_ref = parent;
}
- var media_engine = MediaEngine.get_default ( );
- var resources = yield media_engine.get_resources_for_item (item);
- item.get_resource_list ().add_all (resources);
+ yield item.add_engine_resources ();
return item;
}
diff --git a/src/plugins/gst-launch/rygel-gst-launch-audio-item.vala
b/src/plugins/gst-launch/rygel-gst-launch-audio-item.vala
index 4b60ab0..ffe7409 100644
--- a/src/plugins/gst-launch/rygel-gst-launch-audio-item.vala
+++ b/src/plugins/gst-launch/rygel-gst-launch-audio-item.vala
@@ -39,19 +39,6 @@ public class Rygel.GstLaunch.AudioItem : Rygel.AudioItem {
this.mime_type = mime_type;
this.add_uri ("gst-launch://" + launch_line);
- // Call the MediaEngine to determine which item representations it can support
- var media_engine = MediaEngine.get_default ( );
- media_engine.get_resources_for_item.begin ( this,
- (obj, res) => {
- var added_resources = media_engine
- .get_resources_for_item.end (res);
- debug ("Adding %d resources to item source %s",
- added_resources.size, this.get_primary_uri ());
- foreach (var resrc in added_resources) {
- debug ("Media-export item media resource %s",
- resrc.get_name ());
- }
- this.get_resource_list ().add_all (added_resources);
- });
+ this.add_engine_resources.begin ();
}
}
diff --git a/src/plugins/gst-launch/rygel-gst-launch-video-item.vala
b/src/plugins/gst-launch/rygel-gst-launch-video-item.vala
index a6057ec..1fbc884 100644
--- a/src/plugins/gst-launch/rygel-gst-launch-video-item.vala
+++ b/src/plugins/gst-launch/rygel-gst-launch-video-item.vala
@@ -40,19 +40,6 @@ public class Rygel.GstLaunch.VideoItem : Rygel.VideoItem {
this.mime_type = mime_type;
this.add_uri ("gst-launch://" + launch_line);
- // Call the MediaEngine to determine which item representations it can support
- var media_engine = MediaEngine.get_default ( );
- media_engine.get_resources_for_item.begin ( this,
- (obj, res) => {
- var added_resources = media_engine
- .get_resources_for_item.end (res);
- debug ("Adding %d resources to item source %s",
- added_resources.size, this.get_primary_uri ());
- foreach (var resrc in added_resources) {
- debug ("Media-export item media resource %s",
- resrc.get_name ());
- }
- this.get_resource_list ().add_all (added_resources);
- });
+ this.add_engine_resources.begin ();
}
}
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala
b/src/plugins/media-export/rygel-media-export-media-cache.vala
index 0cb1b88..8b57afd 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -940,21 +940,8 @@ public class Rygel.MediaExport.MediaCache : Object {
item.add_uri (uri);
}
- // Call the MediaEngine to determine which item representations it can support
- var media_engine = MediaEngine.get_default ( );
- media_engine.get_resources_for_item.begin ( item,
- (obj, res) => {
- var added_resources = media_engine
- .get_resources_for_item.end (res);
- debug ("Adding %d resources to item source %s",
- added_resources.size, item.get_primary_uri ());
- foreach (var resrc in added_resources) {
- debug ("Media-export item media resource %s",
- resrc.get_name ());
- }
- item.get_resource_list ().add_all (added_resources);
- });
- break;
+ item.add_engine_resources.begin();
+ break;
default:
assert_not_reached ();
}
diff --git a/src/plugins/mediathek/rygel-mediathek-video-item-factory.vala
b/src/plugins/mediathek/rygel-mediathek-video-item-factory.vala
index 02aadcf..ab4384c 100644
--- a/src/plugins/mediathek/rygel-mediathek-video-item-factory.vala
+++ b/src/plugins/mediathek/rygel-mediathek-video-item-factory.vala
@@ -80,20 +80,7 @@ internal class Rygel.Mediathek.VideoItemFactory : Object {
item.add_uri (uri);
}
- // Call the MediaEngine to determine which item representations it can support
- var media_engine = MediaEngine.get_default ( );
- media_engine.get_resources_for_item.begin ( item,
- (obj, res) => {
- var added_resources = media_engine
- .get_resources_for_item.end (res);
- debug ("Adding %d resources to item source %s",
- added_resources.size, item.get_primary_uri ());
- foreach (var resrc in added_resources) {
- debug ("Media-export item media resource %s",
- resrc.get_name ());
- }
- item.get_resource_list ().add_all (added_resources);
- });
+ yield item.add_engine_resources ();
return item;
}
diff --git a/src/plugins/tracker/rygel-tracker-item-factory.vala
b/src/plugins/tracker/rygel-tracker-item-factory.vala
index dae3840..2ea7320 100644
--- a/src/plugins/tracker/rygel-tracker-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-item-factory.vala
@@ -138,19 +138,9 @@ public abstract class Rygel.Tracker.ItemFactory {
item.add_uri (uri);
}
- protected virtual void add_resources (MediaItem item) throws GLib.Error {
- // Call the MediaEngine to determine which item representations it can support
- var media_engine = MediaEngine.get_default ( );
- media_engine.get_resources_for_item.begin (item,
- (obj, res) => {
- var added_resources = media_engine.get_resources_for_item.end (res);
- debug ("Adding %d resources to item source %s",
- added_resources.size, item.get_primary_uri () );
- foreach (var resrc in added_resources) {
- debug ("Tracker item media resource %s", resrc.get_name ());
- }
- item.get_resource_list ().add_all (added_resources);
- });
+ protected virtual void add_resources (MediaFileItem item)
+ throws GLib.Error {
+ item.add_engine_resources.begin ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]