upnpsoap: make subtitle support more generic

It sounds like more clients may support subtitles using a res element,
so we should make our support more generic.
This commit is contained in:
Justin Maggard 2014-03-12 11:59:10 -07:00
parent cce9a012b3
commit 365d5c3412
4 changed files with 30 additions and 29 deletions

View File

@ -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 */ /* 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, { ELGDevice,
FLAG_DLNA, FLAG_DLNA | FLAG_CAPTION_RES,
"LG", "LG",
"LGE_DLNA_SDK", "LGE_DLNA_SDK",
EUserAgent EUserAgent

View File

@ -23,6 +23,7 @@
#define CLIENT_CACHE_SLOTS 25 #define CLIENT_CACHE_SLOTS 25
/* Client capability/quirk flags */
#define FLAG_DLNA 0x00000001 #define FLAG_DLNA 0x00000001
#define FLAG_MIME_AVI_DIVX 0x00000002 #define FLAG_MIME_AVI_DIVX 0x00000002
#define FLAG_MIME_AVI_AVI 0x00000004 #define FLAG_MIME_AVI_AVI 0x00000004
@ -30,11 +31,16 @@
#define FLAG_MIME_WAV_WAV 0x00000010 #define FLAG_MIME_WAV_WAV 0x00000010
#define FLAG_RESIZE_THUMBS 0x00000020 #define FLAG_RESIZE_THUMBS 0x00000020
#define FLAG_NO_RESIZE 0x00000040 #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 0x00000100
#define FLAG_SAMSUNG_DCM10 0x00000200 #define FLAG_SAMSUNG_DCM10 0x00000200
#define FLAG_AUDIO_ONLY 0x00000400 #define FLAG_AUDIO_ONLY 0x00000400
#define FLAG_FORCE_SORT 0x00000800 #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 { enum match_types {
EMatchNone, EMatchNone,

View File

@ -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( 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 ) if( args->filter & FILTER_PV_SUBTITLE_FILE_TYPE )
strcatf(args->str, "pv:subtitleFileType=\"SRT\" "); strcatf(args->str, "pv:subtitleFileType=\"SRT\" ");
@ -772,6 +772,12 @@ callback(void *args, int argc, char **argv, char **azColName)
strcpy(mime+6, "mpeg"); 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. */ /* From what I read, Samsung TV's expect a [wrong] MIME type of x-mkv. */
if( passed_args->flags & FLAG_SAMSUNG ) 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. */ /* 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 )
ret = asprintf(&alt_title, "%s.", title); title = alt_title;
if( ret > 0 ) else
title = alt_title; alt_title = NULL;
else
alt_title = NULL;
}
} }
} }
else if( *mime == 'a' ) 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); resolution, dlna_buf, mime, detailID, ext, passed_args);
} }
break; 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 ESamsungSeriesCDE:
case ELGDevice:
default: 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\">" ret = strcatf(str, "<sec:CaptionInfoEx sec:type=\"srt\">"
"http://%s:%d/Captions/%s.srt" "http://%s:%d/Captions/%s.srt"
"</sec:CaptionInfoEx>", "</sec:CaptionInfoEx>",
lan_addr[passed_args->iface].str, runtime_vars.port, detailID); lan_addr[passed_args->iface].str, runtime_vars.port, detailID);
}
} }
free(alt_title);
break; break;
} }
} }

View File

@ -33,9 +33,6 @@
#define PV_NAMESPACE \ #define PV_NAMESPACE \
" xmlns:pv=\"http://www.pv.com/pvns/\"" " xmlns:pv=\"http://www.pv.com/pvns/\""
#define FLAG_FREE_OBJECT_ID 0x40000000
#define FLAG_ROOT_CONTAINER 0x80000000
struct Response struct Response
{ {
struct string_s *str; struct string_s *str;