Keep track of how the DVB devices are connected to the host. We will use it later to limit max number of streaming from a single device.
This commit is contained in:
parent
d64268c1d9
commit
1f1ecfffde
6 changed files with 106 additions and 6 deletions
|
@ -138,6 +138,10 @@ typedef struct th_dvb_mux_instance {
|
|||
} th_dvb_mux_instance_t;
|
||||
|
||||
|
||||
|
||||
#define DVB_DEVICE_SLOW 1 // Can only handle one service at a time
|
||||
#define DVB_DEVICE_FAST 2 // Can handle full mux
|
||||
|
||||
/**
|
||||
* DVB Adapter (one of these per physical adapter)
|
||||
*/
|
||||
|
@ -177,6 +181,8 @@ typedef struct th_dvb_adapter {
|
|||
|
||||
char *tda_dvr_path;
|
||||
|
||||
int tda_hostconnection;
|
||||
|
||||
gtimer_t tda_mux_scanner_timer;
|
||||
|
||||
pthread_mutex_t tda_delivery_mutex;
|
||||
|
|
|
@ -187,6 +187,18 @@ dvb_adapter_set_diseqc_version(th_dvb_adapter_t *tda, unsigned int v)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void
|
||||
dvb_adapter_checkspeed(th_dvb_adapter_t *tda)
|
||||
{
|
||||
char dev[64];
|
||||
|
||||
snprintf(dev, sizeof(dev), "dvb/dvb%d.dvr0", tda->tda_adapter_num);
|
||||
tda->tda_hostconnection = get_device_connection(dev);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -255,8 +267,11 @@ tda_add(int adapter_num)
|
|||
|
||||
tda->tda_displayname = strdup(tda->tda_fe_info->name);
|
||||
|
||||
dvb_adapter_checkspeed(tda);
|
||||
|
||||
tvhlog(LOG_INFO, "dvb",
|
||||
"Found adapter %s (%s)", path, tda->tda_fe_info->name);
|
||||
"Found adapter %s (%s) via %s", path, tda->tda_fe_info->name,
|
||||
hostconnection2str(tda->tda_hostconnection));
|
||||
|
||||
TAILQ_INSERT_TAIL(&dvb_adapters, tda, tda_global_link);
|
||||
|
||||
|
@ -518,6 +533,8 @@ dvb_adapter_build_msg(th_dvb_adapter_t *tda)
|
|||
return m;
|
||||
|
||||
htsmsg_add_str(m, "path", tda->tda_rootpath);
|
||||
htsmsg_add_str(m, "hostconnection",
|
||||
hostconnection2str(tda->tda_hostconnection));
|
||||
htsmsg_add_str(m, "devicename", tda->tda_fe_info->name);
|
||||
|
||||
htsmsg_add_str(m, "deliverySystem",
|
||||
|
@ -533,7 +550,6 @@ dvb_adapter_build_msg(th_dvb_adapter_t *tda)
|
|||
|
||||
htsmsg_add_u32(m, "symrateMin", tda->tda_fe_info->symbol_rate_min);
|
||||
htsmsg_add_u32(m, "symrateMax", tda->tda_fe_info->symbol_rate_max);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
|
|
66
src/main.c
66
src/main.c
|
@ -590,3 +590,69 @@ limitedlog(loglimiter_t *ll, const char *sys, const char *o, const char *event)
|
|||
tvhlog(LOG_WARNING, sys, "%s: %s%s", o, event, buf);
|
||||
ll->last = now;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const char *
|
||||
hostconnection2str(int type)
|
||||
{
|
||||
switch(type) {
|
||||
case HOSTCONNECTION_USB12:
|
||||
return "USB (12 Mbit/s)";
|
||||
|
||||
case HOSTCONNECTION_USB480:
|
||||
return "USB (480 Mbit/s)";
|
||||
|
||||
case HOSTCONNECTION_PCI:
|
||||
return "PCI";
|
||||
}
|
||||
return "Unknown";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static int
|
||||
readlinefromfile(const char *path, char *buf, size_t buflen)
|
||||
{
|
||||
int fd = open(path, O_RDONLY);
|
||||
ssize_t r;
|
||||
|
||||
if(fd == -1)
|
||||
return -1;
|
||||
|
||||
r = read(fd, buf, buflen - 1);
|
||||
close(fd);
|
||||
if(r < 0)
|
||||
return -1;
|
||||
|
||||
buf[buflen] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int
|
||||
get_device_connection(const char *dev)
|
||||
{
|
||||
char path[200];
|
||||
char l[64];
|
||||
int speed;
|
||||
|
||||
snprintf(path, sizeof(path), "/sys/class/%s/device/speed", dev);
|
||||
|
||||
if(readlinefromfile(path, l, sizeof(l))) {
|
||||
// Unable to read speed, assume it's PCI
|
||||
return HOSTCONNECTION_PCI;
|
||||
} else {
|
||||
speed = atoi(l);
|
||||
|
||||
return speed >= 480 ? HOSTCONNECTION_USB480 : HOSTCONNECTION_USB12;
|
||||
}
|
||||
}
|
||||
|
|
16
src/tvhead.h
16
src/tvhead.h
|
@ -130,6 +130,19 @@ typedef struct loglimter {
|
|||
void limitedlog(loglimiter_t *ll, const char *sys,
|
||||
const char *o, const char *event);
|
||||
|
||||
|
||||
/**
|
||||
* Device connection types
|
||||
*/
|
||||
#define HOSTCONNECTION_UNKNOWN 0
|
||||
#define HOSTCONNECTION_USB12 1
|
||||
#define HOSTCONNECTION_USB480 2
|
||||
#define HOSTCONNECTION_PCI 3
|
||||
|
||||
const char *hostconnection2str(int type);
|
||||
int get_device_connection(const char *dev);
|
||||
|
||||
|
||||
/**
|
||||
* Stream component types
|
||||
*/
|
||||
|
@ -676,9 +689,6 @@ typedef struct th_transport {
|
|||
|
||||
} th_transport_t;
|
||||
|
||||
|
||||
|
||||
|
||||
const char *streaming_component_type2txt(streaming_component_type_t s);
|
||||
|
||||
static inline unsigned int tvh_strhash(const char *s, unsigned int mod)
|
||||
|
|
|
@ -1088,6 +1088,7 @@ tvheadend.dvb_adapter_general = function(adapterData, satConfStore) {
|
|||
'<h2 style="font-size: 150%">Hardware</h2>' +
|
||||
'<h3>Device path:</h3>{path}' +
|
||||
'<h3>Device name:</h3>{devicename}' +
|
||||
'<h3>Host connection:</h3>{hostconnection}' +
|
||||
'<h3><tpl if="satConf != 0">Intermediate </tpl>Frequency range:</h3>{freqMin} kHz - {freqMax} kHz' +
|
||||
', in steps of {freqStep} kHz' +
|
||||
'<tpl if="symrateMin != 0">' +
|
||||
|
|
|
@ -8,7 +8,8 @@ tvheadend.tvAdapterStore = new Ext.data.JsonStore({
|
|||
'type',
|
||||
'name',
|
||||
'path',
|
||||
'devicename',
|
||||
'devicename',
|
||||
'hostconnection',
|
||||
'currentMux',
|
||||
'services',
|
||||
'muxes',
|
||||
|
|
Loading…
Add table
Reference in a new issue