",
dvb_adaptertype_to_str(tda->tda_type));
if(tda->tda_fe_info != NULL) {
s = tda->tda_type == FE_QPSK ? "kHz" : "Hz";
tcp_qprintf(tq, "Freq. Range:
"
"%s - %s %s, in steps of %s %s
",
nicenum(tda->tda_fe_info->frequency_min),
nicenum(tda->tda_fe_info->frequency_max),
s,
nicenum(tda->tda_fe_info->frequency_stepsize),
s);
if(tda->tda_fe_info->symbol_rate_min) {
tcp_qprintf(tq, "Symbolrate:
"
"%s - %s Baud
",
nicenum(tda->tda_fe_info->symbol_rate_min),
nicenum(tda->tda_fe_info->symbol_rate_max));
}
/* Capabilities */
// tcp_qprintf(tq, "Capabilities:
");
}
tcp_qprintf(tq, "");
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Multiplexes");
tcp_qprintf(tq, "
",
tda->tda_identifier);
ajax_js(tq,
"new Ajax.Updater('dvbmuxlist_%s', "
"'/ajax/dvbadaptermuxlist/%s', {method: 'get', evalScripts: true})",
tda->tda_identifier, tda->tda_identifier);
tcp_qprintf(tq, "
");
dvb_make_add_link(tq, tda, NULL);
tcp_qprintf(tq, "
");
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
tcp_qprintf(tq, "
");
/* Div for displaying services */
tcp_qprintf(tq, "");
tcp_qprintf(tq, "
");
http_output_html(hc, hr);
return 0;
}
/**
* DVB adapter add mux
*/
static int
ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
tcp_queue_t *tq = &hr->hr_tq;
th_dvb_adapter_t *tda;
int caps;
int fetype;
char params[400];
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
if(tda->tda_fe_info == NULL)
return HTTP_STATUS_BAD_REQUEST;
caps = tda->tda_fe_info->caps;
fetype = tda->tda_fe_info->type;
tcp_qprintf(tq, ""
"Add new %s mux
",
dvb_adaptertype_to_str(tda->tda_fe_info->type));
tcp_qprintf(tq,
"Frequency (%s):
"
""
" "
"
",
fetype == FE_QPSK ? "kHz" : "Hz");
snprintf(params, sizeof(params),
"freq: $F('freq')");
/* Symbolrate */
if(fetype == FE_QAM || fetype == FE_QPSK) {
tcp_qprintf(tq,
"Symbolrate:
"
""
" "
"
");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", symrate: $F('symrate')");
}
/* Bandwidth */
if(fetype == FE_OFDM) {
tcp_qprintf(tq,
"Bandwidth:
"
"");
add_option(tq, caps & FE_CAN_BANDWIDTH_AUTO, "AUTO");
add_option(tq, 1 , "8MHz");
add_option(tq, 1 , "7MHz");
add_option(tq, 1 , "6MHz");
tcp_qprintf(tq, "
");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", bw: $F('bw')");
}
/* Constellation */
if(fetype == FE_QAM || fetype == FE_OFDM) {
tcp_qprintf(tq,
"Constellation:
"
"");
add_option(tq, caps & FE_CAN_QAM_AUTO, "AUTO");
add_option(tq, caps & FE_CAN_QPSK, "QPSK");
add_option(tq, caps & FE_CAN_QAM_16, "QAM16");
add_option(tq, caps & FE_CAN_QAM_32, "QAM32");
add_option(tq, caps & FE_CAN_QAM_64, "QAM64");
add_option(tq, caps & FE_CAN_QAM_128, "QAM128");
add_option(tq, caps & FE_CAN_QAM_256, "QAM256");
tcp_qprintf(tq, "
");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", const: $F('const')");
}
/* FEC */
if(fetype == FE_QAM || fetype == FE_QPSK) {
tcp_qprintf(tq,
"FEC:
"
"");
add_option(tq, caps & FE_CAN_FEC_AUTO, "AUTO");
add_option(tq, caps & FE_CAN_FEC_1_2, "1/2");
add_option(tq, caps & FE_CAN_FEC_2_3, "2/3");
add_option(tq, caps & FE_CAN_FEC_3_4, "3/4");
add_option(tq, caps & FE_CAN_FEC_4_5, "4/5");
add_option(tq, caps & FE_CAN_FEC_5_6, "5/6");
add_option(tq, caps & FE_CAN_FEC_6_7, "6/7");
add_option(tq, caps & FE_CAN_FEC_7_8, "7/8");
add_option(tq, caps & FE_CAN_FEC_8_9, "8/9");
tcp_qprintf(tq, "
");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", fec: $F('fec')");
}
if(fetype == FE_QPSK) {
tcp_qprintf(tq,
"Polarisation:
"
"");
add_option(tq, 1, "Vertical");
add_option(tq, 1, "Horizontal");
tcp_qprintf(tq, "
");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", pol: $F('pol')");
}
if(fetype == FE_OFDM) {
tcp_qprintf(tq,
"Transmission mode:
"
"");
add_option(tq, caps & FE_CAN_TRANSMISSION_MODE_AUTO, "AUTO");
add_option(tq, 1 , "2k");
add_option(tq, 1 , "8k");
tcp_qprintf(tq, "
");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", tmode: $F('tmode')");
tcp_qprintf(tq,
"Guard interval:
"
"");
add_option(tq, caps & FE_CAN_GUARD_INTERVAL_AUTO, "AUTO");
add_option(tq, 1 , "1/32");
add_option(tq, 1 , "1/16");
add_option(tq, 1 , "1/8");
add_option(tq, 1 , "1/4");
tcp_qprintf(tq, "
");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", guard: $F('guard')");
tcp_qprintf(tq,
"Hierarchy:
"
"");
add_option(tq, caps & FE_CAN_HIERARCHY_AUTO, "AUTO");
add_option(tq, 1 , "1");
add_option(tq, 1 , "2");
add_option(tq, 1 , "4");
add_option(tq, 1 , "NONE");
tcp_qprintf(tq, "
");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", hier: $F('hier')");
tcp_qprintf(tq,
"FEC Hi:
"
"");
add_option(tq, caps & FE_CAN_FEC_AUTO, "AUTO");
add_option(tq, caps & FE_CAN_FEC_1_2, "1/2");
add_option(tq, caps & FE_CAN_FEC_2_3, "2/3");
add_option(tq, caps & FE_CAN_FEC_3_4, "3/4");
add_option(tq, caps & FE_CAN_FEC_4_5, "4/5");
add_option(tq, caps & FE_CAN_FEC_5_6, "5/6");
add_option(tq, caps & FE_CAN_FEC_6_7, "6/7");
add_option(tq, caps & FE_CAN_FEC_7_8, "7/8");
add_option(tq, caps & FE_CAN_FEC_8_9, "8/9");
tcp_qprintf(tq, "
");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", fechi: $F('fechi')");
tcp_qprintf(tq,
"FEC Low:
"
"");
add_option(tq, caps & FE_CAN_FEC_AUTO, "AUTO");
add_option(tq, caps & FE_CAN_FEC_1_2, "1/2");
add_option(tq, caps & FE_CAN_FEC_2_3, "2/3");
add_option(tq, caps & FE_CAN_FEC_3_4, "3/4");
add_option(tq, caps & FE_CAN_FEC_4_5, "4/5");
add_option(tq, caps & FE_CAN_FEC_5_6, "5/6");
add_option(tq, caps & FE_CAN_FEC_6_7, "6/7");
add_option(tq, caps & FE_CAN_FEC_7_8, "7/8");
add_option(tq, caps & FE_CAN_FEC_8_9, "8/9");
tcp_qprintf(tq, "
");
snprintf(params + strlen(params), sizeof(params) - strlen(params),
", feclo: $F('feclo')");
}
tcp_qprintf(tq,
""
" "
"
", tda->tda_identifier, params);
http_output_html(hc, hr);
return 0;
}
/**
*
*/
static int
ajax_adaptercreatemux_fail(http_connection_t *hc, http_reply_t *hr,
th_dvb_adapter_t *tda, const char *errmsg)
{
tcp_queue_t *tq = &hr->hr_tq;
dvb_make_add_link(tq, tda, errmsg);
http_output_html(hc, hr);
return 0;
}
/**
* DVB adapter create mux (come here on POST after addmux query)
*/
static int
ajax_adaptercreatemux(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
tcp_queue_t *tq;
th_dvb_adapter_t *tda;
const char *v;
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
v = dvb_mux_create_str(tda,
"65535",
NULL,
http_arg_get(&hc->hc_req_args, "freq"),
http_arg_get(&hc->hc_req_args, "symrate"),
http_arg_get(&hc->hc_req_args, "const"),
http_arg_get(&hc->hc_req_args, "fec"),
http_arg_get(&hc->hc_req_args, "fechi"),
http_arg_get(&hc->hc_req_args, "feclo"),
http_arg_get(&hc->hc_req_args, "bw"),
http_arg_get(&hc->hc_req_args, "tmode"),
http_arg_get(&hc->hc_req_args, "guard"),
http_arg_get(&hc->hc_req_args, "hier"),
http_arg_get(&hc->hc_req_args, "pol"),
http_arg_get(&hc->hc_req_args, "port"), 1);
if(v != NULL)
return ajax_adaptercreatemux_fail(hc, hr, tda, v);
tq = &hr->hr_tq;
dvb_make_add_link(tq, tda, "Successfully created");
ajax_js(tq,
"new Ajax.Updater('dvbmuxlist_%s', "
"'/ajax/dvbadaptermuxlist/%s', {method: 'get', evalScripts: true})",
tda->tda_identifier, tda->tda_identifier);
http_output_html(hc, hr);
return 0;
}
/**
* Return a list of all muxes on the given adapter
*/
static int
ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
ajax_table_t ta;
th_dvb_mux_instance_t *tdmi;
tcp_queue_t *tq = &hr->hr_tq;
th_dvb_adapter_t *tda;
char buf[50];
int fetype, n, m;
th_transport_t *t;
int nmuxes = 0;
char **selvector;
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
fetype = tda->tda_type;
/* List of muxes */
LIST_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link)
nmuxes++;
if(nmuxes == 0) {
tcp_qprintf(tq, ""
"No muxes configured
");
} else {
selvector = alloca(sizeof(char *) * (nmuxes + 1));
n = 0;
LIST_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link)
selvector[n++] = tdmi->tdmi_identifier;
selvector[n] = NULL;
ajax_generate_select_functions(tq, "mux", selvector);
ajax_table_top(&ta, hc, tq,
(const char *[])
{"Freq", "Status", "State", "Name", "Services", "", NULL},
(int[])
{16,12,8,16,8,2});
LIST_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link) {
tdmi_displayname(tdmi, buf, sizeof(buf));
ajax_table_row_start(&ta, tdmi->tdmi_identifier);
ajax_table_cell(&ta, NULL,
"%s ",
tdmi->tdmi_identifier, buf);
ajax_table_cell(&ta, "status", "%s", dvb_mux_status(tdmi));
ajax_table_cell(&ta, "state", "%s", dvb_mux_state(tdmi));
ajax_table_cell(&ta, "name", "%s", tdmi->tdmi_network ?: "Unknown");
n = m = 0;
LIST_FOREACH(t, &tdmi->tdmi_transports, tht_mux_link) {
n++;
if(transport_is_available(t))
m++;
}
ajax_table_cell(&ta, "nsvc", "%d / %d", m, n);
ajax_table_cell_checkbox(&ta);
}
ajax_table_bottom(&ta);
tcp_qprintf(tq, "");
tcp_qprintf(tq, "
Select:
");
ajax_a_jsfuncf(tq, "All", "mux_sel_all();");
tcp_qprintf(tq, " / ");
ajax_a_jsfuncf(tq, "None", "mux_sel_none();");
tcp_qprintf(tq, " / ");
ajax_a_jsfuncf(tq, "Invert", "mux_sel_invert();");
tcp_qprintf(tq, "
\r\n");
tcp_qprintf(tq, "");
tcp_qprintf(tq, "
 
");
ajax_a_jsfuncf(tq, "Delete selected",
"mux_sel_do('dvbadapterdelmux/%s', '', '', true)",
tda->tda_identifier);
tcp_qprintf(tq, "
\r\n");
}
http_output_html(hc, hr);
return 0;
}
/**
*
*/
static int
dvbsvccmp(th_transport_t *a, th_transport_t *b)
{
return a->tht_dvb_service_id - b->tht_dvb_service_id;
}
/**
* Display detailes about a mux
*/
static int
ajax_dvbmuxeditor(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
th_dvb_mux_instance_t *tdmi;
tcp_queue_t *tq = &hr->hr_tq;
char buf[1000];
th_transport_t *t;
struct th_transport_list head;
int n = 0;
if(remain == NULL || (tdmi = dvb_mux_find_by_identifier(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
tdmi_displayname(tdmi, buf, sizeof(buf));
LIST_INIT(&head);
LIST_FOREACH(t, &tdmi->tdmi_transports, tht_mux_link) {
if(transport_is_available(t)) {
LIST_INSERT_SORTED(&head, t, tht_tmp_link, dvbsvccmp);
n++;
}
}
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, buf);
ajax_transport_build_list(hc, tq, &head, n);
ajax_box_end(tq, AJAX_BOX_SIDEBOX);
http_output_html(hc, hr);
return 0;
}
/**
* Delete all muxes on an adapter
*/
static int
ajax_adapterdelmux(http_connection_t *hc, http_reply_t *hr,
const char *remain, void *opaque)
{
th_dvb_adapter_t *tda;
th_dvb_mux_instance_t *tdmi;
tcp_queue_t *tq = &hr->hr_tq;
http_arg_t *ra;
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
TAILQ_FOREACH(ra, &hc->hc_req_args, link) {
if(strcmp(ra->val, "selected"))
continue;
if((tdmi = dvb_mux_find_by_identifier(ra->key)) == NULL)
continue;
dvb_mux_destroy(tdmi);
}
tcp_qprintf(tq,
"new Ajax.Updater('dvbadaptereditor', "
"'/ajax/dvbadaptereditor/%s', "
"{method: 'get', evalScripts: true});",
tda->tda_identifier);
http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
return 0;
}
/**
*
*/
void
ajax_config_dvb_init(void)
{
http_path_add("/ajax/dvbadaptermuxlist" , NULL, ajax_adaptermuxlist);
http_path_add("/ajax/dvbadaptersummary" , NULL, ajax_adaptersummary);
http_path_add("/ajax/dvbadaptereditor", NULL, ajax_adaptereditor);
http_path_add("/ajax/dvbadapteraddmux", NULL, ajax_adapteraddmux);
http_path_add("/ajax/dvbadapterdelmux", NULL, ajax_adapterdelmux);
http_path_add("/ajax/dvbadaptercreatemux", NULL, ajax_adaptercreatemux);
http_path_add("/ajax/dvbmuxeditor", NULL, ajax_dvbmuxeditor);
}