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:
parent
b2b700a87d
commit
9a7636f5bc
|
@ -27,6 +27,7 @@
|
||||||
#define DECODE_TYPE_FLAC 2
|
#define DECODE_TYPE_FLAC 2
|
||||||
#define DECODE_TYPE_AUDIOFILE 3
|
#define DECODE_TYPE_AUDIOFILE 3
|
||||||
#define DECODE_TYPE_AAC 4
|
#define DECODE_TYPE_AAC 4
|
||||||
|
#define DECODE_TYPE_MP4 5
|
||||||
|
|
||||||
#define DECODE_STATE_STOP 0
|
#define DECODE_STATE_STOP 0
|
||||||
#define DECODE_STATE_DECODE 1
|
#define DECODE_STATE_DECODE 1
|
||||||
|
|
32
src/ls.c
32
src/ls.c
|
@ -127,6 +127,7 @@ int isMusic(char * utf8file, time_t * mtime) {
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_FAAD
|
#ifdef HAVE_FAAD
|
||||||
if((ret = isAac(utf8file,mtime))) return ret;
|
if((ret = isAac(utf8file,mtime))) return ret;
|
||||||
|
if((ret = isMp4(utf8file,mtime))) return ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -249,6 +250,37 @@ int isOgg(char * utf8file, time_t * mtime) {
|
||||||
return 0;
|
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) {
|
int isAac(char * utf8file, time_t * mtime) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char * file = utf8ToFsCharset(utf8file);
|
char * file = utf8ToFsCharset(utf8file);
|
||||||
|
|
2
src/ls.h
2
src/ls.h
|
@ -28,6 +28,8 @@ int isMp3(char * utf8file, time_t * mtime);
|
||||||
|
|
||||||
int isAac(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 isOgg(char * utf8file, time_t * mtime);
|
||||||
|
|
||||||
int isFlac(char * utf8file, time_t * mtime);
|
int isFlac(char * utf8file, time_t * mtime);
|
||||||
|
|
|
@ -179,6 +179,7 @@ int playerPlay(FILE * fp, char * utf8file) {
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_FAAD
|
#ifdef HAVE_FAAD
|
||||||
else if(isAac(utf8file,NULL)) pc->decodeType = DECODE_TYPE_AAC;
|
else if(isAac(utf8file,NULL)) pc->decodeType = DECODE_TYPE_AAC;
|
||||||
|
else if(isMp4(utf8file,NULL)) pc->decodeType = DECODE_TYPE_MP4;
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
|
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
|
||||||
|
|
|
@ -82,6 +82,9 @@ Song * newSong(char * utf8file) {
|
||||||
else if(isAac(utf8file,&(song->mtime))) {
|
else if(isAac(utf8file,&(song->mtime))) {
|
||||||
song->tag = aacTagDup(utf8file);
|
song->tag = aacTagDup(utf8file);
|
||||||
}
|
}
|
||||||
|
else if(isMp4(utf8file,&(song->mtime))) {
|
||||||
|
song->tag = mp4TagDup(utf8file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!song->tag || song->tag->time<0) {
|
if(!song->tag || song->tag->time<0) {
|
||||||
|
@ -249,6 +252,9 @@ int updateSongInfo(Song * song) {
|
||||||
else if(isAac(utf8file,&(song->mtime))) {
|
else if(isAac(utf8file,&(song->mtime))) {
|
||||||
song->tag = aacTagDup(utf8file);
|
song->tag = aacTagDup(utf8file);
|
||||||
}
|
}
|
||||||
|
else if(isMp4(utf8file,&(song->mtime))) {
|
||||||
|
song->tag = mp4TagDup(utf8file);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!song->tag || song->tag->time<0) return -1;
|
if(!song->tag || song->tag->time<0) return -1;
|
||||||
|
|
22
src/tag.c
22
src/tag.c
|
@ -168,13 +168,27 @@ MpdTag * mp3TagDup(char * utf8file) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_FAAD
|
#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 * aacTagDup(char * utf8file) {
|
||||||
MpdTag * ret = NULL;
|
MpdTag * ret = NULL;
|
||||||
int time;
|
int time = -1;
|
||||||
|
|
||||||
ret = id3Dup(utf8file);
|
#warning getMp4TotalTime needs implementing
|
||||||
|
|
||||||
#warning getAacTotalTime needs implementing
|
|
||||||
//time = getAacTotalTime(rmp2amp(utf8ToFsCharset(utf8file)));
|
//time = getAacTotalTime(rmp2amp(utf8ToFsCharset(utf8file)));
|
||||||
|
|
||||||
if(time>=0) {
|
if(time>=0) {
|
||||||
|
|
Loading…
Reference in New Issue