Home

Dokumentation

Impressum

Dokumentation VDR
 

Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

device.h

Go to the documentation of this file.
00001 
00010 #ifndef __DEVICE_H
00011 #define __DEVICE_H
00012 
00013 #include "thread.h"
00014 #include "tools.h"
00015 
00016 #define MAXDEVICES         16 // the maximum number of devices in the system
00017 #define MAXCACAPS          16 // the maximum number of different CA values per device
00018 #define MAXPIDHANDLES      16 // the maximum number of different PIDs per device
00019 #define MAXRECEIVERS       16 // the maximum number of receivers per device
00020 #define MAXVOLUME         255
00021 #define VOLUMEDELTA         5 // used to increase/decrease the volume
00022 
00023 #define TS_SIZE          188
00024 #define TS_SYNC_BYTE     0x47
00025 #define PID_MASK_HI      0x1F
00026 
00027 enum eSetChannelResult { scrOk, scrNotAvailable, scrNoTransfer, scrFailed };
00028 
00029 
00031 enum ePlayMode {
00035                  pmNone,
00036 
00040                  pmAudioVideo,
00041 
00045                  pmAudioOnly,
00046 
00050                  pmAudioOnlyBlack,
00051 
00055                  pmExtern_THIS_SHOULD_BE_AVOIDED
00056                  // WARNING: USE THIS MODE ONLY AS A LAST RESORT, IF YOU
00057                  // ABSOLUTELY, POSITIVELY CAN'T IMPLEMENT YOUR PLAYER
00058                  // THE WAY IT IS SUPPOSED TO WORK. FORCING THE DEVICE
00059                  // TO RELEASE ITS FILES HANDLES (OR WHATEVER RESOURCES
00060                  // IT MAY USE) TO ALLOW AN EXTERNAL PLAYER TO ACCESS
00061                  // THEM MEANS THAT SUCH A PLAYER WILL NEED TO HAVE
00062                  // DETAILED KNOWLEDGE ABOUT THE INTERNALS OF THE DEVICE
00063                  // IN USE. AS A CONSEQUENCE, YOUR PLAYER MAY NOT WORK
00064                  // IF A PARTICULAR VDR INSTALLATION USES A DEVICE NOT
00065                  // KNOWN TO YOUR PLAYER.
00066                };
00067 
00068 class cOsdBase;
00069 class cChannel;
00070 class cPlayer;
00071 class cReceiver;
00072 class cSpuDecoder;
00073 
00074 
00076 class cDevice : public cThread {
00077 private:
00078   static int numDevices;
00079   static int useDevice;
00080   static cDevice *device[MAXDEVICES];
00081   static cDevice *primaryDevice;
00082 public:
00086   static int NumDevices(void) { return numDevices; }
00087 
00093   static void SetUseDevice(int n);
00094 
00099   static bool UseDevice(int n) { return useDevice == 0 || (useDevice & (1 << n)) != 0; }
00100 
00106   static bool SetPrimaryDevice(int n);
00107 
00111   static cDevice *PrimaryDevice(void) { return primaryDevice; }
00112 
00118   static cDevice *GetDevice(int Index);
00119 
00126   static cDevice *GetDevice(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL);
00127 
00132   static void SetCaCaps(int Index = -1);
00133 
00138   static void Shutdown(void);
00139 
00140 private:
00141   static int nextCardIndex;
00142   int cardIndex;
00143   int caCaps[MAXCACAPS];
00144 protected:
00145   cDevice(void);
00146   virtual ~cDevice();
00147 
00161   static int NextCardIndex(int n = 0);
00162 
00169   virtual void MakePrimaryDevice(bool On);
00170 
00171 public:
00172   bool IsPrimaryDevice(void) const { return this == primaryDevice; }
00173 
00177   int CardIndex(void) const { return cardIndex; }
00178 
00182   int DeviceNumber(void) const;
00183 
00191   int ProvidesCa(int Ca) const;
00192 
00196   virtual bool HasDecoder(void) const;
00197 
00198 
00202 public:
00203 
00211   virtual cOsdBase *NewOsd(int x, int y);
00212 
00217   virtual cSpuDecoder *GetSpuDecoder(void);
00218 
00222 protected:
00223   static int currentChannel;
00224 public:
00228   virtual bool ProvidesSource(int Source) const;
00229 
00245   virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) const;
00246 
00251   bool SwitchChannel(const cChannel *Channel, bool LiveView);
00252 
00258   static bool SwitchChannel(int Direction);
00259 private:
00260 
00264   eSetChannelResult SetChannel(const cChannel *Channel, bool LiveView);
00265 protected:
00269   virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
00270 public:
00274   static int CurrentChannel(void) { return primaryDevice ? currentChannel : 0; }
00275 
00280 private:
00281   bool active;
00282   virtual void Action(void);
00283 protected:
00284   enum ePidType { ptAudio, ptVideo, ptTeletext, ptDolby, ptOther };
00285   class cPidHandle {
00286   public:
00287     int pid;
00288     int handle;
00289     int used;
00290     cPidHandle(void) { pid = used = 0; handle = -1; }
00291     };
00292   cPidHandle pidHandles[MAXPIDHANDLES];
00293 
00297   bool HasPid(int Pid) const;
00298 
00302   bool AddPid(int Pid, ePidType PidType = ptOther);
00303 
00307   void DelPid(int Pid);
00308 
00318   virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
00319 
00324 public:
00325 
00343   virtual bool GrabImage(const char *FileName, bool Jpeg = true, int Quality = -1, int SizeX = -1, int SizeY = -1);
00344 
00349 public:
00354   virtual void SetVideoFormat(bool VideoFormat16_9);
00355 
00356 
00361 private:
00362   bool mute;
00363   int volume;
00364 protected:
00368   virtual void SetVolumeDevice(int Volume);
00369 
00378   virtual int NumAudioTracksDevice(void) const;
00379 
00391   virtual const char **GetAudioTracksDevice(int *CurrentTrack = NULL) const;
00392 
00398   virtual void SetAudioTrackDevice(int Index);
00399 
00400 public:
00401   bool IsMute(void) const { return mute; }
00402 
00406   bool ToggleMute(void);
00407 
00412   void SetVolume(int Volume, bool Absolute = false);
00413 
00414   static int CurrentVolume(void) { return primaryDevice ? primaryDevice->volume : 0; }//XXX???
00415 
00420   int NumAudioTracks(void) const;
00421 
00431   const char **GetAudioTracks(int *CurrentTrack = NULL) const;
00432 
00438   void SetAudioTrack(int Index);
00439 
00440 
00445 private:
00446   cPlayer *player;
00447   bool playerDetached;
00448 protected:
00449 
00453   virtual bool CanReplay(void) const;
00454 
00459   virtual bool SetPlayMode(ePlayMode PlayMode);
00460 
00461 public:
00466   virtual void TrickSpeed(int Speed);
00467 
00473   virtual void Clear(void);
00474 
00478   virtual void Play(void);
00479 
00483   virtual void Freeze(void);
00484 
00490   virtual void Mute(void);
00491 
00495   virtual void StillPicture(const uchar *Data, int Length);
00496 
00503   virtual bool Poll(cPoller &Poller, int TimeoutMs = 0);
00504 
00510   virtual int PlayVideo(const uchar *Data, int Length);
00511 
00517   virtual void PlayAudio(const uchar *Data, int Length);
00518 
00522   bool Replaying(void) const;
00523 
00527   void StopReplay(void);
00528 
00532   bool AttachPlayer(cPlayer *Player);
00533 
00537   void Detach(cPlayer *Player);
00538 
00543   bool PlayerDetached(void);
00544 
00549 private:
00550   cReceiver *receiver[MAXRECEIVERS];
00551   int CanShift(int Ca, int Priority, int UsedCards = 0) const;
00552 protected:
00558   int Priority(void) const;
00559 
00564   virtual bool OpenDvr(void);
00565 
00569   virtual void CloseDvr(void);
00570 
00578   virtual bool GetTSPacket(uchar *&Data);
00579 
00580 public:
00584   int  Ca(void) const;
00585 
00589   bool Receiving(bool CheckAny = false) const;
00590 
00594   bool AttachReceiver(cReceiver *Receiver);
00595 
00599   void Detach(cReceiver *Receiver);
00600   };
00601 
00611 
00612 class cTSBuffer {
00613 private:
00614   int f;
00615   int size;
00616   int cardIndex;
00617   int tsRead;
00618   int tsWrite;
00619   uchar *buf;
00620   bool firstRead;
00621   int Used(void) { return tsRead <= tsWrite ? tsWrite - tsRead : size - tsRead + tsWrite; }
00622 public:
00623   cTSBuffer(int File, int Size, int CardIndex);
00624   ~cTSBuffer();
00625   int Read(void);
00626   uchar *Get(void);
00627   };
00628 
00629 #endif //__DEVICE_H
00630 

Generated on Wed Feb 5 23:30:08 2003 for VDR by doxygen1.3-rc2