[rygel/wip/playlist-item: 11/11] wip: Playlist item.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/playlist-item: 11/11] wip: Playlist item.
- Date: Thu, 22 Nov 2012 10:31:24 +0000 (UTC)
commit e10d8fb55716b441e82069e4ff355d006f54faf8
Author: Krzesimir Nowak <krnowak openismus com>
Date: Thu Nov 22 08:37:24 2012 +0100
wip: Playlist item.
src/librygel-server/filelist.am | 3 +-
src/librygel-server/rygel-item-creator.vala | 2 +
src/librygel-server/rygel-playlist-item.vala | 41 ++++++++++++++++++++
.../rygel-source-connection-manager.vala | 3 +-
src/plugins/media-export/Makefile.am | 1 +
.../media-export/rygel-media-export-item.vala | 6 ++-
.../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 | 3 +-
tests/rygel-item-creator-test.vala | 11 +++++-
11 files changed, 110 insertions(+), 5 deletions(-)
---
diff --git a/src/librygel-server/filelist.am b/src/librygel-server/filelist.am
index a823eea..6ec5ebf 100644
--- a/src/librygel-server/filelist.am
+++ b/src/librygel-server/filelist.am
@@ -28,7 +28,8 @@ LIBRYGEL_SERVER_VAPI_SOURCE_FILES = \
rygel-media-engine.vala \
rygel-http-seek.vala \
rygel-data-source.vala \
- rygel-updatable-object.vala
+ rygel-updatable-object.vala \
+ rygel-playlist-item.vala
LIBRYGEL_SERVER_NONVAPI_SOURCE_FILES = \
rygel-browse.vala \
diff --git a/src/librygel-server/rygel-item-creator.vala b/src/librygel-server/rygel-item-creator.vala
index 1f5dd70..d0bafce 100644
--- a/src/librygel-server/rygel-item-creator.vala
+++ b/src/librygel-server/rygel-item-creator.vala
@@ -447,6 +447,8 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
return new AudioItem (id, parent, title);
case MusicItem.UPNP_CLASS:
return new MusicItem (id, parent, title);
+ case PlaylistItem.UPNP_CLASS:
+ return new PlaylistItem (id, parent, title);
default:
throw new ContentDirectoryError.BAD_METADATA
("Creation of item of class '%s' " +
diff --git a/src/librygel-server/rygel-playlist-item.vala b/src/librygel-server/rygel-playlist-item.vala
new file mode 100644
index 0000000..ff4ad8c
--- /dev/null
+++ b/src/librygel-server/rygel-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.
+ */
+
+/**
+ * Represents a playlist item.
+ *
+ * These objects correspond to DLNA's DIDL_S items.
+ */
+public class Rygel.PlaylistItem : MediaItem {
+ public new const string UPNP_CLASS = "object.item.playlistItem";
+
+ public PlaylistItem (string id,
+ MediaContainer parent,
+ string title,
+ string upnp_class = PlaylistItem.UPNP_CLASS) {
+ base (id, parent, title, upnp_class);
+ }
+
+ public override bool streamable () {
+ return false;
+ }
+}
diff --git a/src/librygel-server/rygel-source-connection-manager.vala b/src/librygel-server/rygel-source-connection-manager.vala
index 77031bd..502b4f6 100644
--- a/src/librygel-server/rygel-source-connection-manager.vala
+++ b/src/librygel-server/rygel-source-connection-manager.vala
@@ -78,7 +78,8 @@ internal class Rygel.SourceConnectionManager : Rygel.ConnectionManager {
// Find the ContentDirectory service attached to this root device.
foreach (var service in root_device.services) {
- if (service.get_type().is_a (typeof (Rygel.ContentDirectory))) {
+ if (service != null &&
+ service.get_type().is_a (typeof (Rygel.ContentDirectory))) {
var content_directory = (Rygel.ContentDirectory) service;
server = content_directory.http_server;
}
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-item.vala b/src/plugins/media-export/rygel-media-export-item.vala
index 90c100b..b31e379 100644
--- a/src/plugins/media-export/rygel-media-export-item.vala
+++ b/src/plugins/media-export/rygel-media-export-item.vala
@@ -40,8 +40,12 @@ 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";
+ 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..74c2ff1 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
@@ -22,7 +22,7 @@
using Gee;
internal class Rygel.MediaExport.WritableDbContainer : DBContainer,
- Rygel.WritableContainer {
+ Rygel.WritableContainer {
public ArrayList<string> create_classes { get; set; }
public WritableDbContainer (MediaCache media_db, string id, string title) {
@@ -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)
diff --git a/tests/rygel-item-creator-test.vala b/tests/rygel-item-creator-test.vala
index 973a7f0..4b779af 100644
--- a/tests/rygel-item-creator-test.vala
+++ b/tests/rygel-item-creator-test.vala
@@ -45,7 +45,7 @@ public const string DIDL_ITEM = """<?xml version="1.0" encoding="UTF-8"?>
<upnp:class>object.item.audioItem</upnp:class>
<res protocolInfo="*:*:*:*" />
</item>
-</DIDL-Lite>""";
+</DIDL-Lite>"""; //"
public class Rygel.ServiceAction : GLib.Object {
public int error_code;
@@ -183,6 +183,15 @@ public class Rygel.PhotoItem : Rygel.MediaItem {
base (id, parent, title);
}
}
+
+public class Rygel.PlaylistItem : Rygel.MediaItem {
+ public const string UPNP_CLASS = "object.item.playlistItem";
+
+ public PlaylistItem (string id, MediaContainer parent, string title) {
+ base (id, parent, title);
+ }
+}
+
public class Rygel.ContentDirectory : GLib.Object {
public Cancellable cancellable;
public MediaContainer root_container;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]