aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-03-17 17:30:50 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-03-17 17:30:50 +0000
commit9a7636f5bc50fdff56012a38076ec51d3b671711 (patch)
tree8d938207f03b1a575d70e535e039975d2bd916fa /src
parentb2b700a87d33eb536f33e59b286f8bd3e240486e (diff)
downloadmpd-9a7636f5bc50fdff56012a38076ec51d3b671711.tar.gz
mpd-9a7636f5bc50fdff56012a38076ec51d3b671711.tar.xz
mpd-9a7636f5bc50fdff56012a38076ec51d3b671711.zip
have AAC and MP4 types
git-svn-id: https://svn.musicpd.org/mpd/trunk@267 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/decode.h1
-rw-r--r--src/ls.c32
-rw-r--r--src/ls.h2
-rw-r--r--src/player.c1
-rw-r--r--src/song.c6
-rw-r--r--src/tag.c22
-rw-r--r--src/tag.h1
7 files changed, 61 insertions, 4 deletions
diff --git a/src/decode.h b/src/decode.h
index 6dd25fdb8..bb32de588 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -27,6 +27,7 @@
#define DECODE_TYPE_FLAC 2
#define DECODE_TYPE_AUDIOFILE 3
#define DECODE_TYPE_AAC 4
+#define DECODE_TYPE_MP4 5
#define DECODE_STATE_STOP 0
#define DECODE_STATE_DECODE 1
diff --git a/src/ls.c b/src/ls.c
index c98b0b65d..f80c7209c 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -127,6 +127,7 @@ int isMusic(char * utf8file, time_t * mtime) {
#endif
#ifdef HAVE_FAAD
if((ret = isAac(utf8file,mtime))) return ret;
+ if((ret = isMp4(utf8file,mtime))) return ret;
#endif
return ret;
@@ -249,6 +250,37 @@ int isOgg(char * utf8file, time_t * mtime) {
return 0;
}
+int isMp4(char * utf8file, time_t * mtime) {
+ struct stat st;
+ char * file = utf8ToFsCharset(utf8file);
+ char * actualFile = file;
+
+ if(actualFile[0]!='/') actualFile = rmp2amp(file);
+
+ if(stat(actualFile,&st)==0) {
+ if(S_ISREG(st.st_mode)) {
+ char * dup;
+ char * cLast;
+ char * cNext;
+ int ret = 0;
+ dup = strdup(file);
+ cNext = cLast = strtok(dup,".");
+ while((cNext = strtok(NULL,"."))) cLast = cNext;
+ if(cLast && (0==strcasecmp(cLast,"m4a") ||
+ 0==strcasecmp(cLast,"mp4")))
+ {
+ if(mtime) *mtime = st.st_mtime;
+ ret = 1;
+ }
+ free(dup);
+ return ret;
+ }
+ else return 0;
+ }
+
+ return 0;
+}
+
int isAac(char * utf8file, time_t * mtime) {
struct stat st;
char * file = utf8ToFsCharset(utf8file);
diff --git a/src/ls.h b/src/ls.h
index 708f81618..063dc7dbd 100644
--- a/src/ls.h
+++ b/src/ls.h
@@ -28,6 +28,8 @@ int isMp3(char * utf8file, time_t * mtime);
int isAac(char * utf8file, time_t * mtime);
+int isMp4(char * utf8file, time_t * mtime);
+
int isOgg(char * utf8file, time_t * mtime);
int isFlac(char * utf8file, time_t * mtime);
diff --git a/src/player.c b/src/player.c
index 54fda2a6e..63c8fed7b 100644
--- a/src/player.c
+++ b/src/player.c
@@ -179,6 +179,7 @@ int playerPlay(FILE * fp, char * utf8file) {
#endif
#ifdef HAVE_FAAD
else if(isAac(utf8file,NULL)) pc->decodeType = DECODE_TYPE_AAC;
+ else if(isMp4(utf8file,NULL)) pc->decodeType = DECODE_TYPE_MP4;
#endif
else {
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
diff --git a/src/song.c b/src/song.c
index 4a0cfd4bb..377487cbd 100644
--- a/src/song.c
+++ b/src/song.c
@@ -82,6 +82,9 @@ Song * newSong(char * utf8file) {
else if(isAac(utf8file,&(song->mtime))) {
song->tag = aacTagDup(utf8file);
}
+ else if(isMp4(utf8file,&(song->mtime))) {
+ song->tag = mp4TagDup(utf8file);
+ }
#endif
if(!song->tag || song->tag->time<0) {
@@ -249,6 +252,9 @@ int updateSongInfo(Song * song) {
else if(isAac(utf8file,&(song->mtime))) {
song->tag = aacTagDup(utf8file);
}
+ else if(isMp4(utf8file,&(song->mtime))) {
+ song->tag = mp4TagDup(utf8file);
+ }
#endif
if(!song->tag || song->tag->time<0) return -1;
diff --git a/src/tag.c b/src/tag.c
index d599b44c4..1f73ffce7 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -168,13 +168,27 @@ MpdTag * mp3TagDup(char * utf8file) {
#endif
#ifdef HAVE_FAAD
-MpdTag * aacTagDup(char * utf8file) {
+MpdTag * mp4TagDup(char * utf8file) {
MpdTag * ret = NULL;
- int time;
+ int time = -1;
- ret = id3Dup(utf8file);
+#warning implement mp4 tag parsing, this includes using mp4v2 and id3
+#warning getMp4TotalTime needs implementing
+ //time = getMp4TotalTime(rmp2amp(utf8ToFsCharset(utf8file)));
+
+ if(time>=0) {
+ if(!ret) ret = newMpdTag();
+ ret->time = time;
+ }
+
+ return ret;
+}
+
+MpdTag * aacTagDup(char * utf8file) {
+ MpdTag * ret = NULL;
+ int time = -1;
-#warning getAacTotalTime needs implementing
+#warning getMp4TotalTime needs implementing
//time = getAacTotalTime(rmp2amp(utf8ToFsCharset(utf8file)));
if(time>=0) {
diff --git a/src/tag.h b/src/tag.h
index 763f1fcb6..36fa76aec 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -38,6 +38,7 @@ MpdTag * mp3TagDup(char * utf8file);
#endif
#ifdef HAVE_FAAD
+MpdTag * mp4TagDup(char * utf8file);
MpdTag * aacTagDup(char * utf8file);
#endif