diff --git a/src/db-generic.h b/src/db-generic.h index 8c3170dc..de7fb26e 100644 --- a/src/db-generic.h +++ b/src/db-generic.h @@ -22,7 +22,7 @@ #ifndef _DB_GENERIC_H_ #define _DB_GENERIC_H_ -#include "mp3-scanner.h" /** for MP3FILE */ +#include "ff-dbstruct.h" /** for MP3FILE */ #include "smart-parser.h" /** for PARSETREE */ #include "webserver.h" /** for WS_CONNINFO */ diff --git a/src/ff-dbstruct.h b/src/ff-dbstruct.h index 306a7886..dc242137 100644 --- a/src/ff-dbstruct.h +++ b/src/ff-dbstruct.h @@ -59,4 +59,139 @@ #define SG_CONTENTRATING 40 #define SG_BITS_PER_SAMPLE 41 #define SG_ALBUM_ARTIST 42 + +/* Packed and unpacked formats */ +typedef struct tag_mp3file { + char *path; + uint32_t index; + char *fname; + char *title; /* TIT2 */ + char *artist; /* TPE1 */ + char *album; /* TALB */ + char *genre; /* TCON */ + char *comment; /* COMM */ + char *type; + char *composer; /* TCOM */ + char *orchestra; /* TPE2 */ + char *conductor; /* TPE3 */ + char *grouping; /* TIT1 */ + char *url; /* daap.songdataurl (asul) */ + + uint32_t bitrate; + uint32_t samplerate; + uint32_t song_length; + uint32_t file_size; /* ?? */ + uint32_t year; /* TDRC */ + + uint32_t track; /* TRCK */ + uint32_t total_tracks; + + uint32_t disc; /* TPOS */ + uint32_t total_discs; + + uint32_t time_added; /* really should be a time_t */ + uint32_t time_modified; + uint32_t time_played; + + uint32_t play_count; + uint32_t rating; + uint32_t db_timestamp; + + uint32_t disabled; + uint32_t bpm; /* TBPM */ + + uint32_t got_id3; + uint32_t id; + + char *description; /* long file type */ + char *codectype; /* song.codectype */ + + uint32_t item_kind; /* song or movie */ + uint32_t data_kind; /* dmap.datakind (asdk) */ + uint32_t force_update; + uint64_t sample_count; + char compilation; + + /* iTunes 5+ */ + uint32_t contentrating; + + /* iTunes 6.0.2 */ + uint32_t has_video; + uint32_t bits_per_sample; + + char *album_artist; +} MP3FILE; + +typedef struct tag_m3ufile { + uint32_t id; /**< integer id (miid) */ + char *title; /**< playlist name as displayed in iTunes (minm) */ + uint32_t type; /**< see PL_ types */ + uint32_t items; /**< number of items (mimc) */ + char *query; /**< where clause if type 1 (MSPS) */ + uint32_t db_timestamp;/**< time last updated */ + char *path; /**< path of underlying playlist (if type 2) */ + uint32_t index; /**< index of playlist for paths with multiple playlists */ +} M3UFILE; + +typedef struct tag_packed_m3ufile { + char *id; + char *title; + char *type; + char *items; + char *query; + char *db_timestamp; + char *path; + char *index; +} PACKED_M3UFILE; + +typedef struct tag_packed_mp3file { + char *id; + char *path; + char *fname; + char *title; + char *artist; + char *album; + char *genre; + char *comment; + char *type; + char *composer; + char *orchestra; + char *conductor; + char *grouping; + char *url; + char *bitrate; + char *samplerate; + char *song_length; + char *file_size; + char *year; + char *track; + char *total_tracks; + char *disc; + char *total_discs; + char *bpm; + char *compilation; + char *rating; + char *play_count; + char *data_kind; + char *item_kind; + char *description; + char *time_added; + char *time_modified; + char *time_played; + char *db_timestamp; + char *disabled; + char *sample_count; + char *force_update; + char *codectype; + char *idx; + char *has_video; + char *contentrating; + char *bits_per_sample; +} PACKED_MP3FILE; + +#define PL_STATICWEB 0 +#define PL_SMART 1 +#define PL_STATICFILE 2 +#define PL_STATICXML 3 + #endif /* _FF_DBSTRUCT_H_ */ diff --git a/src/ff-plugins.h b/src/ff-plugins.h index ea6587fd..150d5182 100644 --- a/src/ff-plugins.h +++ b/src/ff-plugins.h @@ -69,7 +69,7 @@ typedef struct tag_plugin_event_fn { typedef struct tag_plugin_transcode_fn { void *(*ssc_init)(void); void (*ssc_deinit)(void*); - int (*ssc_open)(void*, char *, char*, int); + int (*ssc_open)(void*, MP3FILE *); int (*ssc_close)(void*); int (*ssc_read)(void*, char*, int); char *(*ssc_error)(void*); diff --git a/src/mp3-scanner.h b/src/mp3-scanner.h index d579c5f8..b729290e 100644 --- a/src/mp3-scanner.h +++ b/src/mp3-scanner.h @@ -23,139 +23,8 @@ #define _MP3_SCANNER_H_ #include +#include "ff-dbstruct.h" /* for MP3FILE */ -typedef struct tag_mp3file { - char *path; - uint32_t index; - char *fname; - char *title; /* TIT2 */ - char *artist; /* TPE1 */ - char *album; /* TALB */ - char *genre; /* TCON */ - char *comment; /* COMM */ - char *type; - char *composer; /* TCOM */ - char *orchestra; /* TPE2 */ - char *conductor; /* TPE3 */ - char *grouping; /* TIT1 */ - char *url; /* daap.songdataurl (asul) */ - - uint32_t bitrate; - uint32_t samplerate; - uint32_t song_length; - uint32_t file_size; /* ?? */ - uint32_t year; /* TDRC */ - - uint32_t track; /* TRCK */ - uint32_t total_tracks; - - uint32_t disc; /* TPOS */ - uint32_t total_discs; - - uint32_t time_added; /* really should be a time_t */ - uint32_t time_modified; - uint32_t time_played; - - uint32_t play_count; - uint32_t rating; - uint32_t db_timestamp; - - uint32_t disabled; - uint32_t bpm; /* TBPM */ - - uint32_t got_id3; - uint32_t id; - - char *description; /* long file type */ - char *codectype; /* song.codectype */ - - uint32_t item_kind; /* song or movie */ - uint32_t data_kind; /* dmap.datakind (asdk) */ - uint32_t force_update; - uint64_t sample_count; - char compilation; - - /* iTunes 5+ */ - uint32_t contentrating; - - /* iTunes 6.0.2 */ - uint32_t has_video; - uint32_t bits_per_sample; - - char *album_artist; -} MP3FILE; - -typedef struct tag_m3ufile { - uint32_t id; /**< integer id (miid) */ - char *title; /**< playlist name as displayed in iTunes (minm) */ - uint32_t type; /**< 0=static webmanaged, 1=smart, 2=static m3u (aeSP/MPTY) */ - uint32_t items; /**< number of items (mimc) */ - char *query; /**< where clause if type 1 (MSPS) */ - uint32_t db_timestamp; /**< time last updated */ - char *path; /**< path of underlying playlist (if type 2) */ - uint32_t index; /**< index of playlist for paths with multiple playlists */ -} M3UFILE; - -typedef struct tag_packed_m3ufile { - char *id; - char *title; - char *type; - char *items; - char *query; - char *db_timestamp; - char *path; - char *index; -} PACKED_M3UFILE; - -typedef struct tag_packed_mp3file { - char *id; - char *path; - char *fname; - char *title; - char *artist; - char *album; - char *genre; - char *comment; - char *type; - char *composer; - char *orchestra; - char *conductor; - char *grouping; - char *url; - char *bitrate; - char *samplerate; - char *song_length; - char *file_size; - char *year; - char *track; - char *total_tracks; - char *disc; - char *total_discs; - char *bpm; - char *compilation; - char *rating; - char *play_count; - char *data_kind; - char *item_kind; - char *description; - char *time_added; - char *time_modified; - char *time_played; - char *db_timestamp; - char *disabled; - char *sample_count; - char *force_update; - char *codectype; - char *idx; - char *has_video; - char *contentrating; - char *bits_per_sample; -} PACKED_MP3FILE; - -#define PL_STATICWEB 0 -#define PL_SMART 1 -#define PL_STATICFILE 2 -#define PL_STATICXML 3 #define SCAN_NOT_COMPDIR 0 #define SCAN_IS_COMPDIR 1 diff --git a/src/plugin.c b/src/plugin.c index a1f27525..9cf2e4e1 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -80,7 +80,7 @@ void _plugin_unlock(void); int _plugin_error(char **pe, int error, ...); void _plugin_free(int *pi); void _plugin_recalc_codecs(void); -int _plugin_ssc_transcode(WS_CONNINFO *pwsc, char *file, char *codec, int duration, int offset, int headers); +int _plugin_ssc_transcode(WS_CONNINFO *pwsc, MP3FILE *pmp3, int offset, int headers); /* webserver helpers */ char *pi_ws_uri(WS_CONNINFO *pwsc); @@ -553,7 +553,7 @@ int _plugin_ssc_copy(WS_CONNINFO *pwsc, PLUGIN_TRANSCODE_FN *pfn, * @param duration time in ms * @returns bytes transferred, or -1 on error */ -int _plugin_ssc_transcode(WS_CONNINFO *pwsc, char *file, char *codec, int duration, int offset, int headers) { +int _plugin_ssc_transcode(WS_CONNINFO *pwsc, MP3FILE *pmp3, int offset, int headers) { PLUGIN_ENTRY *ppi, *ptc=NULL; PLUGIN_TRANSCODE_FN *pfn = NULL; void *vp_ssc; @@ -566,7 +566,7 @@ int _plugin_ssc_transcode(WS_CONNINFO *pwsc, char *file, char *codec, int durati ppi = _plugin_list.next; while((ppi) && (!pfn)) { if(ppi->pinfo->type & PLUGIN_TRANSCODE) { - if(strstr(ppi->pinfo->codeclist,codec)) { + if(strstr(ppi->pinfo->codeclist,pmp3->codectype)) { ptc = ppi; pfn = ppi->pinfo->transcode_fns; } @@ -575,12 +575,12 @@ int _plugin_ssc_transcode(WS_CONNINFO *pwsc, char *file, char *codec, int durati } if(pfn) { - DPRINTF(E_DBG,L_PLUG,"Transcoding %s with %s\n",file, + DPRINTF(E_DBG,L_PLUG,"Transcoding %s with %s\n",pmp3->path, ptc->pinfo->server); vp_ssc = pfn->ssc_init(); if(vp_ssc) { - if(pfn->ssc_open(vp_ssc,file,codec,duration)) { + if(pfn->ssc_open(vp_ssc,pmp3)) { /* start reading and throwing */ if(headers) { ws_addresponseheader(pwsc,"Content-Type","audio/wav"); @@ -602,7 +602,7 @@ int _plugin_ssc_transcode(WS_CONNINFO *pwsc, char *file, char *codec, int durati pfn->ssc_close(vp_ssc); } else { DPRINTF(E_LOG,L_PLUG,"Error opening %s for ssc: %s\n", - file,pfn->ssc_error(vp_ssc)); + pmp3->path,pfn->ssc_error(vp_ssc)); } pfn->ssc_deinit(vp_ssc); } else { @@ -865,8 +865,7 @@ void pi_stream(WS_CONNINFO *pwsc, char *id) { "Session %d: Streaming file '%s' to %s (offset %ld)\n", session,pmp3->fname, pwsc->hostname,(long)offset); - bytes_copied = _plugin_ssc_transcode(pwsc,pmp3->path,pmp3->codectype, - pmp3->song_length,offset,1); + bytes_copied = _plugin_ssc_transcode(pwsc,pmp3,offset,1); config_set_status(pwsc,session,NULL); db_dispose_item(pmp3); diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 779544ca..b809e22f 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -22,10 +22,10 @@ ssc_script_la_SOURCES=ssc-script.c out_daap_LTLIBRARIES=out-daap.la out_daap_la_LDFLAGS=-module -avoid-version -out_daap_la_SOURCES=out-daap.c out-daap-proto.c out-daap-db.c +out_daap_la_SOURCES=out-daap.c out-daap-proto.c EXTRA_DIST = compat.h rsp.h xml-rpc.h ssc-ffmpeg.c ssc-script.c out-daap.h \ - out-daap-proto.h out-daap-db.h + out-daap-proto.h AM_CFLAGS = -I.. diff --git a/src/plugins/out-daap-db.c b/src/plugins/out-daap-db.c deleted file mode 100644 index 7a1c1d8a..00000000 --- a/src/plugins/out-daap-db.c +++ /dev/null @@ -1,7 +0,0 @@ -/* - * $Id: $ - */ - -#include "out-daap.h" -#include "out-daap-proto.h" -#include "out-daap-db.h" diff --git a/src/plugins/out-daap-db.h b/src/plugins/out-daap-db.h deleted file mode 100644 index 9ccaf343..00000000 --- a/src/plugins/out-daap-db.h +++ /dev/null @@ -1,8 +0,0 @@ -/* - * $Id: $ - */ - -#ifndef _OUT_DAAP_DB_H_ -#define _OUT_DAAP_DB_H_ - -#endif /* _OUT_DAAP_DB_H_ */ diff --git a/src/plugins/out-daap.c b/src/plugins/out-daap.c index e34774f3..d55c9a82 100644 --- a/src/plugins/out-daap.c +++ b/src/plugins/out-daap.c @@ -38,6 +38,7 @@ #endif #include "compat.h" +#include "ff-dbstruct.h" #include "ff-plugins.h" #include "out-daap.h" #include "out-daap-proto.h" diff --git a/src/plugins/rsp.c b/src/plugins/rsp.c index a39ebb02..939b7e14 100644 --- a/src/plugins/rsp.c +++ b/src/plugins/rsp.c @@ -11,6 +11,7 @@ #include #include "compat.h" +#include "ff-dbstruct.h" #include "ff-plugins.h" #include "rsp.h" #include "xml-rpc.h" diff --git a/src/plugins/ssc-ffmpeg.c b/src/plugins/ssc-ffmpeg.c index c6b01160..84f4d8ef 100644 --- a/src/plugins/ssc-ffmpeg.c +++ b/src/plugins/ssc-ffmpeg.c @@ -99,7 +99,7 @@ char *ssc_ffmpeg_errors[] = { /* Forwards */ void *ssc_ffmpeg_init(void); void ssc_ffmpeg_deinit(void *pv); -int ssc_ffmpeg_open(void *pv, char *file, char *codec, int duration); +int ssc_ffmpeg_open(void *pv, MP3FILE *pmp3); int ssc_ffmpeg_close(void *pv); int ssc_ffmpeg_read(void *pv, char *buffer, int len); char *ssc_ffmpeg_error(void *pv); @@ -163,7 +163,7 @@ void ssc_ffmpeg_deinit(void *vp) { return; } -int ssc_ffmpeg_open(void *vp, char *file, char *codec, int duration) { +int ssc_ffmpeg_open(void *vp, MP3FILE *pmp3) { int i; enum CodecID id=CODEC_ID_FLAC; SSCHANDLE *handle = (SSCHANDLE*)vp; @@ -173,6 +173,13 @@ int ssc_ffmpeg_open(void *vp, char *file, char *codec, int duration) { #endif SCAN_ID3HEADER id3; unsigned int size = 0; + char *file; + char *codec; + int duration; + + file = pmp3->path; + codec = pmp3->codectype; + duration = pmp3->song_length; if(!handle) return FALSE; diff --git a/src/plugins/ssc-script.c b/src/plugins/ssc-script.c index 2a21be1b..c476c468 100644 --- a/src/plugins/ssc-script.c +++ b/src/plugins/ssc-script.c @@ -10,6 +10,7 @@ #include #include +#include "ff-dbstruct.h" #include "ff-plugins.h" #ifndef TRUE @@ -20,7 +21,7 @@ /* Forwards */ void *ssc_script_init(void); void ssc_script_deinit(void *vp); -int ssc_script_open(void *vp, char *file, char *codec, int duration); +int ssc_script_open(void *vp, MP3FILE *pmp3); int ssc_script_close(void *vp); int ssc_script_read(void *vp, char *buffer, int len); char *ssc_script_error(void *vp); @@ -130,13 +131,21 @@ void ssc_script_deinit(void *vp) { * @param codec codec type * @param duration duration in ms */ -int ssc_script_open(void *vp, char *file, char *codec, int duration) { +int ssc_script_open(void *vp, MP3FILE *pmp3) { SSCHANDLE *handle = (SSCHANDLE*)vp; char *cmd; char *newpath; char *metachars = "\"\\!(){}#*?$&<>`"; /* More?? */ char metacount = 0; char *src,*dst; + char *file; + char *codec; + int duration; + + file = pmp3->path; + codec = pmp3->codectype; + duration = pmp3->song_length; + src=file; while(*src) { diff --git a/src/plugins/ssc-wma.cpp b/src/plugins/ssc-wma.cpp index 4426f1d8..6d2832df 100644 --- a/src/plugins/ssc-wma.cpp +++ b/src/plugins/ssc-wma.cpp @@ -66,7 +66,7 @@ char *_ssc_wma_errors[] = { /* Forwards */ void *ssc_wma_init(void); void ssc_wma_deinit(void *pv); -int ssc_wma_open(void *pv, char *file, char *codec, int duration); +int ssc_wma_open(void *pv, MP3FILE *pmp3); int ssc_wma_close(void *pv); int ssc_wma_read(void *pv, char *buffer, int len); char *ssc_wma_error(void *pv); @@ -140,11 +140,18 @@ void ssc_wma_deinit(void *vp) { return; } -int ssc_wma_open(void *vp, char *file, char *codec, int duration) { +int ssc_wma_open(void *vp, MP3FILE *pmp3) { SSCHANDLE *handle = (SSCHANDLE*)vp; HRESULT hr = S_OK; WCHAR fname[PATH_MAX]; DWORD byte_count; + char *file; + char *codec; + int duration; + + file = pmp3->path; + codec = pmp3->codectype; + duration = pmp3->song_length; if(!handle) return FALSE; diff --git a/src/plugins/xml-rpc.c b/src/plugins/xml-rpc.c index 2dbb1442..29066cd5 100644 --- a/src/plugins/xml-rpc.c +++ b/src/plugins/xml-rpc.c @@ -16,6 +16,7 @@ #include #include "compat.h" +#include "ff-dbstruct.h" #include "ff-plugins.h" #include "rsp.h" #include "xml-rpc.h"