From 2309cbf22fddb7ec109a4afe3ad634ce833dac9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20T=C3=B6rnblom?= Date: Fri, 2 Mar 2012 22:11:19 +0100 Subject: [PATCH] added a new htsp method, 'getTicket' that will generate a http access ticket for a channel or recording --- src/htsp.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/htsp.c b/src/htsp.c index 8bb803b1..15dd05f4 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}, };