diff options
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 55 |
1 files changed, 41 insertions, 14 deletions
@@ -4,13 +4,14 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: channels.c 2.13 2010/02/21 13:36:04 kls Exp $ + * $Id: channels.c 2.16 2010/06/05 13:33:57 kls Exp $ */ #include "channels.h" #include <ctype.h> #include "device.h" #include "epg.h" +#include "libsi/si.h" #include "timers.h" // IMPORTANT NOTE: in the 'sscanf()' calls there is a blank after the '%d' @@ -61,6 +62,7 @@ cChannel::cChannel(void) provider = strdup(""); portalName = strdup(""); memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__); + parameters = ""; modification = CHANNELMOD_NONE; schedule = NULL; linkChannels = NULL; @@ -270,14 +272,21 @@ static int IntArraysDiffer(const int *a, const int *b, const char na[][MAXLANGCO return result; } -static int IntArrayToString(char *s, const int *a, int Base = 10, const char n[][MAXLANGCODE2] = NULL) +static int IntArrayToString(char *s, const int *a, int Base = 10, const char n[][MAXLANGCODE2] = NULL, const int *t = NULL) { char *q = s; int i = 0; while (a[i] || i == 0) { q += sprintf(q, Base == 16 ? "%s%X" : "%s%d", i ? "," : "", a[i]); - if (a[i] && n && *n[i]) - q += sprintf(q, "=%s", n[i]); + const char *Delim = "="; + if (a[i]) { + if (n && *n[i]) { + q += sprintf(q, "%s%s", Delim, n[i]); + Delim = ""; + } + if (t && t[i]) + q += sprintf(q, "%s@%d", Delim, t[i]); + } if (!a[i]) break; i++; @@ -286,32 +295,32 @@ static int IntArrayToString(char *s, const int *a, int Base = 10, const char n[] return q - s; } -void cChannel::SetPids(int Vpid, int Ppid, int Vtype, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid) +void cChannel::SetPids(int Vpid, int Ppid, int Vtype, int *Apids, int *Atypes, char ALangs[][MAXLANGCODE2], int *Dpids, int *Dtypes, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid) { int mod = CHANNELMOD_NONE; if (vpid != Vpid || ppid != Ppid || vtype != Vtype || tpid != Tpid) mod |= CHANNELMOD_PIDS; - int m = IntArraysDiffer(apids, Apids, alangs, ALangs) | IntArraysDiffer(dpids, Dpids, dlangs, DLangs) | IntArraysDiffer(spids, Spids, slangs, SLangs); + int m = IntArraysDiffer(apids, Apids, alangs, ALangs) | IntArraysDiffer(atypes, Atypes) | IntArraysDiffer(dpids, Dpids, dlangs, DLangs) | IntArraysDiffer(dtypes, Dtypes) | IntArraysDiffer(spids, Spids, slangs, SLangs); if (m & STRDIFF) mod |= CHANNELMOD_LANGS; if (m & VALDIFF) mod |= CHANNELMOD_PIDS; if (mod) { - const int BufferSize = (MAXAPIDS + MAXDPIDS) * (5 + 1 + MAXLANGCODE2) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod+cod', +10: paranoia + const int BufferSize = (MAXAPIDS + MAXDPIDS) * (5 + 1 + MAXLANGCODE2 + 5) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod+cod@type', +10: paranoia char OldApidsBuf[BufferSize]; char NewApidsBuf[BufferSize]; char *q = OldApidsBuf; - q += IntArrayToString(q, apids, 10, alangs); + q += IntArrayToString(q, apids, 10, alangs, atypes); if (dpids[0]) { *q++ = ';'; - q += IntArrayToString(q, dpids, 10, dlangs); + q += IntArrayToString(q, dpids, 10, dlangs, dtypes); } *q = 0; q = NewApidsBuf; - q += IntArrayToString(q, Apids, 10, ALangs); + q += IntArrayToString(q, Apids, 10, ALangs, Atypes); if (Dpids[0]) { *q++ = ';'; - q += IntArrayToString(q, Dpids, 10, DLangs); + q += IntArrayToString(q, Dpids, 10, DLangs, Dtypes); } *q = 0; const int SBufferSize = MAXSPIDS * (5 + 1 + MAXLANGCODE2) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod', +10: paranoia @@ -330,11 +339,13 @@ void cChannel::SetPids(int Vpid, int Ppid, int Vtype, int *Apids, char ALangs[][ vtype = Vtype; for (int i = 0; i < MAXAPIDS; i++) { apids[i] = Apids[i]; + atypes[i] = Atypes[i]; strn0cpy(alangs[i], ALangs[i], MAXLANGCODE2); } apids[MAXAPIDS] = 0; for (int i = 0; i < MAXDPIDS; i++) { dpids[i] = Dpids[i]; + dtypes[i] = Dtypes[i]; strn0cpy(dlangs[i], DLangs[i], MAXLANGCODE2); } dpids[MAXDPIDS] = 0; @@ -484,13 +495,13 @@ cString cChannel::ToText(const cChannel *Channel) if (Channel->vpid && Channel->vtype) q += snprintf(q, sizeof(vpidbuf) - (q - vpidbuf), "=%d", Channel->vtype); *q = 0; - const int BufferSize = (MAXAPIDS + MAXDPIDS) * (5 + 1 + MAXLANGCODE2) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod+cod', +10: paranoia + const int BufferSize = (MAXAPIDS + MAXDPIDS) * (5 + 1 + MAXLANGCODE2 + 5) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod+cod@type', +10: paranoia char apidbuf[BufferSize]; q = apidbuf; - q += IntArrayToString(q, Channel->apids, 10, Channel->alangs); + q += IntArrayToString(q, Channel->apids, 10, Channel->alangs, Channel->atypes); if (Channel->dpids[0]) { *q++ = ';'; - q += IntArrayToString(q, Channel->dpids, 10, Channel->dlangs); + q += IntArrayToString(q, Channel->dpids, 10, Channel->dlangs, Channel->dtypes); } *q = 0; char caidbuf[MAXCAIDS * 5 + 10]; // 5: 4 digits plus delimiting ',', 10: paranoia @@ -546,7 +557,9 @@ bool cChannel::Parse(const char *s) vpid = ppid = 0; vtype = 0; apids[0] = 0; + atypes[0] = 0; dpids[0] = 0; + dtypes[0] = 0; ok = false; if (parambuf && sourcebuf && vpidbuf && apidbuf) { parameters = parambuf; @@ -579,9 +592,15 @@ bool cChannel::Parse(const char *s) char *strtok_next; while ((q = strtok_r(p, ",", &strtok_next)) != NULL) { if (NumApids < MAXAPIDS) { + atypes[NumApids] = 4; // backwards compatibility char *l = strchr(q, '='); if (l) { *l++ = 0; + char *t = strchr(l, '@'); + if (t) { + *t++ = 0; + atypes[NumApids] = strtol(t, NULL, 10); + } strn0cpy(alangs[NumApids], l, MAXLANGCODE2); } else @@ -593,6 +612,7 @@ bool cChannel::Parse(const char *s) p = NULL; } apids[NumApids] = 0; + atypes[NumApids] = 0; if (dpidbuf) { char *p = dpidbuf; char *q; @@ -600,9 +620,15 @@ bool cChannel::Parse(const char *s) char *strtok_next; while ((q = strtok_r(p, ",", &strtok_next)) != NULL) { if (NumDpids < MAXDPIDS) { + dtypes[NumDpids] = SI::AC3DescriptorTag; // backwards compatibility char *l = strchr(q, '='); if (l) { *l++ = 0; + char *t = strchr(l, '@'); + if (t) { + *t++ = 0; + dtypes[NumDpids] = strtol(t, NULL, 10); + } strn0cpy(dlangs[NumDpids], l, MAXLANGCODE2); } else @@ -614,6 +640,7 @@ bool cChannel::Parse(const char *s) p = NULL; } dpids[NumDpids] = 0; + dtypes[NumDpids] = 0; } if (caidbuf) { |