muine r1234 - in trunk: . libmuine libmuine/id3-vfs m4 src
- From: plaes svn gnome org
- To: svn-commits-list gnome org
- Subject: muine r1234 - in trunk: . libmuine libmuine/id3-vfs m4 src
- Date: Fri, 7 Nov 2008 18:02:49 +0000 (UTC)
Author: plaes
Date: Fri Nov 7 18:02:49 2008
New Revision: 1234
URL: http://svn.gnome.org/viewvc/muine?rev=1234&view=rev
Log:
2008-11-07 Priit Laes <plaes svn gnome org>
Bug 474090 â Switch to taglib-sharp
* TODO:
* README:
* Makefile.am:
* Configure.in:
* src/Makefile.am:
* src/Metadata.cs:
R m4/*:
R libmuine/id3-vfs/*:
R libmuine/metadata.[ch]:
R libmuine/ogg-helper.[ch]:
Use taglib-sharp for metadata loading. Based on the patch by
Vianney le ClÃment.
Removed:
trunk/libmuine/id3-vfs/Makefile.am
trunk/libmuine/id3-vfs/field.h
trunk/libmuine/id3-vfs/file.h
trunk/libmuine/id3-vfs/global.h
trunk/libmuine/id3-vfs/id3-vfs.c
trunk/libmuine/id3-vfs/id3-vfs.h
trunk/libmuine/id3-vfs/mp3bitrate.c
trunk/libmuine/id3-vfs/mp3bitrate.h
trunk/libmuine/id3-vfs/tag.h
trunk/libmuine/metadata.c
trunk/libmuine/metadata.h
trunk/libmuine/ogg-helper.c
trunk/libmuine/ogg-helper.h
trunk/m4/Makefile.am
trunk/m4/ogg.m4
trunk/m4/vorbis.m4
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/README
trunk/TODO
trunk/configure.in
trunk/libmuine/Makefile.am
trunk/src/Makefile.am
trunk/src/Metadata.cs
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Fri Nov 7 18:02:49 2008
@@ -8,7 +8,6 @@
src \
plugins \
doc \
- m4 \
po \
$(NULL)
Modified: trunk/README
==============================================================================
--- trunk/README (original)
+++ trunk/README Fri Nov 7 18:02:49 2008
@@ -48,17 +48,11 @@
Basic requirements:
Mono >= 1.1
- Gtk# >= 2.4.0
+ Gtk# >= 2.6
Gtk+ >= 2.6
+ Taglib-Sharp >= 2.0.3
gdbm
-Audio support:
- vorbis >= 1.0
- FLAC >= 1.1.0
- libid3tag >= 0.15 (optionally, for MP3 support)
- faad2 (optionally, for AAC support)
-
Playback support (one of the options below):
GStreamer 0.10 (used by default)
- GStreamer 0.8 (used by default if Gstreamer 0.10 is not found)
xine-lib >= 1.0.0rc3b
Modified: trunk/TODO
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Fri Nov 7 18:02:49 2008
@@ -22,7 +22,6 @@
it's a tough one. Well, we could emit EOS a bit earlier than usual
and have a fancy adder somewhere in the pipeline that does the mixing
when a new song comes in ..
-o Figure out how to get the peak value from the ID3 RVA2 tag.
o Improve first time dialog once again ..
Perhaps a system-wide music folder gconf key, where sound-juicer dumps the
music, and muine monitors it ..
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Fri Nov 7 18:02:49 2008
@@ -27,6 +27,7 @@
ICON_THEME_REQUIRED=2.10
MONO_REQUIRED=1.1
GTKSHARP_REQUIRED=2.6.0
+TAGLIBSHARP_REQUIRED=2.0.3
MONODOC_REQUIRED=1.1.9
dnl Audio backend stuff
@@ -67,6 +68,9 @@
gconf-sharp-2.0 >= $GTKSHARP_REQUIRED \
gnome-vfs-sharp-2.0 >= $GTKSHARP_REQUIRED)
+PKG_CHECK_MODULES(TAGLIBSHARP,
+ taglib-sharp >= $TAGLIBSHARP_REQUIRED)
+
dnl ndesk-dbus
PKG_CHECK_MODULES(DBUS, ndesk-dbus-1.0 >= 0.4 \
ndesk-dbus-glib-1.0 >= 0.3, have_dbus="yes", have_dbus="no")
@@ -110,59 +114,6 @@
GDBM_LIBS="-lgdbm"
AC_SUBST(GDBM_LIBS)
-dnl Check for Ogg Vorbis
-MM_PATH_OGG(, AC_MSG_ERROR(You need Ogg))
-AC_SUBST(OGG_CFLAGS)
-AC_SUBST(OGG_LIBS)
-
-MM_PATH_VORBIS(, AC_MSG_ERROR(You need Vorbis))
-AC_SUBST(VORBIS_CFLAGS)
-AC_SUBST(VORBIS_LIBS)
-AC_SUBST(VORBISFILE_CFLAGS)
-AC_SUBST(VORBISFILE_LIBS)
-
-dnl Check for FLAC
-PKG_CHECK_MODULES(FLAC, flac)
-AC_SUBST(FLAC_CFLAGS)
-AC_SUBST(FLAC_LIBS)
-
-dnl Check for libid3tag
-AC_ARG_ENABLE(id3tag, [ --disable-id3tag Disable MP3 support],have_id3tag=${enableval},have_id3tag=yes)
-if test "x$have_id3tag" = "xyes"; then
- PKG_CHECK_MODULES(ID3TAG, id3tag >= 0.15, id3tag_detect=yes, id3tag_detect=no)
- if test "x$id3tag_detect" = "xyes"; then
- AC_CHECK_HEADER(id3tag.h, id3tag_detect=yes, id3tag_detect=no)
- fi
- if test "x$id3tag_detect" = "xyes"; then
- ID3TAG_LIBS="-lid3tag -lz"
- AC_DEFINE(HAVE_ID3TAG, 1, id3tag support)
- else
- AC_DEFINE(HAVE_ID3TAG, 0, id3tag support)
- fi
-else
- AC_DEFINE(HAVE_ID3TAG, 0, id3tag support)
-fi
-
-AM_CONDITIONAL(HAVE_ID3TAG, test "x$id3tag_detect" = "xyes")
-AC_SUBST(ID3TAG_LIBS)
-
-dnl Check for FAAD
-AC_ARG_ENABLE(faad2, [ --disable-faad2 Disable AAC support],,enable_faad2=yes)
-if test "x$enable_faad2" = "xyes"; then
- AC_CHECK_HEADER(mp4ff.h, faad2_detect=yes, faad_detect=no)
- if test "x$faad2_detect" = "xyes"; then
- FAAD_LIBS="-lmp4ff -lfaad"
- AC_DEFINE(HAVE_FAAD, 1, faad2 support)
- else
- AC_DEFINE(HAVE_FAAD, 0, faad2 support)
- fi
-else
- AC_DEFINE(HAVE_FAAD, 0, faad2 support)
-fi
-
-AM_CONDITIONAL(HAVE_FAAD, test "x$have_faad2" = "xyes")
-AC_SUBST(FAAD_LIBS)
-
dnl Check for Mono
AC_PATH_PROG(MCS, gmcs)
if test x$MCS = x; then
@@ -215,12 +166,10 @@
data/images/Makefile
data/ui/Makefile
libmuine/Makefile
-libmuine/id3-vfs/Makefile
PluginLib/Makefile
DBusLib/Makefile
src/Makefile
plugins/Makefile
doc/Makefile
-m4/Makefile
po/Makefile.in
])
Modified: trunk/libmuine/Makefile.am
==============================================================================
--- trunk/libmuine/Makefile.am (original)
+++ trunk/libmuine/Makefile.am Fri Nov 7 18:02:49 2008
@@ -1,19 +1,8 @@
-if HAVE_ID3TAG
-id3_vfs_dir = id3-vfs
-id3_vfs_lib = id3-vfs/libid3-vfs.la
-endif
-
-SUBDIRS = $(id3_vfs_dir)
-
INCLUDES = \
-I$(top_srcdir) \
-DG_LOG_DOMAIN=\"libmuine\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
$(MUINE_CFLAGS) \
- $(OGG_CFLAGS) \
- $(ID3TAG_CFLAGS) \
- $(VORBIS_CFLAGS) \
- $(VORBISFILE_CFLAGS) \
$(WARN_CFLAGS) \
-DG_DISABLE_DEPRECATED \
-DGTK_DISABLE_DEPRECATED \
@@ -37,10 +26,6 @@
$(gst_sources) \
macros.h \
player.h \
- metadata.c \
- metadata.h \
- ogg-helper.c \
- ogg-helper.h \
gsequence.c \
gsequence.h \
pointer-list-model.c \
@@ -51,5 +36,5 @@
db.h \
mm-keys.c \
mm-keys.h
-
-libmuine_la_LIBADD = $(id3_vfs_lib) $(MUINE_LIBS) $(OGG_LIBS) $(VORBIS_LIBS) $(VORBISFILE_LIBS) $(GDBM_LIBS) $(ID3TAG_LIBS) $(FLAC_LIBS) $(FAAD_LIBS)
+
+libmuine_la_LIBADD = $(MUINE_LIBS) $(GDBM_LIBS)
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Fri Nov 7 18:02:49 2008
@@ -2,6 +2,7 @@
TARGET = muine.exe
WRAPPER = muine
+MUINE_LIBS = $(GTKSHARP_LIBS) $(TAGLIBSHARP_LIBS)
MUINE_CSFILES = \
$(srcdir)/AddSongWindow.cs \
@@ -108,7 +109,7 @@
< $^ > $@
$(TARGET): $(MUINE_CSFILES) $(MUINE_GENERATED_CSFILES) $(top_builddir)/PluginLib/muine-plugin.dll $(top_builddir)/DBusLib/muine-dbus.dll
- $(CSC) -target:winexe -out:$@ $(MUINE_CSFILES) $(MUINE_GENERATED_CSFILES) $(MUINE_ASSEMBLIES) $(MUINE_RESOURCES) $(GTKSHARP_LIBS)
+ $(CSC) -target:winexe -out:$@ $(MUINE_CSFILES) $(MUINE_GENERATED_CSFILES) $(MUINE_ASSEMBLIES) $(MUINE_RESOURCES) $(MUINE_LIBS)
all: $(TARGET)
Modified: trunk/src/Metadata.cs
==============================================================================
--- trunk/src/Metadata.cs (original)
+++ trunk/src/Metadata.cs Fri Nov 7 18:02:49 2008
@@ -17,14 +17,12 @@
* Boston, MA 02111-1307, USA.
*/
-using System;
-using System.Runtime.InteropServices;
-using System.Collections;
-
-using Gdk;
-
using Mono.Unix;
+using TagLib;
+using TagLib.Id3v2;
+using TagLib.Mpeg4;
+
namespace Muine
{
public class Metadata
@@ -33,233 +31,229 @@
private static readonly string string_error_load =
Catalog.GetString ("Failed to load metadata: {0}");
- // Objects
- private IntPtr raw = IntPtr.Zero;
- private Pixbuf album_art = null;
+ private TagLib.File file = null;
+ private Gdk.Pixbuf album_art = null;
+ private double peak = 0.0, gain = 0.0;
+ private bool peak_set = false, gain_set = false;
// Constructor
- [DllImport ("libmuine")]
- private static extern IntPtr metadata_load (string filename,
- out IntPtr error_message_return);
-
public Metadata (string filename)
{
- IntPtr error_ptr;
-
- raw = metadata_load (filename, out error_ptr);
-
- if (error_ptr != IntPtr.Zero) {
- string error = GLib.Marshaller.PtrToStringGFree (error_ptr);
- throw new Exception (String.Format (string_error_load, error));
+ file = TagLib.File.Create (filename);
+ if (file == null || file.Tag == null || file.Properties.MediaTypes != TagLib.MediaTypes.Audio) {
+ throw new System.Exception (System.String.Format (string_error_load, filename));
}
}
// Properties
// Properties :: Title (get;)
- [DllImport ("libmuine")]
- private static extern IntPtr metadata_get_title (IntPtr metadata);
public string Title {
- get {
- IntPtr title_ptr = metadata_get_title (raw);
-
- string title = String.Empty;
-
- if (title_ptr != IntPtr.Zero) {
- string title_tmp = Marshal.PtrToStringAnsi (title_ptr);
- title = title_tmp.Trim ();
- }
-
- return title;
- }
+ get { return file.Tag.Title != null ? file.Tag.Title : ""; }
}
// Properties :: Artists (get;)
// FIXME: Refactor Artists and Performers properties
- [DllImport ("libmuine")]
- private static extern int metadata_get_artist_count (IntPtr metadata);
-
- [DllImport ("libmuine")]
- private static extern IntPtr metadata_get_artist
- (IntPtr metadata, int index);
public string [] Artists {
- get {
- ArrayList strings = new ArrayList ();
-
- int count = metadata_get_artist_count (raw);
-
- for (int i = 0; i < count; i++) {
- IntPtr artist_ptr = metadata_get_artist (raw, i);
- string artist = Marshal.PtrToStringAnsi (artist_ptr);
-
- if (artist == null || artist.Length <= 0)
- continue;
-
- strings.Add (artist.Trim());
- }
-
- Type string_type = typeof (string);
- return (string []) strings.ToArray (string_type);
- }
+ get { return file.Tag.AlbumArtists; }
}
// Properties :: Performers (get;)
// FIXME: Refactor Artists and Performers properties
- [DllImport ("libmuine")]
- private static extern IntPtr metadata_get_performer
- (IntPtr metadata, int index);
-
- [DllImport ("libmuine")]
- private static extern int metadata_get_performer_count
- (IntPtr metadata);
public string [] Performers {
- get {
- ArrayList strings = new ArrayList ();
-
- int count = metadata_get_performer_count (raw);
-
- for (int i = 0; i < count; i++) {
- IntPtr performer_ptr = metadata_get_performer (raw, i);
- string performer = Marshal.PtrToStringAnsi (performer_ptr);
-
- if (performer == null || performer.Length <= 0)
- continue;
-
- strings.Add (performer.Trim());
- }
-
- Type string_type = typeof (string);
- return (string []) strings.ToArray (string_type);
- }
+ get { return file.Tag.Performers; }
}
// Properties :: Album (get;)
- [DllImport ("libmuine")]
- private static extern IntPtr metadata_get_album (IntPtr metadata);
public string Album {
- get {
- IntPtr album_ptr = metadata_get_album (raw);
-
- string album;
- if (album_ptr == IntPtr.Zero) {
- album = String.Empty;
- } else {
- string album_tmp = Marshal.PtrToStringAnsi (album_ptr);
- album = album_tmp.Trim ();
- }
-
- return album;
- }
+ get { return file.Tag.Album != null ? file.Tag.Album : ""; }
}
// Properties :: AlbumArt (get;)
- [DllImport ("libmuine")]
- private static extern IntPtr metadata_get_album_art (IntPtr metadata);
-
- public Pixbuf AlbumArt {
- get {
- if (album_art != null)
- return album_art;
-
- IntPtr album_art_ptr = metadata_get_album_art (raw);
-
- if (album_art_ptr != IntPtr.Zero)
- album_art = new Pixbuf (album_art_ptr);
+ public Gdk.Pixbuf AlbumArt {
+ get {
+ if (album_art == null) {
+ TagLib.Id3v2.Tag id3v2_tag = (TagLib.Id3v2.Tag) file.GetTag (TagTypes.Id3v2);
+ if (id3v2_tag != null) {
+ // Try to get a cover image first.
+ foreach (AttachedPictureFrame f in id3v2_tag.GetFrames ("APIC")) {
+ if (f.Type == PictureType.FrontCover) {
+ album_art = GetPixbuf (f.Data);
+ if (album_art != null)
+ return album_art;
+ }
+ }
+
+ // Take any image we can get.
+ foreach (AttachedPictureFrame f in id3v2_tag.GetFrames ("APIC")) {
+ album_art = GetPixbuf (f.Data);
+
+ if (album_art != null)
+ return album_art;
+ }
+ }
+
+ /*
+ FIXME!!! API changes...
+ TagLib.Mpeg4.AppleTag apple_tag = (TagLib.Mpeg4.AppleTag) file.GetTag (TagTypes.Apple);
+ if (apple_tag != null) {
+ foreach (AppleDataBox b in apple_tag.DataBoxes ("covr")) {
+ if (b.Flags == (uint) AppleDataBox.FlagTypes.ContainsJpegData ||
+ b.Flags == (uint) AppleDataBox.FlagTypes.ContainsPngData) {
+ album_art = GetPixbuf (b.Data);
+
+ if (album_art != null)
+ return album_art;
+ }
+ }
+ }
+ */
+ }
return album_art;
}
}
// Properties :: TrackNumber (get;)
- [DllImport ("libmuine")]
- private static extern int metadata_get_track_number (IntPtr metadata);
public int TrackNumber {
- get { return metadata_get_track_number (raw); }
+ get { return (int) file.Tag.Track; }
}
// Properties :: TotalTracks (get;)
- [DllImport ("libmuine")]
- private static extern int metadata_get_total_tracks (IntPtr metadata);
public int TotalTracks {
- get { return metadata_get_total_tracks (raw); }
+ get { return (int) file.Tag.TrackCount; }
}
// Properties :: DiscNumber (get;)
- [DllImport ("libmuine")]
- private static extern int metadata_get_disc_number (IntPtr metadata);
public int DiscNumber {
- get { return metadata_get_disc_number (raw); }
+ get { return (int) file.Tag.Disc; }
}
// Properties :: Year (get;)
- [DllImport ("libmuine")]
- private static extern IntPtr metadata_get_year (IntPtr metadata);
public string Year {
- get {
- IntPtr year_ptr = metadata_get_year (raw);
-
- string year = String.Empty;
-
- if (year_ptr != IntPtr.Zero)
- year = Marshal.PtrToStringAnsi (year_ptr);
-
- return year;
- }
+ get { return file.Tag.Year.ToString ();}
}
// Properties :: Duration (get;)
- [DllImport ("libmuine")]
- private static extern int metadata_get_duration (IntPtr metadata);
public int Duration {
- get { return metadata_get_duration (raw); }
+ get { return file.Properties.Duration.Seconds; }
}
// Properties :: MimeType (get;)
- [DllImport ("libmuine")]
- private static extern IntPtr metadata_get_mime_type (IntPtr metadata);
public string MimeType {
- get {
- IntPtr type_ptr = metadata_get_mime_type (raw);
-
- string type = String.Empty;
- if (type_ptr != IntPtr.Zero)
- Marshal.PtrToStringAnsi (type_ptr);
-
- return type;
- }
+ get { return file.MimeType != null ? file.MimeType : ""; }
}
// Properties :: MTime (get;)
- [DllImport ("libmuine")]
- private static extern int metadata_get_mtime (IntPtr metadata);
public int MTime {
- get { return metadata_get_mtime (raw); }
+ get {
+ Mono.Unix.Native.Stat buf;
+ Mono.Unix.Native.Syscall.stat (file.Name, out buf);
+ return (int) buf.st_mtime;
+ }
}
// Properties :: Gain (get;)
- [DllImport ("libmuine")]
- private static extern double metadata_get_gain (IntPtr metadata);
public double Gain {
- get { return metadata_get_gain (raw); }
+ get {
+ if (!gain_set)
+ {
+ gain_set = true;
+
+ TagLib.Ogg.XiphComment xiph_comment = (TagLib.Ogg.XiphComment) file.GetTag (TagTypes.Xiph);
+ TagLib.Id3v2.Tag id3v2_tag = (TagLib.Id3v2.Tag) file.GetTag (TagTypes.Id3v2);
+
+ if (id3v2_tag != null) {
+ foreach (RelativeVolumeFrame f in id3v2_tag.GetFrames ("RVA2")) {
+ gain = f.GetVolumeAdjustment (ChannelType.MasterVolume);
+ return gain;
+ }
+ }
+
+ if (xiph_comment != null) {
+ string [] names = {"replaygain_track_gain", "replaygain_album_gain", "rg_audiophile", "rg_radio"};
+ foreach (string name in names) {
+ string [] l = xiph_comment.GetField (name);
+ if (l != null && l.Length != 0)
+ foreach (string s in l)
+ try {
+ gain = System.Double.Parse (s);
+ return gain;
+ } catch {}
+ }
+ }
+ }
+
+ return gain;
+ }
}
// Properties :: Peak (get;)
- [DllImport ("libmuine")]
- private static extern double metadata_get_peak (IntPtr metadata);
public double Peak {
- get { return metadata_get_peak (raw); }
+ get {
+ if (!peak_set)
+ {
+ peak_set = true;
+
+ TagLib.Ogg.XiphComment xiph_comment = (TagLib.Ogg.XiphComment) file.GetTag (TagTypes.Xiph);
+ TagLib.Id3v2.Tag id3v2_tag = (TagLib.Id3v2.Tag) file.GetTag (TagTypes.Id3v2);
+
+ if (id3v2_tag != null) {
+ foreach (RelativeVolumeFrame f in id3v2_tag.GetFrames ("RVA2")) {
+ peak = f.GetPeakVolume (ChannelType.MasterVolume);
+ return peak;
+ }
+ }
+
+ if (xiph_comment != null) {
+ string [] names = {"replaygain_track_peak", "replaygain_album_peak", "rg_peak"};
+ foreach (string name in names) {
+ string [] l = xiph_comment.GetField (name);
+ if (l != null && l.Length != 0)
+ foreach (string s in l)
+ try {
+ peak = System.Double.Parse (s);
+ return peak;
+ } catch {}
+ }
+ }
+ }
+
+ return peak;
+ }
+ }
+
+ private Gdk.Pixbuf GetPixbuf (ByteVector data)
+ {
+ bool bail = false;
+ Gdk.Pixbuf output;
+ Gdk.PixbufLoader loader = new Gdk.PixbufLoader ();
+
+ try {
+ if (!loader.Write (data.Data))
+ bail = true;
+ } catch {bail = true;}
+
+ try {
+ if (!loader.Close ())
+ bail = true;
+ } catch {bail = true;}
+
+ output = (!bail) ? loader.Pixbuf : null;
+
+ return output;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]