aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Makefile.am7
-rw-r--r--src/inputPlugin.c2
-rw-r--r--src/inputPlugins/mp4_plugin.c (renamed from src/mp4_decode.c)132
-rw-r--r--src/mp4_decode.h43
-rw-r--r--src/tag.c94
5 files changed, 127 insertions, 151 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 478b6c2ef..e9b1f1a0e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,21 +2,22 @@ bin_PROGRAMS = mpd
SUBDIRS = $(ID3_SUBDIR) $(MAD_SUBDIR) $(MP4FF_SUBDIR)
mpd_inputPlugins = inputPlugins/mp3_plugin.c inputPlugins/ogg_plugin.c \
- inputPlugins/flac_plugin.c inputPlugins/audiofile_plugin.c
+ inputPlugins/flac_plugin.c inputPlugins/audiofile_plugin.c \
+ inputPlugins/mp4_plugin.c
mpd_headers = buffer2array.h interface.h command.h playlist.h ls.h \
song.h list.h directory.h tables.h utils.h path.h \
tag.h player.h listen.h conf.h volume.h \
audio.h playerData.h stats.h myfprintf.h sig_handlers.h decode.h log.h \
charConv.h permission.h mpd_types.h pcm_utils.h \
- mp4_decode.h aac_decode.h signal_check.h utf8.h inputStream.h \
+ aac_decode.h signal_check.h utf8.h inputStream.h \
outputBuffer.h replayGain.h inputStream_file.h inputStream_http.h \
inputPlugin.h
mpd_SOURCES = main.c buffer2array.c interface.c command.c playlist.c ls.c \
song.c list.c directory.c tables.c utils.c path.c \
tag.c player.c listen.c conf.c volume.c \
audio.c playerData.c stats.c myfprintf.c sig_handlers.c decode.c log.c \
- charConv.c permission.c pcm_utils.c mp4_decode.c \
+ charConv.c permission.c pcm_utils.c \
aac_decode.c signal_check.c utf8.c inputStream.c outputBuffer.c \
replayGain.c inputStream_file.c inputStream_http.c inputPlugin.c \
$(mpd_headers) $(mpd_inputPlugins)
diff --git a/src/inputPlugin.c b/src/inputPlugin.c
index 2295f7b51..c9ace2839 100644
--- a/src/inputPlugin.c
+++ b/src/inputPlugin.c
@@ -71,6 +71,7 @@ extern InputPlugin mp3Plugin;
extern InputPlugin oggPlugin;
extern InputPlugin flacPlugin;
extern InputPlugin audiofilePlugin;
+extern InputPlugin mp4Plugin;
void initInputPlugins() {
inputPlugin_list = makeList(NULL);
@@ -80,6 +81,7 @@ void initInputPlugins() {
loadInputPlugin(&oggPlugin);
loadInputPlugin(&flacPlugin);
loadInputPlugin(&audiofilePlugin);
+ loadInputPlugin(&mp4Plugin);
}
void finishInputPlugins() {
diff --git a/src/mp4_decode.c b/src/inputPlugins/mp4_plugin.c
index 219053538..b34b3c421 100644
--- a/src/mp4_decode.c
+++ b/src/inputPlugins/mp4_plugin.c
@@ -16,20 +16,19 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "mp4_decode.h"
+#include "../inputPlugin.h"
#ifdef HAVE_FAAD
-#include "command.h"
-#include "utils.h"
-#include "audio.h"
-#include "log.h"
-#include "pcm_utils.h"
-#include "inputStream.h"
-#include "outputBuffer.h"
-#include "decode.h"
+#include "../utils.h"
+#include "../audio.h"
+#include "../log.h"
+#include "../pcm_utils.h"
+#include "../inputStream.h"
+#include "../outputBuffer.h"
+#include "../decode.h"
-#include "mp4ff/mp4ff.h"
+#include "../mp4ff/mp4ff.h"
#include <stdio.h>
#include <unistd.h>
@@ -312,5 +311,116 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc) {
return 0;
}
+MpdTag * mp4DataDup(char * file, int * mp4MetadataFound) {
+ MpdTag * ret = NULL;
+ InputStream inStream;
+ mp4ff_t * mp4fh;
+ mp4ff_callback_t * cb;
+ int32_t track;
+ int32_t time;
+ int32_t scale;
+
+ *mp4MetadataFound = 0;
+
+ if(openInputStream(file) < 0) return NULL;
+
+ cb = malloc(sizeof(mp4ff_callback_t));
+ cb->read = mp4_inputStreamReadCallback;
+ cb->seek = mp4_inputStreamSeekCallback;
+ cb->user_data = &inStream;
+
+ mp4fh = mp4ff_open_read(cb);
+ if(!mp4fh) {
+ free(cb);
+ closeInputStream(&inStream);
+ return NULL;
+ }
+
+ track = mp4_getAACTrack(mp4fh);
+ if(track < 0) {
+ mp4ff_close(mp4fh);
+ closeInputStream(&inStream);
+ free(cb);
+ return NULL;
+ }
+
+ ret = newMpdTag();
+ time = mp4ff_get_track_duration_use_offsets(mp4fh,track);
+ scale = mp4ff_time_scale(mp4fh,track);
+ if(scale < 0) {
+ mp4ff_close(mp4fh);
+ closeInputStream(&inStream);
+ free(cb);
+ freeMpdTag(ret);
+ return NULL;
+ }
+ ret->time = ((float)time)/scale+0.5;
+
+ if(!mp4ff_meta_get_artist(mp4fh,&ret->artist)) {
+ *mp4MetadataFound = 1;
+ }
+
+ if(!mp4ff_meta_get_album(mp4fh,&ret->album)) {
+ *mp4MetadataFound = 1;
+ }
+
+ if(!mp4ff_meta_get_title(mp4fh,&ret->title)) {
+ *mp4MetadataFound = 1;
+ }
+
+ if(!mp4ff_meta_get_track(mp4fh,&ret->track)) {
+ *mp4MetadataFound = 1;
+ }
+
+ mp4ff_close(mp4fh);
+ closeInputStream(&inStream);
+ free(cb);
+
+ return ret;
+}
+
+MpdTag * mp4TagDup(char * file) {
+ MpdTag * ret = NULL;
+ int mp4MetadataFound = 0;
+
+ ret = mp4DataDup(file, &mp4MetadataFound);
+ if(!ret) return NULL;
+ if(!mp4MetadataFound) {
+ MpdTag * temp = id3Dup(file);
+ if(temp) {
+ temp->time = ret->time;
+ freeMpdTag(ret);
+ ret = temp;
+ }
+ }
+
+ return ret;
+}
+
+char * mp4Suffixes[] = {"m4a", "mp4", NULL};
+
+InputPlugin mp4Plugin =
+{
+ "mp4",
+ NULL,
+ mp4_decode,
+ mp4TagDup,
+ INPUT_PLUGIN_STREAM_FILE,
+ mp4Suffixes,
+ NULL
+};
+
+#else
+
+InputPlugin mp4Plugin =
+{
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ NULL
+};
+
#endif /* HAVE_FAAD */
-/* vim:set shiftwidth=4 tabstop=8 expandtab: */
diff --git a/src/mp4_decode.h b/src/mp4_decode.h
deleted file mode 100644
index 31b266f16..000000000
--- a/src/mp4_decode.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* the Music Player Daemon (MPD)
- * (c)2003-2004 by Warren Dukes (shank@mercury.chem.pitt.edu)
- * This project's homepage is: http://www.musicpd.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef MP4_DECODE_H
-#define MP4_DECODE_H
-
-#include "../config.h"
-
-#ifdef HAVE_FAAD
-
-#include "playerData.h"
-
-#include "mp4ff/mp4ff.h"
-
-int mp4_getAACTrack(mp4ff_t *infile);
-
-int mp4_decode(OutputBuffer * cb, DecoderControl * dc);
-
-uint32_t mp4_inputStreamReadCallback(void *inStream, void *buffer,
- uint32_t length);
-
-uint32_t mp4_inputStreamSeekCallback(void *inStream, uint64_t position);
-
-
-#endif /* HAVE_FAAD */
-
-#endif
-/* vim:set shiftwidth=4 tabstop=8 expandtab: */
diff --git a/src/tag.c b/src/tag.c
index c9fcd1242..d9fef82b9 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -44,9 +44,6 @@
#include <id3tag.h>
#endif
#endif
-#ifdef HAVE_FAAD
-#include "mp4ff/mp4ff.h"
-#endif
void printMpdTag(FILE * fp, MpdTag * tag) {
if(tag->artist) myfprintf(fp,"Artist: %s\n",tag->artist);
@@ -167,97 +164,6 @@ MpdTag * aacTagDup(char * utf8file) {
return ret;
}
-
-MpdTag * mp4DataDup(char * utf8file, int * mp4MetadataFound) {
- MpdTag * ret = NULL;
- InputStream inStream;
- mp4ff_t * mp4fh;
- mp4ff_callback_t * cb;
- int32_t track;
- int32_t time;
- int32_t scale;
-
- *mp4MetadataFound = 0;
-
- if(openInputStream(&inStream,rmp2amp(utf8ToFsCharset(utf8file))) < 0)
- {
- return NULL;
- }
-
- cb = malloc(sizeof(mp4ff_callback_t));
- cb->read = mp4_inputStreamReadCallback;
- cb->seek = mp4_inputStreamSeekCallback;
- cb->user_data = &inStream;
-
- mp4fh = mp4ff_open_read(cb);
- if(!mp4fh) {
- free(cb);
- closeInputStream(&inStream);
- return NULL;
- }
-
- track = mp4_getAACTrack(mp4fh);
- if(track < 0) {
- mp4ff_close(mp4fh);
- closeInputStream(&inStream);
- free(cb);
- return NULL;
- }
-
- ret = newMpdTag();
- time = mp4ff_get_track_duration_use_offsets(mp4fh,track);
- scale = mp4ff_time_scale(mp4fh,track);
- if(scale < 0) {
- mp4ff_close(mp4fh);
- closeInputStream(&inStream);
- free(cb);
- freeMpdTag(ret);
- return NULL;
- }
- ret->time = ((float)time)/scale+0.5;
-
- if(!mp4ff_meta_get_artist(mp4fh,&ret->artist)) {
- *mp4MetadataFound = 1;
- }
-
- if(!mp4ff_meta_get_album(mp4fh,&ret->album)) {
- *mp4MetadataFound = 1;
- }
-
- if(!mp4ff_meta_get_title(mp4fh,&ret->title)) {
- *mp4MetadataFound = 1;
- }
-
- if(!mp4ff_meta_get_track(mp4fh,&ret->track)) {
- *mp4MetadataFound = 1;
- }
-
- mp4ff_close(mp4fh);
- closeInputStream(&inStream);
- free(cb);
-
- return ret;
-}
-
-MpdTag * mp4TagDup(char * utf8file) {
- MpdTag * ret = NULL;
- int mp4MetadataFound = 0;
-
- ret = mp4DataDup(utf8file,&mp4MetadataFound);
- if(!ret) return NULL;
- if(!mp4MetadataFound) {
- MpdTag * temp = id3Dup(utf8file);
- if(temp) {
- temp->time = ret->time;
- freeMpdTag(ret);
- ret = temp;
- }
- }
-
- if(ret) validateUtf8Tag(ret);
-
- return ret;
-}
#endif
MpdTag * newMpdTag() {