add wmal and wmap codectypes for wma lossless and wma pro

This commit is contained in:
Ron Pedde 2006-06-04 08:13:50 +00:00
parent 2072b9eaf2
commit 2ca9a89ccf
4 changed files with 89 additions and 9 deletions

View File

@ -20,7 +20,7 @@
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" # include "config.h"
#endif #endif
#define _XOPEN_SOURCE 500 /** unix98? pthread_once_t, etc */ #define _XOPEN_SOURCE 500 /** unix98? pthread_once_t, etc */

View File

@ -242,6 +242,16 @@ typedef struct tag_wma_subheader {
unsigned char objectid[16]; unsigned char objectid[16];
long long size; long long size;
} _PACKED WMA_SUBHEADER; } _PACKED WMA_SUBHEADER;
typedef struct tag_wma_stream_properties {
unsigned char stream_type[16];
unsigned char codec_type[16];
char time_offset[8];
unsigned int tsdl;
unsigned int ecdl;
unsigned short int flags;
unsigned int reserved;
} _PACKED WMA_STREAM_PROP;
#pragma pack() #pragma pack()
/* /*
@ -255,7 +265,8 @@ char *wma_utf16toutf8(unsigned char *utf16, int len);
int wma_parse_content_description(int fd,int size, MP3FILE *pmp3); int wma_parse_content_description(int fd,int size, MP3FILE *pmp3);
int wma_parse_extended_content_description(int fd,int size, MP3FILE *pmp3); int wma_parse_extended_content_description(int fd,int size, MP3FILE *pmp3);
int wma_parse_file_properteis(int fd,int size, MP3FILE *pmp3); int wma_parse_file_properteis(int fd,int size, MP3FILE *pmp3);
int wma_parse_audio_media(int fd, int size, MP3FILE *pmp3);
int wma_parse_stream_properties(int fd, int size, MP3FILE *pmp3);
/** /**
* read an unsigned short int from the fd * read an unsigned short int from the fd
@ -325,6 +336,70 @@ int wma_file_read_bytes(int fd,int len, unsigned char **data) {
return 1; return 1;
} }
/**
* another try to get stream codec type
*
* @param fd fd of the file we are reading from -- positioned at start
* @param size size of the content description block
* @param pmp3 the mp3 struct we are filling with gleaned data
*/
int wma_parse_stream_properties(int fd, int size, MP3FILE *pmp3) {
WMA_STREAM_PROP sp;
WMA_GUID *pguid;
if(r_read(fd,&sp,sizeof(sp)) != sizeof(sp))
return FALSE;
pguid = wma_find_guid(sp.stream_type);
if(!pguid)
return TRUE;
if(strcmp(pguid->name,"ASF_Audio_Media") != 0)
return TRUE;
/* it is an audio stream... find codec. The Type-Specific
* data should be a WAVEFORMATEX... so we'll leverage
* wma_parse_audio_media
*/
return wma_parse_audio_media(fd,size - sizeof(WMA_STREAM_PROP),pmp3);
}
/**
* parse the audio media section... This is essentially a
* WAVFORMATEX structure. Generally we only care about the
* codec type.
*
* @param fd fd of the file we are reading from -- positioned at start
* @param size size of the content description block
* @param pmp3 the mp3 struct we are filling with gleaned data
*/
int wma_parse_audio_media(int fd, int size, MP3FILE *pmp3) {
unsigned short int codec;
if(size < 2)
return TRUE; /* we'll leave it wma. will work or not! */
if(!wma_file_read_short(fd,&codec)) {
return FALSE;
}
DPRINTF(E_DBG,L_SCAN,"WMA Codec Type: %02X\n",codec);
switch(codec) {
case 0x162:
MAYBEFREE(pmp3->codectype);
pmp3->codectype = strdup("wmap"); /* pro */
break;
case 0x163:
MAYBEFREE(pmp3->codectype);
pmp3->codectype = strdup("wmal"); /* lossless */
break;
}
return TRUE;
}
/** /**
* parse the extended content description object. this is an object that * parse the extended content description object. this is an object that
* has ad-hoc tags, basically. * has ad-hoc tags, basically.
@ -830,6 +905,10 @@ int scan_get_wmainfo(char *filename, MP3FILE *pmp3) {
res &= wma_parse_extended_content_description(wma_fd,(int)subhdr.size,pmp3); res &= wma_parse_extended_content_description(wma_fd,(int)subhdr.size,pmp3);
} else if (strcmp(pguid->name,"ASF_File_Properties_Object")==0) { } else if (strcmp(pguid->name,"ASF_File_Properties_Object")==0) {
res &= wma_parse_file_properties(wma_fd,(int)subhdr.size,pmp3); res &= wma_parse_file_properties(wma_fd,(int)subhdr.size,pmp3);
} else if (strcmp(pguid->name,"ASF_Audio_Media")==0) {
res &= wma_parse_audio_media(wma_fd,(int)subhdr.size,pmp3);
} else if (strcmp(pguid->name,"ASF_Stream_Properties_Object")==0) {
res &= wma_parse_stream_properties(wma_fd,(int)subhdr.size,pmp3);
} }
} else { } else {
DPRINTF(E_DBG,L_SCAN,"Unknown subheader: %02hhx%02hhx%02hhx%02hhx-" DPRINTF(E_DBG,L_SCAN,"Unknown subheader: %02hhx%02hhx%02hhx%02hhx-"

View File

@ -143,7 +143,8 @@ int main(int argc, char *argv[]) {
SCANNERLIST *plist; SCANNERLIST *plist;
int option; int option;
char *ext; char *ext;
char *configfile; char *configfile = "mt-daapd.conf";
int debuglevel=1;
memset((void*)&mp3,0x00,sizeof(MP3FILE)); memset((void*)&mp3,0x00,sizeof(MP3FILE));
@ -156,7 +157,7 @@ int main(int argc, char *argv[]) {
while((option = getopt(argc, argv, "d:c:")) != -1) { while((option = getopt(argc, argv, "d:c:")) != -1) {
switch(option) { switch(option) {
case 'd': case 'd':
err_setlevel(atoi(optarg)); debuglevel = atoi(optarg);
break; break;
case 'c': case 'c':
configfile=optarg; configfile=optarg;
@ -182,10 +183,10 @@ int main(int argc, char *argv[]) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
err_setdest(LOGDEST_STDERR);
err_setlevel(debuglevel);
printf("Getting info for %s\n",argv[0]); printf("Getting info for %s\n",argv[0]);
ext = strrchr(argv[0],'.')+1; ext = strrchr(argv[0],'.')+1;
plist=scanner_list; plist=scanner_list;

View File

@ -1,8 +1,8 @@
CC=gcc CC=gcc
CFLAGS := $(CFLAGS) -g -I/opt/local/include -DHAVE_CONFIG_H -I. -I.. -DHOST='"foo"' -DHAVE_SQL CFLAGS := $(CFLAGS) -g -I/opt/local/include -DHAVE_CONFIG_H -I. -I.. -DHOST='"foo"' -DHAVE_SQL -DHAVE_CONFIG_H
LDFLAGS := $(LDFLAGS) -L/opt/local/lib -lid3tag -logg -lvorbisfile -lFLAC -lvorbis -ltag_c -lsqlite -lsqlite3 LDFLAGS := $(LDFLAGS) -L/opt/local/lib -lid3tag -logg -lvorbisfile -lFLAC -lvorbis -ltag_c -lsqlite -lsqlite3 -lm
TARGET = scanner TARGET = scanner
OBJECTS=scanner-driver.o restart.o err.o scan-wma.o scan-aac.o scan-wav.o scan-flac.o scan-ogg.o scan-mp3.o scan-url.o scan-mpc.o os-unix.o conf.o ll.o xml-rpc.o webserver.o uici.o rend-win32.o configfile.o db-generic.o ssc.o db-sql-sqlite3.o db-sql-sqlite2.o db-sql.o smart-parser.o OBJECTS=scanner-driver.o restart.o err.o scan-wma.o scan-aac.o scan-wav.o scan-flac.o scan-ogg.o scan-mp3.o scan-url.o scan-mpc.o os-unix.o conf.o ll.o xml-rpc.o webserver.o uici.o rend-win32.o configfile.o db-generic.o db-sql-sqlite3.o db-sql-sqlite2.o db-sql.o smart-parser.o plugin.o dispatch.o dynamic-art.o
$(TARGET): $(OBJECTS) $(TARGET): $(OBJECTS)
$(CC) -o $(TARGET) $(LDFLAGS) $(OBJECTS) $(CC) -o $(TARGET) $(LDFLAGS) $(OBJECTS)