SAT>IP: use HTTP headers instead UPC XML text to pass RTSP port and Sources

This commit is contained in:
Jaroslav Kysela 2015-03-03 16:49:34 +01:00
parent fd505efe5a
commit afede2267f
2 changed files with 32 additions and 20 deletions

View file

@ -633,12 +633,12 @@ static void
satip_discovery_http_closed(http_client_t *hc, int errn)
{
satip_discovery_t *d = hc->hc_aux;
char *s, *p;
char *s;
htsmsg_t *xml = NULL, *tags, *root, *device;
const char *friendlyname, *manufacturer, *manufacturerURL, *modeldesc;
const char *modelname, *modelnum, *serialnum;
const char *presentation, *tunercfg, *udn, *uuid;
const char *cs, *upc;
const char *cs, *arg;
satip_device_info_t info;
char errbuf[100];
char *argv[10];
@ -735,18 +735,17 @@ satip_discovery_http_closed(http_client_t *hc, int errn)
info.rtsp_port = 554;
info.srcs = 4;
upc = htsmsg_xml_get_cdata_str(device, "UPC");
if (upc && (s = strstr(upc, "{{{")) != NULL &&
strcmp(s + strlen(s) - 3, "}}}") == 0) {
if ((p = strstr(s, "RTSP:")) != NULL) {
if ((i = atoi(p + 5)) > 0 && i < 65535)
info.rtsp_port = i;
}
if ((p = strstr(s, "SRCS:")) != NULL) {
i = atoi(p + 5);
if ((i = atoi(p + 5)) > 0 && i < 128)
info.srcs = i;
}
arg = http_arg_get(&hc->hc_args, "X-SATIP-RTSP-Port");
if (arg) {
i = atoi(arg);
if (i > 0 && i < 65535)
info.rtsp_port = i;
}
arg = http_arg_get(&hc->hc_args, "X-SATIP-Sources");
if (arg) {
i = atoi(arg);
if (i > 0 && i < 128)
info.srcs = i;
}
info.myaddr = strdup(d->myaddr);

View file

@ -55,7 +55,7 @@ satip_server_http_xml(http_connection_t *hc)
<specVersion><major>1</major><minor>1</minor></specVersion>\n\
<device>\n\
<deviceType>urn:ses-com:device:SatIPServer:1</deviceType>\n\
<friendlyName>TVHeadend</friendlyName>\n\
<friendlyName>TVHeadend%s</friendlyName>\n\
<manufacturer>TVHeadend Team</manufacturer>\n\
<manufacturerURL>http://tvheadend.org</manufacturerURL>\n\
<modelDescription>TVHeadend %s</modelDescription>\n\
@ -64,7 +64,7 @@ satip_server_http_xml(http_connection_t *hc)
<modelURL>http://tvheadend.org</modelURL>\n\
<serialNumber>123456</serialNumber>\n\
<UDN>uuid:%s</UDN>\n\
<UPC>TVHeadend %s {{{RTSP:%d;SRCS:%d}}}</UPC>\n\
<UPC>TVHeadend %s</UPC>\n\
<iconList>\n\
<icon>\n\
<mimetype>image/png</mimetype>\n\
@ -100,11 +100,12 @@ satip_server_http_xml(http_connection_t *hc)
</device>\n\
</root>\n"
char buf[sizeof(MSG) + 1024];
char buf[sizeof(MSG) + 1024], buf2[16];
char *devicelist = NULL;
htsbuf_queue_t q;
mpegts_network_t *mn;
int dvbt = 0, dvbs = 0, dvbc = 0, srcs = 0, delim = 0, i;
http_arg_list_t args;
htsbuf_queue_init(&q, 0);
@ -152,10 +153,13 @@ satip_server_http_xml(http_connection_t *hc)
buf, dvbt + dvbs + dvbc ? "tuner settings - global config" : "network assignment");
}
buf2[0] = '\0';
if (satip_server_rtsp_port != 554)
snprintf(buf2, sizeof(buf2), ":%d", satip_server_rtsp_port);
snprintf(buf, sizeof(buf), MSG,
tvheadend_version,
buf2, tvheadend_version,
satip_server_uuid, tvheadend_version,
satip_server_rtsp_port, srcs,
http_server_ip, http_server_port,
http_server_ip, http_server_port,
http_server_ip, http_server_port,
@ -165,7 +169,16 @@ satip_server_http_xml(http_connection_t *hc)
free(devicelist);
http_send_header(hc, 200, "text/xml", strlen(buf), 0, NULL, 10, 0, NULL, NULL);
http_arg_init(&args);
snprintf(buf2, sizeof(buf2), "%d", satip_server_rtsp_port);
http_arg_set(&args, "X-SATIP-RTSP-Port", buf2);
if (srcs) {
snprintf(buf2, sizeof(buf2), "%d", srcs);
http_arg_set(&args, "X-SATIP-Sources", buf2);
}
http_send_header(hc, 200, "text/xml", strlen(buf), 0, NULL, 10, 0, NULL, &args);
http_arg_flush(&args);
tvh_write(hc->hc_fd, buf, strlen(buf));
return 0;