Add support for disabling a certain transport/service directly in the channel editor

This commit is contained in:
Andreas Öman 2008-04-17 20:46:38 +00:00
parent 768eb564c1
commit 0f86ee679c
5 changed files with 43 additions and 4 deletions

View file

@ -423,8 +423,11 @@ ajax_cheditor(http_connection_t *hc, http_reply_t *hr,
tcp_qprintf(tq,
"<div style=\"float: left; width: 13%%\">"
"<input type=\"checkbox\" class=\"nicebox\">"
"</div>");
"<input %stype=\"checkbox\" class=\"nicebox\" "
"onClick=\"new Ajax.Request('/ajax/transport_chdisable/%s', "
"{parameters: {enabled: this.checked}});\">"
"</div>", t->tht_disabled ? "" : "checked ",
t->tht_identifier);
if(s != NULL)
tcp_qprintf(tq, "<div style=\"float: left; width: 87%%\">%s</div>",

View file

@ -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);
}

5
psi.c
View file

@ -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;

View file

@ -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 */

View file

@ -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;