[rygel] media-export: Refactor DVD tracks
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Refactor DVD tracks
- Date: Sat, 13 Feb 2016 09:31:00 +0000 (UTC)
commit 82f434cce83a9643e67748f999fb921f49bde88e
Author: Jens Georg <mail jensge org>
Date: Thu Feb 11 22:29:58 2016 +0100
media-export: Refactor DVD tracks
Let the DVD track fill itself from the XML node
Signed-off-by: Jens Georg <mail jensge org>
.../rygel-media-export-dvd-container.vala | 42 +---------------
.../media-export/rygel-media-export-dvd-track.vala | 53 +++++++++++++++++++-
2 files changed, 53 insertions(+), 42 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-dvd-container.vala
b/src/plugins/media-export/rygel-media-export-dvd-container.vala
index cf4f3e7..af1c78a 100644
--- a/src/plugins/media-export/rygel-media-export-dvd-container.vala
+++ b/src/plugins/media-export/rygel-media-export-dvd-container.vala
@@ -152,48 +152,10 @@ internal class Rygel.MediaExport.DVDContainer : SimpleContainer, UpdatableObject
private MediaFileItem get_item_for_xml (int track, Xml.Node *node) {
var item = new DVDTrack (this.get_track_id (track),
this,
- "Track %d".printf (track + 1));
+ track,
+ node);
item.parent_ref = this;
- var uri = new Soup.URI (this.get_uris ()[0]);
- uri.set_scheme ("dvd");
- uri.set_query ("title=%d".printf (track + 1));
- item.add_uri (uri.to_string (false));
-
- item.dlna_profile = "MPEG_PS";
- item.mime_type = "video/mpeg";
-
- var it = node->children;
- while (it != null) {
- if (it->name == "length") {
- item.duration = (int)double.parse (it->children->content);
- } else if (it->name == "width") {
- item.width = int.parse (it->children->content);
- } else if (it->name == "height") {
- item.height = int.parse (it->children->content);
- } else if (it->name == "PAL") {
- item.dlna_profile = "MPEG_PS_PAL";
- } else if (it->name == "NTSC") {
- item.dlna_profile = "MPEG_PS_NTSC";
- }
- // TODO: Japanese formats...
- it = it->next;
- }
-
- 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);
- });
-
return item;
}
}
diff --git a/src/plugins/media-export/rygel-media-export-dvd-track.vala
b/src/plugins/media-export/rygel-media-export-dvd-track.vala
index d42e1d3..0542843 100644
--- a/src/plugins/media-export/rygel-media-export-dvd-track.vala
+++ b/src/plugins/media-export/rygel-media-export-dvd-track.vala
@@ -23,10 +23,59 @@
using GUPnP;
internal class Rygel.MediaExport.DVDTrack : Rygel.VideoItem {
+ public Xml.Node* node { private get; construct set; }
+ public int track { private get; construct set; }
+
public DVDTrack (string id,
MediaContainer parent,
- string title) {
- base (id, parent, title, Rygel.VideoItem.UPNP_CLASS);
+ int track,
+ Xml.Node* node) {
+ Object (id : id,
+ parent : parent,
+ node : node,
+ title : _("Title %d").printf (track + 1),
+ upnp_class : Rygel.VideoItem.UPNP_CLASS,
+ track : track);
+ }
+
+ public override void constructed () {
+ base.constructed ();
+
+ var uri = new Soup.URI (this.parent.get_uris ()[0]);
+ uri.set_scheme ("dvd");
+ uri.set_query ("title=%d".printf (track + 1));
+ this.add_uri (uri.to_string (false));
+
+ this.dlna_profile = "MPEG_PS";
+ this.mime_type = "video/mpeg";
+
+ var it = node->children;
+ while (it != null) {
+ if (it->name == "length") {
+ this.duration = (int)double.parse (it->children->content);
+ } else if (it->name == "width") {
+ this.width = int.parse (it->children->content);
+ } else if (it->name == "height") {
+ this.height = int.parse (it->children->content);
+ } else if (it->name == "PAL") {
+ this.dlna_profile = "MPEG_PS_PAL";
+ } else if (it->name == "NTSC") {
+ this.dlna_profile = "MPEG_PS_NTSC";
+ }
+ // TODO: Japanese formats...
+ it = it->next;
+ }
+
+ 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 this source %s",
+ added_resources.size,
+ this.get_primary_uri ());
+ this.get_resource_list ().add_all (added_resources);
+ });
}
public override MediaResource get_primary_resource () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]