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.
|
|
|
|
*
|
2004-01-04 12:30:00 +01:00
|
|
|
* $Id: channels.h 1.10 2004/01/04 12:26:37 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
|
|
|
|
#define CHANNELMOD_RETUNE (CHANNELMOD_PIDS | CHANNELMOD_CA)
|
|
|
|
|
|
|
|
#define MAXAPIDS 2
|
|
|
|
#define MAXCAIDS 8
|
|
|
|
|
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;
|
|
|
|
int nid;
|
|
|
|
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; }
|
|
|
|
bool operator== (const tChannelID &arg) const;
|
2004-01-04 12:30:00 +01:00
|
|
|
bool Valid(void) { return tid && sid; } // nid and rid are 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; }
|
|
|
|
static tChannelID FromString(const char *s);
|
|
|
|
const char *ToString(void);
|
|
|
|
static const tChannelID InvalidID;
|
|
|
|
};
|
|
|
|
|
2002-10-06 10:25:42 +02:00
|
|
|
class cChannel : public cListObject {
|
|
|
|
friend class cMenuEditChannel;
|
|
|
|
private:
|
|
|
|
static char *buffer;
|
|
|
|
static const char *ToText(cChannel *Channel);
|
2004-01-04 12:30:00 +01:00
|
|
|
enum { MaxChannelName = 64 }; // 63 chars + terminating 0!
|
2002-11-10 15:50:21 +01:00
|
|
|
int __BeginData__;
|
2002-10-06 10:25:42 +02:00
|
|
|
char name[MaxChannelName];
|
|
|
|
int frequency; // MHz
|
|
|
|
int source;
|
|
|
|
int srate;
|
|
|
|
int vpid;
|
2003-04-26 11:58:54 +02:00
|
|
|
int ppid;
|
2002-10-06 10:25:42 +02:00
|
|
|
int apid1, apid2;
|
|
|
|
int dpid1, dpid2;
|
|
|
|
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;
|
2002-10-06 10:25:42 +02:00
|
|
|
const char *ParametersToString(void);
|
|
|
|
bool StringToParameters(const char *s);
|
|
|
|
public:
|
|
|
|
cChannel(void);
|
2004-01-04 12:30:00 +01:00
|
|
|
cChannel(const cChannel *Channel);
|
2002-11-10 15:50:21 +01:00
|
|
|
cChannel& operator= (const cChannel &Channel);
|
2002-10-06 10:25:42 +02:00
|
|
|
const char *ToText(void);
|
2002-11-10 15:50:21 +01:00
|
|
|
bool Parse(const char *s, bool AllowNonUniqueID = false);
|
2002-10-06 10:25:42 +02:00
|
|
|
bool Save(FILE *f);
|
|
|
|
const char *Name(void) const { return name; }
|
2004-01-04 12:30:00 +01:00
|
|
|
int Frequency(void) const { return frequency; } ///< Returns the actual frequency, as given in 'channels.conf'
|
|
|
|
int Transponder(void) const; ///< Returns the transponder frequency in MHz
|
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; }
|
2002-10-06 10:25:42 +02:00
|
|
|
int Apid1(void) const { return apid1; }
|
|
|
|
int Apid2(void) const { return apid2; }
|
|
|
|
int Dpid1(void) const { return dpid1; }
|
|
|
|
int Dpid2(void) const { return dpid2; }
|
|
|
|
int Tpid(void) const { return tpid; }
|
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; }
|
2003-10-26 13:32:24 +01:00
|
|
|
bool IsCable(void) const { return (source & cSource::st_Mask) == cSource::stCable; }
|
|
|
|
bool IsSat(void) const { return (source & cSource::st_Mask) == cSource::stSat; }
|
|
|
|
bool IsTerr(void) const { return (source & cSource::st_Mask) == cSource::stTerr; }
|
2002-11-24 14:48:38 +01:00
|
|
|
tChannelID GetChannelID(void) const;
|
2004-01-04 12:30:00 +01:00
|
|
|
int Modification(int Mask = CHANNELMOD_ALL);
|
|
|
|
void SetId(int Nid, int Tid, int Sid, int Rid = 0, bool Log = true);
|
|
|
|
void SetName(const char *Name, bool Log = true);
|
|
|
|
void SetPids(int Vpid, int Ppid, int Apid1, int Apid2, int Dpid1, int Dpid2, int Tpid);
|
|
|
|
void SetCaIds(const int *CaIds); // list must be zero-terminated
|
|
|
|
void SetCaDescriptors(int Level);
|
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-01-04 12:30:00 +01:00
|
|
|
bool modified;
|
|
|
|
int beingEdited;
|
2002-10-06 10:25:42 +02:00
|
|
|
public:
|
2004-01-04 12:30:00 +01:00
|
|
|
cChannels(void);
|
2003-08-16 09:18:52 +02:00
|
|
|
virtual bool Load(const char *FileName, bool AllowComments = false, bool MustExist = false);
|
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)
|
|
|
|
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);
|
2002-11-24 14:48:38 +01:00
|
|
|
cChannel *GetByChannelID(tChannelID ChannelID, bool TryWithoutRid = false);
|
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-01-04 12:30:00 +01:00
|
|
|
void SetModified(void);
|
|
|
|
bool Modified(void);
|
|
|
|
cChannel *NewChannel(int Source, int Transponder, const char *Name, int Nid, int Tid, int Sid, int Rid = 0);
|
2002-10-06 10:25:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern cChannels Channels;
|
|
|
|
|
|
|
|
#endif //__CHANNELS_H
|