From 2036062aa452036d42ee9a0a91492b0bb265e10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Fri, 7 Dec 2007 08:24:13 +0000 Subject: [PATCH] move transport_set_channel() to transport.c and add transport_set_prio() --- channels.c | 60 ------------------------------------------- transports.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ transports.h | 2 ++ 3 files changed, 74 insertions(+), 60 deletions(-) diff --git a/channels.c b/channels.c index a7935a39..2d4979a9 100644 --- a/channels.c +++ b/channels.c @@ -239,66 +239,6 @@ channel_find(const char *name, int create, th_channel_group_t *tcg) } -/** - * - */ -static int -transportcmp(th_transport_t *a, th_transport_t *b) -{ - return a->tht_prio - b->tht_prio; -} - - -/** - * - */ -int -transport_set_channel(th_transport_t *t, th_channel_t *ch) -{ - th_stream_t *st; - char *chname; - const char *n; - - char pid[30]; - char lang[30]; - - assert(t->tht_uniquename != NULL); - t->tht_channel = ch; - LIST_INSERT_SORTED(&ch->ch_transports, t, tht_channel_link, transportcmp); - - chname = utf8toprintable(ch->ch_name); - - syslog(LOG_DEBUG, "Added service \"%s\" for channel \"%s\"", - t->tht_name, chname); - free(chname); - - LIST_FOREACH(st, &t->tht_streams, st_link) { - if(st->st_caid != 0) { - n = psi_caid2name(st->st_caid); - } else { - n = htstvstreamtype2txt(st->st_type); - } - if(st->st_pid < 8192) { - snprintf(pid, sizeof(pid), " on pid [%d]", st->st_pid); - } else { - pid[0] = 0; - } - - if(st->st_lang[0]) { - snprintf(lang, sizeof(lang), ", language \"%s\"", st->st_lang); - } else { - lang[0] = 0; - } - - syslog(LOG_DEBUG, " Stream \"%s\"%s%s", n, lang, pid); - } - - return 0; -} - - - - /** * */ diff --git a/transports.c b/transports.c index 24d8c14d..9079627d 100644 --- a/transports.c +++ b/transports.c @@ -366,3 +366,75 @@ transport_add_stream(th_transport_t *t, int pid, tv_streamtype_t type) avgstat_init(&st->st_cc_errors, 10); return st; } + + +/** + * + */ +static int +transportcmp(th_transport_t *a, th_transport_t *b) +{ + return a->tht_prio - b->tht_prio; +} + + +/** + * + */ +int +transport_set_channel(th_transport_t *t, th_channel_t *ch) +{ + th_stream_t *st; + char *chname; + const char *n; + + char pid[30]; + char lang[30]; + + assert(t->tht_uniquename != NULL); + t->tht_channel = ch; + LIST_INSERT_SORTED(&ch->ch_transports, t, tht_channel_link, transportcmp); + + chname = utf8toprintable(ch->ch_name); + + syslog(LOG_DEBUG, "Added service \"%s\" for channel \"%s\"", + t->tht_name, chname); + free(chname); + + LIST_FOREACH(st, &t->tht_streams, st_link) { + if(st->st_caid != 0) { + n = psi_caid2name(st->st_caid); + } else { + n = htstvstreamtype2txt(st->st_type); + } + if(st->st_pid < 8192) { + snprintf(pid, sizeof(pid), " on pid [%d]", st->st_pid); + } else { + pid[0] = 0; + } + + if(st->st_lang[0]) { + snprintf(lang, sizeof(lang), ", language \"%s\"", st->st_lang); + } else { + lang[0] = 0; + } + + syslog(LOG_DEBUG, " Stream \"%s\"%s%s", n, lang, pid); + } + + return 0; +} + + +/** + * + */ +void +transport_set_priority(th_transport_t *t, int prio) +{ + th_channel_t *ch = t->tht_channel; + + LIST_REMOVE(t, tht_channel_link); + t->tht_prio = prio; + LIST_INSERT_SORTED(&ch->ch_transports, t, tht_channel_link, transportcmp); +} diff --git a/transports.h b/transports.h index f4f29e0c..b32ce758 100644 --- a/transports.h +++ b/transports.h @@ -36,4 +36,6 @@ th_transport_t *transport_find(th_channel_t *ch, unsigned int weight); th_stream_t *transport_add_stream(th_transport_t *t, int pid, tv_streamtype_t type); +void transport_set_priority(th_transport_t *t, int prio); + #endif /* TRANSPORTS_H */