Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
esfilter: add logical stream index, enhance the CA type filtering
- add the logical stream index - see help
- add the PID filtering for the CA type
- fix the service info dialog (do not show some filtered CAIDs)
  • Loading branch information
perexg committed Jul 31, 2014
1 parent 8ca95e9 commit a181174
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 9 deletions.
10 changes: 9 additions & 1 deletion docs/html/config_esfilter.html
Expand Up @@ -67,9 +67,17 @@
<dt>CA Provider
<dd>The CA provider to compare. Empty field means any.

<dt>Stream Index
<dd>The logical stream index to compare. Note that this index is computed
using all filters. Example: If filter is set to AC3 audio type and
the language to 'eng' and there are two AC3 'eng' streams in
the service, the first stream could be identified using number 1
and the second using number 2.

<dt>PID
<dd>Program identification (PID) number to compare. Zero means any.
This comparison is processed only when service comparison is active.
This comparison is processed only when service comparison is active
and for the Conditional Access filter.

<dt>Action
<dd>The rule action defines the operation when all comparisons succeeds.
Expand Down
8 changes: 5 additions & 3 deletions src/api/api_service.c
Expand Up @@ -93,7 +93,7 @@ api_service_mapper_notify ( void )
}

static htsmsg_t *
api_service_streams_get_one ( elementary_stream_t *es )
api_service_streams_get_one ( elementary_stream_t *es, int use_filter )
{
htsmsg_t *e = htsmsg_create_map();
htsmsg_add_u32(e, "index", es->es_index);
Expand All @@ -115,6 +115,8 @@ api_service_streams_get_one ( elementary_stream_t *es )
caid_t *ca;
htsmsg_t *e2, *l2 = htsmsg_create_list();
LIST_FOREACH(ca, &es->es_caids, link) {
if (use_filter && !ca->use)
continue;
e2 = htsmsg_create_map();
htsmsg_add_u32(e2, "caid", ca->caid);
htsmsg_add_u32(e2, "provider", ca->providerid);
Expand Down Expand Up @@ -163,12 +165,12 @@ api_service_streams
htsmsg_add_msg(st, NULL, e);
}
TAILQ_FOREACH(es, &s->s_components, es_link)
htsmsg_add_msg(st, NULL, api_service_streams_get_one(es));
htsmsg_add_msg(st, NULL, api_service_streams_get_one(es, 0));
if (TAILQ_FIRST(&s->s_filt_components) == NULL ||
s->s_status == SERVICE_IDLE)
service_build_filter(s);
TAILQ_FOREACH(es, &s->s_filt_components, es_filt_link)
htsmsg_add_msg(stf, NULL, api_service_streams_get_one(es));
htsmsg_add_msg(stf, NULL, api_service_streams_get_one(es, 1));
*resp = htsmsg_create_map();
htsmsg_add_str(*resp, "name", s->s_nicename);
htsmsg_add_msg(*resp, "streams", st);
Expand Down
30 changes: 30 additions & 0 deletions src/esfilter.c
Expand Up @@ -642,6 +642,12 @@ const idclass_t esfilter_class_video = {
.set = esfilter_class_service_set,
.list = esfilter_class_service_enum,
},
{
.type = PT_INT,
.id = "sindex",
.name = "Stream Index",
.off = offsetof(esfilter_t, esf_sindex),
},
{
.type = PT_INT,
.id = "pid",
Expand Down Expand Up @@ -703,6 +709,12 @@ const idclass_t esfilter_class_audio = {
.set = esfilter_class_service_set,
.list = esfilter_class_service_enum,
},
{
.type = PT_INT,
.id = "sindex",
.name = "Stream Index",
.off = offsetof(esfilter_t, esf_sindex),
},
{
.type = PT_INT,
.id = "pid",
Expand Down Expand Up @@ -764,6 +776,12 @@ const idclass_t esfilter_class_teletext = {
.set = esfilter_class_service_set,
.list = esfilter_class_service_enum,
},
{
.type = PT_INT,
.id = "sindex",
.name = "Stream Index",
.off = offsetof(esfilter_t, esf_sindex),
},
{
.type = PT_INT,
.id = "pid",
Expand Down Expand Up @@ -825,6 +843,12 @@ const idclass_t esfilter_class_subtit = {
.set = esfilter_class_service_set,
.list = esfilter_class_service_enum,
},
{
.type = PT_INT,
.id = "sindex",
.name = "Stream Index",
.off = offsetof(esfilter_t, esf_sindex),
},
{
.type = PT_INT,
.id = "pid",
Expand Down Expand Up @@ -894,6 +918,12 @@ const idclass_t esfilter_class_ca = {
.set = esfilter_class_service_set,
.list = esfilter_class_service_enum,
},
{
.type = PT_INT,
.id = "sindex",
.name = "Stream Index",
.off = offsetof(esfilter_t, esf_sindex),
},
{
.type = PT_INT,
.id = "pid",
Expand Down
1 change: 1 addition & 0 deletions src/esfilter.h
Expand Up @@ -91,6 +91,7 @@ typedef struct esfilter {
uint32_t esf_type;
char esf_language[4];
char esf_service[UUID_HEX_SIZE];
int esf_sindex;
int esf_pid;
uint16_t esf_caid;
uint32_t esf_caprovider;
Expand Down
19 changes: 14 additions & 5 deletions src/service.c
Expand Up @@ -346,7 +346,7 @@ service_build_filter(service_t *t)
elementary_stream_t *st, *st2, **sta;
esfilter_t *esf;
caid_t *ca, *ca2;
int i, n, p, o, exclusive;
int i, n, p, o, exclusive, sindex;
uint32_t mask;

/* rebuild the filtered and ordered components */
Expand Down Expand Up @@ -387,6 +387,7 @@ service_build_filter(service_t *t)
TAILQ_FOREACH(esf, &esfilters[i], esf_link) {
if (!esf->esf_enabled)
continue;
sindex = 0;
TAILQ_FOREACH(st, &t->s_components, es_link) {
if ((mask & SCT_MASK(st->es_type)) == 0)
continue;
Expand All @@ -402,6 +403,8 @@ service_build_filter(service_t *t)
continue;
}
if (i == ESF_CLASS_CA) {
if (esf->esf_pid && esf->esf_pid != st->es_pid)
continue;
ca = NULL;
if ((esf->esf_caid != (uint16_t)-1 || esf->esf_caprovider != -1)) {
LIST_FOREACH(ca, &st->es_caids, link) {
Expand All @@ -414,9 +417,12 @@ service_build_filter(service_t *t)
if (ca == NULL)
continue;
}
sindex++;
if (esf->esf_sindex && esf->esf_sindex != sindex)
continue;
if (esf->esf_log)
tvhlog(LOG_INFO, "service", "esfilter: %s %03d %05d %04x %06x \"%s\" %s",
esfilter_class2txt(i), esf->esf_index, st->es_pid,
tvhlog(LOG_INFO, "service", "esfilter: %s %03d %03d %05d %04x %06x \"%s\" %s",
esfilter_class2txt(i), st->es_index, esf->esf_index, st->es_pid,
esf->esf_caid, esf->esf_caprovider, t->s_nicename,
esfilter_action2txt(esf->esf_action));
switch (esf->esf_action) {
Expand Down Expand Up @@ -464,9 +470,12 @@ service_build_filter(service_t *t)
break;
}
} else {
sindex++;
if (esf->esf_sindex && esf->esf_sindex != sindex)
continue;
if (esf->esf_log)
tvhlog(LOG_INFO, "service", "esfilter: %s %03d %05d %s %s \"%s\" %s",
esfilter_class2txt(i), esf->esf_index,
tvhlog(LOG_INFO, "service", "esfilter: %s %03d %03d %05d %s %s \"%s\" %s",
esfilter_class2txt(i), st->es_index, esf->esf_index,
st->es_pid, streaming_component_type2txt(st->es_type),
lang_code_get(st->es_lang), t->s_nicename,
esfilter_action2txt(esf->esf_action));
Expand Down

0 comments on commit a181174

Please sign in to comment.