27 char *sourcebuf = NULL;
32 int fields = sscanf(s,
"%a[^-]-%d-%d-%d-%d", &sourcebuf, &nid, &tid, &sid, &rid);
33 if (fields == 4 || fields == 5) {
89 if (Channel->linkChannels) {
90 for (
cLinkChannel *lc = Channel->linkChannels->First(); lc; lc = Channel->linkChannels->
Next(lc)) {
91 if (lc->Channel() ==
this) {
92 Channel->linkChannels->
Del(lc);
96 if (Channel->linkChannels->Count() == 0) {
97 delete Channel->linkChannels;
98 Channel->linkChannels = NULL;
146 switch (toupper(Polarization)) {
147 case 'H': Frequency += 100000;
break;
148 case 'V': Frequency += 200000;
break;
149 case 'L': Frequency += 300000;
break;
150 case 'R': Frequency += 400000;
break;
151 default:
esyslog(
"ERROR: invalid value for Polarization '%c'", Polarization);
162 const char *p = strpbrk(
parameters,
"HVLRhvlr");
172 if (Timer->Channel() ==
this)
197 if (strchr(Parameters,
':')) {
198 esyslog(
"ERROR: parameter string '%s' contains ':'", Parameters);
210 if (abs(
srate - Srate) <= 1)
233 if (
nid != Nid ||
tid != Tid ||
sid != Sid ||
rid != Rid) {
253 bool nn = strcmp(
name, Name) != 0;
254 bool ns = strcmp(
shortName, ShortName) != 0;
255 bool np = strcmp(
provider, Provider) != 0;
256 if (nn || ns || np) {
294 for (
int i = 0; a[i] || b[i]; i++) {
295 if (!a[i] || !b[i]) {
299 if (na && nb && strcmp(na[i], nb[i]) != 0)
311 while (a[i] || i == 0) {
312 q += sprintf(q, Base == 16 ?
"%s%X" :
"%s%d", i ?
"," :
"", a[i]);
313 const char *Delim =
"=";
316 q += sprintf(q,
"%s%s", Delim, n[i]);
320 q += sprintf(q,
"%s@%d", Delim, t[i]);
330 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)
335 int m =
IntArraysDiffer(
apids, Apids,
alangs, ALangs) |
IntArraysDiffer(
atypes, Atypes) |
IntArraysDiffer(
dpids, Dpids,
dlangs, DLangs) |
IntArraysDiffer(
dtypes, Dtypes) |
IntArraysDiffer(
spids, Spids,
slangs, SLangs);
341 const int BufferSize = (
MAXAPIDS +
MAXDPIDS) * (5 + 1 + MAXLANGCODE2 + 5) + 10;
342 char OldApidsBuf[BufferSize];
343 char NewApidsBuf[BufferSize];
344 char *q = OldApidsBuf;
359 char OldSpidsBuf[SBufferSize];
360 char NewSpidsBuf[SBufferSize];
368 dsyslog(
"changing pids of channel %d from %d+%d=%d:%s:%s:%d to %d+%d=%d:%s:%s:%d",
Number(),
vpid,
ppid,
vtype, OldApidsBuf, OldSpidsBuf,
tpid, Vpid, Ppid, Vtype, NewApidsBuf, NewSpidsBuf, Tpid);
372 for (
int i = 0; i <
MAXAPIDS; i++) {
378 for (
int i = 0; i <
MAXDPIDS; i++) {
384 for (
int i = 0; i <
MAXSPIDS; i++) {
397 if (SubtitlingTypes) {
401 if (CompositionPageIds) {
405 if (AncillaryPageIds) {
436 char OldCaIdsBuf[
MAXCAIDS * 5 + 10];
437 char NewCaIdsBuf[
MAXCAIDS * 5 + 10];
441 dsyslog(
"changing caids of channel %d from %s to %s",
Number(), OldCaIdsBuf, NewCaIdsBuf);
442 for (
int i = 0; i <=
MAXCAIDS; i++) {
457 if (
Number() && Level > 1)
475 lcb = LinkChannels->
Next(lcb);
484 q += sprintf(q,
"linking channel %d from",
Number());
487 lc->Channel()->SetRefChannel(NULL);
488 q += sprintf(q,
" %d", lc->Channel()->Number());
493 q += sprintf(q,
" none");
494 q += sprintf(q,
" to");
498 lc->Channel()->SetRefChannel(
this);
499 q += sprintf(q,
" %d", lc->Channel()->Number());
504 q += sprintf(q,
" none");
523 char FullName[strlen(Channel->
name) + 1 + strlen(Channel->
shortName) + 1 + strlen(Channel->
provider) + 1 + 10];
525 q += sprintf(q,
"%s", Channel->
name);
528 q += sprintf(q,
",%s", Channel->
shortName);
529 else if (strchr(Channel->
name,
','))
530 q += sprintf(q,
",");
532 q += sprintf(q,
";%s", Channel->
provider);
546 q += snprintf(q,
sizeof(vpidbuf),
"%d", Channel->
vpid);
548 q += snprintf(q,
sizeof(vpidbuf) - (q - vpidbuf),
"+%d", Channel->
ppid);
550 q += snprintf(q,
sizeof(vpidbuf) - (q - vpidbuf),
"=%d", Channel->
vtype);
553 char apidbuf[ABufferSize];
556 if (Channel->
dpids[0]) {
562 char tpidbuf[TBufferSize];
564 q += snprintf(q,
sizeof(tpidbuf),
"%d", Channel->
tpid);
572 if (Channel->
spids[0]) {
580 buffer =
cString::sprintf(
"%s:%d:%s:%s:%d:%s:%s:%s:%s:%d:%d:%d:%d\n", FullName, Channel->
frequency, *Channel->
parameters, *
cSource::ToString(Channel->
source), Channel->
srate, vpidbuf, apidbuf, tpidbuf, caidbuf, Channel->
sid, Channel->
nid, Channel->
tid, Channel->
rid);
595 if (*++s ==
'@' && *++s) {
598 int n = strtol(s, &p, 10);
599 if (!errno && p != s && n > 0) {
609 char *namebuf = NULL;
610 char *sourcebuf = NULL;
611 char *parambuf = NULL;
612 char *vpidbuf = NULL;
613 char *apidbuf = NULL;
614 char *tpidbuf = NULL;
615 char *caidbuf = NULL;
616 int fields = sscanf(s,
"%a[^:]:%d :%a[^:]:%a[^:] :%d :%a[^:]:%a[^:]:%a[^:]:%a[^:]:%d :%d :%d :%d ", &namebuf, &
frequency, ¶mbuf, &sourcebuf, &
srate, &vpidbuf, &apidbuf, &tpidbuf, &caidbuf, &
sid, &
nid, &
tid, &
rid);
623 if (sscanf(tpidbuf,
"%d", &
tpid) != 1)
637 if (parambuf && sourcebuf && vpidbuf && apidbuf) {
642 if ((p = strchr(vpidbuf,
'=')) != NULL) {
644 if (sscanf(p,
"%d", &
vtype) != 1)
647 if ((p = strchr(vpidbuf,
'+')) != NULL) {
649 if (sscanf(p,
"%d", &
ppid) != 1)
652 if (sscanf(vpidbuf,
"%d", &
vpid) != 1)
659 char *dpidbuf = strchr(apidbuf,
';');
666 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
669 char *l = strchr(q,
'=');
672 char *t = strchr(l,
'@');
675 atypes[NumApids] = strtol(t, NULL, 10);
681 if ((
apids[NumApids] = strtol(q, NULL, 10)) != 0)
685 esyslog(
"ERROR: too many APIDs!");
695 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
698 char *l = strchr(q,
'=');
701 char *t = strchr(l,
'@');
704 dtypes[NumDpids] = strtol(t, NULL, 10);
710 if ((
dpids[NumDpids] = strtol(q, NULL, 10)) != 0)
714 esyslog(
"ERROR: too many DPIDs!");
721 if ((p = strchr(tpidbuf,
';')) != NULL) {
725 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
727 char *l = strchr(q,
'=');
734 spids[NumSpids++] = strtol(q, NULL, 10);
737 esyslog(
"ERROR: too many SPIDs!");
743 if ((p = strchr(tpidbuf,
'+')) != NULL) {
747 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
750 char *l = strchr(q,
'=');
753 if (sscanf(q,
"%d", &page) == 1) {
760 esyslog(
"ERROR: invalid Teletext page!");
763 esyslog(
"ERROR: too many Teletext pages!");
768 if (sscanf(tpidbuf,
"%d", &
tpid) != 1)
775 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
777 caids[NumCaIds++] = strtol(q, NULL, 16) & 0xFFFF;
782 esyslog(
"ERROR: too many CA ids!");
790 char *p = strchr(namebuf,
';');
795 p = strrchr(namebuf,
',');
812 esyslog(
"ERROR: channel data results in invalid ID!");
824 return fprintf(f,
"%s", *
ToText()) > 0;
859 if (!channel->GroupSep())
862 ChannelSorter.
Sort();
897 while (channel && !(channel->
GroupSep() && *channel->
Name()))
898 channel =
Get(++Idx);
899 return channel ? Idx : -1;
905 while (channel && !(channel->
GroupSep() && *channel->
Name()))
906 channel =
Get(--Idx);
907 return channel ? Idx : -1;
913 while (channel && channel->
GroupSep())
914 channel =
Get(++Idx);
915 return channel ? Idx : -1;
921 while (channel && channel->
GroupSep())
922 channel =
Get(--Idx);
923 return channel ? Idx : -1;
932 if (channel->GroupSep()) {
933 if (channel->Number() > Number)
934 Number = channel->Number();
939 channel->SetNumber(Number++);
948 if (!channel->GroupSep()) {
949 if (channel->Number() == Number)
951 else if (SkipGap && channel->Number() > Number)
952 return SkipGap > 0 ? channel : previous;
974 int sid = ChannelID.
Sid();
990 if (TryWithoutPolarization) {
1003 int source = ChannelID.
Source();
1004 int nid = ChannelID.
Nid();
1005 int tid = ChannelID.
Tid();
1007 if (channel->Tid() == tid && channel->Nid() == nid && channel->Source() == source)
1017 if (!channel->GroupSep() && channel != OldChannel && channel->
GetChannelID() == NewChannelID)
1033 if (!channel->GroupSep())
1044 if (!channel->GroupSep())
1067 dsyslog(
"creating new channel '%s,%s;%s' on %s transponder %d with id %d-%d-%d-%d", Name, ShortName, Provider, *
cSource::ToString(Transponder->
Source()), Transponder->
Transponder(), Nid, Tid, Sid, Rid);
1070 NewChannel->SetId(Nid, Tid, Sid, Rid);
1071 NewChannel->SetName(Name, ShortName, Provider);
1084 snprintf(buffer,
sizeof(buffer),
"%s", Channel->
Name());
1086 snprintf(buffer,
sizeof(buffer),
"%d%s %s", Channel->
Number(), Number ?
"-" :
"", Channel->
Name());
1089 snprintf(buffer,
sizeof(buffer),
"%d-", Number);
1091 snprintf(buffer,
sizeof(buffer),
"%s",
tr(
"*** Invalid Channel ***"));
static cString ToString(int Code)
void SetId(int Nid, int Tid, int Sid, int Rid=0)
int Modified(void)
Returns 0 if no channels have been modified, 1 if an automatic modification has been made...
static char ToChar(int Code)
static tChannelID FromString(const char *s)
int GetPrevGroup(int Idx)
int MaxShortChannelNameLength(void)
const cLinkChannels * LinkChannels(void) const
void CopyTransponderData(const cChannel *Channel)
cList< cHashObject > * GetList(unsigned int Id) const
uint16_t compositionPageIds[MAXSPIDS]
void Add(cListObject *Object, cListObject *After=NULL)
static cString ToText(const cChannel *Channel)
uint16_t ancillaryPageIds[MAXSPIDS]
static cString sprintf(const char *fmt,...) __attribute__((format(printf
#define CHANNELMOD_TRANSP
void Del(cListObject *Object, unsigned int Id)
static bool IsTerr(int Code)
uchar subtitlingTypes[MAXSPIDS]
cChannel * Get(int Index) const
const char * ShortName(bool OrName=false) const
cChannel & operator=(const cChannel &Channel)
bool GroupSep(void) const
tChannelID & ClrPolarization(void)
int MaxChannelNameLength(void)
int nid
actually the "original" network id
cString ChannelString(const cChannel *Channel, int Number)
int Transponder(void) const
Returns the transponder frequency in MHz, plus the polarization in case of sat.
const cSchedule * schedule
int totalTtxtSubtitlePages
int maxShortChannelNameLength
const char * Parameters(void) const
bool Load(const char *FileName, bool AllowComments=false, bool MustExist=false)
bool SetTransponderData(int Source, int Frequency, int Srate, const char *Parameters, bool Quiet=false)
const char * Name(void) const
cChannel * NewChannel(const cChannel *Transponder, const char *Name, const char *ShortName, const char *Provider, int Nid, int Tid, int Sid, int Rid=0)
T * Next(const T *object) const
void SetName(const char *Name, const char *ShortName, const char *Provider)
void SetTeletextSubtitlePages(tTeletextSubtitlePage pages[], int numberOfPages)
#define ISTRANSPONDER(f1, f2)
virtual int Compare(const cListObject &ListObject) const
Must return 0 if this object is equal to ListObject, a positive value if it is "greater", and a negative value if it is "smaller".
char alangs[MAXAPIDS][MAXLANGCODE2]
bool Parse(const char *s)
cListObject * Next(void) const
bool SwitchChannel(const cChannel *Channel, bool LiveView)
Switches the device to the given Channel, initiating transfer mode if necessary.
int GetNextNormal(int Idx)
int GetPrevNormal(int Idx)
void SetCaDescriptors(int Level)
char dlangs[MAXDPIDS][MAXLANGCODE2]
tChannelID GetChannelID(void) const
void SetModified(bool ByUser=false)
int GetNextGroup(int Idx)
cString TransponderDataToString(void) const
cChannel * GetByServiceID(int Source, int Transponder, unsigned short ServiceID)
const cChannel * RefChannel(void) const
int Frequency(void) const
Returns the actual frequency, as given in 'channels.conf'.
static int IntArrayToString(char *s, const int *a, int Base=10, const char n[][MAXLANGCODE2]=NULL, const int *t=NULL)
void SetSubtitlingDescriptors(uchar *SubtitlingTypes, uint16_t *CompositionPageIds, uint16_t *AncillaryPageIds)
cChannel * GetByChannelID(tChannelID ChannelID, bool TryWithoutRid=false, bool TryWithoutPolarization=false)
bool HasTimer(void) const
char ttxtLanguage[MAXLANGCODE1]
void SetLinkChannels(cLinkChannels *LinkChannels)
bool HasUniqueChannelID(cChannel *NewChannel, cChannel *OldChannel=NULL)
void Del(cListObject *Object, bool DeleteObject=true)
cString ToString(void) const
void SetRefChannel(cChannel *RefChannel)
int ShowChannelNamesWithSource
cChannel * GetByNumber(int Number, int SkipGap=0)
tTeletextSubtitlePage teletextSubtitlePages[MAXTXTPAGES]
int PageNumber(void) const
static cDevice * PrimaryDevice(void)
Returns the primary device.
void DeleteDuplicateChannels(void)
static int FromString(const char *s)
static int IntArraysDiffer(const int *a, const int *b, const char na[][MAXLANGCODE2]=NULL, const char nb[][MAXLANGCODE2]=NULL)
char slangs[MAXSPIDS][MAXLANGCODE2]
void Add(cListObject *Object, unsigned int Id)
cHash< cChannel > channelsHashSid
cChannel * GetByTransponderID(tChannelID ChannelID)
static const tChannelID InvalidID
int Modification(int Mask=CHANNELMOD_ALL)
bool SwitchTo(int Number)
void UnhashChannel(cChannel *Channel)
cChannelSorter(cChannel *Channel)
void 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)
void SetPortalName(const char *PortalName)
tChannelID & ClrRid(void)
cLinkChannels * linkChannels
void SetCaIds(const int *CaIds)
cString ToText(void) const
int fixedTtxtSubtitlePages
void HashChannel(cChannel *Channel)