private const string DEFAULT_SORT_CRITERIA = "+upnp:class,+dc:title";
public const string ALBUM_SORT_CRITERIA = "+upnp:class," +
+ "+rygel:originalVolumeNumber," +
"+upnp:originalTrackNumber," +
"+dc:title";
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 = \
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;
}
case 9:
update_v9_v10 ();
break;
+ case 10:
+ update_v10_v11 ();
+ break;
default:
warning ("Cannot upgrade");
database = null;
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;
+ }
+ }
}
-1,
item.id,
item.dlna_profile,
- Database.null ()};
+ Database.null (),
+ -1};
if (item is AudioItem) {
var audio_item = item as AudioItem;
values[6] = music_item.album;
values[17] = music_item.genre;
values[12] = music_item.track_number;
+ values[18] = music_item.disc;
}
}
case "upnp:originalTrackNumber":
column = "m.track";
break;
+ case "rygel:originalVolumeNumber":
+ column = "m.disc";
+ break;
default:
var message = "Unsupported column %s".printf (operand);
--- /dev/null
+/*
+ * 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);
+ }
+}
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:
private const string SEARCH_CONTAINER_PREFIX = QueryContainer.PREFIX +
"upnp:class," +
- MusicItem.UPNP_CLASS +
+ Rygel.MusicItem.UPNP_CLASS +
",";
public static MediaContainer get_instance () throws Error {
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);
TIMESTAMP,
URI,
DLNA_PROFILE,
- GENRE
+ GENRE,
+ DISC
}
internal enum Rygel.MediaExport.SQLString {
"(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) " +
"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 +
"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, " +
"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) " +
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)
// 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) {