Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
HTSP: It seems that XBMC PVR does not like big tag identifiers, renumber
  • Loading branch information
perexg committed Aug 21, 2014
1 parent 3c088cb commit 40cabce
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/channels.h
Expand Up @@ -95,6 +95,8 @@ typedef struct channel_tag {

struct dvr_autorec_entry_list ct_autorecs;

int ct_htsp_id;

} channel_tag_t;

/**
Expand Down
28 changes: 24 additions & 4 deletions src/htsp_server.c
Expand Up @@ -453,6 +453,26 @@ if (!htsp_user_access_channel(htsp, ch))\
* File helpers
* *************************************************************************/

static uint32_t
htsp_channel_tag_get_identifier(channel_tag_t *ct)
{
static int prev = 0;
if (ct->ct_htsp_id == 0)
ct->ct_htsp_id = ++prev;
return ct->ct_htsp_id;
}

static channel_tag_t *
htsp_channel_tag_find_by_identifier(uint32_t id)
{
channel_tag_t *ct;

TAILQ_FOREACH(ct, &channel_tags, ct_link)
if (id == ct->ct_htsp_id)
return ct;
return NULL;
}

/**
*
*/
Expand Down Expand Up @@ -575,7 +595,7 @@ htsp_build_channel(channel_t *ch, const char *method, htsp_connection_t *htsp)
LIST_FOREACH(ctm, &ch->ch_ctms, ctm_channel_link) {
ct = ctm->ctm_tag;
if(ct->ct_enabled && !ct->ct_internal)
htsmsg_add_u32(tags, NULL, idnode_get_short_uuid(&ct->ct_id));
htsmsg_add_u32(tags, NULL, htsp_channel_tag_get_identifier(ct));
}

LIST_FOREACH(csm, &ch->ch_services, csm_chn_link) {
Expand Down Expand Up @@ -607,7 +627,7 @@ htsp_build_tag(channel_tag_t *ct, const char *method, int include_channels)
htsmsg_t *out = htsmsg_create_map();
htsmsg_t *members = include_channels ? htsmsg_create_list() : NULL;

htsmsg_add_u32(out, "tagId", idnode_get_short_uuid(&ct->ct_id));
htsmsg_add_u32(out, "tagId", htsp_channel_tag_get_identifier(ct));

htsmsg_add_str(out, "tagName", ct->ct_name);
htsmsg_add_str(out, "tagIcon", ct->ct_icon);
Expand Down Expand Up @@ -1071,7 +1091,7 @@ htsp_method_epgQuery(htsp_connection_t *htsp, htsmsg_t *in)
if (!(ch = channel_find_by_id(u32)))
return htsp_error("Channel does not exist");
if(!(htsmsg_get_u32(in, "tagId", &u32)))
if (!(ct = channel_tag_find_by_identifier(u32)))
if (!(ct = htsp_channel_tag_find_by_identifier(u32)))
return htsp_error("Channel tag does not exist");
if (!htsmsg_get_u32(in, "contentType", &u32)) {
if(htsp->htsp_version < 6) u32 <<= 4;
Expand Down Expand Up @@ -2461,7 +2481,7 @@ void
htsp_tag_delete(channel_tag_t *ct)
{
htsmsg_t *m = htsmsg_create_map();
htsmsg_add_u32(m, "tagId", idnode_get_short_uuid(&ct->ct_id));
htsmsg_add_u32(m, "tagId", htsp_channel_tag_get_identifier(ct));
htsmsg_add_str(m, "method", "tagDelete");
htsp_async_send(m, HTSP_ASYNC_ON);
}
Expand Down

1 comment on commit 40cabce

@rafdalb
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know if it is the problem but I was able to connect to tvh via xbmc plugin up to build 1236. After that I get a Error in xbmc log ".ERROR: AddOnLog: Tvheadend HTSP Client: GetChannels - tag points to unknown channel 1533223669"

Please sign in to comment.