[rygel] core,tracker,media-export: Respect disc number
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core,tracker,media-export: Respect disc number
- Date: Sun, 12 Aug 2012 17:54:27 +0000 (UTC)
commit 0651af8d9c92e01f24e5692abac11ec0c6b91a24
Author: Jens Georg <mail jensge org>
Date: Sun Aug 12 19:35:46 2012 +0200
core,tracker,media-export: Respect disc number
Previously we did not care about the volume number of a music piece
while sorting. This cannot be mapped to UPnP, but at least in the
default sort order of albums this is respected now.
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=639809
src/librygel-server/rygel-media-container.vala | 1 +
src/plugins/media-export/Makefile.am | 1 +
.../media-export/rygel-media-export-item.vala | 5 ++-
.../rygel-media-export-media-cache-upgrader.vala | 24 +++++++++++++
.../rygel-media-export-media-cache.vala | 7 +++-
.../rygel-media-export-music-item.vala | 36 ++++++++++++++++++++
.../rygel-media-export-object-factory.vala | 2 +-
.../rygel-media-export-root-container.vala | 4 +-
.../rygel-media-export-sql-factory.vala | 12 ++++---
.../rygel-media-export-writable-db-container.vala | 2 +-
.../tracker/rygel-tracker-upnp-property-map.vala | 4 ++
11 files changed, 87 insertions(+), 11 deletions(-)
---
diff --git a/src/librygel-server/rygel-media-container.vala b/src/librygel-server/rygel-media-container.vala
index d1beb0d..5780c31 100644
--- a/src/librygel-server/rygel-media-container.vala
+++ b/src/librygel-server/rygel-media-container.vala
@@ -40,6 +40,7 @@ public abstract class Rygel.MediaContainer : MediaObject {
private const string DEFAULT_SORT_CRITERIA = "+upnp:class,+dc:title";
public const string ALBUM_SORT_CRITERIA = "+upnp:class," +
+ "+rygel:originalVolumeNumber," +
"+upnp:originalTrackNumber," +
"+dc:title";
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index e4f8f4d..0fd3370 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -36,6 +36,7 @@ librygel_media_export_la_SOURCES = \
rygel-media-export-jpeg-writer.vala \
rygel-media-export-object-factory.vala \
rygel-media-export-writable-db-container.vala \
+ rygel-media-export-music-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 cc775b5..4a1efa6 100644
--- a/src/plugins/media-export/rygel-media-export-item.vala
+++ b/src/plugins/media-export/rygel-media-export-item.vala
@@ -195,8 +195,11 @@ namespace Rygel.MediaExport.ItemFactory {
dlna_info.info.get_tags ().get_string (TAG_ARTIST, out item.artist);
dlna_info.info.get_tags ().get_string (TAG_ALBUM, out item.album);
dlna_info.info.get_tags ().get_string (TAG_GENRE, out item.genre);
-
uint tmp;
+ dlna_info.info.get_tags ().get_uint (TAG_ALBUM_VOLUME_NUMBER,
+ out tmp);
+ item.disc = (int) tmp;
+
dlna_info.info.get_tags() .get_uint (TAG_TRACK_NUMBER, out tmp);
item.track_number = (int) tmp;
}
diff --git a/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala b/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
index 93d73d7..a1690bd 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
@@ -107,6 +107,9 @@ internal class Rygel.MediaExport.MediaCacheUpgrader {
case 9:
update_v9_v10 ();
break;
+ case 10:
+ update_v10_v11 ();
+ break;
default:
warning ("Cannot upgrade");
database = null;
@@ -341,4 +344,25 @@ internal class Rygel.MediaExport.MediaCacheUpgrader {
database = null;
}
}
+
+ private void update_v10_v11 () {
+ try {
+ this.database.begin ();
+ this.database.exec ("ALTER TABLE Meta_Data " +
+ " ADD COLUMN disc INTEGER");
+ // Force reindexing of audio data to get disc number
+ this.database.exec ("UPDATE Object SET timestamp = 0 WHERE " +
+ " upnp_id IN (" +
+ "SELECT object_fk FROM Meta_Data WHERE " +
+ " class LIKE 'object.item.audioItem.%')");
+ this.database.exec ("UPDATE schema_info SET version = '11'");
+ database.commit ();
+ database.exec ("VACUUM");
+ database.analyze ();
+ } catch (DatabaseError error) {
+ database.rollback ();
+ warning ("Database upgrade failed: %s", error.message);
+ database = null;
+ }
+ }
}
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 14e909c..b8265b5 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -515,7 +515,8 @@ public class Rygel.MediaExport.MediaCache : Object {
-1,
item.id,
item.dlna_profile,
- Database.null ()};
+ Database.null (),
+ -1};
if (item is AudioItem) {
var audio_item = item as AudioItem;
@@ -530,6 +531,7 @@ public class Rygel.MediaExport.MediaCache : Object {
values[6] = music_item.album;
values[17] = music_item.genre;
values[12] = music_item.track_number;
+ values[18] = music_item.disc;
}
}
@@ -782,6 +784,9 @@ public class Rygel.MediaExport.MediaCache : Object {
case "upnp:originalTrackNumber":
column = "m.track";
break;
+ case "rygel:originalVolumeNumber":
+ column = "m.disc";
+ break;
default:
var message = "Unsupported column %s".printf (operand);
diff --git a/src/plugins/media-export/rygel-media-export-music-item.vala b/src/plugins/media-export/rygel-media-export-music-item.vala
new file mode 100644
index 0000000..27f9db8
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-music-item.vala
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 Jens Georg <mail jensge org>.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * 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.MusicItem : Rygel.MusicItem {
+ public int disc;
+
+ public MusicItem (string id,
+ MediaContainer parent,
+ string title,
+ string upnp_class = Rygel.MusicItem.UPNP_CLASS) {
+ base (id, parent, title, upnp_class);
+ }
+}
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 d6761f9..7a5b59b 100644
--- a/src/plugins/media-export/rygel-media-export-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-object-factory.vala
@@ -76,7 +76,7 @@ internal class Rygel.MediaExport.ObjectFactory : Object {
string title,
string upnp_class) {
switch (upnp_class) {
- case MusicItem.UPNP_CLASS:
+ case Rygel.MusicItem.UPNP_CLASS:
case AudioItem.UPNP_CLASS:
return new MusicItem (id, parent, title);
case VideoItem.UPNP_CLASS:
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 ffe359f..04a286c 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -55,7 +55,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
private const string SEARCH_CONTAINER_PREFIX = QueryContainer.PREFIX +
"upnp:class," +
- MusicItem.UPNP_CLASS +
+ Rygel.MusicItem.UPNP_CLASS +
",";
public static MediaContainer get_instance () throws Error {
@@ -421,7 +421,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
private void add_default_virtual_folders () {
try {
this.add_virtual_containers_for_class (_("Music"),
- MusicItem.UPNP_CLASS,
+ Rygel.MusicItem.UPNP_CLASS,
virtual_folders_music);
this.add_virtual_containers_for_class (_("Pictures"),
PhotoItem.UPNP_CLASS);
diff --git a/src/plugins/media-export/rygel-media-export-sql-factory.vala b/src/plugins/media-export/rygel-media-export-sql-factory.vala
index 00a3764..9222fe4 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -43,7 +43,8 @@ internal enum Rygel.MediaExport.DetailColumn {
TIMESTAMP,
URI,
DLNA_PROFILE,
- GENRE
+ GENRE,
+ DISC
}
internal enum Rygel.MediaExport.SQLString {
@@ -76,8 +77,8 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"(size, mime_type, width, height, class, " +
"author, album, date, bitrate, " +
"sample_freq, bits_per_sample, channels, " +
- "track, color_depth, duration, object_fk, dlna_profile, genre) VALUES " +
- "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ "track, color_depth, duration, object_fk, dlna_profile, genre, disc) VALUES " +
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
private const string INSERT_OBJECT_STRING =
"INSERT OR REPLACE INTO Object (upnp_id, title, type_fk, parent, timestamp, uri) " +
@@ -92,7 +93,7 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"m.height, m.class, m.author, m.album, m.date, m.bitrate, " +
"m.sample_freq, m.bits_per_sample, m.channels, m.track, " +
"m.color_depth, m.duration, o.upnp_id, o.parent, o.timestamp, " +
- "o.uri, m.dlna_profile, m.genre ";
+ "o.uri, m.dlna_profile, m.genre, m.disc ";
private const string GET_OBJECT_WITH_PATH =
"SELECT DISTINCT " + ALL_DETAILS_STRING +
@@ -159,7 +160,7 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"SELECT DISTINCT %s AS _column FROM meta_data AS m " +
"WHERE _column IS NOT NULL %s ORDER BY _column LIMIT ?,?";
- internal const string schema_version = "10";
+ internal const string schema_version = "11";
internal const string CREATE_META_DATA_TABLE_STRING =
"CREATE TABLE meta_data (size INTEGER NOT NULL, " +
"mime_type TEXT NOT NULL, " +
@@ -177,6 +178,7 @@ internal class Rygel.MediaExport.SQLFactory : Object {
"bits_per_sample INTEGER, " +
"channels INTEGER, " +
"track INTEGER, " +
+ "disc INTEGER, " +
"color_depth INTEGER, " +
"object_fk TEXT UNIQUE CONSTRAINT " +
"object_fk_id REFERENCES Object(upnp_id) " +
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 061d54d..9330c7a 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
@@ -33,7 +33,7 @@ internal class Rygel.MediaExport.WritableDbContainer : DBContainer,
this.create_classes.add (PhotoItem.UPNP_CLASS);
this.create_classes.add (VideoItem.UPNP_CLASS);
this.create_classes.add (AudioItem.UPNP_CLASS);
- this.create_classes.add (MusicItem.UPNP_CLASS);
+ this.create_classes.add (Rygel.MusicItem.UPNP_CLASS);
}
public async void add_item (Rygel.MediaItem item, Cancellable? cancellable)
diff --git a/src/plugins/tracker/rygel-tracker-upnp-property-map.vala b/src/plugins/tracker/rygel-tracker-upnp-property-map.vala
index ad4ebb8..76266a6 100644
--- a/src/plugins/tracker/rygel-tracker-upnp-property-map.vala
+++ b/src/plugins/tracker/rygel-tracker-upnp-property-map.vala
@@ -74,6 +74,10 @@ public class Rygel.Tracker.UPnPPropertyMap : Object {
// Picture & Video Items
this.add_key_chain ("width", "nfo:width");
this.add_key_chain ("height", "nfo:height");
+
+ this.add_key_chain ("rygel:originalVolumeNumber",
+ "nmm:musicAlbumDisc",
+ "nmm:setNumber");
}
public new string @get (string property) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]