vdr-1.4.7/channels.h

Go to the documentation of this file.
00001 /*
00002  * channels.h: Channel handling
00003  *
00004  * See the main source file 'vdr.c' for copyright information and
00005  * how to reach the author.
00006  *
00007  * $Id: channels.h 1.42 2006/05/28 15:03:56 kls Exp $
00008  */
00009 
00010 #ifndef __CHANNELS_H
00011 #define __CHANNELS_H
00012 
00013 #include "config.h"
00014 #include "sources.h"
00015 #include "thread.h"
00016 #include "tools.h"
00017 
00018 #define ISTRANSPONDER(f1, f2)  (abs((f1) - (f2)) < 4) //XXX
00019 
00020 #define CHANNELMOD_NONE     0x00
00021 #define CHANNELMOD_ALL      0xFF
00022 #define CHANNELMOD_NAME     0x01
00023 #define CHANNELMOD_PIDS     0x02
00024 #define CHANNELMOD_ID       0x04
00025 #define CHANNELMOD_CA       0x10
00026 #define CHANNELMOD_TRANSP   0x20
00027 #define CHANNELMOD_LANGS    0x40
00028 #define CHANNELMOD_RETUNE   (CHANNELMOD_PIDS | CHANNELMOD_CA | CHANNELMOD_TRANSP)
00029 
00030 #define CHANNELSMOD_NONE    0
00031 #define CHANNELSMOD_AUTO    1
00032 #define CHANNELSMOD_USER    2
00033 
00034 #define MAXAPIDS 32 // audio
00035 #define MAXDPIDS 16 // dolby (AC3 + DTS)
00036 #define MAXSPIDS  8 // subtitles
00037 #define MAXCAIDS  8 // conditional access
00038 
00039 #define MAXLANGCODE1 4 // a 3 letter language code, zero terminated
00040 #define MAXLANGCODE2 8 // up to two 3 letter language codes, separated by '+' and zero terminated
00041 
00042 #define CA_FTA           0x0000
00043 #define CA_DVB_MIN       0x0001
00044 #define CA_DVB_MAX       0x000F
00045 #define CA_USER_MIN      0x0010
00046 #define CA_USER_MAX      0x00FF
00047 #define CA_ENCRYPTED_MIN 0x0100
00048 #define CA_ENCRYPTED_MAX 0xFFFF
00049 
00050 struct tChannelParameterMap {
00051   int userValue;
00052   int driverValue;
00053   };
00054 
00055 //XXX into cChannel???
00056 int MapToUser(int Value, const tChannelParameterMap *Map);
00057 int MapToDriver(int Value, const tChannelParameterMap *Map);
00058 int UserIndex(int Value, const tChannelParameterMap *Map);
00059 int DriverIndex(int Value, const tChannelParameterMap *Map);
00060 
00061 extern const tChannelParameterMap InversionValues[];
00062 extern const tChannelParameterMap BandwidthValues[];
00063 extern const tChannelParameterMap CoderateValues[];
00064 extern const tChannelParameterMap ModulationValues[];
00065 extern const tChannelParameterMap TransmissionValues[];
00066 extern const tChannelParameterMap GuardValues[];
00067 extern const tChannelParameterMap HierarchyValues[];
00068 
00069 struct tChannelID {
00070 private:
00071   int source;
00072   int nid; 
00073   int tid;
00074   int sid;
00075   int rid;
00076 public:
00077   tChannelID(void) { source = nid = tid = sid = rid = 0; }
00078   tChannelID(int Source, int Nid, int Tid, int Sid, int Rid = 0) { source = Source; nid = Nid; tid = Tid; sid = Sid; rid = Rid; }
00079   bool operator== (const tChannelID &arg) const { return source == arg.source && nid == arg.nid && tid == arg.tid && sid == arg.sid && rid == arg.rid; }
00080   bool Valid(void) const { return (nid || tid) && sid; } // rid is optional and source may be 0//XXX source may not be 0???
00081   tChannelID &ClrRid(void) { rid = 0; return *this; }
00082   tChannelID &ClrPolarization(void);
00083   int Source(void) { return source; }
00084   int Nid(void) { return nid; }
00085   int Tid(void) { return tid; }
00086   int Sid(void) { return sid; }
00087   int Rid(void) { return rid; }
00088   static tChannelID FromString(const char *s);
00089   cString ToString(void) const;
00090   static const tChannelID InvalidID;
00091   };
00092 
00093 class cChannel;
00094 
00095 class cLinkChannel : public cListObject {
00096 private:
00097   cChannel *channel;
00098 public:
00099   cLinkChannel(cChannel *Channel) { channel = Channel; }
00100   cChannel *Channel(void) { return channel; }
00101   };
00102 
00103 class cLinkChannels : public cList<cLinkChannel> {
00104   };
00105 
00106 class cSchedule;
00107 
00108 class cChannel : public cListObject {
00109   friend class cSchedules;
00110   friend class cMenuEditChannel;
00111 private:
00112   static cString ToText(const cChannel *Channel);
00113   char *name;
00114   char *shortName;
00115   char *provider;
00116   char *portalName;
00117   int __BeginData__;
00118   int frequency; // MHz
00119   int source;
00120   int srate;
00121   int vpid;
00122   int ppid;
00123   int apids[MAXAPIDS + 1]; // list is zero-terminated
00124   char alangs[MAXAPIDS][MAXLANGCODE2];
00125   int dpids[MAXDPIDS + 1]; // list is zero-terminated
00126   char dlangs[MAXDPIDS][MAXLANGCODE2];
00127   int spids[MAXSPIDS + 1]; // list is zero-terminated
00128   char slangs[MAXSPIDS][MAXLANGCODE2];
00129   int tpid;
00130   int caids[MAXCAIDS + 1]; // list is zero-terminated
00131   int nid;
00132   int tid;
00133   int sid;
00134   int rid;
00135   int number;    // Sequence number assigned on load
00136   bool groupSep;
00137   char polarization;
00138   int inversion;
00139   int bandwidth;
00140   int coderateH;
00141   int coderateL;
00142   int modulation;
00143   int transmission;
00144   int guard;
00145   int hierarchy;
00146   int __EndData__;
00147   int modification;
00148   mutable const cSchedule *schedule;
00149   cLinkChannels *linkChannels;
00150   cChannel *refChannel;
00151   cString ParametersToString(void) const;
00152   bool StringToParameters(const char *s);
00153 public:
00154   cChannel(void);
00155   cChannel(const cChannel &Channel);
00156   ~cChannel();
00157   cChannel& operator= (const cChannel &Channel);
00158   cString ToText(void) const;
00159   bool Parse(const char *s);
00160   bool Save(FILE *f);
00161   const char *Name(void) const { return name; }
00162   const char *ShortName(bool OrName = false) const { return (OrName && isempty(shortName)) ? name : shortName; }
00163   const char *Provider(void) const { return provider; }
00164   const char *PortalName(void) const { return portalName; }
00165   int Frequency(void) const { return frequency; } 
00166   int Transponder(void) const;                    
00167   static int Transponder(int Frequency, char Polarization); 
00168   int Source(void) const { return source; }
00169   int Srate(void) const { return srate; }
00170   int Vpid(void) const { return vpid; }
00171   int Ppid(void) const { return ppid; }
00172   const int *Apids(void) const { return apids; }
00173   const int *Dpids(void) const { return dpids; }
00174   const int *Spids(void) const { return spids; }
00175   int Apid(int i) const { return (0 <= i && i < MAXAPIDS) ? apids[i] : 0; }
00176   int Dpid(int i) const { return (0 <= i && i < MAXDPIDS) ? dpids[i] : 0; }
00177   int Spid(int i) const { return (0 <= i && i < MAXSPIDS) ? spids[i] : 0; }
00178   const char *Alang(int i) const { return (0 <= i && i < MAXAPIDS) ? alangs[i] : ""; }
00179   const char *Dlang(int i) const { return (0 <= i && i < MAXDPIDS) ? dlangs[i] : ""; }
00180   const char *Slang(int i) const { return (0 <= i && i < MAXSPIDS) ? slangs[i] : ""; }
00181   int Tpid(void) const { return tpid; }
00182   int Ca(int Index = 0) const { return Index < MAXCAIDS ? caids[Index] : 0; }
00183   int Nid(void) const { return nid; }
00184   int Tid(void) const { return tid; }
00185   int Sid(void) const { return sid; }
00186   int Rid(void) const { return rid; }
00187   int Number(void) const { return number; }
00188   void SetNumber(int Number) { number = Number; }
00189   bool GroupSep(void) const { return groupSep; }
00190   char Polarization(void) const { return polarization; }
00191   int Inversion(void) const { return inversion; }
00192   int Bandwidth(void) const { return bandwidth; }
00193   int CoderateH(void) const { return coderateH; }
00194   int CoderateL(void) const { return coderateL; }
00195   int Modulation(void) const { return modulation; }
00196   int Transmission(void) const { return transmission; }
00197   int Guard(void) const { return guard; }
00198   int Hierarchy(void) const { return hierarchy; }
00199   const cLinkChannels* LinkChannels(void) const { return linkChannels; }
00200   const cChannel *RefChannel(void) const { return refChannel; }
00201   bool IsCable(void) const { return cSource::IsCable(source); }
00202   bool IsSat(void) const { return cSource::IsSat(source); }
00203   bool IsTerr(void) const { return cSource::IsTerr(source); }
00204   tChannelID GetChannelID(void) const { return tChannelID(source, nid, (nid || tid) ? tid : Transponder(), sid, rid); }
00205   bool HasTimer(void) const;
00206   int Modification(int Mask = CHANNELMOD_ALL);
00207   void CopyTransponderData(const cChannel *Channel);
00208   bool SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH);
00209   bool SetCableTransponderData(int Source, int Frequency, int Modulation, int Srate, int CoderateH);
00210   bool SetTerrTransponderData(int Source, int Frequency, int Bandwidth, int Modulation, int Hierarchy, int CodeRateH, int CodeRateL, int Guard, int Transmission);
00211   void SetId(int Nid, int Tid, int Sid, int Rid = 0);
00212   void SetName(const char *Name, const char *ShortName, const char *Provider);
00213   void SetPortalName(const char *PortalName);
00214   void SetPids(int Vpid, int Ppid, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int Tpid);
00215   void SetCaIds(const int *CaIds); // list must be zero-terminated
00216   void SetCaDescriptors(int Level);
00217   void SetLinkChannels(cLinkChannels *LinkChannels);
00218   void SetRefChannel(cChannel *RefChannel);
00219   };
00220 
00221 class cChannels : public cRwLock, public cConfig<cChannel> {
00222 private:
00223   int maxNumber;
00224   int modified;
00225   int beingEdited;
00226   cHash<cChannel> channelsHashSid;
00227   void DeleteDuplicateChannels(void);
00228 public:
00229   cChannels(void);
00230   bool Load(const char *FileName, bool AllowComments = false, bool MustExist = false);
00231   void HashChannel(cChannel *Channel);
00232   void UnhashChannel(cChannel *Channel);
00233   int GetNextGroup(int Idx);   // Get next channel group
00234   int GetPrevGroup(int Idx);   // Get previous channel group
00235   int GetNextNormal(int Idx);  // Get next normal channel (not group)
00236   int GetPrevNormal(int Idx);  // Get previous normal channel (not group)
00237   void ReNumber(void);         // Recalculate 'number' based on channel type
00238   cChannel *GetByNumber(int Number, int SkipGap = 0);
00239   cChannel *GetByServiceID(int Source, int Transponder, unsigned short ServiceID);
00240   cChannel *GetByChannelID(tChannelID ChannelID, bool TryWithoutRid = false, bool TryWithoutPolarization = false);
00241   int BeingEdited(void) { return beingEdited; }
00242   void IncBeingEdited(void) { beingEdited++; }
00243   void DecBeingEdited(void) { beingEdited--; }
00244   bool HasUniqueChannelID(cChannel *NewChannel, cChannel *OldChannel = NULL);
00245   bool SwitchTo(int Number);
00246   int MaxNumber(void) { return maxNumber; }
00247   void SetModified(bool ByUser = false);
00248   int Modified(void);
00252   cChannel *NewChannel(const cChannel *Transponder, const char *Name, const char *ShortName, const char *Provider, int Nid, int Tid, int Sid, int Rid = 0);
00253   };
00254 
00255 extern cChannels Channels;
00256 
00257 cString ChannelString(const cChannel *Channel, int Number);
00258 
00259 #endif //__CHANNELS_H

Generated on Tue Nov 6 19:57:51 2007 for VDR by  doxygen 1.5.3-20071008