25 char *sourcebuf = NULL;
30 int fields = sscanf(s,
"%m[^-]-%d-%d-%d-%d", &sourcebuf, &
nid, &
tid, &
sid, &
rid);
142 switch (toupper(Polarization)) {
147 default:
esyslog(
"ERROR: invalid value for Polarization '%c'", Polarization);
159 const char *p = strpbrk(
parameters,
"HVLRhvlr");
238 if (Channels &&
Number()) {
239 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);
272 if (nn || ns || np) {
310 for (
int i = 0; a[i] || b[i]; i++) {
311 if (!a[i] || !b[i]) {
315 if (na && nb && strcmp(na[i], nb[i]) != 0)
327 while (a[i] || i == 0) {
328 q += sprintf(q, Base == 16 ?
"%s%X" :
"%s%d", i ?
"," :
"", a[i]);
329 const char *Delim =
"=";
332 q += sprintf(q,
"%s%s", Delim, n[i]);
336 q += sprintf(q,
"%s@%d", Delim, t[i]);
346bool 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)
353 int m =
IntArraysDiffer(
apids,
Apids,
alangs, ALangs) |
IntArraysDiffer(
atypes,
Atypes) |
IntArraysDiffer(
dpids,
Dpids,
dlangs, DLangs) |
IntArraysDiffer(
dtypes,
Dtypes) |
IntArraysDiffer(
spids,
Spids,
slangs, SLangs);
360 char OldApidsBuf[BufferSize];
361 char NewApidsBuf[BufferSize];
362 char *q = OldApidsBuf;
377 char OldSpidsBuf[SBufferSize];
378 char NewSpidsBuf[SBufferSize];
386 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);
390 for (
int i = 0; i <
MAXAPIDS; i++) {
396 for (
int i = 0; i <
MAXDPIDS; i++) {
402 for (
int i = 0; i <
MAXSPIDS; i++) {
416 bool Modified =
false;
417 if (SubtitlingTypes) {
418 for (
int i = 0; i <
MAXSPIDS; i++) {
424 for (
int i = 0; i <
MAXSPIDS; i++) {
430 for (
int i = 0; i <
MAXSPIDS; i++) {
447 if (lc->Channel() == LinkChannel) {
464 char OldCaIdsBuf[
MAXCAIDS * 5 + 10];
465 char NewCaIdsBuf[
MAXCAIDS * 5 + 10];
469 dsyslog(
"changing caids of channel %d (%s) from %s to %s",
Number(),
name, OldCaIdsBuf, NewCaIdsBuf);
470 for (
int i = 0; i <=
MAXCAIDS; i++) {
485 if (
Number() && Level > 1)
514 q += sprintf(q,
"linking channel %d (%s) from",
Number(),
name);
517 lc->Channel()->SetRefChannel(NULL);
518 q += sprintf(q,
" %d", lc->Channel()->Number());
523 q += sprintf(q,
" none");
524 q += sprintf(q,
" to");
528 lc->Channel()->SetRefChannel(
this);
529 q += sprintf(q,
" %d", lc->Channel()->Number());
534 q += sprintf(q,
" none");
554 char FullName[strlen(Channel->
name) + 1 + strlen(Channel->
shortName) + 1 + strlen(Channel->
provider) + 1 + 10];
556 q += sprintf(q,
"%s", Channel->
name);
559 q += sprintf(q,
",%s", Channel->
shortName);
560 else if (strchr(Channel->
name,
','))
561 q += sprintf(q,
",");
563 q += sprintf(q,
";%s", Channel->
provider);
577 q += snprintf(q,
sizeof(vpidbuf),
"%d", Channel->
vpid);
579 q += snprintf(q,
sizeof(vpidbuf) - (q - vpidbuf),
"+%d", Channel->
ppid);
581 q += snprintf(q,
sizeof(vpidbuf) - (q - vpidbuf),
"=%d", Channel->
vtype);
584 char apidbuf[ABufferSize];
587 if (Channel->
dpids[0]) {
593 char tpidbuf[TBufferSize];
595 q += snprintf(q,
sizeof(tpidbuf),
"%d", Channel->
tpid);
596 if (Channel->
spids[0]) {
604 buffer =
cString::sprintf(
"%s:%d:%s:%s:%d:%s:%s:%s:%s:%d:%d:%d:%d", FullName, Channel->
frequency, *Channel->
parameters, *
cSource::ToString(Channel->
source), Channel->
srate, vpidbuf, apidbuf, tpidbuf, caidbuf, Channel->
sid, Channel->
nid, Channel->
tid, Channel->
rid);
619 if (*++s ==
'@' && *++s) {
622 int n = strtol(s, &p, 10);
623 if (!errno && p != s && n > 0) {
633 char *namebuf = NULL;
634 char *sourcebuf = NULL;
635 char *parambuf = NULL;
636 char *vpidbuf = NULL;
637 char *apidbuf = NULL;
638 char *tpidbuf = NULL;
639 char *caidbuf = NULL;
640 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);
647 if (sscanf(tpidbuf,
"%d", &
tpid) != 1)
661 if (parambuf && sourcebuf && vpidbuf && apidbuf) {
667 if ((p = strchr(vpidbuf,
'=')) != NULL) {
669 if (sscanf(p,
"%d", &
vtype) != 1)
672 if ((p = strchr(vpidbuf,
'+')) != NULL) {
674 if (sscanf(p,
"%d", &
ppid) != 1)
677 if (sscanf(vpidbuf,
"%d", &
vpid) != 1)
684 char *dpidbuf = strchr(apidbuf,
';');
691 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
694 char *l = strchr(q,
'=');
697 char *t = strchr(l,
'@');
700 atypes[NumApids] = strtol(t, NULL, 10);
706 if ((
apids[NumApids] = strtol(q, NULL, 10)) != 0)
710 esyslog(
"ERROR: too many APIDs!");
720 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
723 char *l = strchr(q,
'=');
726 char *t = strchr(l,
'@');
729 dtypes[NumDpids] = strtol(t, NULL, 10);
735 if ((
dpids[NumDpids] = strtol(q, NULL, 10)) != 0)
739 esyslog(
"ERROR: too many DPIDs!");
746 if ((p = strchr(tpidbuf,
';')) != NULL) {
750 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
752 char *l = strchr(q,
'=');
759 spids[NumSpids++] = strtol(q, NULL, 10);
762 esyslog(
"ERROR: too many SPIDs!");
767 if (sscanf(tpidbuf,
"%d", &
tpid) != 1)
774 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
776 caids[NumCaIds++] = strtol(q, NULL, 16) & 0xFFFF;
781 esyslog(
"ERROR: too many CA ids!");
789 char *p = strchr(namebuf,
';');
794 p = strrchr(namebuf,
',');
810 esyslog(
"ERROR: channel data results in invalid ID!");
822 return fprintf(f,
"%s\n", *
ToText()) > 0;
868 if (!Channel->GroupSep())
871 ChannelSorter.
Sort();
907 while (Channel && !(Channel->
GroupSep() && *Channel->
Name()))
908 Channel =
Get(++Idx);
909 return Channel ? Idx : -1;
915 while (Channel && !(Channel->
GroupSep() && *Channel->
Name()))
916 Channel =
Get(--Idx);
917 return Channel ? Idx : -1;
923 while (Channel && Channel->
GroupSep())
924 Channel =
Get(++Idx);
925 return Channel ? Idx : -1;
931 while (Channel && Channel->
GroupSep())
932 Channel =
Get(--Idx);
933 return Channel ? Idx : -1;
942 if (Channel->GroupSep()) {
943 if (Channel->Number() > Number)
944 Number = Channel->Number();
949 Channel->SetNumber(Number++);
956 int Number = From->
Number();
957 if (Number < To->Number()) {
961 if (Channel->GroupSep()) {
962 if (Channel->Number() > Number)
963 Number = Channel->Number();
968 return Number == To->
Number();
977 ch->DelLinkChannel(Channel);
985 if (!Channel->GroupSep()) {
986 if (Channel->Number() == Number)
988 else if (SkipGap && Channel->Number() > Number)
989 return SkipGap > 0 ? Channel : Previous;
1011 int sid = ChannelID.
Sid();
1019 if (TryWithoutRid) {
1027 if (TryWithoutPolarization) {
1041 int source = ChannelID.
Source();
1042 int nid = ChannelID.
Nid();
1043 int tid = ChannelID.
Tid();
1045 if (Channel->Tid() == tid && Channel->Nid() == nid && Channel->Source() == source)
1055 if (!Channel->GroupSep() && Channel != OldChannel && Channel->
GetChannelID() == NewChannelID)
1071 for (
const cChannel *Channel = Channels->First(); Channel; Channel = Channels->
Next(Channel)) {
1072 if (!Channel->GroupSep())
1083 for (
const cChannel *Channel = Channels->First(); Channel; Channel = Channels->
Next(Channel)) {
1084 if (!Channel->GroupSep())
1107 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);
1120#define CHANNELMARKOBSOLETE "OBSOLETE"
1121#define CHANNELTIMEOBSOLETE 3600
1125 bool ChannelsModified =
false;
1127 if (time(NULL) - Channel->Seen() >
CHANNELTIMEOBSOLETE && Channel->Source() == Source && Channel->Nid() == Nid && Channel->Tid() == Tid && Channel->Rid() == 0) {
1132 return ChannelsModified;
1140 snprintf(buffer,
sizeof(buffer),
"%s", Channel->
Name());
1142 snprintf(buffer,
sizeof(buffer),
"%d%s %s", Channel->
Number(), Number ?
"-" :
"", Channel->
Name());
1145 snprintf(buffer,
sizeof(buffer),
"%d-", Number);
1147 snprintf(buffer,
sizeof(buffer),
"%s",
tr(
"*** Invalid Channel ***"));
#define CHANNELMARKOBSOLETE
static int IntArrayToString(char *s, const int *a, int Base=10, const char n[][MAXLANGCODE2]=NULL, const int *t=NULL)
#define CHANNELTIMEOBSOLETE
static int IntArraysDiffer(const int *a, const int *b, const char na[][MAXLANGCODE2]=NULL, const char nb[][MAXLANGCODE2]=NULL)
cString ChannelString(const cChannel *Channel, int Number)
#define CHANNELMOD_TRANSP
#define LOCK_CHANNELS_READ
#define ISTRANSPONDER(f1, f2)
#define LOCK_CHANNELS_WRITE
cChannelSorter(cChannel *Channel)
virtual int Compare(const cListObject &ListObject) const override
Must return 0 if this object is equal to ListObject, a positive value if it is "greater",...
const int * Dpids(void) const
const cChannel * RefChannel(void) const
bool Parse(const char *s)
const int * Atypes(void) const
static cString ToText(const cChannel *Channel)
cString TransponderDataToString(void) const
bool SetCaIds(const int *CaIds)
bool SetName(const char *Name, const char *ShortName, const char *Provider)
cString ToText(void) const
const uint16_t * CompositionPageIds(void) const
bool SetPortalName(const char *PortalName)
bool SetLinkChannels(cLinkChannels *LinkChannels)
const char * Name(void) const
tChannelID GetChannelID(void) const
bool 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 cSchedule * schedule
char alangs[MAXAPIDS][MAXLANGCODE2]
char dlangs[MAXDPIDS][MAXLANGCODE2]
bool GroupSep(void) const
const char * Parameters(void) const
const int * Dtypes(void) const
void CopyTransponderData(const cChannel *Channel)
int Frequency(void) const
Returns the actual frequency, as given in 'channels.conf'.
void SetRefChannel(cChannel *RefChannel)
const char * ShortName(bool OrName=false) const
bool SetTransponderData(int Source, int Frequency, int Srate, const char *Parameters, bool Quiet=false)
char slangs[MAXSPIDS][MAXLANGCODE2]
const char * PortalName(void) const
uchar subtitlingTypes[MAXSPIDS]
bool SetSource(int Source)
const int * Apids(void) const
bool SetId(cChannels *Channels, int Nid, int Tid, int Sid, int Rid=0)
int Modification(int Mask=CHANNELMOD_ALL) const
bool SetCaDescriptors(int Level)
cLinkChannels * linkChannels
int Transponder(void) const
Returns the transponder frequency in MHz, plus the polarization in case of sat.
uint16_t ancillaryPageIds[MAXSPIDS]
const uint16_t * AncillaryPageIds(void) const
void DelLinkChannel(cChannel *LinkChannel)
const char * Provider(void) const
bool SetSubtitlingDescriptors(uchar *SubtitlingTypes, uint16_t *CompositionPageIds, uint16_t *AncillaryPageIds)
const cLinkChannels * LinkChannels(void) const
void UpdateNameSource(void)
const int * Spids(void) const
uint16_t compositionPageIds[MAXSPIDS]
cChannel & operator=(const cChannel &Channel)
static cChannels * GetChannelsWrite(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of channels for write access.
void UnhashChannel(cChannel *Channel)
static int MaxChannelNameLength(void)
int GetNextGroup(int Idx) const
Get next channel group.
bool HasUniqueChannelID(const cChannel *NewChannel, const cChannel *OldChannel=NULL) const
bool MoveNeedsDecrement(cChannel *From, cChannel *To)
int GetPrevNormal(int Idx) const
Get previous normal channel (not group).
static int maxChannelNameLength
const cChannel * GetByServiceID(int Source, int Transponder, unsigned short ServiceID) const
bool ModifiedByUser(int &State) const
Returns true if the channels have been modified by the user since the last call to this function with...
static int MaxShortChannelNameLength(void)
static int maxShortChannelNameLength
void HashChannel(cChannel *Channel)
static const cChannels * GetChannelsRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of channels for read access.
cHash< cChannel > channelsHashSid
void ReNumber(void)
Recalculate 'number' based on channel type.
const cChannel * GetByNumber(int Number, int SkipGap=0) const
void SetModifiedByUser(void)
static cChannels channels
cChannel * NewChannel(const cChannel *Transponder, const char *Name, const char *ShortName, const char *Provider, int Nid, int Tid, int Sid, int Rid=0)
const cChannel * GetByTransponderID(tChannelID ChannelID) const
bool MarkObsoleteChannels(int Source, int Nid, int Tid)
const cChannel * GetByChannelID(tChannelID ChannelID, bool TryWithoutRid=false, bool TryWithoutPolarization=false) const
bool SwitchTo(int Number) const
void DeleteDuplicateChannels(void)
int GetPrevGroup(int Idx) const
Get previous channel group.
static bool Load(const char *FileName, bool AllowComments=false, bool MustExist=false)
void Del(cChannel *Channel)
Delete the given Channel from the list.
int GetNextNormal(int Idx) const
Get next normal channel (not group).
cConfig(const char *NeedsLocking=NULL)
const char * FileName(void)
static cDevice * PrimaryDevice(void)
Returns the primary device.
bool SwitchChannel(const cChannel *Channel, bool LiveView)
Switches the device to the given Channel, initiating transfer mode if necessary.
void Del(cListObject *Object, unsigned int Id)
cList< cHashObject > * GetList(unsigned int Id) const
void Add(cListObject *Object, unsigned int Id)
void Del(cListObject *Object, bool DeleteObject=true)
bool Lock(cStateKey &StateKey, bool Write=false, int TimeoutMs=0) const
Tries to get a lock on this list and returns true if successful.
void Add(cListObject *Object, cListObject *After=NULL)
cListObject(const cListObject &ListObject)
cListObject * Next(void) const
const T * First(void) const
Returns the first element in this list, or NULL if the list is empty.
cList(const char *NeedsLocking=NULL)
const T * Next(const T *Object) const
< Returns the element immediately before Object in this list, or NULL if Object is the first element ...
const cChannel * Get(int Index) const
int ShowChannelNamesWithSource
static int FromString(const char *s)
static bool IsTerr(int Code)
static cString ToString(int Code)
static char ToChar(int Code)
static cString sprintf(const char *fmt,...) __attribute__((format(printf
tChannelID & ClrRid(void)
static const tChannelID InvalidID
int nid
actually the "original" network id
static tChannelID FromString(const char *s)
cString ToString(void) const
tChannelID & ClrPolarization(void)