From 0f86ee679cae9611ebb146de2711f1a19268e9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Thu, 17 Apr 2008 20:46:38 +0000 Subject: [PATCH] Add support for disabling a certain transport/service directly in the channel editor --- ajaxui/ajaxui_config_channels.c | 7 +++++-- ajaxui/ajaxui_config_transport.c | 27 +++++++++++++++++++++++++++ psi.c | 5 +++++ transports.c | 6 ++++-- tvhead.h | 2 ++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/ajaxui/ajaxui_config_channels.c b/ajaxui/ajaxui_config_channels.c index 5052c932..a99c3e24 100644 --- a/ajaxui/ajaxui_config_channels.c +++ b/ajaxui/ajaxui_config_channels.c @@ -423,8 +423,11 @@ ajax_cheditor(http_connection_t *hc, http_reply_t *hr, tcp_qprintf(tq, "
" - "" - "
"); + "" + "", t->tht_disabled ? "" : "checked ", + t->tht_identifier); if(s != NULL) tcp_qprintf(tq, "
%s
", diff --git a/ajaxui/ajaxui_config_transport.c b/ajaxui/ajaxui_config_transport.c index e92c2d40..b8801c30 100644 --- a/ajaxui/ajaxui_config_transport.c +++ b/ajaxui/ajaxui_config_transport.c @@ -389,6 +389,29 @@ ajax_transport_op(http_connection_t *hc, http_reply_t *hr, } +/** + * + */ +int +ajax_transport_chdisable(http_connection_t *hc, http_reply_t *hr, + const char *remain, void *opaque) +{ + th_transport_t *t; + const char *s; + + if(remain == NULL || (t = transport_find_by_identifier(remain)) == NULL) + return HTTP_STATUS_NOT_FOUND; + + if((s = http_arg_get(&hc->hc_req_args, "enabled")) == NULL) + return HTTP_STATUS_BAD_REQUEST; + + t->tht_disabled = !strcasecmp(s, "false"); + http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0); + t->tht_config_change(t); + return 0; +} + + /** * */ @@ -400,4 +423,8 @@ ajax_config_transport_init(void) http_path_add("/ajax/transport_op", NULL, ajax_transport_op); + + http_path_add("/ajax/transport_chdisable", NULL, + ajax_transport_chdisable); + } diff --git a/psi.c b/psi.c index ce486444..d6ffeee5 100644 --- a/psi.c +++ b/psi.c @@ -552,6 +552,9 @@ psi_save_transport(FILE *fp, th_transport_t *t) fprintf(fp, "\tpcr = %d\n", t->tht_pcr_pid); + if(t->tht_disabled) + fprintf(fp, "\tdisabled = 1\n"); + LIST_FOREACH(st, &t->tht_streams, st_link) { fprintf(fp, "\tstream {\n"); fprintf(fp, "\t\tpid = %d\n", st->st_pid); @@ -586,6 +589,8 @@ psi_load_transport(struct config_head *cl, th_transport_t *t) t->tht_pcr_pid = atoi(config_get_str_sub(cl, "pcr", "0")); + t->tht_disabled = atoi(config_get_str_sub(cl, "disabled", "0")); + TAILQ_FOREACH(ce, cl, ce_link) { if(ce->ce_type != CFG_SUB || strcasecmp("stream", ce->ce_key)) continue; diff --git a/transports.c b/transports.c index 4836bbcf..e24ab09e 100644 --- a/transports.c +++ b/transports.c @@ -261,12 +261,14 @@ transport_find(th_channel_t *ch, unsigned int weight) /* First, sort all transports in order */ LIST_FOREACH(t, &ch->ch_transports, tht_channel_link) - cnt++; + if(!t->tht_disabled) + cnt++; vec = alloca(cnt * sizeof(th_transport_t *)); i = 0; LIST_FOREACH(t, &ch->ch_transports, tht_channel_link) - vec[i++] = t; + if(!t->tht_disabled) + vec[i++] = t; /* Sort transports, lower priority should come come earlier in the vector (i.e. it will be more favoured when selecting a transport */ diff --git a/tvhead.h b/tvhead.h index b948b94a..fdd2af91 100644 --- a/tvhead.h +++ b/tvhead.h @@ -402,6 +402,8 @@ typedef struct th_transport { avgstat_t tht_rate; int tht_monitor_suspend; + int tht_disabled; + int tht_cc_error_log_limiter; int tht_rate_error_log_limiter;