Pass mp3struct to ssc plugins so they can take advantage of metainfo

This commit is contained in:
Ron Pedde 2006-11-06 03:42:38 +00:00
parent b5008ded8d
commit 792fa16f1e
14 changed files with 179 additions and 165 deletions

View File

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

View File

@ -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_ */

View File

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

View File

@ -23,139 +23,8 @@
#define _MP3_SCANNER_H_
#include <sys/types.h>
#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

View File

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

View File

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

View File

@ -1,7 +0,0 @@
/*
* $Id: $
*/
#include "out-daap.h"
#include "out-daap-proto.h"
#include "out-daap-db.h"

View File

@ -1,8 +0,0 @@
/*
* $Id: $
*/
#ifndef _OUT_DAAP_DB_H_
#define _OUT_DAAP_DB_H_
#endif /* _OUT_DAAP_DB_H_ */

View File

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

View File

@ -11,6 +11,7 @@
#include <string.h>
#include "compat.h"
#include "ff-dbstruct.h"
#include "ff-plugins.h"
#include "rsp.h"
#include "xml-rpc.h"

View File

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

View File

@ -10,6 +10,7 @@
#include <stdlib.h>
#include <string.h>
#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) {

View File

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

View File

@ -16,6 +16,7 @@
#include <zlib.h>
#include "compat.h"
#include "ff-dbstruct.h"
#include "ff-plugins.h"
#include "rsp.h"
#include "xml-rpc.h"