[rygel/wip/playlist-item: 4/9] media-export: Add playlist item.



commit ca671e3ef9fb524b3cbd877ad0aaca19d13ac3f4
Author: Krzesimir Nowak <krnowak openismus com>
Date:   Fri Nov 23 17:58:37 2012 +0100

    media-export: Add playlist item.

 src/plugins/media-export/Makefile.am               |    1 +
 .../media-export/rygel-media-export-harvester.vala |    4 +-
 .../rygel-media-export-harvesting-task.vala        |    4 +-
 .../media-export/rygel-media-export-item.vala      |    7 +++-
 .../rygel-media-export-object-factory.vala         |    2 +
 .../rygel-media-export-playlist-item.vala          |   41 ++++++++++++++++++++
 .../rygel-media-export-root-container.vala         |    2 +
 .../rygel-media-export-writable-db-container.vala  |    1 +
 8 files changed, 59 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index 5c9338b..5ef84c4 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -39,6 +39,7 @@ librygel_media_export_la_SOURCES = \
 	rygel-media-export-music-item.vala \
 	rygel-media-export-video-item.vala \
 	rygel-media-export-photo-item.vala \
+	rygel-media-export-playlist-item.vala \
 	rygel-media-export-collate.c
 
 librygel_media_export_la_VALAFLAGS = \
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala b/src/plugins/media-export/rygel-media-export-harvester.vala
index 02a7f16..7016856 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -156,7 +156,9 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
                 info.get_content_type ().has_prefix ("image/") ||
                 info.get_content_type ().has_prefix ("video/") ||
                 info.get_content_type ().has_prefix ("audio/") ||
-                info.get_content_type () == "application/ogg") {
+                info.get_content_type () == "application/ogg" ||
+                info.get_content_type () == "application/xml" ||
+                info.get_content_type () == "text/xml") {
                 string id;
                 try {
                     MediaContainer parent_container = null;
diff --git a/src/plugins/media-export/rygel-media-export-harvesting-task.vala b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
index 40470fa..d4c6826 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -187,7 +187,9 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
             if (info.get_content_type ().has_prefix ("image/") ||
                 info.get_content_type ().has_prefix ("video/") ||
                 info.get_content_type ().has_prefix ("audio/") ||
-                info.get_content_type () == "application/ogg") {
+                info.get_content_type () == "application/ogg" ||
+                info.get_content_type () == "application/xml" ||
+                info.get_content_type () == "text/xml") {
                 return this.push_if_changed_or_unknown (file, info);
             }
 
diff --git a/src/plugins/media-export/rygel-media-export-item.vala b/src/plugins/media-export/rygel-media-export-item.vala
index 2a786d8..454fb45 100644
--- a/src/plugins/media-export/rygel-media-export-item.vala
+++ b/src/plugins/media-export/rygel-media-export-item.vala
@@ -40,8 +40,13 @@ namespace Rygel.MediaExport.ItemFactory {
             item = new VideoItem (MediaCache.get_id (file), parent, title);
         } else if (mime.has_prefix ("image/")) {
             item = new PhotoItem (MediaCache.get_id (file), parent, title);
-        } else {
+        } else if (mime.has_prefix ("audio/")) {
             item = new MusicItem (MediaCache.get_id (file), parent, title);
+        } else { // application/xml
+            // DLNA requires that DIDL_S playlist have text/xml MIME type.
+            mime = "text/xml";
+            debug ("Creating playlist item: %s.", title);
+            item = new PlaylistItem (MediaCache.get_id (file), parent, title);
         }
 
         item.mime_type = mime;
diff --git a/src/plugins/media-export/rygel-media-export-object-factory.vala b/src/plugins/media-export/rygel-media-export-object-factory.vala
index 5be14bd..3773bb4 100644
--- a/src/plugins/media-export/rygel-media-export-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-object-factory.vala
@@ -84,6 +84,8 @@ internal class Rygel.MediaExport.ObjectFactory : Object {
             case Rygel.PhotoItem.UPNP_CLASS:
             case Rygel.ImageItem.UPNP_CLASS:
                 return new PhotoItem (id, parent, title);
+            case Rygel.PlaylistItem.UPNP_CLASS:
+                return new PlaylistItem (id, parent, title);
             default:
                 assert_not_reached ();
         }
diff --git a/src/plugins/media-export/rygel-media-export-playlist-item.vala b/src/plugins/media-export/rygel-media-export-playlist-item.vala
new file mode 100644
index 0000000..e2abe66
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-playlist-item.vala
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * Author: Krzesimir Nowak <krnowak openismus com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * Own MusicItem class to provide disc number inside music item for sorting
+ * and metadata extraction.
+ */
+internal class Rygel.MediaExport.PlaylistItem : Rygel.PlaylistItem,
+                                                Rygel.UpdatableObject {
+    public PlaylistItem (string         id,
+                         MediaContainer parent,
+                         string         title,
+                         string         upnp_class = Rygel.PlaylistItem.UPNP_CLASS) {
+        base (id, parent, title, upnp_class);
+    }
+
+    public async void commit () throws Error {
+        var cache = MediaCache.get_default ();
+        cache.save_item (this);
+    }
+
+}
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index 5fdd310..f3af66b 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -426,6 +426,8 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
                                                    Rygel.PhotoItem.UPNP_CLASS);
             this.add_virtual_containers_for_class (_("Videos"),
                                                    Rygel.VideoItem.UPNP_CLASS);
+            this.add_virtual_containers_for_class (_("Playlists"),
+                                                   Rygel.PlaylistItem.UPNP_CLASS);
         } catch (Error error) {};
     }
 
diff --git a/src/plugins/media-export/rygel-media-export-writable-db-container.vala b/src/plugins/media-export/rygel-media-export-writable-db-container.vala
index f3c3073..20746f0 100644
--- a/src/plugins/media-export/rygel-media-export-writable-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-writable-db-container.vala
@@ -34,6 +34,7 @@ internal class Rygel.MediaExport.WritableDbContainer : DBContainer,
         this.create_classes.add (Rygel.VideoItem.UPNP_CLASS);
         this.create_classes.add (Rygel.AudioItem.UPNP_CLASS);
         this.create_classes.add (Rygel.MusicItem.UPNP_CLASS);
+        this.create_classes.add (Rygel.PlaylistItem.UPNP_CLASS);
     }
 
     public async void add_item (Rygel.MediaItem item, Cancellable? cancellable)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]