Add support for TBPM (beats per minute) tag on MP3 files
This commit is contained in:
parent
a3eb5a6d53
commit
5748b6502d
|
@ -503,15 +503,19 @@ DAAP_BLOCK* daap_add_song_entry(DAAP_BLOCK* mlcl, MP3FILE* song, MetaField_t met
|
|||
if(mlit) {
|
||||
if(wantsMeta(meta, metaItemKind))
|
||||
g = g && daap_add_char(mlit,"mikd",song->item_kind); /* audio */
|
||||
|
||||
if(wantsMeta(meta, metaSongDataKind))
|
||||
g = g && daap_add_char(mlit,"asdk",0); /* local file */
|
||||
|
||||
if(song->album && (wantsMeta(meta, metaSongAlbum)))
|
||||
g = g && daap_add_string(mlit,"asal",song->album);
|
||||
|
||||
if(song->artist && wantsMeta(meta, metaSongArtist))
|
||||
g = g && daap_add_string(mlit,"asar",song->artist);
|
||||
|
||||
// g = g && daap_add_short(mlit,"asbt",0); /* bpm */
|
||||
if(song->bpm && (wantsMeta(meta, metaSongBPM)))
|
||||
g = g && daap_add_short(mlit,"asbt",song->bpm); /* bpm */
|
||||
|
||||
if(song->bitrate && (wantsMeta(meta, metaSongBitRate)))
|
||||
g = g && daap_add_short(mlit,"asbr",song->bitrate); /* bitrate!! */
|
||||
|
||||
|
@ -927,7 +931,9 @@ DAAP_BLOCK *daap_response_playlist_items(unsigned int playlist, char* metaStr, c
|
|||
if(wantsMeta(meta, metaContainerItemId))
|
||||
g = g && daap_add_int(mlit,"mcti",playlist);
|
||||
} else g = 0;
|
||||
#ifdef OPT_QUERY
|
||||
}
|
||||
#endif
|
||||
} else g = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
/*
|
||||
* Defines
|
||||
*/
|
||||
#define DB_VERSION 2
|
||||
#define DB_VERSION 3
|
||||
#define STRLEN(a) (a) ? strlen((a)) + 1 : 1
|
||||
#define MAYBEFREE(a) { if((a)) free((a)); };
|
||||
|
||||
|
@ -84,6 +84,7 @@ typedef struct tag_playlist {
|
|||
|
||||
typedef struct tag_mp3packed {
|
||||
int version;
|
||||
int struct_size; // so we can upgrade in place next time... doh!
|
||||
int bitrate;
|
||||
int samplerate;
|
||||
int song_length;
|
||||
|
@ -100,6 +101,8 @@ typedef struct tag_mp3packed {
|
|||
int time_modified;
|
||||
int time_played;
|
||||
|
||||
int bpm; // DB Version 3
|
||||
|
||||
unsigned int id; /* inode */
|
||||
|
||||
int path_len;
|
||||
|
@ -517,6 +520,8 @@ datum *db_packrecord(MP3FILE *pmp3) {
|
|||
ppacked=(MP3PACKED *)result->dptr;
|
||||
|
||||
ppacked->version=DB_VERSION;
|
||||
ppacked->struct_size=sizeof(MP3PACKED);
|
||||
|
||||
ppacked->bitrate=pmp3->bitrate;
|
||||
ppacked->samplerate=pmp3->samplerate;
|
||||
ppacked->song_length=pmp3->song_length;
|
||||
|
@ -529,6 +534,7 @@ datum *db_packrecord(MP3FILE *pmp3) {
|
|||
ppacked->time_added=pmp3->time_added;
|
||||
ppacked->time_modified=pmp3->time_modified;
|
||||
ppacked->time_played=pmp3->time_played;
|
||||
ppacked->bpm=pmp3->bpm;
|
||||
ppacked->id=pmp3->id;
|
||||
|
||||
ppacked->path_len=STRLEN(pmp3->path);
|
||||
|
@ -630,6 +636,7 @@ int db_unpackrecord(datum *pdatum, MP3FILE *pmp3) {
|
|||
pmp3->time_added=ppacked->time_added;
|
||||
pmp3->time_modified=ppacked->time_modified;
|
||||
pmp3->time_played=ppacked->time_played;
|
||||
pmp3->bpm=ppacked->bpm;
|
||||
pmp3->id=ppacked->id;
|
||||
|
||||
offset=0;
|
||||
|
|
|
@ -794,6 +794,9 @@ int scan_get_mp3tags(char *file, MP3FILE *pmp3) {
|
|||
} else if(!strcmp(pid3frame->id,"TLEN")) {
|
||||
pmp3->song_length = atoi(utf8_text) / 1000;
|
||||
DPRINTF(ERR_DEBUG, " Length: %d\n", pmp3->song_length);
|
||||
} else if(!strcmp(pid3frame->id,"TBPM")) {
|
||||
pmp3->bpm = atoi(utf8_text);
|
||||
DPRINTF(ERR_DEBUG, "BPM: %d\n", pmp3->bpm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -903,10 +906,7 @@ int scan_get_aacfileinfo(char *file, MP3FILE *pmp3) {
|
|||
fread((void*)&temp_int,1,sizeof(int),infile);
|
||||
temp_int=ntohl(temp_int);
|
||||
/* DWB: use ms time instead of sec */
|
||||
if(temp_int > 720000)
|
||||
pmp3->song_length=temp_int / 90; /* PlayFair? */
|
||||
else
|
||||
pmp3->song_length=temp_int * 1000 / 600;
|
||||
pmp3->song_length=temp_int * 1000 / 600;
|
||||
|
||||
DPRINTF(ERR_DEBUG,"Song length: %d seconds\n", pmp3->song_length / 1000);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@ typedef struct tag_mp3file {
|
|||
int time_added;
|
||||
int time_modified;
|
||||
int time_played;
|
||||
|
||||
int bpm; /* TBPM */
|
||||
|
||||
int got_id3;
|
||||
unsigned int id;
|
||||
|
|
|
@ -542,6 +542,7 @@ int ws_getheaders(WS_CONNINFO *pwsc) {
|
|||
* ws_getgetvars
|
||||
*
|
||||
* parse a GET string of variables (or POST)
|
||||
*
|
||||
*/
|
||||
int ws_getgetvars(WS_CONNINFO *pwsc, char *string) {
|
||||
char *new_string;
|
||||
|
|
Loading…
Reference in New Issue