diff --git a/htmlui.c b/htmlui.c index eb65abbc..77e6bf74 100644 --- a/htmlui.c +++ b/htmlui.c @@ -35,9 +35,11 @@ #include "epg.h" #include "pvr.h" #include "strtab.h" +#include "dvb.h" +#include "iptv_input.h" static struct strtab recstatustxt[] = { - { "Scheduled", HTSTV_PVR_STATUS_SCHEDULED }, + { "Recording scheduled",HTSTV_PVR_STATUS_SCHEDULED }, { "Recording", HTSTV_PVR_STATUS_RECORDING }, { "Done", HTSTV_PVR_STATUS_DONE }, @@ -81,8 +83,15 @@ pvrstatus_to_html(tv_pvr_status_t pvrstatus, const char **text, static void -html_header(tcp_queue_t *tq, const char *title, int javascript) +html_header(tcp_queue_t *tq, const char *title, int javascript, int width) { + char w[30]; + + if(width > 0) + snprintf(w, sizeof(w), "width: %dpx; ", width); + else + w[0] = 0; + tcp_qprintf(tq, "\r\n" @@ -105,7 +114,7 @@ html_header(tcp_queue_t *tq, const char *title, int javascript) "" "body {margin: 4px 4px; " "font: 75% Verdana, Arial, Helvetica, sans-serif; " - "width: 600px; margin-right: auto; margin-left: auto;}\r\n" + "%s margin-right: auto; margin-left: auto;}\r\n" "" "#box {background: #cccc99;}\r\n" ".roundtop {background: #ffffff;}\r\n" @@ -133,6 +142,8 @@ html_header(tcp_queue_t *tq, const char *title, int javascript) ".content {padding-left: 3px; border-left: 1px solid #000000; " "border-right: 1px solid #000000;}\r\n" "" + ".statuscont {float: left; margin: 4px; width: 400px}\r\n" + "" ".logo {padding: 2px; width: 60px; height: 56px; " "float: left};\r\n" "" @@ -143,7 +154,7 @@ html_header(tcp_queue_t *tq, const char *title, int javascript) "#meny li{display: inline; list-style-type: none;}\r\n" "#meny a{padding: 1.15em 0.8em; text-decoration: none;}\r\n" "-->\r\n" - ""); + "", w); if(javascript) { tcp_qprintf(tq, @@ -210,6 +221,9 @@ box_bottom(tcp_queue_t *tq) static void top_menu(tcp_queue_t *tq) { + tcp_qprintf(tq, "
"); + box_top(tq, "box"); tcp_qprintf(tq, @@ -221,7 +235,7 @@ top_menu(tcp_queue_t *tq) "
"); box_bottom(tq); - tcp_qprintf(tq, "
\r\n"); + tcp_qprintf(tq, "
\r\n"); } @@ -319,13 +333,14 @@ output_event(http_connection_t *hc, tcp_queue_t *tq, th_channel_t *ch, "" "" "%02d:%02d - %02d:%02d" - "%s", + "%s", bufa, overlibstuff, simple ? 80 : 100, e == cur ? ";font-weight:bold" : "", a.tm_hour, a.tm_min, b.tm_hour, b.tm_min, - simple ? 100 : 250, + simple ? 100 : 350, e == cur ? ";font-weight:bold" : "", title ); @@ -352,11 +367,8 @@ page_root(http_connection_t *hc, const char *remain, void *opaque) int i; int simple = is_client_simple(hc); - tcp_init_queue(&tq, -1); - - html_header(&tq, "HTS/tvheadend", !simple); - + html_header(&tq, "HTS/tvheadend", !simple, 700); top_menu(&tq); epg_lock(); @@ -383,8 +395,9 @@ page_root(http_connection_t *hc, const char *remain, void *opaque) e = epg_event_find_current_or_upcoming(ch); for(i = 0; i < 3 && e != NULL; i++) { + output_event(hc, &tq, ch, e, simple); - e = TAILQ_NEXT(e, e_link); + e = TAILQ_NEXT(e, e_link); } tcp_qprintf(&tq, ""); @@ -440,7 +453,7 @@ page_channel(http_connection_t *hc, const char *remain, void *opaque) tcp_init_queue(&tq, -1); - html_header(&tq, "HTS/tvheadend", !simple); + html_header(&tq, "HTS/tvheadend", !simple, 700); top_menu(&tq); @@ -461,8 +474,8 @@ page_channel(http_connection_t *hc, const char *remain, void *opaque) for(w = 0; w < 7; w++) { tcp_qprintf(&tq, - "%s
", + "" + "%s
", ch->ch_tag, w, days[(wday + w) % 7]); @@ -471,8 +484,9 @@ page_channel(http_connection_t *hc, const char *remain, void *opaque) if(a.tm_wday != wday + w) break; - if(a.tm_wday == wday + doff) + if(a.tm_wday == wday + doff) { output_event(hc, &tq, ch, e, simple); + } e = TAILQ_NEXT(e, e_link); } } @@ -536,7 +550,7 @@ page_event(http_connection_t *hc, const char *remain, void *opaque) tcp_init_queue(&tq, -1); - html_header(&tq, "HTS/tvheadend", 0); + html_header(&tq, "HTS/tvheadend", 0, 700); top_menu(&tq); tcp_qprintf(&tq, "
", eventid); @@ -619,7 +633,7 @@ pvrcmp(const void *A, const void *B) } /** - * Event page + * PVR log */ static int page_pvrlog(http_connection_t *hc, const char *remain, void *opaque) @@ -637,7 +651,7 @@ page_pvrlog(http_connection_t *hc, const char *remain, void *opaque) pvr_rec_t **pv; tcp_init_queue(&tq, -1); - html_header(&tq, "HTS/tvheadend", 0); + html_header(&tq, "HTS/tvheadend", 0, 700); top_menu(&tq); box_top(&tq, "box"); @@ -740,6 +754,163 @@ page_pvrlog(http_connection_t *hc, const char *remain, void *opaque) return 0; } + +static void +html_iptv_status(tcp_queue_t *tq, th_transport_t *t, const char *status) +{ + tcp_qprintf(tq, + "" + "%s (%s)" + "", + inet_ntoa(t->tht_iptv_group_addr), + t->tht_channel->ch_name); + + tcp_qprintf(tq, + "" + "%s" + "
", + status); + +} + + +/** + * System status + */ +static int +page_status(http_connection_t *hc, const char *remain, void *opaque) +{ + tcp_queue_t tq; + int simple = is_client_simple(hc); + th_dvb_adapter_t *tda; + th_transport_t *t; + th_dvb_mux_instance_t *tdmi; + const char *txt; + + tcp_init_queue(&tq, -1); + + html_header(&tq, "HTS/tvheadend", !simple, -1); + + top_menu(&tq); + + tcp_qprintf(&tq, "
"); + + tcp_qprintf(&tq, "
"); + + + /* DVB adapters */ + + box_top(&tq, "box"); + tcp_qprintf(&tq, "
"); + tcp_qprintf(&tq, "DVB source adapters
"); + + if(LIST_FIRST(&dvb_adapters_running) == NULL) { + tcp_qprintf(&tq, "No DVB adapters configured
"); + } else { + LIST_FOREACH(tda, &dvb_adapters_running, tda_link) { + tcp_qprintf(&tq, "
%s
", tda->tda_path, tda->tda_name); + LIST_FOREACH(tdmi, &tda->tda_muxes_active, tdmi_adapter_link) { + + tcp_qprintf(&tq, + "" + "%s" + "", + tdmi->tdmi_mux->tdm_title); + + txt = tdmi->tdmi_status ?: "Ok"; + if(tdmi->tdmi_fec_err_per_sec > DVB_FEC_ERROR_LIMIT) + txt = "Too high FEC rate"; + + tcp_qprintf(&tq, + "" + "%s" + "", + txt); + + switch(tdmi->tdmi_state) { + default: + txt = "???"; + break; + case TDMI_IDLE: + txt = "Idle"; + break; + case TDMI_RUNNING: + txt = "Running"; + break; + } + + tcp_qprintf(&tq, + "" + "%s" + "", + txt); + + tcp_qprintf(&tq, + "" + "%d" + "
", + tdmi->tdmi_fec_err_per_sec); + } + } + } + tcp_qprintf(&tq, "
"); + box_bottom(&tq); + + tcp_qprintf(&tq, "
"); + + /* IPTV adapters */ + + box_top(&tq, "box"); + tcp_qprintf(&tq, "
"); + tcp_qprintf(&tq, "IPTV sources

