};
+static struct strtab cdlongname[] = {
+ { "None", COMMERCIAL_DETECT_NONE },
+ { "Swedish TV4 Teletext", COMMERCIAL_DETECT_TTP192 },
+};
+
/**
* Display all channels within the group
*/
th_channel_t *ch;
th_transport_t *t;
const char *s;
+ int i;
if(remain == NULL || (ch = channel_by_tag(atoi(remain))) == NULL)
return HTTP_STATUS_BAD_REQUEST;
"<div class=\"infoprefixwidewidefat\">"
"Commercial detection:</div>"
"<div>"
- "<select id=\"cdetect_%d\" class=\"textinput\">",
+ "<select class=\"textinput\" "
+ "onChange=\"new Ajax.Request('/ajax/chsetcomdetect/%d', "
+ "{parameters: {how: this.value}});\">",
ch->ch_tag);
- tcp_qprintf(tq, "<option>None</option>");
- tcp_qprintf(tq, "<option>TV4 Teletext, p192</option>");
+
+ for(i = 0; i < sizeof(cdlongname) / sizeof(cdlongname[0]); i++) {
+ tcp_qprintf(tq, "<option %svalue=%d>%s</option>",
+ cdlongname[i].val == ch->ch_commercial_detection ?
+ "selected " : "",
+ cdlongname[i].val, cdlongname[i].str);
+ }
tcp_qprintf(tq, "</select></div>");
tcp_qprintf(tq, "</div>");
return 0;
}
+/**
+ * Change commercial detection type for channel(s)
+ */
+static int
+ajax_chsetcomdetect(http_connection_t *hc, http_reply_t *hr,
+ const char *remain, void *opaque)
+{
+ th_channel_t *ch;
+ const char *s;
+
+ if(remain == NULL || (ch = channel_by_tag(atoi(remain))) == NULL)
+ return HTTP_STATUS_BAD_REQUEST;
+
+ if((s = http_arg_get(&hc->hc_req_args, "how")) == NULL)
+ return HTTP_STATUS_BAD_REQUEST;
+
+ ch->ch_commercial_detection = atoi(s);
+
+ channel_settings_write(ch);
+ http_output(hc, hr, "text/javascript; charset=UTF-8", NULL, 0);
+ return 0;
+}
+
/**
*
http_path_add("/ajax/chgroup_editor", NULL, ajax_chgroup_editor);
http_path_add("/ajax/cheditor", NULL, ajax_cheditor);
http_path_add("/ajax/chop/changegroup", NULL, ajax_changegroup);
+ http_path_add("/ajax/chsetcomdetect", NULL, ajax_chsetcomdetect);
}
#include "channels.h"
#include "transports.h"
-static void channel_settings_write(th_channel_t *ch);
-
struct th_channel_list channels;
int nchannels;
channel_settings_write(ch);
}
-/**
- *
- */
-void
-channel_set_teletext_rundown(th_channel_t *ch, int v)
-{
- ch->ch_teletext_rundown = v;
- channel_settings_write(ch);
-}
/**
*
free(t);
}
+
+static struct strtab commercial_detect_tab[] = {
+ { "none", COMMERCIAL_DETECT_NONE },
+ { "ttp192", COMMERCIAL_DETECT_TTP192 },
+};
+
+
/**
*
*/
char buf[PATH_MAX];
DIR *dir;
struct dirent *d;
- const char *name, *grp;
+ const char *name, *grp, *x;
th_channel_t *ch;
th_channel_group_t *tcg;
+ int v;
TAILQ_INIT(&all_channel_groups);
TAILQ_INIT(&cl);
if(name != NULL && grp != NULL) {
tcg = channel_group_find(grp, 1);
ch = channel_find(name, 1, tcg);
-
- ch->ch_teletext_rundown =
- atoi(config_get_str_sub(&cl, "teletext-rundown", "0"));
+
+ x = config_get_str_sub(&cl, "commercial-detect", NULL);
+ if(x != NULL) {
+ v = str2val(x, commercial_detect_tab);
+ if(v > 1)
+ ch->ch_commercial_detection = v;
+ }
}
-
config_free0(&cl);
}
/**
* Write out a config file for a channel
*/
-static void
+void
channel_settings_write(th_channel_t *ch)
{
FILE *fp;
fprintf(fp, "name = %s\n", ch->ch_name);
fprintf(fp, "channel-group = %s\n", ch->ch_group->tcg_name);
- if(ch->ch_teletext_rundown)
- fprintf(fp, "teletext-rundown = %d\n", ch->ch_teletext_rundown);
+
+ fprintf(fp, "commercial-detect = %s\n",
+ val2str(ch->ch_commercial_detection, commercial_detect_tab) ?: "?");
fclose(fp);
}
void channel_group_settings_write(void);
+void channel_settings_write(th_channel_t *ch);
+
#endif /* CHANNELS_H */
}
if(update_tt_clock(t, (char *)buf + 34)) {
- if(ch->ch_teletext_rundown != 0) {
- ttp = tt_get_page(ttd, ch->ch_teletext_rundown);
+ if(ch->ch_commercial_detection == COMMERCIAL_DETECT_TTP192) {
+ ttp = tt_get_page(ttd, 192);
teletext_rundown(t, ch, ttp);
}
}
break;
}
- if(ttp->ttp_page == ch->ch_teletext_rundown)
+ if(ttp->ttp_page == 192 &&
+ ch->ch_commercial_detection == COMMERCIAL_DETECT_TTP192)
teletext_rundown(t, ch, ttp);
}
}
int ch_tag;
- int ch_teletext_rundown;
+ enum {
+ COMMERCIAL_DETECT_NONE,
+ COMMERCIAL_DETECT_TTP192,
+ } ch_commercial_detection;
struct event_queue ch_epg_events;
struct event *ch_epg_cur_event;