From: John Törnblom Date: Fri, 2 Mar 2012 21:11:19 +0000 (+0100) Subject: added a new htsp method, 'getTicket' that will generate a http access ticket for... X-Git-Tag: 2.99~16^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2309cbf22fddb7ec109a4afe3ad634ce833dac9b;p=thirdparty%2Ftvheadend.git added a new htsp method, 'getTicket' that will generate a http access ticket for a channel or recording --- diff --git a/src/htsp.c b/src/htsp.c index 8bb803b17..15dd05f40 100644 --- a/src/htsp.c +++ b/src/htsp.c @@ -487,6 +487,36 @@ htsp_method_async(htsp_connection_t *htsp, htsmsg_t *in) return NULL; } +/** + * Request a ticket for a http url pointing to a channel or dvr + */ +static htsmsg_t * +htsp_method_getTicket(htsp_connection_t *htsp, htsmsg_t *in) +{ + htsmsg_t *out; + uint32_t id; + char path[255]; + const char *ticket = NULL; + + if(!htsmsg_get_u32(in, "channelId", &id)) { + snprintf(path, sizeof(path), "/stream/channelid/%d", id); + ticket = access_ticket_create(path); + } else if(!htsmsg_get_u32(in, "dvrId", &id)) { + snprintf(path, sizeof(path), "/dvrfile/%d", id); + ticket = access_ticket_create(path); + } else { + return htsp_error("Missing argument 'channelId' or 'dvrId'"); + } + + out = htsmsg_create_map(); + + htsmsg_add_str(out, "path", path); + htsmsg_add_str(out, "ticket", ticket); + + return out; +} + + /** * add a Dvrentry */ @@ -1034,6 +1064,7 @@ struct { { "cancelDvrEntry", htsp_method_cancelDvrEntry, ACCESS_RECORDER}, { "deleteDvrEntry", htsp_method_deleteDvrEntry, ACCESS_RECORDER}, { "epgQuery", htsp_method_epgQuery, ACCESS_STREAMING}, + { "getTicket", htsp_method_getTicket, ACCESS_STREAMING}, };