diff --git a/clients.c b/clients.c index 7cdf863..85c3246 100644 --- a/clients.c +++ b/clients.c @@ -128,7 +128,7 @@ struct client_type_s client_types[] = /* User-Agent: Linux/2.6.31-1.0 UPnP/1.0 DLNADOC/1.50 INTEL_NMPR/2.0 LGE_DLNA_SDK/1.5.0 */ { ELGDevice, - FLAG_DLNA, + FLAG_DLNA | FLAG_CAPTION_RES, "LG", "LGE_DLNA_SDK", EUserAgent diff --git a/clients.h b/clients.h index 7c7cbf7..6849122 100644 --- a/clients.h +++ b/clients.h @@ -23,6 +23,7 @@ #define CLIENT_CACHE_SLOTS 25 +/* Client capability/quirk flags */ #define FLAG_DLNA 0x00000001 #define FLAG_MIME_AVI_DIVX 0x00000002 #define FLAG_MIME_AVI_AVI 0x00000004 @@ -30,11 +31,16 @@ #define FLAG_MIME_WAV_WAV 0x00000010 #define FLAG_RESIZE_THUMBS 0x00000020 #define FLAG_NO_RESIZE 0x00000040 -#define FLAG_MS_PFS 0x00000080 // Microsoft PlaysForSure client +#define FLAG_MS_PFS 0x00000080 /* Microsoft PlaysForSure client */ #define FLAG_SAMSUNG 0x00000100 #define FLAG_SAMSUNG_DCM10 0x00000200 #define FLAG_AUDIO_ONLY 0x00000400 #define FLAG_FORCE_SORT 0x00000800 +#define FLAG_CAPTION_RES 0x00001000 +/* Response-related flags */ +#define FLAG_HAS_CAPTIONS 0x20000000 +#define FLAG_FREE_OBJECT_ID 0x40000000 +#define FLAG_ROOT_CONTAINER 0x80000000 enum match_types { EMatchNone, diff --git a/upnpsoap.c b/upnpsoap.c index 18f1e15..3868f27 100644 --- a/upnpsoap.c +++ b/upnpsoap.c @@ -664,7 +664,7 @@ add_res(char *size, char *duration, char *bitrate, char *sampleFrequency, } if( args->filter & (FILTER_PV_SUBTITLE_FILE_TYPE|FILTER_PV_SUBTITLE_FILE_URI) ) { - if( sql_get_int_field(db, "SELECT ID from CAPTIONS where ID = '%s'", detailID) > 0 ) + if( args->flags & FLAG_HAS_CAPTIONS ) { if( args->filter & FILTER_PV_SUBTITLE_FILE_TYPE ) strcatf(args->str, "pv:subtitleFileType=\"SRT\" "); @@ -772,6 +772,12 @@ callback(void *args, int argc, char **argv, char **azColName) strcpy(mime+6, "mpeg"); } } + if( (passed_args->flags & FLAG_CAPTION_RES) || + (passed_args->filter & (FILTER_SEC_CAPTION_INFO_EX|FILTER_PV_SUBTITLE_FILE_TYPE|FILTER_PV_SUBTITLE_FILE_URI)) ) + { + if( sql_get_int_field(db, "SELECT ID from CAPTIONS where ID = '%s'", detailID) > 0 ) + passed_args->flags |= FLAG_HAS_CAPTIONS; + } /* From what I read, Samsung TV's expect a [wrong] MIME type of x-mkv. */ if( passed_args->flags & FLAG_SAMSUNG ) { @@ -781,16 +787,13 @@ callback(void *args, int argc, char **argv, char **azColName) } } /* LG hack: subtitles won't get used unless dc:title contains a dot. */ - else if( passed_args->client == ELGDevice && (passed_args->filter & FILTER_RES) ) + else if( passed_args->client == ELGDevice && (passed_args->flags & FLAG_HAS_CAPTIONS) ) { - if( sql_get_int_field(db, "SELECT ID from CAPTIONS where ID = '%s'", detailID) > 0 ) - { - ret = asprintf(&alt_title, "%s.", title); - if( ret > 0 ) - title = alt_title; - else - alt_title = NULL; - } + ret = asprintf(&alt_title, "%s.", title); + if( ret > 0 ) + title = alt_title; + else + alt_title = NULL; } } else if( *mime == 'a' ) @@ -962,28 +965,23 @@ callback(void *args, int argc, char **argv, char **azColName) resolution, dlna_buf, mime, detailID, ext, passed_args); } break; - case ELGDevice: - if( alt_title ) - { - ret = strcatf(str, "<res protocolInfo=\"http-get:*:text/srt:*\">" - "http://%s:%d/Captions/%s.srt" - "</res>", - lan_addr[passed_args->iface].str, runtime_vars.port, detailID); - free(alt_title); - } - break; case ESamsungSeriesCDE: + case ELGDevice: default: - if( passed_args->filter & FILTER_SEC_CAPTION_INFO_EX ) + if( passed_args->flags & FLAG_HAS_CAPTIONS ) { - if( sql_get_int_field(db, "SELECT ID from CAPTIONS where ID = '%s'", detailID) > 0 ) - { + if( passed_args->flags & FLAG_CAPTION_RES ) + ret = strcatf(str, "<res protocolInfo=\"http-get:*:text/srt:*\">" + "http://%s:%d/Captions/%s.srt" + "</res>", + lan_addr[passed_args->iface].str, runtime_vars.port, detailID); + else if( passed_args->filter & FILTER_SEC_CAPTION_INFO_EX ) ret = strcatf(str, "<sec:CaptionInfoEx sec:type=\"srt\">" "http://%s:%d/Captions/%s.srt" "</sec:CaptionInfoEx>", lan_addr[passed_args->iface].str, runtime_vars.port, detailID); - } } + free(alt_title); break; } } diff --git a/upnpsoap.h b/upnpsoap.h index 4e027d0..484f512 100644 --- a/upnpsoap.h +++ b/upnpsoap.h @@ -33,9 +33,6 @@ #define PV_NAMESPACE \ " xmlns:pv=\"http://www.pv.com/pvns/\"" -#define FLAG_FREE_OBJECT_ID 0x40000000 -#define FLAG_ROOT_CONTAINER 0x80000000 - struct Response { struct string_s *str;