From ba162fc082c4d2514a15cb38df249aa8dd6bbfbb Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Thu, 31 May 2012 18:37:22 +0000 Subject: [PATCH] * Add flag to force downscaled thumbnails rather than using embedded ones. * Add DirecTV client detection. --- minidlnatypes.h | 1 + upnphttp.c | 7 +++++++ upnphttp.h | 11 ++++++----- upnpsoap.c | 31 ++++++++++++++----------------- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/minidlnatypes.h b/minidlnatypes.h index 89592df..2ed17c2 100644 --- a/minidlnatypes.h +++ b/minidlnatypes.h @@ -85,6 +85,7 @@ enum client_types { ESamsungSeriesB, EMarantzDMP, ELifeTab, + EDirecTV, EStandardDLNA150 = 100 }; diff --git a/upnphttp.c b/upnphttp.c index dc37b10..f27cd1e 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -347,6 +347,7 @@ ParseHttpHeaders(struct upnphttp * h) else if(strstrc(p, "fbxupnpav/", '\r')) { h->req_client = EFreeBox; + h->reqflags |= FLAG_RESIZE_THUMBS; } else if(strncmp(p, "SMP8634", 7)==0) { @@ -367,6 +368,12 @@ ParseHttpHeaders(struct upnphttp * h) { h->req_client = ENetgearEVA2000; h->reqflags |= FLAG_MS_PFS; + h->reqflags |= FLAG_RESIZE_THUMBS; + } + else if(strstrc(p, "DIRECTV ", '\r')) + { + h->req_client = EDirecTV; + h->reqflags |= FLAG_RESIZE_THUMBS; } else if(strstrc(p, "UPnP/1.0 DLNADOC/1.50 Intel_SDK_for_UPnP_devices/1.2", '\r')) { diff --git a/upnphttp.h b/upnphttp.h index dfa0329..e23ef72 100644 --- a/upnphttp.h +++ b/upnphttp.h @@ -133,11 +133,12 @@ struct upnphttp { #define FLAG_MIME_AVI_AVI 0x00400000 #define FLAG_MIME_FLAC_FLAC 0x00800000 #define FLAG_MIME_WAV_WAV 0x01000000 -#define FLAG_NO_RESIZE 0x02000000 -#define FLAG_MS_PFS 0x04000000 // Microsoft PlaysForSure client -#define FLAG_SAMSUNG 0x08000000 -#define FLAG_SAMSUNG_TV 0x10000000 -#define FLAG_AUDIO_ONLY 0x20000000 +#define FLAG_RESIZE_THUMBS 0x02000000 +#define FLAG_NO_RESIZE 0x04000000 +#define FLAG_MS_PFS 0x08000000 // Microsoft PlaysForSure client +#define FLAG_SAMSUNG 0x10000000 +#define FLAG_SAMSUNG_TV 0x20000000 +#define FLAG_AUDIO_ONLY 0x40000000 #define FLAG_FREE_OBJECT_ID 0x00000001 #define FLAG_ROOT_CONTAINER 0x00000002 diff --git a/upnpsoap.c b/upnpsoap.c index c3d323c..7ce20fb 100644 --- a/upnpsoap.c +++ b/upnpsoap.c @@ -926,7 +926,7 @@ callback(void *args, int argc, char **argv, char **azColName) ret = strcatf(str, "<upnp:album>%s</upnp:album>", "[No Keywords]"); /* EVA2000 doesn't seem to handle embedded thumbnails */ - if( passed_args->client != ENetgearEVA2000 && tn && atoi(tn) ) { + if( !(passed_args->flags & FLAG_RESIZE_THUMBS) && tn && atoi(tn) ) { ret = strcatf(str, "<upnp:albumArtURI>" "http://%s:%d/Thumbnails/%s.jpg" "</upnp:albumArtURI>", @@ -940,31 +940,28 @@ callback(void *args, int argc, char **argv, char **azColName) } if( passed_args->filter & FILTER_RES ) { mime_to_ext(mime, ext); - if( (passed_args->client == EFreeBox) && tn && atoi(tn) ) { - ret = strcatf(str, "<res protocolInfo=\"http-get:*:%s:%s\">" - "http://%s:%d/Thumbnails/%s.jpg" - "</res>", - mime, "DLNA.ORG_PN=JPEG_TN", lan_addr[passed_args->iface].str, - runtime_vars.port, detailID); - } add_res(size, duration, bitrate, sampleFrequency, nrAudioChannels, resolution, dlna_buf, mime, detailID, ext, passed_args); - if( (*mime == 'i') && (passed_args->client != EFreeBox) ) { - int srcw = atoi(strsep(&resolution, "x")); - int srch = atoi(resolution); - if( !dlna_pn ) { - add_resized_res(srcw, srch, 4096, 4096, "JPEG_LRG", detailID, passed_args); + if( *mime == 'i' ) { + int srcw, srch; + if( resolution && (sscanf(resolution, "%dx%d", &srcw, &srch) == 2) ) + { + if( srcw > 4096 || srch > 4096 ) + add_resized_res(srcw, srch, 4096, 4096, "JPEG_LRG", detailID, passed_args); + if( srcw > 1024 || srch > 768 ) + add_resized_res(srcw, srch, 1024, 768, "JPEG_MED", detailID, passed_args); + if( srcw > 640 || srch > 480 ) + add_resized_res(srcw, srch, 640, 480, "JPEG_SM", detailID, passed_args); } - if( !dlna_pn || !strncmp(dlna_pn, "JPEG_L", 6) || !strncmp(dlna_pn, "JPEG_M", 6) ) { - add_resized_res(srcw, srch, 640, 480, "JPEG_SM", detailID, passed_args); - } - if( tn && atoi(tn) ) { + if( !(passed_args->flags & FLAG_RESIZE_THUMBS) && tn && atoi(tn) ) { ret = strcatf(str, "<res protocolInfo=\"http-get:*:%s:%s\">" "http://%s:%d/Thumbnails/%s.jpg" "</res>", mime, "DLNA.ORG_PN=JPEG_TN;DLNA.ORG_CI=1", lan_addr[passed_args->iface].str, runtime_vars.port, detailID); } + else + add_resized_res(srcw, srch, 160, 160, "JPEG_TN", detailID, passed_args); } else if( *mime == 'v' ) { switch( passed_args->client ) {