Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
epggrab: otamux - add subscriptions statistics, fixes #2927
  • Loading branch information
perexg committed Jun 13, 2015
1 parent 5556f70 commit f0cb852
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/epggrab/module/eit.c
Expand Up @@ -584,6 +584,7 @@ _eit_callback
epggrab_module_t *mod;
epggrab_ota_mux_t *ota = NULL;
mpegts_psi_table_state_t *st;
th_subscription_t *ths;

if (!epggrab_ota_running)
return -1;
Expand All @@ -592,9 +593,19 @@ _eit_callback
map = mt->mt_opaque;
mod = (epggrab_module_t *)map->om_module;

/* Statistics */
ths = mpegts_mux_find_subscription_by_name(mm, "epggrab");
if (ths) {
ths->ths_bytes_in += len;
ths->ths_bytes_out += len;
}

/* Validate */
if(tableid < 0x4e || tableid > 0x6f || len < 11)
if(tableid < 0x4e || tableid > 0x6f || len < 11) {
if (ths)
ths->ths_total_err++;
return -1;
}

/* Basic info */
sid = ptr[0] << 8 | ptr[1];
Expand Down
17 changes: 17 additions & 0 deletions src/epggrab/module/opentv.c
Expand Up @@ -544,6 +544,7 @@ opentv_table_callback
opentv_status_t *sta;
opentv_module_t *mod;
epggrab_ota_mux_t *ota;
th_subscription_t *ths;

if (!epggrab_ota_running) return -1;

Expand All @@ -559,6 +560,14 @@ opentv_table_callback
mjd = ((int)buf[5] << 8) | buf[6];
mjd = (mjd - 40587) * 86400;

/* Statistics */
ths = mpegts_mux_find_subscription_by_name(mt->mt_mux, "epggrab");
if (ths) {
ths->ths_bytes_in += len;
ths->ths_bytes_out += len;
}


/* Begin */
r = dvb_table_begin((mpegts_psi_table_t *)mt, buf, len,
tableid, (uint64_t)cid << 32 | mjd, 7,
Expand Down Expand Up @@ -622,13 +631,21 @@ opentv_bat_callback
opentv_status_t *sta;
opentv_module_t *mod;
epggrab_ota_mux_t *ota;
th_subscription_t *ths;

if (!epggrab_ota_running) return -1;

sta = mt->mt_opaque;
mod = sta->os_mod;
ota = sta->os_ota;

/* Statistics */
ths = mpegts_mux_find_subscription_by_name(mt->mt_mux, "epggrab");
if (ths) {
ths->ths_bytes_in += len;
ths->ths_bytes_out += len;
}

r = dvb_bat_callback(mt, buf, len, tableid);

/* Register */
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts.h
Expand Up @@ -846,6 +846,7 @@ void mpegts_mux_remove_subscriber(mpegts_mux_t *mm, th_subscription_t *s, int re
int mpegts_mux_subscribe(mpegts_mux_t *mm, mpegts_input_t *mi,
const char *name, int weight, int flags);
void mpegts_mux_unsubscribe_by_name(mpegts_mux_t *mm, const char *name);
th_subscription_t *mpegts_mux_find_subscription_by_name(mpegts_mux_t *mm, const char *name);

void mpegts_mux_unsubscribe_linked(mpegts_input_t *mi, service_t *t);

Expand Down
15 changes: 15 additions & 0 deletions src/input/mpegts/mpegts_mux.c
Expand Up @@ -1237,6 +1237,21 @@ mpegts_mux_unsubscribe_by_name
}
}

th_subscription_t *
mpegts_mux_find_subscription_by_name
( mpegts_mux_t *mm, const char *name )
{
const service_t *t;
th_subscription_t *s;

LIST_FOREACH(s, &mm->mm_raw_subs, ths_mux_link) {
t = s->ths_service;
if (t && t->s_type == STYPE_RAW && !strcmp(s->ths_title, name))
return s;
}
return NULL;
}

void
mpegts_mux_tuning_error ( const char *mux_uuid, mpegts_mux_instance_t *mmi_match )
{
Expand Down

0 comments on commit f0cb852

Please sign in to comment.