From a1592da5e1671eb714802987e0b319a8851b73dc Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Thu, 17 Oct 2013 21:38:47 +0100 Subject: [PATCH] started work on better setup for input/hardware etc... --- Makefile | 1 - src/api/api_input.c | 14 +++++++-- src/api/api_mpegts.c | 16 ---------- src/idnode.c | 2 +- src/input.c | 7 ++++- src/input.h | 49 ++++++++++++++++++++++++------ src/webui/static/app/tvadapters.js | 2 +- 7 files changed, 60 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 7558fefd..ea18e139 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,6 @@ SRCS-$(CONFIG_MPEGTS) += \ # DVB SRCS-${CONFIG_LINUXDVB} += \ src/input/mpegts/linuxdvb/linuxdvb.c \ - src/input/mpegts/linuxdvb/linuxdvb_hardware.c \ src/input/mpegts/linuxdvb/linuxdvb_device.c \ src/input/mpegts/linuxdvb/linuxdvb_adapter.c \ src/input/mpegts/linuxdvb/linuxdvb_frontend.c \ diff --git a/src/api/api_input.c b/src/api/api_input.c index f6cef7db..9dbf7bd4 100644 --- a/src/api/api_input.c +++ b/src/api/api_input.c @@ -56,11 +56,21 @@ api_input_status return 0; } +static idnode_set_t * +api_input_hw_tree ( void ) +{ + tvh_hardware_t *th; + idnode_set_t *is = idnode_set_create(); + TVH_HARDWARE_FOREACH(th) + idnode_set_add(is, &th->th_id, NULL); + return is; +} + void api_input_init ( void ) { static api_hook_t ah[] = { - { "input/status", ACCESS_ANONYMOUS, api_input_status, NULL }, -// { "input/tree", ACCESS_ANONYMOUS, NULL, NULL }, + { "input/status", ACCESS_ANONYMOUS, api_input_status, NULL }, + { "hardware/tree", ACCESS_ADMIN, api_idnode_tree, api_input_hw_tree }, { NULL }, }; diff --git a/src/api/api_mpegts.c b/src/api/api_mpegts.c index da13a017..8af61049 100644 --- a/src/api/api_mpegts.c +++ b/src/api/api_mpegts.c @@ -341,21 +341,6 @@ api_linuxdvb_scanfile_list } #endif -/* - * Adapter list - * - * TODO: this will need reworking for mpegps etc... - */ -static idnode_set_t * -api_tvadapter_tree ( void ) -{ -#if ENABLE_LINUXDVB - return linuxdvb_root(); -#else - return NULL; -#endif -} - /* * Init */ @@ -368,7 +353,6 @@ api_mpegts_init ( void ) extern const idclass_t linuxdvb_satconf_class; static api_hook_t ah[] = { - { "tvadapter/tree", ACCESS_ANONYMOUS, api_idnode_tree, api_tvadapter_tree }, { "mpegts/input/network_list", ACCESS_ANONYMOUS, api_mpegts_input_network_list, NULL }, { "mpegts/network/grid", ACCESS_ANONYMOUS, api_idnode_grid, api_mpegts_network_grid }, { "mpegts/network/class", ACCESS_ANONYMOUS, api_idnode_class, (void*)&mpegts_network_class }, diff --git a/src/idnode.c b/src/idnode.c index 060dfae0..c260f505 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -457,7 +457,7 @@ idnode_cmp_title idnode_t *inb = *(idnode_t**)b; const char *sa = idnode_get_title(ina); const char *sb = idnode_get_title(inb); - return strcmp(sa, sb); + return strcmp(sa ?: "", sb ?: ""); } static int diff --git a/src/input.c b/src/input.c index dd1ef2ec..e156f164 100644 --- a/src/input.c +++ b/src/input.c @@ -18,7 +18,12 @@ #include "input.h" -tvh_input_list_t tvh_inputs; +tvh_input_list_t tvh_inputs; +tvh_hardware_list_t tvh_hardware; + +/* + * Input status handling + */ htsmsg_t * tvh_input_stream_create_msg diff --git a/src/input.h b/src/input.h index 7bd63ba2..a74a8bf2 100644 --- a/src/input.h +++ b/src/input.h @@ -22,19 +22,31 @@ #include "idnode.h" #include "queue.h" +/* + * Type-defs + */ +typedef struct tvh_hardware tvh_hardware_t; +typedef struct tvh_input tvh_input_t; +typedef struct tvh_input_stream tvh_input_stream_t; +typedef struct tvh_input_stream_stats tvh_input_stream_stats_t; + +typedef LIST_HEAD(,tvh_hardware) tvh_hardware_list_t; +typedef LIST_HEAD(,tvh_input) tvh_input_list_t; +typedef LIST_HEAD(,tvh_input_stream) tvh_input_stream_list_t; + /* * Input stream structure - used for getting statistics about active streams */ -typedef struct tvh_input_stream_stats +struct tvh_input_stream_stats { int signal; ///< Signal level (0-100) int ber; ///< Bit error rate (0-100?) int unc; ///< Uncorrectable errors int snr; ///< Signal 2 Noise (dB) int bps; ///< Bandwidth (bps) -} tvh_input_stream_stats_t; +}; -typedef struct tvh_input_stream { +struct tvh_input_stream { LIST_ENTRY(tvh_input_stream) link; @@ -45,10 +57,7 @@ typedef struct tvh_input_stream { int max_weight; ///< Current max weight tvh_input_stream_stats_t stats; - -} tvh_input_stream_t; - -typedef LIST_HEAD(,tvh_input_stream) tvh_input_stream_list_t; +}; /* * Generic input super-class @@ -62,10 +71,29 @@ typedef struct tvh_input { } tvh_input_t; -typedef LIST_HEAD(,tvh_input) tvh_input_list_t; -tvh_input_list_t tvh_inputs; +/* + * Generic hardware super-class + */ +typedef struct tvh_hardware { + idnode_t th_id; + LIST_ENTRY(tvh_hardware) th_link; +} tvh_input_hw_t; + + +/* + * Class and Global list defs + */ +extern const idclass_t tvh_input_class; + +tvh_input_list_t tvh_inputs; +tvh_hardware_list_t tvh_hardware; #define TVH_INPUT_FOREACH(x) LIST_FOREACH(x, &tvh_inputs, ti_link) +#define TVH_HARDWARE_FOREACH(x) LIST_FOREACH(x, &tvh_hardware, th_link) + +/* + * Methods + */ void input_init ( void ); @@ -73,6 +101,9 @@ htsmsg_t * tvh_input_stream_create_msg ( tvh_input_stream_t *st ); void tvh_input_stream_destroy ( tvh_input_stream_t *st ); +/* + * Input subsystem includes + */ #if ENABLE_MPEGPS #include "input/mpegps.h" diff --git a/src/webui/static/app/tvadapters.js b/src/webui/static/app/tvadapters.js index c537a2b0..7e0ed001 100644 --- a/src/webui/static/app/tvadapters.js +++ b/src/webui/static/app/tvadapters.js @@ -1,3 +1,3 @@ tvheadend.tvadapters = function() { - return tvheadend.idnode_tree({ url: 'api/tvadapter/tree', title: 'TV adapters'}); + return tvheadend.idnode_tree({ url: 'api/hardware/tree', title: 'TV adapters'}); }