ref: c7c6d38a6e0223e9a210fde529fc84cf4cebce01
parent: 9e7e4c1abd383bd519551222d3e553c32729b035
author: menno <menno>
date: Wed Dec 3 13:38:09 EST 2003
XMMS plugin update
--- a/README.linux
+++ b/README.linux
@@ -1,5 +1,13 @@
-To compile under Linux:
+To compile under Linux.
+----------------------
+just run :
+ - autoreconf -vsf
+then run configure with options you want.
+run ./configure --help for more informations.
-chmod +x bootstrap
-./bootstrap
-./configure
+about the xmms plugin.
+---------------------
+ The xmms plugin need to be build after the install of the faad project.
+so after you have installed correctly faad (--with-xmms options) you need
+to configure and build the xmms plugin part in the plugins/xmms directory.
+Read the README and INSTALL files into the xmms directory.
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
AC_INIT
-AM_INIT_AUTOMAKE(faad2, 2.0.rc3)
+AM_INIT_AUTOMAKE(faad2, 2.0)
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)
@@ -86,25 +86,23 @@
fi
if test x$WITHXMMS = xyes; then
- AC_CHECK_PROGS(XMMS_CONFIG, xmms-config,"not_found")
- if test "$XMMS_CONFIG" = "not_found"; then
- AC_MSG_ERROR("*** xmms-config not found - xmms plugin can't be build")
- fi
- AC_CHECK_HEADER(pthread.h,,
- AC_MSG_ERROR(*** pthread headers support not installed or not found))
- AC_CHECK_HEADER(id3.h,,
- AC_MSG_ERROR(*** id3lib headers support not installed or not found))
- AC_CHECK_PROGS(GTK_CONFIG, gtk-config, "not_found")
-
- if test x$GTK_CONFIG = xnot_found; then
- AC_MSG_ERROR("*** gtk-config not found - xmms plugin can't be build")
- fi
-
- AM_CONDITIONAL(HAVE_XMMS, true)
- AC_MSG_NOTICE("xmms plugin requires libmp4v2 to be build")
+AC_MSG_NOTICE(
+***
+*** the xmms plugin must be build after faad
+*** you need to have libfaad and libmp4v2 installed on your system
+*** and also xmms installed correctly
+*** before the creation of the xmms plugin
+
+*** xmms plugin requires libmp4v2 to be build
+*** so libmp4v2 will be build and install
+
+*** after this build install the package and go into plugins/xmms
+*** and run configure in this directory
+***)
AM_CONDITIONAL(WITH_MP4V2, true)
else
- AM_CONDITIONAL(HAVE_XMMS, false)
+ AC_MSG_NOTICE(no xmms build configured)
+# AM_CONDITIONAL(HAVE_XMMS, false)
fi
if test x$WITHDRM = xyes; then
@@ -114,8 +112,6 @@
AC_CONFIG_FILES(libfaad/Makefile frontend/Makefile common/Makefile plugins/Makefile Makefile )
AC_CONFIG_FILES(plugins/mpeg4ip/Makefile)
-AC_CONFIG_FILES(plugins/xmms/Makefile plugins/xmms/src/Makefile)
-AC_CONFIG_FILES(plugins/xmmsmp4/Makefile plugins/xmmsmp4/src/Makefile)
AC_CONFIG_FILES(common/mp4ff/Makefile common/mp4v2/Makefile)
AC_OUTPUT
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,13 +1,5 @@
if HAVE_MPEG4IP
-if HAVE_XMMS
-SUBDIRS = mpeg4ip xmms xmmsmp4
-else
SUBDIRS = mpeg4ip
-endif
else
-if HAVE_XMMS
-SUBDIRS = xmms xmmsmp4
-else
SUBDIRS =
-endif
endif
--- a/plugins/xmms/AUTHORS
+++ b/plugins/xmms/AUTHORS
@@ -1,3 +1,3 @@
-xmms-aac plugin for xmms-1.2.7
+xmms-mp4 plugin for xmms-1.2.x
re-coded by ciberfred from scratch
--- a/plugins/xmms/ChangeLog
+++ b/plugins/xmms/ChangeLog
@@ -1,3 +1,7 @@
+1 December 2003:
+ * remove aac plug and merge the aac part with the mp4 part
+ so now 2 plugins in one :)
+
4 juillet 2003:
* package the plugin for faad2
* upgrade code to libfaad2-2.0 API
--- a/plugins/xmms/INSTALL
+++ b/plugins/xmms/INSTALL
@@ -1,1 +1,4 @@
-see README file
+ton install the mp4/aac plugin run :
+ - autoreconf -vfs && configure
+and install as root with :
+ - make install-strip
--- a/plugins/xmms/NEWS
+++ b/plugins/xmms/NEWS
@@ -1,3 +1,8 @@
+1 Decembre 2003
+---------------
+merge du plugin aac et du plugin mp4. modification des script du projet faad
+le plugin ne doit pas etre construit en meme temps que le projet
+
4 Juillet 2003
--------------
integration du plugin xmms-aac dans le projet faad2 version 2.x
--- a/plugins/xmms/README
+++ b/plugins/xmms/README
@@ -1,18 +1,16 @@
- this is an AAC InputPlugin source written from scratch for Xmms 1.2.7
- by ciberfred from France
- version 0.5 (build of 4 july 2003)
-
+ xmms-mp4 plugin v0.4
+ (dynamic version)
+ "a mp4/aac audio player for xmms"
+ coded by ciberfred from france
-------------
-Hey, nice to see that i could realise a plugin for xmms .. :), so what about
-this plugin. This is a plugin to play AAC files (.aac) encoded with FAAC or
-the M$ windows program psytel aacenc.exe
+This source code allow to xmms to read .mp4/.m4a/.aac files
-The plugin read aac files with and without ID3tag(version 2.x), AAC files
-are MPEG2 or MPEG4 files that could be found in MPEG4 audio files (.mp4).
-MPEG4 files with aac inside could be read by RealPlayer or Quicktime and with
-my mp4 audio only xmms plugin. Also you could check the lamip project on
-sourceforge.
+About.
+ This plugin is a merge between aac and mp4 plugin. so now you could read
+all new and old files encoded with different encoder and different format
+(for the aac part). This is possible since the libfaad2 allow to read
+old aac ADTS format.
For any informations about this plugin contact me at :
@@ -29,22 +27,12 @@
This error is comming from faad2
To remove this error use psystrip.exe windows program on the file. This maybe
resolve this problem.
+ -------------------------------------------------------------
-this plugin was tested with the psytel encoder 2.15 (MPEG4 version for all
-profile)
+This plugin was tested with the psytel encoder v2.15 and a nero encoder
-I don't test it for more than 2 channels file, i don't have such files...
-if you wana test and give feedback could be great :)
-
-Also note that if you have old aac files encoded with psytel 2.15 you should
-use the 0.4 version of this plugin. (see my home page). This version
-handle the new AAC files with new ADTS header size.
-------------------------------------------------------------
-To build this plugin just run and install the faad2 package
-also check that you have :
-id3lib-3.8.x (http://www.id3.org), the lastiest version is better
-xmms-1.2.7 (http://www.xmms.org)
--
-Fr�d�ric Fondriest from France
+Fr�d�ric Fondriest
--- a/plugins/xmms/configure.in
+++ b/plugins/xmms/configure.in
@@ -1,25 +1,23 @@
-dnl configure.in for faad2-2.0 package
+dnl configure.in for xmms faad2-2.0 package
-AC_INIT(src/libaac.c)
-AM_INIT_AUTOMAKE(libaac, 0.5)
+AC_INIT(src/libmp4.c)
+AM_INIT_AUTOMAKE(libmp4, 0.4)
dnl save CFLAGS since AC_PROG_CC insert "-g -O2" if CFLAGS is empty
cflags_save="$CFLAGS"
-AC_DISABLE_STATIC
AM_DISABLE_STATIC
AC_PROG_CC
-AC_PROG_CXX
AC_PROG_LIBTOOL
+AC_PROG_INSTALL
+AC_CHECK_PROGS(XMMS_CONFIG, xmms-config,
+ [AC_MSG_ERROR("*** xmms-config not found check PATH or install xmms")])
-AC_CHECK_PROGS(XMMS_CONFIG, xmms-config,"no_found")
-if test "$XMMS_CONFIG" = "no_found"; then
- AC_MSG_ERROR("*** xmms-config not found check PATH or install xmms")
-fi
+AC_CHECK_LIB(mp4v2, MP4Create, ,AC_MSG_ERROR(*** libmp4v2 not installed), -lstdc++)
-CFLAGS="$cflags_save `xmms-config --cflags` -Wall"
+CFLAGS="$cflags_save `xmms-config --cflags`"
CPPFLAGS="$CPPFLAGS $CFLAGS"
AC_SUBST(CFLAGS)
@@ -27,20 +25,14 @@
AC_MSG_ERROR(*** pthread headers support not installed or not found))
AC_CHECK_HEADER(id3.h,,
AC_MSG_ERROR(*** id3lib headers support not installed or not found))
-
-dnl *** check for presence of libfaad2 in the system
-dnl *** it's maybe a new version than provided here (faad2-1.1)
-dnl ***
-dnl ***
-have_libfaad2=yes
AC_CHECK_HEADER(faad.h,,
- [echo "*** use libfaad2-2.0 in static mode"
- have_libfaad2=no])
-AM_CONDITIONAL(USE_STATIC_FAAD2, test $have_libfaad2 = no)
+ AC_MSG_ERROR(*** faad header not installed check your CFLAGS))
AC_OUTPUT(Makefile src/Makefile )
-echo "***"
-echo "*** configuration xmms-aac plugin done (version 0.5)"
-echo "***"
-echo "*** note that if you can't decode aac files you need"
-echo "*** the old libfaad2-1.1, typicaly for files encoded with psytel-2.15"
+
+echo ""
+echo "-------==========MP4 & MPEG2/4-AAC decoder configured===========------"
+echo "CFLAGS: $CFLAGS"
+echo "CXXFLAGS: $CXXFLAGS"
+echo "install-dir = `xmms-config --input-plugin-dir`"
+echo ""
--- a/plugins/xmms/src/Makefile.am
+++ b/plugins/xmms/src/Makefile.am
@@ -1,13 +1,9 @@
libdir = `xmms-config --input-plugin-dir`
-lib_LTLIBRARIES = libaac.la
+lib_LTLIBRARIES = libmp4.la
-libaac_la_CFLAGS = `xmms-config --cflags` `$GTK_CONFIG --cflags` -Wall \
- -I$(top_builddir)/include
-
-libaac_la_LIBADD = $(top_builddir)/libfaad/libfaad.la
+INCLUDES = -I../../../common/mp4v2 -DHAVE_GLIB_H=1 -I../../../
-libaac_la_LDFLAGS = -module -avoid-version `xmms-config --libs` \
- `$GTK_CONFIG --libs` -lpthread -lz -lid3 -lstdc++
-libaac_la_SOURCES = libaac.c id3.cpp dialog_gtk1.c aac_utils.c \
- aac_utils.h
+libaac_la_CFLAGS = `xmms-config --cflags` -Wall -I$(top_srcdir)/include
+libaac_la_LDFLAGS = -module -avoid-version `xmms-config --libs` -lfaad -lpthread -lstdc++ -lmp4v2
+libaac_la_SOURCES = libmp4.c mp4_utils.c aac_utils.c
--- a/plugins/xmms/src/aac_utils.c
+++ b/plugins/xmms/src/aac_utils.c
@@ -1,12 +1,17 @@
/*
-** utils for AAC informations
+ *
+ * utils for AAC informations
*/
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
-#include "aac_utils.h"
+#define ADTS_HEADER_SIZE 8
+#define SEEK_TABLE_CHUNK 60
+#define MPEG4_TYPE 0
+#define MPEG2_TYPE 1
+
// Read ADTS header, the file descriptor must be at
// the begining of the aac frame not at the id3tag
@@ -72,11 +77,12 @@
}
(*seekTableLength) = SEEK_TABLE_CHUNK;
}
- if(id==0){//MPEG-4
- frameLength = ((unsigned int)header[4]<<5)|((unsigned int)header[5]>>3);
- }else{//MPEG-2
+
+ //if(id==0){//MPEG-4
+ //frameLength = ((unsigned int)header[4]<<5)|((unsigned int)header[5]>>3);
+ //}else{//MPEG-2
frameLength = (((unsigned int)header[3]&0x3)<<11)|((unsigned int)header[4]<<3)|(header[5]>>5);
- }
+ //}
if(frameInsec==43){//???
frameInsec=0;
}
--- a/plugins/xmms/src/aac_utils.h
+++ /dev/null
@@ -1,11 +1,0 @@
-#ifndef __AACUTILS_H__
-#define __AACUTILS_H__
-
-#define ADTS_HEADER_SIZE 8
-#define SEEK_TABLE_CHUNK 60
-#define MPEG4_TYPE 0
-#define MPEG2_TYPE 1
-
-int getAacInfo(FILE *);
-void checkADTSForSeeking(FILE *, unsigned long **, unsigned long *);
-#endif
--- a/plugins/xmms/src/dialog_gtk1.c
+++ /dev/null
@@ -1,348 +1,0 @@
-
-#include <gtk/gtk.h>
-
-char *title=0;
-char *artist=0;
-char *album=0;
-char *year=0;
-char *track=0;
-char *genre=0;
-char *comment=0;
-char *composer=0;
-char *url=0;
-char *originalArtist=0;
-char *encodedby=0;
-
-void updateWindowDatas(void);
-GtkWidget* createDialogInfo(void);
-
-GtkWidget* createDialogInfo(void)
-
-{
- GtkWidget *window1;
- GtkWidget *fixed1;
- GtkWidget *button1;
- GtkWidget *AACTypeentry;
- GtkWidget *HeaderTypeentry;
- GtkWidget *frame1;
- GtkWidget *fixed2;
- GtkWidget *Titleentry;
- GtkWidget *Artistentry;
- GtkWidget *Trackentry;
- GtkWidget *Albumentry;
- GtkWidget *Yearentry;
- GtkWidget *CommentText;
- GtkWidget *Composerentry;
- GtkWidget *label9;
- GtkWidget *label8;
- GtkWidget *label3;
- GtkWidget *label4;
- GtkWidget *label6;
- GtkWidget *label7;
- GtkWidget *label5;
- GtkWidget *OrArtistentry;
- GtkWidget *label10;
- GtkWidget *Encodedentry;
- GtkWidget *label11;
- GtkWidget *label1;
- GtkWidget *label2;
- GtkTooltips *tooltips;
-
- updateWindowDatas();
- tooltips = gtk_tooltips_new ();
-
- window1 = gtk_window_new (GTK_WINDOW_DIALOG);
- gtk_object_set_data (GTK_OBJECT (window1), "window1", window1);
- gtk_window_set_title (GTK_WINDOW (window1), "AAC info");
-
- fixed1 = gtk_fixed_new ();
- gtk_widget_ref (fixed1);
- gtk_object_set_data_full (GTK_OBJECT (window1), "fixed1", fixed1,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (fixed1);
- gtk_container_add (GTK_CONTAINER (window1), fixed1);
-
- button1 = gtk_button_new_with_label ("Close");
- gtk_widget_ref (button1);
- gtk_object_set_data_full (GTK_OBJECT (window1), "button1", button1,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_signal_connect_object(GTK_OBJECT(button1), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window1));
- gtk_widget_show (button1);
- gtk_fixed_put (GTK_FIXED (fixed1), button1, 408, 16);
- gtk_widget_set_uposition (button1, 408, 16);
- gtk_widget_set_usize (button1, 47, 22);
-
- AACTypeentry = gtk_entry_new ();
- gtk_widget_ref (AACTypeentry);
- gtk_object_set_data_full (GTK_OBJECT (window1), "AACTypeentry", AACTypeentry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (AACTypeentry);
- gtk_fixed_put (GTK_FIXED (fixed1), AACTypeentry, 128, 8);
- gtk_widget_set_uposition (AACTypeentry, 128, 8);
- gtk_widget_set_usize (AACTypeentry, 96, 16);
- gtk_entry_set_editable (GTK_ENTRY (AACTypeentry), FALSE);
-
- HeaderTypeentry = gtk_entry_new ();
- gtk_widget_ref (HeaderTypeentry);
- gtk_object_set_data_full (GTK_OBJECT (window1), "HeaderTypeentry", HeaderTypeentry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (HeaderTypeentry);
- gtk_fixed_put (GTK_FIXED (fixed1), HeaderTypeentry, 128, 32);
- gtk_widget_set_uposition (HeaderTypeentry, 128, 32);
- gtk_widget_set_usize (HeaderTypeentry, 96, 16);
- gtk_entry_set_editable (GTK_ENTRY (HeaderTypeentry), FALSE);
-
- frame1 = gtk_frame_new ("ID3v2 Tag");
- gtk_widget_ref (frame1);
- gtk_object_set_data_full (GTK_OBJECT (window1), "frame1", frame1,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (frame1);
- gtk_fixed_put (GTK_FIXED (fixed1), frame1, 8, 64);
- gtk_widget_set_uposition (frame1, 8, 64);
- gtk_widget_set_usize (frame1, 464, 192);
-
- fixed2 = gtk_fixed_new ();
- gtk_widget_ref (fixed2);
- gtk_object_set_data_full (GTK_OBJECT (window1), "fixed2", fixed2,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (fixed2);
- gtk_container_add (GTK_CONTAINER (frame1), fixed2);
-
- Titleentry = gtk_entry_new ();
- gtk_widget_ref (Titleentry);
- gtk_object_set_data_full (GTK_OBJECT (window1), "Titleentry", Titleentry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (Titleentry);
- gtk_fixed_put (GTK_FIXED (fixed2), Titleentry, 80, 0);
- gtk_widget_set_uposition (Titleentry, 80, 0);
- gtk_widget_set_usize (Titleentry, 232, 16);
- gtk_entry_set_editable (GTK_ENTRY (Titleentry), FALSE);
- gtk_entry_set_text (GTK_ENTRY (Titleentry), title);
-
- Artistentry = gtk_entry_new ();
- gtk_widget_ref (Artistentry);
- gtk_object_set_data_full (GTK_OBJECT (window1), "Artistentry", Artistentry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (Artistentry);
- gtk_fixed_put (GTK_FIXED (fixed2), Artistentry, 80, 16);
- gtk_widget_set_uposition (Artistentry, 80, 16);
- gtk_widget_set_usize (Artistentry, 232, 16);
- gtk_entry_set_editable (GTK_ENTRY (Artistentry), FALSE);
- gtk_entry_set_text (GTK_ENTRY (Artistentry), artist);
-
- Trackentry = gtk_entry_new ();
- gtk_widget_ref (Trackentry);
- gtk_object_set_data_full (GTK_OBJECT (window1), "Trackentry", Trackentry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (Trackentry);
- gtk_fixed_put (GTK_FIXED (fixed2), Trackentry, 400, 32);
- gtk_widget_set_uposition (Trackentry, 400, 32);
- gtk_widget_set_usize (Trackentry, 56, 16);
- gtk_entry_set_editable (GTK_ENTRY (Trackentry), FALSE);
- gtk_entry_set_text (GTK_ENTRY (Trackentry), track);
-
- Albumentry = gtk_entry_new ();
- gtk_widget_ref (Albumentry);
- gtk_object_set_data_full (GTK_OBJECT (window1), "Albumentry", Albumentry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (Albumentry);
- gtk_fixed_put (GTK_FIXED (fixed2), Albumentry, 80, 32);
- gtk_widget_set_uposition (Albumentry, 80, 32);
- gtk_widget_set_usize (Albumentry, 232, 16);
- gtk_entry_set_editable (GTK_ENTRY (Albumentry), FALSE);
- gtk_entry_set_text (GTK_ENTRY (Albumentry), album);
-
- Yearentry = gtk_entry_new ();
- gtk_widget_ref (Yearentry);
- gtk_object_set_data_full (GTK_OBJECT (window1), "Yearentry", Yearentry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (Yearentry);
- gtk_fixed_put (GTK_FIXED (fixed2), Yearentry, 384, 0);
- gtk_widget_set_uposition (Yearentry, 384, 0);
- gtk_widget_set_usize (Yearentry, 72, 16);
- gtk_entry_set_editable (GTK_ENTRY (Yearentry), FALSE);
- gtk_entry_set_text (GTK_ENTRY (Yearentry), year);
-
- CommentText = gtk_text_new (NULL, NULL);
- gtk_widget_ref (CommentText);
- gtk_object_set_data_full (GTK_OBJECT (window1), "CommentText", CommentText,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (CommentText);
- gtk_fixed_put (GTK_FIXED (fixed2), CommentText, 80, 56);
- gtk_widget_set_uposition (CommentText, 80, 56);
- gtk_widget_set_usize (CommentText, 376, 48);
-
- Composerentry = gtk_entry_new ();
- gtk_widget_ref (Composerentry);
- gtk_object_set_data_full (GTK_OBJECT (window1), "Composerentry", Composerentry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (Composerentry);
- gtk_fixed_put (GTK_FIXED (fixed2), Composerentry, 80, 112);
- gtk_widget_set_uposition (Composerentry, 80, 112);
- gtk_widget_set_usize (Composerentry, 232, 16);
- gtk_entry_set_editable (GTK_ENTRY (Composerentry), FALSE);
- gtk_entry_set_text (GTK_ENTRY (Composerentry), composer);
-
- label9 = gtk_label_new ("Composer :");
- gtk_widget_ref (label9);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label9", label9,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label9);
- gtk_fixed_put (GTK_FIXED (fixed2), label9, 0, 112);
- gtk_widget_set_uposition (label9, 0, 112);
- gtk_widget_set_usize (label9, 80, 16);
- gtk_label_set_justify (GTK_LABEL (label9), GTK_JUSTIFY_RIGHT);
-
- label8 = gtk_label_new ("Comment :");
- gtk_widget_ref (label8);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label8", label8,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label8);
- gtk_fixed_put (GTK_FIXED (fixed2), label8, 0, 72);
- gtk_widget_set_uposition (label8, 0, 72);
- gtk_widget_set_usize (label8, 72, 16);
- gtk_label_set_justify (GTK_LABEL (label8), GTK_JUSTIFY_RIGHT);
-
- label3 = gtk_label_new ("Title :");
- gtk_widget_ref (label3);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label3", label3,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label3);
- gtk_fixed_put (GTK_FIXED (fixed2), label3, 8, 0);
- gtk_widget_set_uposition (label3, 8, 0);
- gtk_widget_set_usize (label3, 56, 16);
- gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_RIGHT);
-
- label4 = gtk_label_new ("Artist :");
- gtk_widget_ref (label4);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label4", label4,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label4);
- gtk_fixed_put (GTK_FIXED (fixed2), label4, 8, 16);
- gtk_widget_set_uposition (label4, 8, 16);
- gtk_widget_set_usize (label4, 56, 16);
- gtk_label_set_justify (GTK_LABEL (label4), GTK_JUSTIFY_RIGHT);
-
- label6 = gtk_label_new ("Album :");
- gtk_widget_ref (label6);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label6", label6,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label6);
- gtk_fixed_put (GTK_FIXED (fixed2), label6, 8, 32);
- gtk_widget_set_uposition (label6, 8, 32);
- gtk_widget_set_usize (label6, 48, 16);
- gtk_label_set_justify (GTK_LABEL (label6), GTK_JUSTIFY_RIGHT);
-
- label7 = gtk_label_new ("Year :");
- gtk_widget_ref (label7);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label7", label7,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label7);
- gtk_fixed_put (GTK_FIXED (fixed2), label7, 328, 0);
- gtk_widget_set_uposition (label7, 328, 0);
- gtk_widget_set_usize (label7, 64, 16);
- gtk_label_set_justify (GTK_LABEL (label7), GTK_JUSTIFY_RIGHT);
-
- label5 = gtk_label_new ("Track N\260 :");
- gtk_widget_ref (label5);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label5", label5,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label5);
- gtk_fixed_put (GTK_FIXED (fixed2), label5, 328, 32);
- gtk_widget_set_uposition (label5, 328, 32);
- gtk_widget_set_usize (label5, 64, 16);
- gtk_label_set_justify (GTK_LABEL (label5), GTK_JUSTIFY_RIGHT);
-
- OrArtistentry = gtk_entry_new ();
- gtk_widget_ref (OrArtistentry);
- gtk_object_set_data_full (GTK_OBJECT (window1), "OrArtistentry", OrArtistentry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (OrArtistentry);
- gtk_fixed_put (GTK_FIXED (fixed2), OrArtistentry, 80, 128);
- gtk_widget_set_uposition (OrArtistentry, 80, 128);
- gtk_widget_set_usize (OrArtistentry, 232, 16);
- gtk_tooltips_set_tip (tooltips, OrArtistentry, "Original Artist", NULL);
- gtk_entry_set_editable (GTK_ENTRY (OrArtistentry), FALSE);
- gtk_entry_set_text (GTK_ENTRY (OrArtistentry), originalArtist);
-
- label10 = gtk_label_new ("Or. Artist :");
- gtk_widget_ref (label10);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label10", label10,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label10);
- gtk_fixed_put (GTK_FIXED (fixed2), label10, 0, 128);
- gtk_widget_set_uposition (label10, 0, 128);
- gtk_widget_set_usize (label10, 72, 16);
-
- Encodedentry = gtk_entry_new ();
- gtk_widget_ref (Encodedentry);
- gtk_object_set_data_full (GTK_OBJECT (window1), "Encodedentry", Encodedentry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (Encodedentry);
- gtk_fixed_put (GTK_FIXED (fixed2), Encodedentry, 112, 144);
- gtk_widget_set_uposition (Encodedentry, 112, 144);
- gtk_widget_set_usize (Encodedentry, 200, 16);
- gtk_entry_set_editable (GTK_ENTRY (Encodedentry), FALSE);
- gtk_entry_set_text (GTK_ENTRY (Encodedentry), encodedby);
-
- label11 = gtk_label_new ("Encoded by :");
- gtk_widget_ref (label11);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label11", label11,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label11);
- gtk_fixed_put (GTK_FIXED (fixed2), label11, 0, 144);
- gtk_widget_set_uposition (label11, 0, 144);
- gtk_widget_set_usize (label11, 104, 16);
- gtk_label_set_justify (GTK_LABEL (label11), GTK_JUSTIFY_RIGHT);
-
- label1 = gtk_label_new ("AAC Type :");
- gtk_widget_ref (label1);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label1", label1,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label1);
- gtk_fixed_put (GTK_FIXED (fixed1), label1, 8, 8);
- gtk_widget_set_uposition (label1, 8, 8);
- gtk_widget_set_usize (label1, 112, 16);
- gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_RIGHT);
-
- label2 = gtk_label_new ("Header Type :");
- gtk_widget_ref (label2);
- gtk_object_set_data_full (GTK_OBJECT (window1), "label2", label2,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label2);
- gtk_fixed_put (GTK_FIXED (fixed1), label2, 8, 32);
- gtk_widget_set_uposition (label2, 8, 32);
- gtk_widget_set_usize (label2, 112, 16);
- gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_RIGHT);
-
- gtk_object_set_data (GTK_OBJECT (window1), "tooltips", tooltips);
-
- return window1;
-}
-
-// to don't have Gtk errors...
-void updateWindowDatas(void)
-{
- if(!title)
- title="";
- if(!artist)
- artist="";
- if(!album)
- album="";
- if(!year)
- year="";
- if(!track)
- track="";
- if(!genre)
- genre="";
- if(!comment)
- comment="";
- if(!composer)
- composer="";
- if(!url)
- url="";
- if(!originalArtist)
- originalArtist="";
- if(!encodedby)
- encodedby="";
-}
--- a/plugins/xmms/src/id3.cpp
+++ /dev/null
@@ -1,157 +1,0 @@
-/*
-** function to read id3tag from aac files
-*/
-
-#include <id3/tag.h>
-#include <id3/utils.h>
-#include <id3/misc_support.h>
-#include <id3/readers.h>
-#include <stdio.h>
-
-// this is to show the cpp functions to the C interface...
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void readID3tag(char*);
-void clearWindowDatas(void);
-extern char *title;
-extern char *artist;
-extern char *album;
-extern char *year;
-extern char *track;
-extern char *genre;
-extern char *comment;
-extern char *composer;
-extern char *url;
-extern char *originalArtist;
-extern char *encodedby;
-
-#ifdef __cplusplus
-}
-#endif
-
-
-void readID3tag(char *filename)
-{
- ID3_Tag tag;
-
- tag.Link(filename, ID3TT_ALL);
- ID3_Tag::Iterator *iter = tag.CreateIterator();
- ID3_Frame *frame = NULL;
-
- while((frame = iter->GetNext()) != NULL){
- ID3_FrameID FrameID = frame->GetID();
- switch (FrameID)
- {
- case ID3FID_TITLE:
- {
- title = ID3_GetString(frame, ID3FN_TEXT);
- break;
- }
- case ID3FID_LEADARTIST:
- {
- artist = ID3_GetString(frame, ID3FN_TEXT);
- break;
- }
- case ID3FID_ALBUM:
- {
- album = ID3_GetString(frame, ID3FN_TEXT);
- break;
- }
- case ID3FID_YEAR:
- {
- year = ID3_GetString(frame, ID3FN_TEXT);
- break;
- }
- case ID3FID_TRACKNUM:
- {
- track = ID3_GetString(frame, ID3FN_TEXT);
- break;
- }
- case ID3FID_CONTENTTYPE:
- {
- genre = ID3_GetString(frame, ID3FN_TEXT);
- break;
- }
- case ID3FID_COMMENT:
- {
- comment = ID3_GetString(frame, ID3FN_TEXT);
- break;
- }
- case ID3FID_COMPOSER:
- {
- composer = ID3_GetString(frame, ID3FN_TEXT);
- break;
- }
- case ID3FID_WWWARTIST:
- {
- url = ID3_GetString(frame, ID3FN_URL);
- break;
- }
- case ID3FID_ORIGARTIST:
- {
- originalArtist = ID3_GetString(frame, ID3FN_TEXT);
- break;
- }
- case ID3FID_ENCODEDBY:
- {
- encodedby = ID3_GetString(frame, ID3FN_TEXT);
- break;
- }
- default:
- break;
- }
- }
- delete iter;
- return;
-}
-
-void clearWindowDatas(void)
-{
- if(title)
- if(strcmp(title,"")!=0){
- delete [] title;
- }
- if(artist)
- if(strcmp(artist,"")!=0){
- delete [] artist;
- }
- if(album)
- if(strcmp(album,"")!=0){
- delete [] album;
- }
- if(year)
- if(strcmp(year,"")!=0){
- delete [] year;
- }
- if(track)
- if(strcmp(track,"")!=0){
- delete [] track;
- }
- if(genre)
- if(strcmp(genre,"")!=0){
- delete [] genre;
- }
- if(comment)
- if(strcmp(comment,"")!=0){
- delete [] comment;
- }
- if(composer)
- if(strcmp(composer,"")!=0){
- delete [] composer;
- }
- if(url)
- if(strcmp(url,"")!=0){
- delete [] url;
- }
- if(originalArtist)
- if(strcmp(originalArtist,"")!=0){
- delete [] originalArtist;
- }
- if(encodedby)
- if(strcmp(encodedby,"")!=0){
- delete [] encodedby;
- }
- title=artist=album=year=track=genre=comment=composer=url=originalArtist=encodedby=0;
-}
--- a/plugins/xmms/src/libaac.c
+++ /dev/null
@@ -1,435 +1,0 @@
-/*
-** AAC plugin for XMMS 1.2.7
-** by ciberfred
-** ------------------------------------------------
-**
-** need libfaad2 package from http://www.audiocoding.com
-** and id3lib-3.8.x package from http://id3lib.sourceforge.org
-**
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#include "faad.h"
-#include "xmms/plugin.h"
-#include "xmms/util.h"
-#include "xmms/configfile.h"
-#include "xmms/titlestring.h"
-#include "aac_utils.h"
-
-#define AAC_DESCRIPTION "MPEG2/4 AAC player - 1.2.7"
-#define AAC_VERSION "AAC player - 15 June 2003 (v0.4)"
-#define AAC_ABOUT "Writen from scratch by ciberfred from France\n"
-#define PATH2CONFIGFILE "/.xmms/Plugins/aacConfig.txt"
-#define BUFFER_SIZE FAAD_MIN_STREAMSIZE*64
-
-static void aac_init(void);
-static void aac_play(char*);
-static void aac_stop(void);
-static void aac_pause(short);
-static int aac_getTime(void);
-static void aac_seek(int);
-static void aac_cleanup(void);
-static void aac_about(void);
-static void aac_configuration(void);
-static void *aac_decode(void*);
-
-static void aac_getSongInfo(char*);
-static int aac_isFile(char*);
-
-extern void readID3tag(char*);
-extern GtkWidget *createDialogInfo(void);
-extern void clearWindowDatas(void);
-
-static GtkWidget *infoBoxWindow = NULL;
-extern char *title, *artist, *album, *track, *genre;
-
-
-/*****************************************************************************/
-/*
-** struct need by xmms for Library Interface
-*/
-
-InputPlugin aac_ip =
- {
- 0, // handle
- 0, // filename
- AAC_DESCRIPTION,// description
- aac_init, // init_func
- aac_about, // aboutbox
- aac_configuration, // configuration
- aac_isFile, // ???
- 0, // scan dir
- aac_play, // when play button
- aac_stop, // when stop
- aac_pause, // when pause
- aac_seek, // when seek
- 0, // set equalizer
- aac_getTime, // ???
- 0, // get volume
- 0, // set volume
- aac_cleanup, // the cleanup function :)
- 0, // obsolete (???)
- 0, // send visualisation data
- 0, // set player window info
- 0, // set song title text
- 0, // get song title text to show on Playlist
- aac_getSongInfo,// file info box
- 0 // pointer to outputPlugin
- };
-static gboolean bPlaying = FALSE;
-static gboolean bOutputOpen = FALSE;
-static pthread_t decodeThread;
-static gboolean bSeek = FALSE;
-static gint seekPosition = -1; // track position
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-static unsigned long *positionTable = 0;
-int aacType;
-/*****************************************************************************/
-
-InputPlugin *get_iplugin_info(void)
-{
- return (&aac_ip);
-}
-
-
-static void aac_init(void)
-{
- ConfigFile* cfg;
-
- memset(&decodeThread, 0, sizeof(pthread_t));
- cfg = xmms_cfg_open_default_file();
- xmms_cfg_read_boolean(cfg, "AAC", "seeking", &bSeek);
- xmms_cfg_free(cfg);
-}
-
-static void aac_cleanup(void)
-{
- memset(&decodeThread, 0, sizeof(pthread_t));
- if(positionTable){
- free(positionTable);
- }
-
-}
-
-static void aac_play(char *filename)
-{
- bPlaying = TRUE;
- if(pthread_create(&decodeThread, 0, aac_decode, g_strdup(filename))!=0){
- printf("Error creating pthread, can't play file\n");
- }
-
- return;
-}
-
-static void aac_stop(void)
-{
- if (bPlaying){
- bPlaying = FALSE;
- pthread_join(decodeThread, NULL);
- memset(&decodeThread, 0, sizeof(pthread_t));
- aac_ip.output->close_audio();
- clearWindowDatas();
- }
-}
-
-static void aac_pause(short paused)
-{
- if(bOutputOpen){
- aac_ip.output->pause(paused);
- }
-}
-
-static int aac_getTime(void)
-{
- if (!bPlaying){
- return (-1);
- }
- else{
- return (aac_ip.output->output_time());
- }
-}
-
-static void aac_seek(int time)
-{
- seekPosition=time;
- while(bPlaying && seekPosition!=-1) xmms_usleep(10000);
-}
-
-static void aac_getSongInfo(char *filename)
-{
- infoBoxWindow = createDialogInfo();
- gtk_widget_show(infoBoxWindow);
-}
-
-static void *aac_decode(void *args)
-{
- char *filename = args;
- char *xmmstitle=NULL;
- FILE *file = NULL;
- faacDecHandle decoder = 0;
- unsigned char *buffer = 0;
- unsigned long bufferconsumed = 0;
- unsigned long samplerate = 0;
- unsigned long lenght=0;
- char channels;
- unsigned long buffervalid = 0;
- TitleInput *input;
- char *temp = g_strdup(filename);
- char *ext = strrchr(temp, '.');
-
- pthread_mutex_lock(&mutex);
- seekPosition=-1;
- clearWindowDatas();
- if((file = fopen(filename, "rb")) == 0){
- printf("can't find file %s\n", filename);
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- if(bSeek){
- checkADTSForSeeking(file, &positionTable, &lenght);
- if((aacType = getAacInfo(file)) ==-1){
- g_print("erreur getAAC\n");
- fclose(file);
- if(positionTable){
- free(positionTable); positionTable=0;
- }
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- }
- if((decoder = faacDecOpen()) == NULL){
- printf("Open Decoder Error\n");
- fclose(file);
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- if((buffer = g_malloc(BUFFER_SIZE)) == NULL){
- printf("error g_malloc\n");
- fclose(file);
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
-
- if((buffervalid = fread(buffer, 1, BUFFER_SIZE, file))==0){
- printf("Error file NULL\n");
- g_free(buffer);
- fclose(file);
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- XMMS_NEW_TITLEINPUT(input);
- input->file_name = g_basename(temp);
- input->file_ext = ext ? ext+1 : NULL;
- input->file_path = temp;
- if(!strncmp(buffer, "ID3", 3)){
- int size = 0;
-
- readID3tag(filename);
- if(title)
- input->track_name = g_strdup(title);
- if(artist)
- input->performer = g_strdup(artist);
- if(genre)
- input->genre = g_strdup(genre);
- if(track)
- input->track_number = atoi(track);
- fseek(file, 0, SEEK_SET);
-/*
-** hum .. horrible hack taken from the winamp plugin to jump
-** the tag, is there any id3 function to do this ???? hum... seems not :(
-*/
- size = (buffer[6]<<21) | (buffer[7]<<14) | (buffer[8]<<7) | buffer[9];
- size+=10;
- fread(buffer, 1, size, file);
- if(bSeek){
- checkADTSForSeeking(file, &positionTable, &lenght);
- if((aacType = getAacInfo(file)) ==-1){
- printf("erreur getAAC\n");
- g_free(buffer); buffer=0;
- faacDecClose(decoder);
- fclose(file);
- aac_ip.output->close_audio();
- if(positionTable){
- free(positionTable); positionTable=0;
- }
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- printf("AAC-%s Type\n", aacType?"MPEG2":"MPEG4");
- }
- buffervalid = fread(buffer, 1, BUFFER_SIZE, file);
- }
- xmmstitle = xmms_get_titlestring(xmms_get_gentitle_format(), input);
- if(xmmstitle == NULL)
- xmmstitle = g_strdup(input->file_name);
- g_free(temp);
- g_free(input->performer);
- g_free(input->album_name);
- g_free(input->track_name);
- g_free(input->genre);
- g_free(input);
-
- bufferconsumed = faacDecInit(decoder, buffer, buffervalid, &samplerate, &channels);
- if((bOutputOpen = aac_ip.output->open_audio(FMT_S16_NE, samplerate, channels)) == FALSE){
- printf("Output Error\n");
- g_free(buffer); buffer=0;
- faacDecClose(decoder);
- fclose(file);
- aac_ip.output->close_audio();
- if(positionTable){
- free(positionTable); positionTable=0;
- }
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- if(bSeek){
- aac_ip.set_info(xmmstitle, lenght*1000, -1, samplerate, channels);
- }else{
- aac_ip.set_info(xmmstitle, -1, -1, samplerate, channels);
- }
- aac_ip.output->flush(0);
- while(bPlaying && buffervalid > 0){
- faacDecFrameInfo finfo;
- unsigned long samplesdecoded;
- char *sample_buffer = NULL;
-
- if(bSeek && seekPosition!=-1){
- fseek(file, positionTable[seekPosition], SEEK_SET);
- bufferconsumed=0;
- buffervalid = fread(buffer, 1, BUFFER_SIZE, file);
- aac_ip.output->flush(seekPosition*1000);
- seekPosition=-1;
- }
- if(bufferconsumed > 0){
- memmove(buffer, &buffer[bufferconsumed], buffervalid-bufferconsumed);
- buffervalid -= bufferconsumed;
- buffervalid += fread(&buffer[buffervalid], 1, BUFFER_SIZE-buffervalid, file);
- bufferconsumed = 0;
- }
- sample_buffer = faacDecDecode(decoder, &finfo, buffer, buffervalid);
- if(finfo.error){
- buffervalid = 0;
- printf("FAAD2 Error %s\n", faacDecGetErrorMessage(finfo.error));
- printf("---Use Psystrip.exe on the file to avoid the ADTS error---\n");
- }
- bufferconsumed += finfo.bytesconsumed;
- samplesdecoded = finfo.samples;
- if((samplesdecoded<=0) && !sample_buffer){
- printf("error\n");
- }
- while(bPlaying && aac_ip.output->buffer_free() < (samplesdecoded<<1)){
- xmms_usleep(10000);
- }
- aac_ip.add_vis_pcm(aac_ip.output->written_time(), FMT_S16_LE, channels, samplesdecoded<<1, sample_buffer);
- aac_ip.output->write_audio(sample_buffer, samplesdecoded<<1);
- }
- while(bPlaying && aac_ip.output->buffer_playing()){
- xmms_usleep(10000);
- }
- aac_ip.output->buffer_free();
- aac_ip.output->close_audio();
- bPlaying = FALSE;
- bOutputOpen = FALSE;
- g_free(buffer);
- faacDecClose(decoder);
- g_free(xmmstitle);
- fclose(file);
- seekPosition = -1;
- if(positionTable){
- free(positionTable); positionTable=0;
- }
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
-}
-
-static int aac_isFile(char *filename)
-{
- char *extention = strrchr(filename, '.');
- if (extention && !strcasecmp(extention, ".aac")){
- return (1);
- }
- return(0);
-}
-
-static void aac_about(void)
-{
- static GtkWidget *aboutbox;
-
- if(aboutbox!=NULL)
- return;
-
- aboutbox = xmms_show_message(
- "About MPEG2/4-AAC plugin",
- "decoding engine : FAAD2 team\n"
- "Plugin coder : ciberfred",
- "Ok", FALSE, NULL, NULL);
- gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy",
- GTK_SIGNAL_FUNC(gtk_widget_destroyed),
- &aboutbox);
-}
-
-
-static GtkWidget *checkbutton;
-static GtkWidget *window;
-static void aac_configuration_save(GtkWidget *widget, gpointer data)
-{
- ConfigFile *cfg;
- bSeek = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton));
- cfg = xmms_cfg_open_default_file();
- xmms_cfg_write_boolean(cfg, "AAC", "seeking", bSeek);
- xmms_cfg_free(cfg);
- gtk_widget_destroy(window);
-}
-
-static void aac_configuration(void)
-{
- GtkWidget *vbox, *hbox;
- GtkWidget *NotaBene;
- GtkWidget *button2;
-
- window = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_signal_connect(GTK_OBJECT(window), "destroy",
- GTK_SIGNAL_FUNC(gtk_widget_destroyed),
- &window);
- gtk_window_set_title(GTK_WINDOW(window), "AAC Plugin Configuration");
- gtk_widget_set_usize(window, 220, 200);
-
- vbox = gtk_vbox_new(FALSE, 2);
- gtk_container_add(GTK_CONTAINER(window), vbox);
-
- NotaBene = gtk_text_new(NULL, NULL);
- GTK_WIDGET_UNSET_FLAGS (NotaBene, GTK_CAN_FOCUS);
- gtk_text_insert(GTK_TEXT(NotaBene), NULL, NULL, NULL,
- "Remember that unable seeking"
- " is not suitable for playing"
- " file from network.\n"
- "Seeking must read first all aac file before playing.",-1);
- gtk_box_pack_start(GTK_BOX(vbox), NotaBene, FALSE, FALSE, 0);
-
- checkbutton = gtk_check_button_new_with_label("Unable Seeking");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), bSeek);
- gtk_box_pack_start(GTK_BOX(vbox), checkbutton, FALSE, FALSE, 0);
-
- hbox = gtk_hbutton_box_new();
- gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-
- button2 = gtk_button_new_with_label ("Save");
- gtk_signal_connect_object(GTK_OBJECT(button2), "clicked",
- GTK_SIGNAL_FUNC(aac_configuration_save),
- GTK_OBJECT(window));
- gtk_box_pack_start(GTK_BOX(hbox), button2, FALSE, FALSE, 0);
- button2 = gtk_button_new_with_label ("Close");
- gtk_signal_connect_object(GTK_OBJECT(button2), "clicked",
- GTK_SIGNAL_FUNC(gtk_widget_destroy),
- GTK_OBJECT(window));
- gtk_box_pack_start(GTK_BOX(hbox), button2, FALSE, FALSE, 0);
- gtk_widget_show_all(window);
-}
-
--- /dev/null
+++ b/plugins/xmms/src/libmp4.c
@@ -1,0 +1,501 @@
+/*
+ * MP4/AAC decoder for xmms
+ *
+ * OPTIONNAL need
+ * --------------
+ * libid3 (3.8.x - www.id3.org)
+*/
+
+#include <pthread.h>
+#include <gtk/gtk.h>
+#include "faad.h"
+#include "mp4.h"
+
+#include <xmms/plugin.h>
+#include <xmms/util.h>
+#include <xmms/configfile.h>
+#include <xmms/titlestring.h>
+
+#define MP4_DESCRIPTION "MP4 & MPEG2/4-AAC audio player - 1.2.x"
+#define MP4_VERSION "ver. 0.4 - 24 November 2003"
+#define LIBMP4V2_VERSION "-faad2-version"
+#define MP4_ABOUT "Written by ciberfred"
+#define BUFFER_SIZE FAAD_MIN_STREAMSIZE*64
+
+static void mp4_init(void);
+static void mp4_about(void);
+static void mp4_play(char *);
+static void mp4_stop(void);
+static void mp4_pause(short);
+static void mp4_seek(int);
+static int mp4_getTime(void);
+static void mp4_cleanup(void);
+static void mp4_getSongInfo(char *);
+static int mp4_isFile(char *);
+static void* mp4Decode(void *);
+
+InputPlugin mp4_ip =
+ {
+ 0, // handle
+ 0, // filename
+ MP4_DESCRIPTION,
+ mp4_init,
+ mp4_about,
+ 0, // configuration
+ mp4_isFile,
+ 0, //scandir
+ mp4_play,
+ mp4_stop,
+ mp4_pause,
+ mp4_seek,
+ 0, // set equalizer
+ mp4_getTime,
+ 0, // get volume
+ 0,
+ mp4_cleanup,
+ 0, // obsolete
+ 0, // send visualisation data
+ 0, // set player window info
+ 0, // set song title text
+ 0, // get song title text
+ mp4_getSongInfo, // info box
+ 0, // to output plugin
+ };
+
+typedef struct _mp4cfg{
+ gshort file_type;
+#define FILE_UNKNOW 0
+#define FILE_MP4 1
+#define FILE_AAC 2
+} Mp4Config;
+
+static Mp4Config mp4cfg;
+static gboolean bPlaying = FALSE;
+static pthread_t decodeThread;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static int seekPosition = -1;
+
+
+InputPlugin *get_iplugin_info(void)
+{
+ return(&mp4_ip);
+}
+
+static void mp4_init(void)
+{
+ memset(&decodeThread, 0, sizeof(pthread_t));
+ mp4cfg.file_type = FILE_UNKNOW;
+ seekPosition = -1;
+ return;
+}
+
+static void mp4_play(char *filename)
+{
+ bPlaying = TRUE;
+ pthread_create(&decodeThread, 0, mp4Decode, g_strdup(filename));
+ return;
+}
+
+static void mp4_stop(void)
+{
+ if(bPlaying){
+ bPlaying = FALSE;
+ pthread_join(decodeThread, NULL);
+ memset(&decodeThread, 0, sizeof(pthread_t));
+ mp4_ip.output->close_audio();
+ }
+}
+
+static int mp4_isFile(char *filename)
+{
+ if(filename){
+ gchar* extention;
+
+ extention = strrchr(filename, '.');
+ if (extention &&
+ !strcasecmp(extention, ".mp4") || // official extention
+ !strcasecmp(extention, ".m4a") || // Apple mp4 extention
+ !strcasecmp(extention, ".aac") // old MPEG2/4-AAC extention
+ ){
+ return (1);
+ }
+ }
+ return(0);
+}
+
+static void mp4_about(void)
+{
+ static GtkWidget *aboutbox;
+
+ if(aboutbox!=NULL)
+ return;
+ aboutbox = xmms_show_message("About MP4 AAC player plugin",
+ "libfaad2-" FAAD2_VERSION "\n"
+ "libmp4v2-" LIBMP4V2_VERSION "\n"
+ "plugin version: " MP4_VERSION "\n"
+ MP4_ABOUT,
+ "Ok", FALSE, NULL, NULL);
+ gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy",
+ GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+ &aboutbox);
+}
+
+static void mp4_pause(short flag)
+{
+ mp4_ip.output->pause(flag);
+}
+
+static void mp4_seek(int time)
+{
+ seekPosition = time;
+ while(bPlaying && seekPosition!=-1)
+ xmms_usleep(10000);
+}
+
+static int mp4_getTime(void)
+{
+ if(!bPlaying)
+ return (-1);
+ else
+ return (mp4_ip.output->output_time());
+}
+
+static void mp4_cleanup(void)
+{
+}
+
+static void mp4_getSongInfo(char *filename)
+{
+ if(mp4cfg.file_type == FILE_MP4)
+ getMP4info(filename);
+ else if(mp4cfg.file_type == FILE_AAC)
+ ;
+}
+
+static void *mp4Decode(void *args)
+{
+ MP4FileHandle mp4file;
+
+ pthread_mutex_lock(&mutex);
+ seekPosition = -1;
+ bPlaying = TRUE;
+ if(!(mp4file = MP4Read(args, 0))){
+ mp4cfg.file_type = FILE_AAC;
+ MP4Close(mp4file);
+ }else{
+ mp4cfg.file_type = FILE_MP4;
+ }
+
+ if(mp4cfg.file_type == FILE_MP4){
+ // We are reading a MP4 file
+ gint mp4track;
+
+ if((mp4track = getAACTrack(mp4file)) < 0){
+ //TODO: check here for others Audio format.....
+ g_print("Unsupported Audio track type\n");
+ g_free(args);
+ MP4Close(mp4file);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }else{
+ faacDecHandle decoder;
+ unsigned char *buffer = NULL;
+ guint bufferSize = 0;
+ gulong samplerate;
+ guchar channels;
+ guint avgBitrate;
+ MP4Duration duration;
+ gulong msDuration;
+ MP4SampleId numSamples;
+ MP4SampleId sampleID = 1;
+
+ decoder = faacDecOpen();
+ MP4GetTrackESConfiguration(mp4file, mp4track, &buffer, &bufferSize);
+ if(!buffer){
+ g_free(args);
+ faacDecClose(decoder);
+ MP4Close(mp4file);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ if(faacDecInit2(decoder, buffer, bufferSize, &samplerate, &channels)<0){
+ g_free(args);
+ faacDecClose(decoder);
+ MP4Close(mp4file);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ g_free(buffer);
+ if(channels == 0){
+ g_print("Number of Channels not supported\n");
+ g_free(args);
+ faacDecClose(decoder);
+ MP4Close(mp4file);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ duration = MP4GetTrackDuration(mp4file, mp4track);
+ msDuration = MP4ConvertFromTrackDuration(mp4file, mp4track, duration,
+ MP4_MSECS_TIME_SCALE);
+ numSamples = MP4GetTrackNumberOfSamples(mp4file, mp4track);
+ mp4_ip.output->open_audio(FMT_S16_NE, samplerate, channels);
+ mp4_ip.output->flush(0);
+ mp4_ip.set_info(args, msDuration, -1, samplerate/1000, channels);
+ g_print("MP4 - %d channels @ %d Hz\n", channels, samplerate);
+
+ while(bPlaying){
+ void* sampleBuffer;
+ faacDecFrameInfo frameInfo;
+ gint rc;
+
+ if(seekPosition!=-1){
+ duration = MP4ConvertToTrackDuration(mp4file,
+ mp4track,
+ seekPosition*1000,
+ MP4_MSECS_TIME_SCALE);
+ sampleID = MP4GetSampleIdFromTime(mp4file, mp4track, duration, 0);
+ mp4_ip.output->flush(seekPosition*1000);
+ seekPosition = -1;
+ }
+ buffer=NULL;
+ bufferSize=0;
+ if(sampleID > numSamples){
+ mp4_ip.output->close_audio();
+ g_free(args);
+ faacDecClose(decoder);
+ MP4Close(mp4file);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ rc = MP4ReadSample(mp4file, mp4track, sampleID++, &buffer, &bufferSize,
+ NULL, NULL, NULL, NULL);
+ //g_print("%d/%d\n", sampleID-1, numSamples);
+ if((rc==0) || (buffer== NULL)){
+ g_print("MP4: read error\n");
+ sampleBuffer = NULL;
+ sampleID=0;
+ mp4_ip.output->buffer_free();
+ mp4_ip.output->close_audio();
+ g_free(args);
+ faacDecClose(decoder);
+ MP4Close(mp4file);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }else{
+ sampleBuffer = faacDecDecode(decoder, &frameInfo, buffer, bufferSize);
+ if(frameInfo.error > 0){
+ g_print("MP4: %s\n",
+ faacDecGetErrorMessage(frameInfo.error));
+ mp4_ip.output->close_audio();
+ g_free(args);
+ faacDecClose(decoder);
+ MP4Close(mp4file);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ if(buffer){
+ g_free(buffer); buffer=NULL; bufferSize=0;
+ }
+ while(bPlaying && mp4_ip.output->buffer_free()<frameInfo.samples<<1)
+ xmms_usleep(30000);
+ }
+ mp4_ip.add_vis_pcm(mp4_ip.output->written_time(),
+ FMT_S16_NE,
+ channels,
+ frameInfo.samples<<1,
+ sampleBuffer);
+ mp4_ip.output->write_audio(sampleBuffer, frameInfo.samples<<1);
+ }
+ while(bPlaying && mp4_ip.output->buffer_free()){
+ xmms_usleep(10000);
+ }
+ mp4_ip.output->close_audio();
+ g_free(args);
+ faacDecClose(decoder);
+ MP4Close(mp4file);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ } else{
+ // WE ARE READING AN AAC FILE
+ FILE *file = NULL;
+ faacDecHandle decoder = 0;
+ guchar *buffer = 0;
+ gulong bufferconsumed = 0;
+ gulong samplerate = 0;
+ guchar channels;
+ gulong buffervalid = 0;
+ TitleInput* input;
+ gchar *temp = g_strdup(args);
+ gchar *ext = strrchr(temp, '.');
+ gchar *xmmstitle = NULL;
+ faacDecConfigurationPtr config;
+
+ if((file = fopen(args, "rb")) == 0){
+ g_print("AAC: can't find file %s\n", args);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ if((decoder = faacDecOpen()) == NULL){
+ g_print("AAC: Open Decoder Error\n");
+ fclose(file);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ config = faacDecGetCurrentConfiguration(decoder);
+ config->useOldADTSFormat = 0;
+ faacDecSetConfiguration(decoder, config);
+ if((buffer = g_malloc(BUFFER_SIZE)) == NULL){
+ g_print("AAC: error g_malloc\n");
+ fclose(file);
+ bPlaying = FALSE;
+ faacDecClose(decoder);
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ if((buffervalid = fread(buffer, 1, BUFFER_SIZE, file))==0){
+ g_print("AAC: Error reading file\n");
+ g_free(buffer);
+ fclose(file);
+ bPlaying = FALSE;
+ faacDecClose(decoder);
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ XMMS_NEW_TITLEINPUT(input);
+ input->file_name = g_basename(temp);
+ input->file_ext = ext ? ext+1 : NULL;
+ input->file_path = temp;
+ if(!strncmp(buffer, "ID3", 3)){
+ gint size = 0;
+
+ fseek(file, 0, SEEK_SET);
+ size = (buffer[6]<<21) | (buffer[7]<<14) | (buffer[8]<<7) | buffer[9];
+ size+=10;
+ fread(buffer, 1, size, file);
+ buffervalid = fread(buffer, 1, BUFFER_SIZE, file);
+ }
+ xmmstitle = xmms_get_titlestring(xmms_get_gentitle_format(), input);
+ if(xmmstitle == NULL)
+ xmmstitle = g_strdup(input->file_name);
+ if(temp) g_free(temp);
+ if(input->performer) g_free(input->performer);
+ if(input->album_name) g_free(input->album_name);
+ if(input->track_name) g_free(input->track_name);
+ if(input->genre) g_free(input->genre);
+ g_free(input);
+ bufferconsumed = faacDecInit(decoder,
+ buffer,
+ buffervalid,
+ &samplerate,
+ &channels);
+ if(mp4_ip.output->open_audio(FMT_S16_NE,samplerate,channels) == FALSE){
+ g_print("AAC: Output Error\n");
+ g_free(buffer); buffer=0;
+ faacDecClose(decoder);
+ fclose(file);
+ mp4_ip.output->close_audio();
+ /*
+ if(positionTable){
+ g_free(positionTable); positionTable=0;
+ }
+ */
+ g_free(xmmstitle);
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+ }
+ //if(bSeek){
+ //mp4_ip.set_info(xmmstitle, lenght*1000, -1, samplerate, channels);
+ //}else{
+ mp4_ip.set_info(xmmstitle, -1, -1, samplerate, channels);
+ //}
+ mp4_ip.output->flush(0);
+
+ while(bPlaying && buffervalid > 0){
+ faacDecFrameInfo finfo;
+ unsigned long samplesdecoded;
+ char* sample_buffer = NULL;
+ /*
+ if(bSeek && seekPosition!=-1){
+ fseek(file, positionTable[seekPosition], SEEK_SET);
+ bufferconsumed=0;
+ buffervalid = fread(buffer, 1, BUFFER_SIZE, file);
+ aac_ip.output->flush(seekPosition*1000);
+ seekPosition=-1;
+ }
+ */
+ if(bufferconsumed > 0){
+ memmove(buffer, &buffer[bufferconsumed], buffervalid-bufferconsumed);
+ buffervalid -= bufferconsumed;
+ buffervalid += fread(&buffer[buffervalid], 1,
+ BUFFER_SIZE-buffervalid, file);
+ bufferconsumed = 0;
+ }
+ sample_buffer = faacDecDecode(decoder, &finfo, buffer, buffervalid);
+ if(finfo.error){
+ config = faacDecGetCurrentConfiguration(decoder);
+ if(config->useOldADTSFormat != 1){
+ faacDecClose(decoder);
+ decoder = faacDecOpen();
+ config = faacDecGetCurrentConfiguration(decoder);
+ config->useOldADTSFormat = 1;
+ faacDecSetConfiguration(decoder, config);
+ finfo.bytesconsumed=0;
+ finfo.samples = 0;
+ faacDecInit(decoder,
+ buffer,
+ buffervalid,
+ &samplerate,
+ &channels);
+ }else{
+ g_print("FAAD2 Warning %s\n", faacDecGetErrorMessage(finfo.error));
+ buffervalid = 0;
+ }
+ }
+ bufferconsumed += finfo.bytesconsumed;
+ samplesdecoded = finfo.samples;
+ if((samplesdecoded<=0) && !sample_buffer){
+ g_print("AAC: error sample decoding\n");
+ continue;
+ }
+ while(bPlaying && mp4_ip.output->buffer_free() < (samplesdecoded<<1)){
+ xmms_usleep(10000);
+ }
+ mp4_ip.add_vis_pcm(mp4_ip.output->written_time(),
+ FMT_S16_LE, channels,
+ samplesdecoded<<1, sample_buffer);
+ mp4_ip.output->write_audio(sample_buffer, samplesdecoded<<1);
+ }
+ while(bPlaying && mp4_ip.output->buffer_playing()){
+ xmms_usleep(10000);
+ }
+ mp4_ip.output->buffer_free();
+ mp4_ip.output->close_audio();
+ bPlaying = FALSE;
+ g_free(buffer);
+ faacDecClose(decoder);
+ g_free(xmmstitle);
+ fclose(file);
+ seekPosition = -1;
+ /*
+ if(positionTable){
+ g_free(positionTable); positionTable=0;
+ }
+ */
+ bPlaying = FALSE;
+ pthread_mutex_unlock(&mutex);
+ pthread_exit(NULL);
+
+ }
+}
--- /dev/null
+++ b/plugins/xmms/src/mp4_utils.c
@@ -1,0 +1,151 @@
+/*
+** some function for MP4 file based on libmp4v2 from mpeg4ip project
+*/
+#include <mp4.h>
+#include <faad.h>
+
+const char *mp4AudioNames[]=
+ {
+ "MPEG-1 Audio Layers 1,2 or 3",
+ "MPEG-2 low biterate (MPEG-1 extension) - MP3",
+ "MPEG-2 AAC Main Profile",
+ "MPEG-2 AAC Low Complexity profile",
+ "MPEG-2 AAC SSR profile",
+ "MPEG-4 audio (MPEG-4 AAC)",
+ 0
+ };
+
+const u_int8_t mp4AudioTypes[] =
+ {
+ MP4_MPEG1_AUDIO_TYPE, // 0x6B
+ MP4_MPEG2_AUDIO_TYPE, // 0x69
+ MP4_MPEG2_AAC_MAIN_AUDIO_TYPE, // 0x66
+ MP4_MPEG2_AAC_LC_AUDIO_TYPE, // 0x67
+ MP4_MPEG2_AAC_SSR_AUDIO_TYPE, // 0x68
+ MP4_MPEG4_AUDIO_TYPE, // 0x40
+ 0
+ };
+
+/* MPEG-4 Audio types from 14496-3 Table 1.5.1 (from mp4.h)*/
+const char *mpeg4AudioNames[]=
+ {
+ "!!!!MPEG-4 Audio track Invalid !!!!!!!",
+ "MPEG-4 AAC Main profile",
+ "MPEG-4 AAC Low Complexity profile",
+ "MPEG-4 AAC SSR profile",
+ "MPEG-4 AAC Long Term Prediction profile",
+ "MPEG-4 AAC Scalable",
+ "MPEG-4 CELP",
+ "MPEG-4 HVXC",
+ "MPEG-4 Text To Speech",
+ "MPEG-4 Main Synthetic profile",
+ "MPEG-4 Wavetable Synthesis profile",
+ "MPEG-4 MIDI Profile",
+ "MPEG-4 Algorithmic Synthesis and Audio FX profile"
+ };
+
+int getAACTrack(MP4FileHandle file)
+{
+ int numTracks = MP4GetNumberOfTracks(file, NULL, 0);
+ int i=0;
+
+ for(i=0;i<numTracks;i++){
+ MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0);
+ const char *trackType = MP4GetTrackType(file, trackID);
+ if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){//we found audio track !
+ int j=0;
+ u_int8_t audiotype = MP4GetTrackAudioType(file, trackID);
+ while(mp4AudioTypes[j]){ // what kind of audio is ?
+ if(mp4AudioTypes[j] == audiotype){
+ if(mp4AudioTypes[j] == MP4_MPEG4_AUDIO_TYPE){//MPEG4 audio ok
+ audiotype = MP4GetTrackAudioMpeg4Type(file, trackID);
+ printf("%d-%s\n", audiotype, mpeg4AudioNames[audiotype]);
+ return (trackID);
+ }
+ else{
+ printf("%s\n", mp4AudioNames[j]);
+ if (mp4AudioTypes[j]== MP4_MPEG2_AAC_LC_AUDIO_TYPE ||
+ mp4AudioTypes[j]== MP4_MPEG2_AAC_MAIN_AUDIO_TYPE ||
+ mp4AudioTypes[j]== MP4_MPEG2_AAC_SSR_AUDIO_TYPE)
+ return(trackID);
+ return(-1);
+ }
+ }
+ j++;
+ }
+ }
+ }
+ return(-1);
+}
+
+int getAudioTrack(MP4FileHandle file)
+{
+ int numTracks = MP4GetNumberOfTracks(file, NULL,0);
+ int i=0;
+
+ for(i=0;i<numTracks;i++){
+ MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0);
+ const char *trackType = MP4GetTrackType(file, trackID);
+ if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){
+ return(trackID);
+ }
+ }
+ return(-1);
+}
+
+int getVideoTrack(MP4FileHandle file)
+{
+ int numTracks = MP4GetNumberOfTracks(file, NULL, 0);
+ int i=0;
+
+ for(i=0;i<numTracks; i++){
+ MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0);
+ const char *trackType = MP4GetTrackType(file, trackID);
+ if(!strcmp(trackType, MP4_VIDEO_TRACK_TYPE)){
+ return (trackID);
+ }
+ }
+ return(-1);
+}
+
+void getMP4info(char* file)
+{
+ MP4FileHandle mp4file;
+ MP4Duration trackDuration;
+ int numTracks;
+ int i=0;
+
+ if(!(mp4file = MP4Read(file,0)))
+ return;
+ //MP4Dump(mp4file, 0, 0);
+ numTracks = MP4GetNumberOfTracks(mp4file, NULL, 0);
+ g_print("there are %d track(s)\n", numTracks);
+ for(i=0;i<numTracks;i++){
+ MP4TrackId trackID = MP4FindTrackId(mp4file, i, NULL, 0);
+ const char *trackType = MP4GetTrackType(mp4file, trackID);
+ printf("Track %d, %s", trackID, trackType);
+ if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){//we found audio track !
+ int j=0;
+ u_int8_t audiotype = MP4GetTrackAudioType(mp4file, trackID);
+ while(mp4AudioTypes[j]){ // what kind of audio is ?
+ if(mp4AudioTypes[j] == audiotype){
+ if(mp4AudioTypes[j] == MP4_MPEG4_AUDIO_TYPE){
+ audiotype = MP4GetTrackAudioMpeg4Type(mp4file, trackID);
+ g_print(" %s", mpeg4AudioNames[audiotype]);
+ }
+ else{
+ printf(" %s", mp4AudioNames[j]);
+ }
+ g_print(" duration :%d",
+ MP4ConvertFromTrackDuration(mp4file, trackID,
+ MP4GetTrackDuration(mp4file,
+ trackID),
+ MP4_MSECS_TIME_SCALE));
+ }
+ j++;
+ }
+ }
+ printf("\n");
+ }
+ MP4Close(mp4file);
+}
--- a/plugins/xmmsmp4/Makefile.am
+++ /dev/null
@@ -1,2 +1,0 @@
-SUBDIRS = src
-
--- a/plugins/xmmsmp4/src/Makefile.am
+++ /dev/null
@@ -1,12 +1,0 @@
-libdir = `xmms-config --input-plugin-dir`
-
-lib_LTLIBRARIES = libmp4.la
-libmp4_la_CFLAGS = -I$(top_builddir)/common/mp4v2 \
- -I$(top_builddir)/include \
- `xmms-config --cflags` -DHAVE_GLIB_H=1
-
-libmp4_la_LDFLAGS = -module -avoid-version `xmms-config --libs` -lpthread -lstdc++
-
-libmp4_la_LIBADD = $(top_builddir)/libfaad/libfaad.la $(top_builddir)/common/mp4v2/libmp4v2.la
-
-libmp4_la_SOURCES = libmp4.c libmp4_utils.c libmp4_utils.h
--- a/plugins/xmmsmp4/src/libmp4.c
+++ /dev/null
@@ -1,303 +1,0 @@
-/*
-** a mp4 AAC audio player for XMMS by ciberfred
-**
-*/
-
-#include "mp4.h"
-#include <pthread.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-
-
-#include "faad.h"
-
-#include "xmms/plugin.h"
-#include "xmms/util.h"
-#include "xmms/configfile.h"
-#include "xmms/titlestring.h"
-
-#include "libmp4_utils.h"
-
-#define MP4_DESCRIPTION "MP4 audio player - 1.2.7"
-#define MP4_VERSION "mp4 audio player (v0.3) - 1 Aout 2003"
-#define MP4_ABOUT "Written from scratch by ciberfred"
-
-static void mp4_init(void);
-static void mp4_about(void);
-static void mp4_play(char *);
-static void mp4_stop(void);
-static void mp4_pause(short);
-static void mp4_seek(int);
-static int mp4_getTime(void);
-static void mp4_cleanup(void);
-static void mp4_getSongInfo(char *);
-static int mp4_isFile(char *);
-
-static void *mp4Decode(void *args);
-
-InputPlugin mp4_ip =
- {
- 0, // handle
- 0, // filename
- MP4_DESCRIPTION,
- mp4_init,
- mp4_about,
- 0, // configuration
- mp4_isFile,
- 0, //scandir
- mp4_play,
- mp4_stop,
- mp4_pause,
- mp4_seek,
- 0, // set equalizer
- mp4_getTime,
- 0, // get volume
- 0,
- mp4_cleanup,
- 0, // obsolete
- 0, // send visualisation data
- 0, // set player window info
- 0, // set song title text
- 0, // get song title text
- mp4_getSongInfo, // info box
- 0, // to output plugin
- };
-
-
-static gboolean bPlaying = FALSE;
-static pthread_t decodeThread;
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-static int seekPosition = -1;
-
-InputPlugin *get_iplugin_info(void)
-{
- return(&mp4_ip);
-}
-
-static void mp4_init(void)
-{
- memset(&decodeThread, 0, sizeof(pthread_t));
- return;
-}
-
-static void mp4_play(char *filename)
-{
- bPlaying = TRUE;
- pthread_create(&decodeThread, 0, mp4Decode, g_strdup(filename));
- return;
-}
-
-static void mp4_stop(void)
-{
- if(bPlaying){
- bPlaying = FALSE;
- pthread_join(decodeThread, NULL);
- memset(&decodeThread, 0, sizeof(pthread_t));
- mp4_ip.output->close_audio();
- }
-}
-
-static void *mp4Decode(void *args)
-{
- unsigned long msDuration;
- unsigned char *buffer = NULL;
- int bufferSize = 0;
- int lastframe = 0;
- faacDecHandle decoder;
- MP4SampleId numSamples;
- MP4SampleId sampleID=1;
- MP4FileHandle mp4file;
- MP4Duration duration;
- int mp4track;
- unsigned long samplerate;
- unsigned char channels;
- unsigned int avgBitrate;
-
-
- pthread_mutex_lock(&mutex);
- seekPosition = -1;
- bPlaying = TRUE;
- if(!(mp4file = MP4Read(args, 0))){
- printf("can't open file: %s\n", args);
- free(args);
- bPlaying = FALSE;
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- if((mp4track = getAACTrack(mp4file)) < 0){
-// check here for others Audio format.....
-
- g_print("Unsupported Audio track type\n");
- free(args);
- MP4Close(mp4file);
- bPlaying = FALSE;
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- decoder = faacDecOpen();
- MP4GetTrackESConfiguration(mp4file, mp4track, &buffer, &bufferSize);
- if(!buffer){
- free(args);
- faacDecClose(decoder);
- MP4Close(mp4file);
- bPlaying = FALSE;
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- if(faacDecInit2(decoder, buffer, bufferSize, &samplerate, &channels)<0){
- free(args);
- faacDecClose(decoder);
- MP4Close(mp4file);
- bPlaying = FALSE;
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- free(buffer);
- if(channels == 0){
- g_print("Number of Channels not supported\n");
- free(args);
- faacDecClose(decoder);
- MP4Close(mp4file);
- bPlaying = FALSE;
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- mp4_ip.output->open_audio(FMT_S16_NE, samplerate, channels);
- mp4_ip.output->flush(0);
- g_print("MP4 flush\n");
- duration = MP4GetTrackDuration(mp4file, mp4track);
- msDuration = MP4ConvertFromTrackDuration(mp4file, mp4track, duration,
- MP4_MSECS_TIME_SCALE);
- numSamples = MP4GetTrackNumberOfSamples(mp4file, mp4track);
- //mp4_ip.set_info(args, msDuration, -1, samplerate/1000, channels);
-
- while(bPlaying){
- void *sampleBuffer;
- faacDecFrameInfo frameInfo;
- int rc;
-
- if(seekPosition!=-1){
- duration = MP4ConvertToTrackDuration(mp4file, mp4track,seekPosition*1000,
- MP4_MSECS_TIME_SCALE);
- sampleID = MP4GetSampleIdFromTime(mp4file, mp4track, duration, 0);
- mp4_ip.output->flush(seekPosition*1000);
- seekPosition = -1;
- }
- buffer=NULL;
- bufferSize=0;
- if(sampleID > numSamples){
- mp4_ip.output->close_audio();
- free(args);
- faacDecClose(decoder);
- MP4Close(mp4file);
- bPlaying = FALSE;
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- rc = MP4ReadSample(mp4file, mp4track, sampleID++, &buffer, &bufferSize,
- NULL, NULL, NULL, NULL);
- //g_print("%d/%d\n", sampleID-1, numSamples);
- if((rc==0) || (buffer== NULL)){
- printf("read error\n");
- sampleBuffer = NULL;
- sampleID=0;
- mp4_ip.output->buffer_free();
- mp4_ip.output->close_audio();
- free(args);
- faacDecClose(decoder);
- MP4Close(mp4file);
- bPlaying = FALSE;
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- else{
- sampleBuffer = faacDecDecode(decoder, &frameInfo, buffer, bufferSize);
- if(frameInfo.error > 0){
- printf("FAAD2 error : %s\n", faacDecGetErrorMessage(frameInfo.error));
- mp4_ip.output->close_audio();
- free(args);
- faacDecClose(decoder);
- MP4Close(mp4file);
- bPlaying = FALSE;
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
- }
- if(buffer){
- free(buffer); buffer=0;
- }
- while(bPlaying && mp4_ip.output->buffer_free()<frameInfo.samples<<1)
- xmms_usleep(30000);
- }
- //mp4_ip.add_vis_pcm(mp4_ip.output->written_time(), FMT_S16_NE, channels, frameInfo.samples<<1, sampleBuffer);
- mp4_ip.output->write_audio(sampleBuffer, frameInfo.samples<<1);
- }
- while(bPlaying && mp4_ip.output->buffer_free()){
- xmms_usleep(10000);
- }
- mp4_ip.output->close_audio();
- free(args);
- faacDecClose(decoder);
- MP4Close(mp4file);
- bPlaying = FALSE;
- pthread_mutex_unlock(&mutex);
- pthread_exit(NULL);
-}
-
-static int mp4_isFile(char *filename)
-{
- char *extention = strrchr(filename, '.');
- if (extention &&
- !strcasecmp(extention, ".mp4") ||
- !strcasecmp(extention, ".m4a")
- ){
- return (1);
- }
- return(0);
-}
-
-static void mp4_about(void)
-{
- static GtkWidget *aboutbox;
-
- if(aboutbox!=NULL)
- return;
-
- aboutbox = xmms_show_message(
- "About MP4 AAC player plugin",
- "decoding engine : FAAD2 (30 July 2003)\n"
- "plugin version : 0.3 (ciberfred)/static",
- "Ok", FALSE, NULL, NULL);
- gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy",
- GTK_SIGNAL_FUNC(gtk_widget_destroyed),
- &aboutbox);
-}
-
-static void mp4_pause(short flag)
-{
- mp4_ip.output->pause(flag);
-}
-
-static void mp4_seek(int time)
-{
- seekPosition = time;
- while(bPlaying && seekPosition!=-1) xmms_usleep(10000);
-}
-
-static int mp4_getTime(void)
-{
- if (!bPlaying){
- return (-1);
- }
- else{
- return (mp4_ip.output->output_time());
- }
-}
-
-static void mp4_cleanup(void)
-{
-}
-
-static void mp4_getSongInfo(char *filename)
-{
- getMP4info(filename);
-}
--- a/plugins/xmmsmp4/src/libmp4_utils.c
+++ /dev/null
@@ -1,153 +1,0 @@
-/*
-** some function for MP4 file based on libmp4v2 from mpeg4ip project
-*/
-#include <mp4.h>
-#include <faad.h>
-#include "libmp4_utils.h"
-
-
-const char *mp4AudioNames[]=
- {
- "MPEG-1 Audio Layers 1,2 or 3",
- "MPEG-2 low biterate (MPEG-1 extension) - MP3",
- "MPEG-2 AAC Main Profile",
- "MPEG-2 AAC Low Complexity profile",
- "MPEG-2 AAC SSR profile",
- "MPEG-4 audio (MPEG-4 AAC)",
- 0
- };
-
-const u_int8_t mp4AudioTypes[] =
- {
- MP4_MPEG1_AUDIO_TYPE, // 0x6B
- MP4_MPEG2_AUDIO_TYPE, // 0x69
- MP4_MPEG2_AAC_MAIN_AUDIO_TYPE, // 0x66
- MP4_MPEG2_AAC_LC_AUDIO_TYPE, // 0x67
- MP4_MPEG2_AAC_SSR_AUDIO_TYPE, // 0x68
- MP4_MPEG4_AUDIO_TYPE, // 0x40
- 0
- };
-
-/* MPEG-4 Audio types from 14496-3 Table 1.5.1 (from mp4.h)*/
-const char *mpeg4AudioNames[]=
- {
- "!!!!MPEG-4 Audio track Invalid !!!!!!!",
- "MPEG-4 AAC Main profile",
- "MPEG-4 AAC Low Complexity profile",
- "MPEG-4 AAC SSR profile",
- "MPEG-4 AAC Long Term Prediction profile",
- "MPEG-4 AAC Scalable",
- "MPEG-4 CELP",
- "MPEG-4 HVXC",
- "MPEG-4 Text To Speech",
- "MPEG-4 Main Synthetic profile",
- "MPEG-4 Wavetable Synthesis profile",
- "MPEG-4 MIDI Profile",
- "MPEG-4 Algorithmic Synthesis and Audio FX profile"
- };
-
-int getAACTrack(MP4FileHandle file)
-{
- int numTracks = MP4GetNumberOfTracks(file, NULL, 0);
- int i=0;
-
- for(i=0;i<numTracks;i++){
- MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0);
- const char *trackType = MP4GetTrackType(file, trackID);
- if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){//we found audio track !
- int j=0;
- u_int8_t audiotype = MP4GetTrackAudioType(file, trackID);
- while(mp4AudioTypes[j]){ // what kind of audio is ?
- if(mp4AudioTypes[j] == audiotype){
- if(mp4AudioTypes[j] == MP4_MPEG4_AUDIO_TYPE){//MPEG4 audio ok
- audiotype = MP4GetTrackAudioMpeg4Type(file, trackID);
- printf("%d-%s\n", audiotype, mpeg4AudioNames[audiotype]);
- return (trackID);
- }
- else{
- printf("%s\n", mp4AudioNames[j]);
- if (mp4AudioTypes[j]== MP4_MPEG2_AAC_LC_AUDIO_TYPE ||
- mp4AudioTypes[j]== MP4_MPEG2_AAC_MAIN_AUDIO_TYPE ||
- mp4AudioTypes[j]== MP4_MPEG2_AAC_SSR_AUDIO_TYPE)
- return(trackID);
- return(-1);
- }
- }
- j++;
- }
- }
- }
- return(-1);
-}
-
-int getAudioTrack(MP4FileHandle file)
-{
- int numTracks = MP4GetNumberOfTracks(file, NULL,0);
- int i=0;
-
- for(i=0;i<numTracks;i++){
- MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0);
- const char *trackType = MP4GetTrackType(file, trackID);
- if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){
- return(trackID);
- }
- }
- return(-1);
-}
-
-int getVideoTrack(MP4FileHandle file)
-{
- int numTracks = MP4GetNumberOfTracks(file, NULL, 0);
- int i=0;
-
- for(i=0;i<numTracks; i++){
- MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0);
- const char *trackType = MP4GetTrackType(file, trackID);
- if(!strcmp(trackType, MP4_VIDEO_TRACK_TYPE)){
- return (trackID);
- }
- }
- return(-1);
-}
-
-void getMP4info(char* file)
-{
- MP4FileHandle mp4file;
- MP4Duration trackDuration;
- int numTracks;
- int i=0;
-
- if(!(mp4file = MP4Read(file,0)))
- return;
- //MP4Dump(mp4file, 0, 0);
- numTracks = MP4GetNumberOfTracks(mp4file, NULL, 0);
- printf("there is %d track(s)\n", numTracks);
- for(i=0;i<numTracks;i++){
- MP4TrackId trackID = MP4FindTrackId(mp4file, i, NULL, 0);
- const char *trackType = MP4GetTrackType(mp4file, trackID);
- printf("Track %d, %s", trackID, trackType);
- if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){//we found audio track !
- int j=0;
- u_int8_t audiotype = MP4GetTrackAudioType(mp4file, trackID);
- while(mp4AudioTypes[j]){ // what kind of audio is ?
- if(mp4AudioTypes[j] == audiotype){
- if(mp4AudioTypes[j] == MP4_MPEG4_AUDIO_TYPE){
- audiotype = MP4GetTrackAudioMpeg4Type(mp4file, trackID);
- printf(" %s", mpeg4AudioNames[audiotype]);
- }
- else{
- printf(" %s", mp4AudioNames[j]);
- }
- printf(" duration :%d",
- MP4ConvertFromTrackDuration(mp4file, trackID,
- MP4GetTrackDuration(mp4file,
- trackID),
- MP4_MSECS_TIME_SCALE));
- }
- j++;
- }
- }
- printf("\n");
- }
- MP4Close(mp4file);
-}
--- a/plugins/xmmsmp4/src/libmp4_utils.h
+++ /dev/null
@@ -1,9 +1,0 @@
-#ifndef __MP4UTILS_H_
-#define __MP4UTILS_H_
-
-int getAACTrack(MP4FileHandle);
-int getAudioTrack(MP4FileHandle);
-int getVideoTrack(MP4FileHandle);
-void getMP4info(char*);
-
-#endif