From: leslie Date: Sat, 5 Dec 2009 10:40:17 +0000 (+0800) Subject: sasc: added HannibalX's ignore SID patch X-Git-Tag: upstream/620~133 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=65883f1d8c9829ba3e27bc99e04acadf06804300;p=sasc-ng.git sasc: added HannibalX's ignore SID patch --- diff --git a/contrib/sasc-ng/dvbloopback/src/plugin_getsid.c b/contrib/sasc-ng/dvbloopback/src/plugin_getsid.c index 71de566..102e432 100644 --- a/contrib/sasc-ng/dvbloopback/src/plugin_getsid.c +++ b/contrib/sasc-ng/dvbloopback/src/plugin_getsid.c @@ -85,12 +85,14 @@ static int opt_allpids = 0; static int opt_resetpidmap = 0; static int opt_experimental = 0; static int opt_orbit = 0; +static char *opt_ignore = 0; static struct option Sid_Opts[] = { {"sid-filt", 1, &sid_opt, 'f'}, {"sid-allpid", 0, &sid_opt, 'p'}, {"sid-nocache", 0, &sid_opt, 'c'}, {"sid-orbit", 1, &sid_opt, 'o'}, {"sid-experimental", 0, &sid_opt, 'e'}, + {"sid-ignore", 1, &sid_opt, 'i'}, {0, 0, 0, 0}, }; @@ -300,6 +302,37 @@ static int read_nit(unsigned char *buf, struct nit_data *nit, unsigned int size) } return 0; } + +static bool cmp_wild(const char *pat, const char *s) +{ + while(1) { + if (!*s || !*pat) return *pat==*s; // true if length matched + if (*pat!='?' && *pat!=*s) return false; + pat++; s++; + } +} + +static bool ignore_sid(int sid) +{ + bool ret = false; + if (opt_ignore) { + char s_sid[32]; + sprintf(s_sid,"%u",sid); + + char **save, *ignored = strdup(opt_ignore); + char *tok = strtok_r(ignored, ",", save); + while(tok) { + if (cmp_wild(tok,s_sid)) { + ret = true; + break; + } + tok = strtok_r(0, ",", save); + } + free(ignored); + } + return ret; +} + static int read_pmt(unsigned char *buf, struct filter *filt, struct sid_data *sid_data, unsigned int size) { // @@ -345,6 +378,11 @@ static int read_pmt(unsigned char *buf, struct filter *filt, free_sid(sid_ll); return -1; } + if (ignore_sid(sid)) { + dprintf0("Ignoring SID %d.\n", sid); + free_sid(sid_ll); + return -1; + } if(sidnum->seen) { dprintf0("Already seen sid: %d\n", sid); free_sid(sid_ll); @@ -978,6 +1016,8 @@ static struct option *parseopt_sid(arg_enum_t cmd) if(cmd == ARG_HELP) { printf(" --sid-filt : Maximum number of open filters (default 2)\n"); printf(" --sid-allpid : Parse all pids instead of just A/V\n"); + printf(" --sid-ignore \n"); + printf(" : When tuning, ignore given SIDs\n"); printf(" --sid-nocache : Don't cache pid<->sid mapping\n"); printf(" --sid-orbit : Set the satellit orbit to 'val' and don't scan the NIT\n"); printf(" --sid-experimental: Enable experimental tuning code\n"); @@ -1003,6 +1043,8 @@ static struct option *parseopt_sid(arg_enum_t cmd) opt_resetpidmap = 1; case 'e': opt_experimental = 1; + case 'i': + opt_ignore = optarg; } //must reset sid_opt after every call sid_opt = 0;