Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
channel: fix channel_find_by_number for maj.min support, fixes #2321
  • Loading branch information
perexg committed Sep 20, 2014
1 parent 710119a commit 1b6c227
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
16 changes: 14 additions & 2 deletions src/channels.c
Expand Up @@ -402,11 +402,23 @@ channel_find_by_id ( uint32_t i )
}

channel_t *
channel_find_by_number ( int no )
channel_find_by_number ( const char *no )
{
channel_t *ch;
uint32_t maj, min = 0;
uint64_t cno;
char *s;

if (no == NULL)
return NULL;
if ((s = strchr(no, '.')) != NULL) {
*s = '\0';
min = atoi(s + 1);
}
maj = atoi(no);
cno = (uint64_t)maj * CHANNEL_SPLIT + (uint64_t)min;
CHANNEL_FOREACH(ch)
if(channel_get_number(ch) == no)
if(channel_get_number(ch) == cno)
break;
return ch;
}
Expand Down
2 changes: 1 addition & 1 deletion src/channels.h
Expand Up @@ -149,7 +149,7 @@ channel_t *channel_find_by_name(const char *name);

channel_t *channel_find_by_id(uint32_t id);

channel_t *channel_find_by_number(int no);
channel_t *channel_find_by_number(const char *no);

#define channel_find channel_find_by_uuid

Expand Down
4 changes: 2 additions & 2 deletions src/webui/webui.c
Expand Up @@ -722,7 +722,7 @@ page_http_playlist(http_connection_t *hc, const char *remain, void *opaque)
if(nc == 2 && !strcmp(components[0], "channelid"))
ch = channel_find_by_id(atoi(components[1]));
else if(nc == 2 && !strcmp(components[0], "channelnumber"))
ch = channel_find_by_number(atoi(components[1]));
ch = channel_find_by_number(components[1]);
else if(nc == 2 && !strcmp(components[0], "channelname"))
ch = channel_find_by_name(components[1]);
else if(nc == 2 && !strcmp(components[0], "channel"))
Expand Down Expand Up @@ -1004,7 +1004,7 @@ http_stream(http_connection_t *hc, const char *remain, void *opaque)
if(!strcmp(components[0], "channelid")) {
ch = channel_find_by_id(atoi(components[1]));
} else if(!strcmp(components[0], "channelnumber")) {
ch = channel_find_by_number(atoi(components[1]));
ch = channel_find_by_number(components[1]);
} else if(!strcmp(components[0], "channelname")) {
ch = channel_find_by_name(components[1]);
} else if(!strcmp(components[0], "channel")) {
Expand Down

0 comments on commit 1b6c227

Please sign in to comment.