27 char *sourcebuf = NULL;
32 int fields = sscanf(s,
"%m[^-]-%d-%d-%d-%d", &sourcebuf, &
nid, &
tid, &
sid, &
rid);
33 if (fields == 4 || fields == 5) {
90 if (Channel->linkChannels) {
91 for (
cLinkChannel *lc = Channel->linkChannels->First(); lc; lc = Channel->linkChannels->
Next(lc)) {
92 if (lc->Channel() ==
this) {
93 Channel->linkChannels->
Del(lc);
97 if (Channel->linkChannels->Count() == 0) {
98 delete Channel->linkChannels;
99 Channel->linkChannels = NULL;
147 switch (toupper(Polarization)) {
152 default:
esyslog(
"ERROR: invalid value for Polarization '%c'", Polarization);
163 const char *p = strpbrk(
parameters,
"HVLRhvlr");
173 if (Timer->Channel() ==
this)
236 dsyslog(
"changing id of channel %d (%s) from %d-%d-%d-%d to %d-%d-%d-%d",
Number(),
name,
nid,
tid,
sid,
rid,
Nid,
Tid,
Sid,
Rid);
266 if (nn || ns || np) {
304 for (
int i = 0; a[i] || b[i]; i++) {
305 if (!a[i] || !b[i]) {
309 if (na && nb && strcmp(na[i], nb[i]) != 0)
321 while (a[i] || i == 0) {
322 q += sprintf(q, Base == 16 ?
"%s%X" :
"%s%d", i ?
"," :
"", a[i]);
323 const char *Delim =
"=";
326 q += sprintf(q,
"%s%s", Delim, n[i]);
330 q += sprintf(q,
"%s@%d", Delim, t[i]);
340 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)
347 int m =
IntArraysDiffer(
apids,
Apids,
alangs, ALangs) |
IntArraysDiffer(
atypes, Atypes) |
IntArraysDiffer(
dpids,
Dpids,
dlangs, DLangs) |
IntArraysDiffer(
dtypes, Dtypes) |
IntArraysDiffer(
spids,
Spids,
slangs, SLangs);
354 char OldApidsBuf[BufferSize];
355 char NewApidsBuf[BufferSize];
356 char *q = OldApidsBuf;
371 char OldSpidsBuf[SBufferSize];
372 char NewSpidsBuf[SBufferSize];
380 dsyslog(
"changing pids of channel %d (%s) from %d+%d=%d:%s:%s:%d to %d+%d=%d:%s:%s:%d",
Number(),
name,
vpid,
ppid,
vtype, OldApidsBuf, OldSpidsBuf,
tpid,
Vpid,
Ppid,
Vtype, NewApidsBuf, NewSpidsBuf,
Tpid);
384 for (
int i = 0; i <
MAXAPIDS; i++) {
390 for (
int i = 0; i <
MAXDPIDS; i++) {
396 for (
int i = 0; i <
MAXSPIDS; i++) {
410 if (SubtitlingTypes) {
414 if (CompositionPageIds) {
418 if (AncillaryPageIds) {
434 char OldCaIdsBuf[
MAXCAIDS * 5 + 10];
435 char NewCaIdsBuf[
MAXCAIDS * 5 + 10];
439 dsyslog(
"changing caids of channel %d (%s) from %s to %s",
Number(),
name, OldCaIdsBuf, NewCaIdsBuf);
440 for (
int i = 0; i <=
MAXCAIDS; i++) {
455 if (
Number() && Level > 1)
482 q += sprintf(q,
"linking channel %d (%s) from",
Number(),
name);
485 lc->Channel()->SetRefChannel(NULL);
486 q += sprintf(q,
" %d", lc->Channel()->Number());
491 q += sprintf(q,
" none");
492 q += sprintf(q,
" to");
496 lc->Channel()->SetRefChannel(
this);
497 q += sprintf(q,
" %d", lc->Channel()->Number());
502 q += sprintf(q,
" none");
521 char FullName[strlen(Channel->
name) + 1 + strlen(Channel->
shortName) + 1 + strlen(Channel->
provider) + 1 + 10];
523 q += sprintf(q,
"%s", Channel->
name);
526 q += sprintf(q,
",%s", Channel->
shortName);
527 else if (strchr(Channel->
name,
','))
528 q += sprintf(q,
",");
530 q += sprintf(q,
";%s", Channel->
provider);
544 q += snprintf(q,
sizeof(vpidbuf),
"%d", Channel->
vpid);
546 q += snprintf(q,
sizeof(vpidbuf) - (q - vpidbuf),
"+%d", Channel->
ppid);
548 q += snprintf(q,
sizeof(vpidbuf) - (q - vpidbuf),
"=%d", Channel->
vtype);
551 char apidbuf[ABufferSize];
554 if (Channel->
dpids[0]) {
560 char tpidbuf[TBufferSize];
562 q += snprintf(q,
sizeof(tpidbuf),
"%d", Channel->
tpid);
563 if (Channel->
spids[0]) {
571 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);
586 if (*++s ==
'@' && *++s) {
589 int n = strtol(s, &p, 10);
590 if (!errno && p != s && n > 0) {
600 char *namebuf = NULL;
601 char *sourcebuf = NULL;
602 char *parambuf = NULL;
603 char *vpidbuf = NULL;
604 char *apidbuf = NULL;
605 char *tpidbuf = NULL;
606 char *caidbuf = NULL;
607 int fields = sscanf(s,
"%m[^:]:%d :%m[^:]:%m[^:] :%d :%m[^:]:%m[^:]:%m[^:]:%m[^:]:%d :%d :%d :%d ", &namebuf, &
frequency, ¶mbuf, &sourcebuf, &
srate, &vpidbuf, &apidbuf, &tpidbuf, &caidbuf, &
sid, &
nid, &
tid, &
rid);
614 if (sscanf(tpidbuf,
"%d", &
tpid) != 1)
628 if (parambuf && sourcebuf && vpidbuf && apidbuf) {
633 if ((p = strchr(vpidbuf,
'=')) != NULL) {
635 if (sscanf(p,
"%d", &
vtype) != 1)
638 if ((p = strchr(vpidbuf,
'+')) != NULL) {
640 if (sscanf(p,
"%d", &
ppid) != 1)
643 if (sscanf(vpidbuf,
"%d", &
vpid) != 1)
650 char *dpidbuf = strchr(apidbuf,
';');
657 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
660 char *l = strchr(q,
'=');
663 char *t = strchr(l,
'@');
666 atypes[NumApids] = strtol(t, NULL, 10);
672 if ((
apids[NumApids] = strtol(q, NULL, 10)) != 0)
676 esyslog(
"ERROR: too many APIDs!");
686 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
689 char *l = strchr(q,
'=');
692 char *t = strchr(l,
'@');
695 dtypes[NumDpids] = strtol(t, NULL, 10);
701 if ((
dpids[NumDpids] = strtol(q, NULL, 10)) != 0)
705 esyslog(
"ERROR: too many DPIDs!");
712 if ((p = strchr(tpidbuf,
';')) != NULL) {
716 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
718 char *l = strchr(q,
'=');
725 spids[NumSpids++] = strtol(q, NULL, 10);
728 esyslog(
"ERROR: too many SPIDs!");
733 if (sscanf(tpidbuf,
"%d", &
tpid) != 1)
740 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
742 caids[NumCaIds++] = strtol(q, NULL, 16) & 0xFFFF;
747 esyslog(
"ERROR: too many CA ids!");
755 char *p = strchr(namebuf,
';');
760 p = strrchr(namebuf,
',');
777 esyslog(
"ERROR: channel data results in invalid ID!");
789 return fprintf(f,
"%s", *
ToText()) > 0;
824 if (!channel->GroupSep())
827 ChannelSorter.
Sort();
862 while (channel && !(channel->
GroupSep() && *channel->
Name()))
863 channel =
Get(++Idx);
864 return channel ? Idx : -1;
870 while (channel && !(channel->
GroupSep() && *channel->
Name()))
871 channel =
Get(--Idx);
872 return channel ? Idx : -1;
878 while (channel && channel->
GroupSep())
879 channel =
Get(++Idx);
880 return channel ? Idx : -1;
886 while (channel && channel->
GroupSep())
887 channel =
Get(--Idx);
888 return channel ? Idx : -1;
897 if (channel->GroupSep()) {
898 if (channel->Number() > Number)
899 Number = channel->Number();
904 channel->SetNumber(Number++);
913 if (!channel->GroupSep()) {
914 if (channel->Number() == Number)
916 else if (SkipGap && channel->Number() > Number)
917 return SkipGap > 0 ? channel : previous;
939 int sid = ChannelID.
Sid();
955 if (TryWithoutPolarization) {
968 int source = ChannelID.
Source();
969 int nid = ChannelID.
Nid();
970 int tid = ChannelID.
Tid();
972 if (channel->Tid() == tid && channel->Nid() == nid && channel->Source() == source)
982 if (!channel->GroupSep() && channel != OldChannel && channel->
GetChannelID() == NewChannelID)
998 if (!channel->GroupSep())
1009 if (!channel->GroupSep())
1032 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);
1045 #define CHANNELMARKOBSOLETE "OBSOLETE" 1046 #define CHANNELTIMEOBSOLETE 3600 // seconds to wait before declaring a channel obsolete (in case it has actually been seen before) 1051 if (time(NULL) - channel->Seen() >
CHANNELTIMEOBSOLETE && channel->Source() == Source && channel->Nid() == Nid && channel->Tid() == Tid && channel->Rid() == 0) {
1066 snprintf(buffer,
sizeof(buffer),
"%s", Channel->
Name());
1068 snprintf(buffer,
sizeof(buffer),
"%d%s %s", Channel->
Number(), Number ?
"-" :
"", Channel->
Name());
1071 snprintf(buffer,
sizeof(buffer),
"%d-", Number);
1073 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...
#define CHANNELTIMEOBSOLETE
cString TransponderDataToString(void) const
static char ToChar(int Code)
static tChannelID FromString(const char *s)
const char * Provider(void) const
int GetPrevGroup(int Idx)
int MaxShortChannelNameLength(void)
void CopyTransponderData(const cChannel *Channel)
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)
void MarkObsoleteChannels(int Source, int Nid, int Tid)
uchar subtitlingTypes[MAXSPIDS]
const cLinkChannels * LinkChannels(void) const
cChannel & operator=(const cChannel &Channel)
tChannelID & ClrPolarization(void)
cList< cHashObject > * GetList(unsigned int Id) const
const int * Spids(void) const
int MaxChannelNameLength(void)
int nid
actually the "original" network id
cString ChannelString(const cChannel *Channel, int Number)
const cSchedule * schedule
const char * FileName(void)
const char * PortalName(void) const
int maxShortChannelNameLength
const int * Apids(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)
int Transponder(void) const
Returns the transponder frequency in MHz, plus the polarization in case of sat.
cChannel * NewChannel(const cChannel *Transponder, const char *Name, const char *ShortName, const char *Provider, int Nid, int Tid, int Sid, int Rid=0)
void SetName(const char *Name, const char *ShortName, const char *Provider)
const int * Dpids(void) const
#define ISTRANSPONDER(f1, f2)
char alangs[MAXAPIDS][MAXLANGCODE2]
bool Parse(const char *s)
cString ToString(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)
T * Next(const T *object) const
bool GroupSep(void) const
const cChannel * RefChannel(void) const
int GetPrevNormal(int Idx)
void SetCaDescriptors(int Level)
char dlangs[MAXDPIDS][MAXLANGCODE2]
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".
void SetModified(bool ByUser=false)
int GetNextGroup(int Idx)
cChannel * GetByServiceID(int Source, int Transponder, unsigned short ServiceID)
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)
cChannel * Get(int Index) const
const char * Name(void) const
void SetLinkChannels(cLinkChannels *LinkChannels)
bool HasUniqueChannelID(cChannel *NewChannel, cChannel *OldChannel=NULL)
void Del(cListObject *Object, bool DeleteObject=true)
void SetRefChannel(cChannel *RefChannel)
int ShowChannelNamesWithSource
cChannel * GetByNumber(int Number, int SkipGap=0)
static cDevice * PrimaryDevice(void)
Returns the primary device.
void DeleteDuplicateChannels(void)
tChannelID GetChannelID(void) const
int Frequency(void) const
Returns the actual frequency, as given in 'channels.conf'.
static int FromString(const char *s)
cListObject * Next(void) const
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)
cString ToText(void) const
bool HasTimer(void) const
cChannelSorter(cChannel *Channel)
const char * ShortName(bool OrName=false) const
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)
const char * Parameters(void) const
void SetPortalName(const char *PortalName)
tChannelID & ClrRid(void)
cLinkChannels * linkChannels
#define CHANNELMARKOBSOLETE
void SetCaIds(const int *CaIds)
void HashChannel(cChannel *Channel)