"); + + LIST_FOREACH(t, &all_transports, tht_global_link) { + if(t->tht_type != TRANSPORT_IPTV) + continue; + html_iptv_status(&tq, t, + t->tht_status == TRANSPORT_IDLE ? "Idle" : "Running"); + } + + LIST_FOREACH(t, &iptv_stale_transports, tht_adapter_link) + html_iptv_status(&tq, t, "Probe failed"); + + tcp_qprintf(&tq, "
"); + box_bottom(&tq); + + tcp_qprintf(&tq, "
"); + + + tcp_qprintf(&tq, "
"); + box_top(&tq, "box"); + tcp_qprintf(&tq, "
"); + tcp_qprintf(&tq, "space for a rent"); + tcp_qprintf(&tq, "
"); + box_bottom(&tq); + tcp_qprintf(&tq, "
"); + + + tcp_qprintf(&tq, "
"); + box_top(&tq, "box"); + tcp_qprintf(&tq, "
"); + tcp_qprintf(&tq, "space for a rent"); + tcp_qprintf(&tq, "
"); + box_bottom(&tq); + tcp_qprintf(&tq, "
"); + + tcp_qprintf(&tq, "
"); + + html_footer(&tq); + http_output_queue(hc, &tq, "text/html; charset=UTF-8"); + return 0; +} + + /** * HTML user interface setup code */ @@ -750,4 +921,5 @@ htmlui_start(void) http_path_add("/event", NULL, page_event); http_path_add("/channel", NULL, page_channel); http_path_add("/pvrlog", NULL, page_pvrlog); + http_path_add("/status", NULL, page_status); } diff --git a/iptv_input.c b/iptv_input.c index f94f10fe..8c7bd855 100644 --- a/iptv_input.c +++ b/iptv_input.c @@ -42,8 +42,8 @@ #include "psi.h" #include "tsdemux.h" -static struct th_transport_list iptv_probing_transports; -static struct th_transport_list iptv_stale_transports; +struct th_transport_list iptv_probing_transports; +struct th_transport_list iptv_stale_transports; static dtimer_t iptv_probe_timer; static void iptv_probe_transport(th_transport_t *t); diff --git a/iptv_input.h b/iptv_input.h index 4d1cc8d2..2a86706f 100644 --- a/iptv_input.h +++ b/iptv_input.h @@ -27,4 +27,7 @@ int iptv_start_feed(th_transport_t *t, int status); int iptv_stop_feed(th_transport_t *t); +extern struct th_transport_list iptv_probing_transports; +extern struct th_transport_list iptv_stale_transports; + #endif /* IPTV_INPUT_H_ */