Project

General

Profile

Feature #4461 » 0007-hdhomerun-Add-device.xml-API.patch

Em Smith, 2020-06-12 01:18

View differences:

src/webui/webui.c
1746 1746

  
1747 1747

  
1748 1748

  
1749
/**
1750
 * Needed for some clients.  This contains much the same as discover,
1751
 * but in xml format.
1752
 */
1753
static int
1754
hdhomerun_server_device_xml(http_connection_t *hc, const char *remain, void *opaque)
1755
{
1756
  const char *server_name = config.server_name ?: "TVHeadend";
1757
  const char *hdhr_user = config.hdhomerun_server_username ?: "";
1758
  access_t *perm = access_get_by_username(hdhr_user);
1759
  char http_ip[128];
1760
  htsbuf_queue_t *hq;
1761
  const uint32_t deviceid = tvh_crc32((const uint8_t*)server_name, strlen(server_name), 0);
1762

  
1763
  if (access_verify2(perm, ACCESS_STREAMING)) {
1764
    access_destroy(perm);
1765
    return http_noaccess_code(hc);
1766
  }
1767
  hq = &hc->hc_reply;
1768

  
1769
  tcp_get_str_from_ip(hc->hc_self, http_ip, sizeof(http_ip));
1770
  htsbuf_qprintf(hq, "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">"
1771
                 "<specVersion>"
1772
                 "<major>1</major>"
1773
                 "<minor>0</minor>"
1774
                 "</specVersion>"
1775
                 "<URLBase>http://%s:%u</URLBase>"
1776
                 "<device>"
1777
                 "<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>"
1778
                 "<friendlyName>%s</friendlyName>"
1779
                 "<manufacturer>Silicondust</manufacturer>"
1780
                 "<modelName>HDTC-2US</modelName>"
1781
                 "<modelNumber>HDTC-2US</modelNumber>"
1782
                 "<serialNumber></serialNumber>"
1783
                 /* Version 5 UUID (random) with top part as server id*/
1784
                 "<UDN>%8.8x-745e-5d9a-8903-4a02327a7e09</UDN>"
1785
                 "</device>"
1786
                 "</root>",
1787
                 http_ip, tvheadend_webui_port,
1788
                 server_name,
1789
                 deviceid);
1790

  
1791
  http_output_content(hc, "application/xml");
1792
  access_destroy(perm);
1793
  return 0;
1794
}
1795

  
1749 1796
/**
1750 1797
 *
1751 1798
 */
......
2286 2333
  http_path_add("/discover.json", NULL, hdhomerun_server_discover, ACCESS_ANONYMOUS);
2287 2334
  http_path_add("/lineup.json", NULL, hdhomerun_server_lineup, ACCESS_ANONYMOUS);
2288 2335
  http_path_add("/lineup_status.json", NULL, hdhomerun_server_lineup_status, ACCESS_ANONYMOUS);
2336
  http_path_add("/device.xml", NULL, hdhomerun_server_device_xml, ACCESS_ANONYMOUS);
2289 2337

  
2290 2338
  http_path_add_modify("/play", NULL, page_play, ACCESS_ANONYMOUS, page_play_path_modify5);
2291 2339
  http_path_add_modify("/play/ticket", NULL, page_play_ticket, ACCESS_ANONYMOUS, page_play_path_modify12);
2292
- 
(11-11/19)