started work on better setup for input/hardware etc...

This commit is contained in:
Adam Sutton 2013-10-17 21:38:47 +01:00
parent ce48eeb9d4
commit a1592da5e1
7 changed files with 60 additions and 31 deletions

View file

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

View file

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

View file

@ -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 },

View file

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

View file

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

View file

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

View file

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