have AAC and MP4 types

git-svn-id: https://svn.musicpd.org/mpd/trunk@267 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes 2004-03-17 17:30:50 +00:00
parent b2b700a87d
commit 9a7636f5bc
7 changed files with 61 additions and 4 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -168,13 +168,27 @@ MpdTag * mp3TagDup(char * utf8file) {
#endif
#ifdef HAVE_FAAD
MpdTag * mp4TagDup(char * utf8file) {
MpdTag * ret = NULL;
int time = -1;
#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;
int time = -1;
ret = id3Dup(utf8file);
#warning getAacTotalTime needs implementing
#warning getMp4TotalTime needs implementing
//time = getAacTotalTime(rmp2amp(utf8ToFsCharset(utf8file)));
if(time>=0) {

View File

@ -38,6 +38,7 @@ MpdTag * mp3TagDup(char * utf8file);
#endif
#ifdef HAVE_FAAD
MpdTag * mp4TagDup(char * utf8file);
MpdTag * aacTagDup(char * utf8file);
#endif