2002-10-06 10:25:42 +02:00
|
|
|
/*
|
|
|
|
* channels.h: Channel handling
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2007-10-12 14:52:30 +02:00
|
|
|
* $Id: channels.h 1.45 2007/09/02 10:23:11 kls Exp $
|
2002-10-06 10:25:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CHANNELS_H
|
|
|
|
#define __CHANNELS_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "sources.h"
|
2004-01-04 12:30:00 +01:00
|
|
|
#include "thread.h"
|
2002-10-06 10:25:42 +02:00
|
|
|
#include "tools.h"
|
|
|
|
|
|
|
|
#define ISTRANSPONDER(f1, f2) (abs((f1) - (f2)) < 4) //XXX
|
|
|
|
|
2004-01-04 12:30:00 +01:00
|
|
|
#define CHANNELMOD_NONE 0x00
|
|
|
|
#define CHANNELMOD_ALL 0xFF
|
|
|
|
#define CHANNELMOD_NAME 0x01
|
|
|
|
#define CHANNELMOD_PIDS 0x02
|
|
|
|
#define CHANNELMOD_ID 0x04
|
|
|
|
#define CHANNELMOD_CA 0x10
|
2004-01-11 15:54:37 +01:00
|
|
|
#define CHANNELMOD_TRANSP 0x20
|
2005-05-07 13:15:34 +02:00
|
|
|
#define CHANNELMOD_LANGS 0x40
|
2004-01-11 15:54:37 +01:00
|
|
|
#define CHANNELMOD_RETUNE (CHANNELMOD_PIDS | CHANNELMOD_CA | CHANNELMOD_TRANSP)
|
2004-01-04 12:30:00 +01:00
|
|
|
|
2004-10-17 11:50:21 +02:00
|
|
|
#define CHANNELSMOD_NONE 0
|
|
|
|
#define CHANNELSMOD_AUTO 1
|
|
|
|
#define CHANNELSMOD_USER 2
|
|
|
|
|
2005-01-16 14:40:47 +01:00
|
|
|
#define MAXAPIDS 32 // audio
|
2005-02-20 14:07:52 +01:00
|
|
|
#define MAXDPIDS 16 // dolby (AC3 + DTS)
|
2007-10-12 14:52:30 +02:00
|
|
|
#define MAXSPIDS 32 // subtitles
|
2005-01-16 14:40:47 +01:00
|
|
|
#define MAXCAIDS 8 // conditional access
|
2004-01-04 12:30:00 +01:00
|
|
|
|
2005-09-04 14:48:39 +02:00
|
|
|
#define MAXLANGCODE1 4 // a 3 letter language code, zero terminated
|
|
|
|
#define MAXLANGCODE2 8 // up to two 3 letter language codes, separated by '+' and zero terminated
|
|
|
|
|
2006-01-07 14:10:17 +01:00
|
|
|
#define CA_FTA 0x0000
|
|
|
|
#define CA_DVB_MIN 0x0001
|
|
|
|
#define CA_DVB_MAX 0x000F
|
|
|
|
#define CA_USER_MIN 0x0010
|
|
|
|
#define CA_USER_MAX 0x00FF
|
|
|
|
#define CA_ENCRYPTED_MIN 0x0100
|
|
|
|
#define CA_ENCRYPTED_MAX 0xFFFF
|
|
|
|
|
2002-10-06 10:25:42 +02:00
|
|
|
struct tChannelParameterMap {
|
|
|
|
int userValue;
|
|
|
|
int driverValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
//XXX into cChannel???
|
|
|
|
int MapToUser(int Value, const tChannelParameterMap *Map);
|
|
|
|
int MapToDriver(int Value, const tChannelParameterMap *Map);
|
|
|
|
int UserIndex(int Value, const tChannelParameterMap *Map);
|
|
|
|
int DriverIndex(int Value, const tChannelParameterMap *Map);
|
|
|
|
|
|
|
|
extern const tChannelParameterMap InversionValues[];
|
|
|
|
extern const tChannelParameterMap BandwidthValues[];
|
|
|
|
extern const tChannelParameterMap CoderateValues[];
|
|
|
|
extern const tChannelParameterMap ModulationValues[];
|
|
|
|
extern const tChannelParameterMap TransmissionValues[];
|
|
|
|
extern const tChannelParameterMap GuardValues[];
|
|
|
|
extern const tChannelParameterMap HierarchyValues[];
|
|
|
|
|
2002-11-24 14:48:38 +01:00
|
|
|
struct tChannelID {
|
|
|
|
private:
|
|
|
|
int source;
|
2006-02-19 14:41:15 +01:00
|
|
|
int nid; ///< actually the "original" network id
|
2002-11-24 14:48:38 +01:00
|
|
|
int tid;
|
|
|
|
int sid;
|
|
|
|
int rid;
|
|
|
|
public:
|
|
|
|
tChannelID(void) { source = nid = tid = sid = rid = 0; }
|
|
|
|
tChannelID(int Source, int Nid, int Tid, int Sid, int Rid = 0) { source = Source; nid = Nid; tid = Tid; sid = Sid; rid = Rid; }
|
2005-05-26 11:25:36 +02:00
|
|
|
bool operator== (const tChannelID &arg) const { return source == arg.source && nid == arg.nid && tid == arg.tid && sid == arg.sid && rid == arg.rid; }
|
2005-05-28 09:53:54 +02:00
|
|
|
bool Valid(void) const { return (nid || tid) && sid; } // rid is optional and source may be 0//XXX source may not be 0???
|
2002-11-24 14:48:38 +01:00
|
|
|
tChannelID &ClrRid(void) { rid = 0; return *this; }
|
2004-02-13 15:50:26 +01:00
|
|
|
tChannelID &ClrPolarization(void);
|
2005-09-11 13:23:49 +02:00
|
|
|
int Source(void) { return source; }
|
|
|
|
int Nid(void) { return nid; }
|
|
|
|
int Tid(void) { return tid; }
|
|
|
|
int Sid(void) { return sid; }
|
|
|
|
int Rid(void) { return rid; }
|
2002-11-24 14:48:38 +01:00
|
|
|
static tChannelID FromString(const char *s);
|
2005-05-28 09:53:54 +02:00
|
|
|
cString ToString(void) const;
|
2002-11-24 14:48:38 +01:00
|
|
|
static const tChannelID InvalidID;
|
|
|
|
};
|
|
|
|
|
2004-02-08 11:05:22 +01:00
|
|
|
class cChannel;
|
|
|
|
|
|
|
|
class cLinkChannel : public cListObject {
|
|
|
|
private:
|
|
|
|
cChannel *channel;
|
|
|
|
public:
|
|
|
|
cLinkChannel(cChannel *Channel) { channel = Channel; }
|
|
|
|
cChannel *Channel(void) { return channel; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class cLinkChannels : public cList<cLinkChannel> {
|
|
|
|
};
|
|
|
|
|
2006-01-14 15:52:40 +01:00
|
|
|
class cSchedule;
|
|
|
|
|
2002-10-06 10:25:42 +02:00
|
|
|
class cChannel : public cListObject {
|
2006-01-14 15:52:40 +01:00
|
|
|
friend class cSchedules;
|
2002-10-06 10:25:42 +02:00
|
|
|
friend class cMenuEditChannel;
|
|
|
|
private:
|
2004-12-26 12:45:22 +01:00
|
|
|
static cString ToText(const cChannel *Channel);
|
2004-10-31 12:53:00 +01:00
|
|
|
char *name;
|
|
|
|
char *shortName;
|
|
|
|
char *provider;
|
2004-10-31 13:01:35 +01:00
|
|
|
char *portalName;
|
2002-11-10 15:50:21 +01:00
|
|
|
int __BeginData__;
|
2002-10-06 10:25:42 +02:00
|
|
|
int frequency; // MHz
|
|
|
|
int source;
|
|
|
|
int srate;
|
|
|
|
int vpid;
|
2003-04-26 11:58:54 +02:00
|
|
|
int ppid;
|
2004-01-25 15:32:08 +01:00
|
|
|
int apids[MAXAPIDS + 1]; // list is zero-terminated
|
2005-09-04 14:48:39 +02:00
|
|
|
char alangs[MAXAPIDS][MAXLANGCODE2];
|
2005-01-16 14:40:47 +01:00
|
|
|
int dpids[MAXDPIDS + 1]; // list is zero-terminated
|
2005-09-04 14:48:39 +02:00
|
|
|
char dlangs[MAXDPIDS][MAXLANGCODE2];
|
2005-01-16 14:40:47 +01:00
|
|
|
int spids[MAXSPIDS + 1]; // list is zero-terminated
|
2005-09-04 14:48:39 +02:00
|
|
|
char slangs[MAXSPIDS][MAXLANGCODE2];
|
2002-10-06 10:25:42 +02:00
|
|
|
int tpid;
|
2004-01-04 12:30:00 +01:00
|
|
|
int caids[MAXCAIDS + 1]; // list is zero-terminated
|
2002-11-24 14:48:38 +01:00
|
|
|
int nid;
|
|
|
|
int tid;
|
2002-10-06 10:25:42 +02:00
|
|
|
int sid;
|
2002-11-24 14:48:38 +01:00
|
|
|
int rid;
|
2002-10-06 10:25:42 +02:00
|
|
|
int number; // Sequence number assigned on load
|
|
|
|
bool groupSep;
|
|
|
|
char polarization;
|
|
|
|
int inversion;
|
|
|
|
int bandwidth;
|
|
|
|
int coderateH;
|
|
|
|
int coderateL;
|
|
|
|
int modulation;
|
|
|
|
int transmission;
|
|
|
|
int guard;
|
|
|
|
int hierarchy;
|
2002-11-10 15:50:21 +01:00
|
|
|
int __EndData__;
|
2004-01-04 12:30:00 +01:00
|
|
|
int modification;
|
2006-01-14 15:52:40 +01:00
|
|
|
mutable const cSchedule *schedule;
|
2004-02-08 11:05:22 +01:00
|
|
|
cLinkChannels *linkChannels;
|
|
|
|
cChannel *refChannel;
|
2004-12-26 12:45:22 +01:00
|
|
|
cString ParametersToString(void) const;
|
2002-10-06 10:25:42 +02:00
|
|
|
bool StringToParameters(const char *s);
|
|
|
|
public:
|
|
|
|
cChannel(void);
|
2004-02-08 11:05:22 +01:00
|
|
|
cChannel(const cChannel &Channel);
|
|
|
|
~cChannel();
|
2002-11-10 15:50:21 +01:00
|
|
|
cChannel& operator= (const cChannel &Channel);
|
2004-12-26 12:45:22 +01:00
|
|
|
cString ToText(void) const;
|
2005-05-06 13:49:01 +02:00
|
|
|
bool Parse(const char *s);
|
2002-10-06 10:25:42 +02:00
|
|
|
bool Save(FILE *f);
|
|
|
|
const char *Name(void) const { return name; }
|
2004-10-31 12:53:00 +01:00
|
|
|
const char *ShortName(bool OrName = false) const { return (OrName && isempty(shortName)) ? name : shortName; }
|
|
|
|
const char *Provider(void) const { return provider; }
|
2004-10-31 13:01:35 +01:00
|
|
|
const char *PortalName(void) const { return portalName; }
|
2004-01-04 12:30:00 +01:00
|
|
|
int Frequency(void) const { return frequency; } ///< Returns the actual frequency, as given in 'channels.conf'
|
2004-02-13 15:50:26 +01:00
|
|
|
int Transponder(void) const; ///< Returns the transponder frequency in MHz, plus the polarization in case of sat
|
|
|
|
static int Transponder(int Frequency, char Polarization); ///< builds the transponder from the given Frequency and Polarization
|
2002-10-06 10:25:42 +02:00
|
|
|
int Source(void) const { return source; }
|
|
|
|
int Srate(void) const { return srate; }
|
|
|
|
int Vpid(void) const { return vpid; }
|
2003-04-26 11:58:54 +02:00
|
|
|
int Ppid(void) const { return ppid; }
|
2005-01-16 14:40:47 +01:00
|
|
|
const int *Apids(void) const { return apids; }
|
|
|
|
const int *Dpids(void) const { return dpids; }
|
|
|
|
const int *Spids(void) const { return spids; }
|
2004-12-17 14:55:49 +01:00
|
|
|
int Apid(int i) const { return (0 <= i && i < MAXAPIDS) ? apids[i] : 0; }
|
2005-01-16 14:40:47 +01:00
|
|
|
int Dpid(int i) const { return (0 <= i && i < MAXDPIDS) ? dpids[i] : 0; }
|
|
|
|
int Spid(int i) const { return (0 <= i && i < MAXSPIDS) ? spids[i] : 0; }
|
2004-12-17 14:55:49 +01:00
|
|
|
const char *Alang(int i) const { return (0 <= i && i < MAXAPIDS) ? alangs[i] : ""; }
|
2005-01-16 14:40:47 +01:00
|
|
|
const char *Dlang(int i) const { return (0 <= i && i < MAXDPIDS) ? dlangs[i] : ""; }
|
|
|
|
const char *Slang(int i) const { return (0 <= i && i < MAXSPIDS) ? slangs[i] : ""; }
|
2002-10-06 10:25:42 +02:00
|
|
|
int Tpid(void) const { return tpid; }
|
2007-01-07 14:46:14 +01:00
|
|
|
const int *Caids(void) const { return caids; }
|
2004-01-04 12:30:00 +01:00
|
|
|
int Ca(int Index = 0) const { return Index < MAXCAIDS ? caids[Index] : 0; }
|
|
|
|
int Nid(void) const { return nid; }
|
|
|
|
int Tid(void) const { return tid; }
|
2002-10-06 10:25:42 +02:00
|
|
|
int Sid(void) const { return sid; }
|
2004-01-04 12:30:00 +01:00
|
|
|
int Rid(void) const { return rid; }
|
2002-10-06 10:25:42 +02:00
|
|
|
int Number(void) const { return number; }
|
|
|
|
void SetNumber(int Number) { number = Number; }
|
|
|
|
bool GroupSep(void) const { return groupSep; }
|
|
|
|
char Polarization(void) const { return polarization; }
|
|
|
|
int Inversion(void) const { return inversion; }
|
|
|
|
int Bandwidth(void) const { return bandwidth; }
|
|
|
|
int CoderateH(void) const { return coderateH; }
|
|
|
|
int CoderateL(void) const { return coderateL; }
|
|
|
|
int Modulation(void) const { return modulation; }
|
|
|
|
int Transmission(void) const { return transmission; }
|
|
|
|
int Guard(void) const { return guard; }
|
|
|
|
int Hierarchy(void) const { return hierarchy; }
|
2005-09-17 10:03:19 +02:00
|
|
|
const cLinkChannels* LinkChannels(void) const { return linkChannels; }
|
|
|
|
const cChannel *RefChannel(void) const { return refChannel; }
|
2005-05-14 09:47:06 +02:00
|
|
|
bool IsCable(void) const { return cSource::IsCable(source); }
|
|
|
|
bool IsSat(void) const { return cSource::IsSat(source); }
|
|
|
|
bool IsTerr(void) const { return cSource::IsTerr(source); }
|
2005-05-28 13:57:08 +02:00
|
|
|
tChannelID GetChannelID(void) const { return tChannelID(source, nid, (nid || tid) ? tid : Transponder(), sid, rid); }
|
2006-02-28 14:00:28 +01:00
|
|
|
bool HasTimer(void) const;
|
2004-01-04 12:30:00 +01:00
|
|
|
int Modification(int Mask = CHANNELMOD_ALL);
|
2005-08-06 12:13:55 +02:00
|
|
|
void CopyTransponderData(const cChannel *Channel);
|
2004-10-17 12:22:56 +02:00
|
|
|
bool SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH);
|
|
|
|
bool SetCableTransponderData(int Source, int Frequency, int Modulation, int Srate, int CoderateH);
|
|
|
|
bool SetTerrTransponderData(int Source, int Frequency, int Bandwidth, int Modulation, int Hierarchy, int CodeRateH, int CodeRateL, int Guard, int Transmission);
|
|
|
|
void SetId(int Nid, int Tid, int Sid, int Rid = 0);
|
2004-10-31 12:53:00 +01:00
|
|
|
void SetName(const char *Name, const char *ShortName, const char *Provider);
|
2004-10-31 13:01:35 +01:00
|
|
|
void SetPortalName(const char *PortalName);
|
2007-10-12 14:52:30 +02:00
|
|
|
void SetPids(int Vpid, int Ppid, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
|
2004-01-04 12:30:00 +01:00
|
|
|
void SetCaIds(const int *CaIds); // list must be zero-terminated
|
|
|
|
void SetCaDescriptors(int Level);
|
2004-02-08 11:05:22 +01:00
|
|
|
void SetLinkChannels(cLinkChannels *LinkChannels);
|
|
|
|
void SetRefChannel(cChannel *RefChannel);
|
2002-10-06 10:25:42 +02:00
|
|
|
};
|
|
|
|
|
2004-01-04 12:30:00 +01:00
|
|
|
class cChannels : public cRwLock, public cConfig<cChannel> {
|
|
|
|
private:
|
2002-10-06 10:25:42 +02:00
|
|
|
int maxNumber;
|
2004-10-17 11:50:21 +02:00
|
|
|
int modified;
|
2004-01-04 12:30:00 +01:00
|
|
|
int beingEdited;
|
2005-09-11 13:23:49 +02:00
|
|
|
cHash<cChannel> channelsHashSid;
|
2005-05-06 13:49:01 +02:00
|
|
|
void DeleteDuplicateChannels(void);
|
2002-10-06 10:25:42 +02:00
|
|
|
public:
|
2004-01-04 12:30:00 +01:00
|
|
|
cChannels(void);
|
2004-01-05 10:15:19 +01:00
|
|
|
bool Load(const char *FileName, bool AllowComments = false, bool MustExist = false);
|
2005-09-11 13:23:49 +02:00
|
|
|
void HashChannel(cChannel *Channel);
|
|
|
|
void UnhashChannel(cChannel *Channel);
|
2002-10-06 10:25:42 +02:00
|
|
|
int GetNextGroup(int Idx); // Get next channel group
|
|
|
|
int GetPrevGroup(int Idx); // Get previous channel group
|
|
|
|
int GetNextNormal(int Idx); // Get next normal channel (not group)
|
2006-05-28 10:48:50 +02:00
|
|
|
int GetPrevNormal(int Idx); // Get previous normal channel (not group)
|
2002-10-06 10:25:42 +02:00
|
|
|
void ReNumber(void); // Recalculate 'number' based on channel type
|
2002-10-19 15:33:37 +02:00
|
|
|
cChannel *GetByNumber(int Number, int SkipGap = 0);
|
2004-01-04 12:30:00 +01:00
|
|
|
cChannel *GetByServiceID(int Source, int Transponder, unsigned short ServiceID);
|
2004-02-13 15:50:26 +01:00
|
|
|
cChannel *GetByChannelID(tChannelID ChannelID, bool TryWithoutRid = false, bool TryWithoutPolarization = false);
|
2007-07-21 15:05:20 +02:00
|
|
|
cChannel *GetByTransponderID(tChannelID ChannelID);
|
2004-01-04 12:30:00 +01:00
|
|
|
int BeingEdited(void) { return beingEdited; }
|
|
|
|
void IncBeingEdited(void) { beingEdited++; }
|
|
|
|
void DecBeingEdited(void) { beingEdited--; }
|
2002-11-10 15:50:21 +01:00
|
|
|
bool HasUniqueChannelID(cChannel *NewChannel, cChannel *OldChannel = NULL);
|
2002-10-06 10:25:42 +02:00
|
|
|
bool SwitchTo(int Number);
|
|
|
|
int MaxNumber(void) { return maxNumber; }
|
2004-10-17 11:50:21 +02:00
|
|
|
void SetModified(bool ByUser = false);
|
|
|
|
int Modified(void);
|
|
|
|
///< Returns 0 if no channels have been modified, 1 if an automatic
|
|
|
|
///< modification has been made, and 2 if the user has made a modification.
|
|
|
|
///< Calling this function resets the 'modified' flag to 0.
|
2004-10-31 12:53:00 +01:00
|
|
|
cChannel *NewChannel(const cChannel *Transponder, const char *Name, const char *ShortName, const char *Provider, int Nid, int Tid, int Sid, int Rid = 0);
|
2002-10-06 10:25:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern cChannels Channels;
|
|
|
|
|
2004-12-26 12:45:22 +01:00
|
|
|
cString ChannelString(const cChannel *Channel, int Number);
|
2004-05-16 10:35:36 +02:00
|
|
|
|
2002-10-06 10:25:42 +02:00
|
|
|
#endif //__CHANNELS_H
|