vdr  2.6.9
device.h
Go to the documentation of this file.
1 /*
2  * device.h: The basic device interface
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: device.h 5.5 2024/07/06 11:19:21 kls Exp $
8  */
9 
10 #ifndef __DEVICE_H
11 #define __DEVICE_H
12 
13 #include "channels.h"
14 #include "ci.h"
15 #include "dvbsubtitle.h"
16 #include "eit.h"
17 #include "filter.h"
18 #include "nit.h"
19 #include "pat.h"
20 #include "positioner.h"
21 #include "remux.h"
22 #include "ringbuffer.h"
23 #include "sdt.h"
24 #include "sections.h"
25 #include "spu.h"
26 #include "thread.h"
27 #include "tools.h"
28 
29 #define MAXDEVICES 16 // the maximum number of devices in the system
30 #define MAXPIDHANDLES 64 // the maximum number of different PIDs per device
31 #define MAXRECEIVERS 16 // the maximum number of receivers per device
32 #define MAXVOLUME 255
33 #define VOLUMEDELTA (MAXVOLUME / Setup.VolumeSteps) // used to increase/decrease the volume
34 #define MAXOCCUPIEDTIMEOUT 99 // max. time (in seconds) a device may be occupied
35 
37 
38 // Note that VDR itself always uses pmAudioVideo when replaying a recording!
39 enum ePlayMode { pmNone, // audio/video from decoder
40  pmAudioVideo, // audio/video from player
41  pmAudioOnly, // audio only from player, video from decoder
42  pmAudioOnlyBlack, // audio only from player, no video (black screen)
43  pmVideoOnly, // video only from player, audio from decoder
45  // external player (e.g. MPlayer), release the device
46  // WARNING: USE THIS MODE ONLY AS A LAST RESORT, IF YOU
47  // ABSOLUTELY, POSITIVELY CAN'T IMPLEMENT YOUR PLAYER
48  // THE WAY IT IS SUPPOSED TO WORK. FORCING THE DEVICE
49  // TO RELEASE ITS FILES HANDLES (OR WHATEVER RESOURCES
50  // IT MAY USE) TO ALLOW AN EXTERNAL PLAYER TO ACCESS
51  // THEM MEANS THAT SUCH A PLAYER WILL NEED TO HAVE
52  // DETAILED KNOWLEDGE ABOUT THE INTERNALS OF THE DEVICE
53  // IN USE. AS A CONSEQUENCE, YOUR PLAYER MAY NOT WORK
54  // IF A PARTICULAR VDR INSTALLATION USES A DEVICE NOT
55  // KNOWN TO YOUR PLAYER.
56  };
57 
61  };
62 
66  ttAudioLast = ttAudioFirst + 31, // MAXAPIDS - 1
69  ttDolbyLast = ttDolbyFirst + 15, // MAXDPIDS - 1
72  ttSubtitleLast = ttSubtitleFirst + 31, // MAXSPIDS - 1
74  };
75 
76 #define IS_AUDIO_TRACK(t) (ttAudioFirst <= (t) && (t) <= ttAudioLast)
77 #define IS_DOLBY_TRACK(t) (ttDolbyFirst <= (t) && (t) <= ttDolbyLast)
78 #define IS_SUBTITLE_TRACK(t) (ttSubtitleFirst <= (t) && (t) <= ttSubtitleLast)
79 
80 struct tTrackId {
81  uint16_t id; // The PES packet id or the PID.
82  char language[MAXLANGCODE2]; // something like either "eng" or "deu+eng"
83  char description[32]; // something like "Dolby Digital 5.1"
84  };
85 
86 class cPlayer;
87 class cReceiver;
88 class cLiveSubtitle;
89 
90 class cDeviceHook : public cListObject {
91 public:
92  cDeviceHook(void);
96  virtual bool DeviceProvidesTransponder(const cDevice *Device, const cChannel *Channel) const;
98  virtual bool DeviceProvidesEIT(const cDevice *Device) const;
100  };
101 
103 
104 #define DTV_STAT_VALID_NONE 0x0000
105 #define DTV_STAT_VALID_STRENGTH 0x0001
106 #define DTV_STAT_VALID_CNR 0x0002
107 #define DTV_STAT_VALID_BERPRE 0x0004
108 #define DTV_STAT_VALID_BERPOST 0x0008
109 #define DTV_STAT_VALID_PER 0x0010
110 #define DTV_STAT_VALID_STATUS 0x0020
111 
112 #define DTV_STAT_HAS_NONE 0x0000
113 #define DTV_STAT_HAS_SIGNAL 0x0001
114 #define DTV_STAT_HAS_CARRIER 0x0002
115 #define DTV_STAT_HAS_VITERBI 0x0004
116 #define DTV_STAT_HAS_SYNC 0x0008
117 #define DTV_STAT_HAS_LOCK 0x0010
118 
119 class cDevice : public cThread {
120  friend class cLiveSubtitle;
121  friend class cDeviceHook;
122  friend class cReceiver;
123 private:
124  static int numDevices;
125  static int useDevice;
128 public:
129  static int NumDevices(void) { return numDevices; }
131  static bool WaitForAllDevicesReady(int Timeout = 0);
137  static void SetUseDevice(int n);
141  static bool UseDevice(int n) { return useDevice == 0 || (useDevice & (1 << n)) != 0; }
144  static bool SetPrimaryDevice(int n);
148  static cDevice *PrimaryDevice(void) { return primaryDevice; }
150  static cDevice *ActualDevice(void);
153  static cDevice *GetDevice(int Index);
157  static cDevice *GetDevice(const cChannel *Channel, int Priority, bool LiveView, bool Query = false);
176  static cDevice *GetDeviceForTransponder(const cChannel *Channel, int Priority);
184  static void Shutdown(void);
187 private:
188  static int nextCardIndex;
190 protected:
191  cDevice(void);
192  virtual ~cDevice();
193  virtual bool Ready(void);
198  static int NextCardIndex(int n = 0);
210  virtual void MakePrimaryDevice(bool On);
217  virtual bool IsBonded(void) const { return false; }
222 public:
223  bool IsPrimaryDevice(bool CheckDecoder = true) const { return this == primaryDevice && (!CheckDecoder || HasDecoder()); }
224  int CardIndex(void) const { return cardIndex; }
226  int DeviceNumber(void) const;
228  virtual cString DeviceType(void) const;
234  virtual cString DeviceName(void) const;
237  virtual bool HasDecoder(void) const;
239  virtual bool AvoidRecording(void) const { return false; }
242 
243 // Device hooks
244 
245 private:
247 protected:
248  bool DeviceHooksProvidesTransponder(const cChannel *Channel) const;
249  bool DeviceHooksProvidesEIT(void) const;
250 
251 // SPU facilities
252 
253 private:
256 public:
257  virtual cSpuDecoder *GetSpuDecoder(void);
260 
261 // Channel facilities
262 
263 private:
265  time_t occupiedFrom;
268 protected:
269  static int currentChannel;
270 public:
271  virtual bool ProvidesSource(int Source) const;
273  virtual bool ProvidesTransponder(const cChannel *Channel) const;
277  virtual bool ProvidesTransponderExclusively(const cChannel *Channel) const;
280  virtual bool ProvidesChannel(const cChannel *Channel, int Priority = IDLEPRIORITY, bool *NeedsDetachReceivers = NULL) const;
294  virtual bool ProvidesEIT(void) const;
298  virtual int NumProvidedSystems(void) const;
304  virtual const cPositioner *Positioner(void) const;
309  virtual bool SignalStats(int &Valid, double *Strength = NULL, double *Cnr = NULL, double *BerPre = NULL, double *BerPost = NULL, double *Per = NULL, int *Status = NULL) const;
326  virtual int SignalStrength(void) const;
331  virtual int SignalQuality(void) const;
336  virtual const cChannel *GetCurrentlyTunedTransponder(void) const;
341  virtual bool IsTunedToTransponder(const cChannel *Channel) const;
344  virtual bool MaySwitchTransponder(const cChannel *Channel) const;
349  virtual void SetPowerSaveMode(bool On);
354  void SetPowerSaveIfUnused(void);
357  bool SwitchChannel(const cChannel *Channel, bool LiveView);
360  static bool SwitchChannel(int Direction);
364 private:
365  eSetChannelResult SetChannel(const cChannel *Channel, bool LiveView);
367 protected:
368  virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
370 public:
371  static int CurrentChannel(void) { return primaryDevice ? currentChannel : 0; }
373 #ifndef DEPRECATED_SETCURRENTCHANNEL
374 #define DEPRECATED_SETCURRENTCHANNEL 0
375 #endif
376 #if DEPRECATED_SETCURRENTCHANNEL
377  static void SetCurrentChannel(const cChannel *Channel) { currentChannel = Channel ? Channel->Number() : 0; }
378 #endif
379  static void SetCurrentChannel(int ChannelNumber) { currentChannel = ChannelNumber; }
383  void ForceTransferMode(void);
385  int Occupied(int Priority = MINPRIORITY) const;
388  void SetOccupied(int Seconds, int Priority = MINPRIORITY, time_t From = 0);
400  virtual bool HasLock(int TimeoutMs = 0) const;
406  virtual bool HasProgramme(void) const;
409 
410 // PID handle facilities
411 
412 private:
413  mutable cMutex mutexPids;
414  virtual void Action(void);
415 protected:
417  class cPidHandle {
418  public:
419  int pid;
421  int handle;
422  int used;
423  cPidHandle(void) { pid = streamType = used = 0; handle = -1; }
424  };
426  bool HasPid(int Pid) const;
428  bool AddPid(int Pid, ePidType PidType = ptOther, int StreamType = 0);
430  void DelPid(int Pid, ePidType PidType = ptOther);
432  virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
440 public:
441  void DelLivePids(void);
443 
444 // Section filter facilities
445 
446 private:
452 protected:
453  void StartSectionHandler(void);
457  void StopSectionHandler(void);
461 public:
462  virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
466  virtual int ReadFilter(int Handle, void *Buffer, size_t Length);
470  virtual void CloseFilter(int Handle);
475  void AttachFilter(cFilter *Filter);
477  void Detach(cFilter *Filter);
479  const cSdtFilter *SdtFilter(void) const { return sdtFilter; }
481 
482 // Common Interface facilities:
483 
484 private:
486  void ReleaseCamSlot(void);
488 public:
489  virtual bool HasCi(void);
491  virtual bool HasInternalCam(void) { return false; }
497  void SetCamSlot(cCamSlot *CamSlot);
499  cCamSlot *CamSlot(void) const { return camSlot; }
502 
503 // Image Grab facilities
504 
505 public:
506  virtual uchar *GrabImage(int &Size, bool Jpeg = true, int Quality = -1, int SizeX = -1, int SizeY = -1);
518  bool GrabImageFile(const char *FileName, bool Jpeg = true, int Quality = -1, int SizeX = -1, int SizeY = -1);
523 
524 // Video format facilities
525 
526 public:
527  virtual void SetVideoDisplayFormat(eVideoDisplayFormat VideoDisplayFormat);
533  virtual void SetVideoFormat(bool VideoFormat16_9);
538  virtual void GetVideoSize(int &Width, int &Height, double &VideoAspect);
545  virtual void GetOsdSize(int &Width, int &Height, double &PixelAspect);
556 
557 // Track facilities
558 
559 private:
569 protected:
570  virtual void SetAudioTrackDevice(eTrackType Type);
572  virtual void SetSubtitleTrackDevice(eTrackType Type);
574 public:
575  void ClrAvailableTracks(bool DescriptionsOnly = false, bool IdsOnly = false);
580  bool SetAvailableTrack(eTrackType Type, int Index, uint16_t Id, const char *Language = NULL, const char *Description = NULL);
587  const tTrackId *GetTrack(eTrackType Type);
590  int NumTracks(eTrackType FirstTrack, eTrackType LastTrack) const;
593  int NumAudioTracks(void) const;
597  int NumSubtitleTracks(void) const;
600  bool SetCurrentAudioTrack(eTrackType Type);
604  bool SetCurrentSubtitleTrack(eTrackType Type, bool Manual = false);
610  void EnsureAudioTrack(bool Force = false);
614  void EnsureSubtitleTrack(void);
617  void SetKeepTracks(bool KeepTracks) { keepTracks = KeepTracks; }
621 
622 // Audio facilities
623 
624 private:
625  bool mute;
626  int volume;
627 protected:
628  virtual int GetAudioChannelDevice(void);
631  virtual void SetAudioChannelDevice(int AudioChannel);
633  virtual void SetVolumeDevice(int Volume);
635  virtual void SetDigitalAudioDevice(bool On);
639 public:
640  bool IsMute(void) const { return mute; }
641  bool ToggleMute(void);
643  int GetAudioChannel(void);
646  void SetAudioChannel(int AudioChannel);
649  void SetVolume(int Volume, bool Absolute = false);
652  static int CurrentVolume(void) { return primaryDevice ? primaryDevice->volume : 0; }//XXX???
653 
654 // Player facilities
655 
656 private:
663 protected:
664  const cPatPmtParser *PatPmtParser(void) const { return &patPmtParser; }
667  virtual bool CanReplay(void) const;
669  virtual bool SetPlayMode(ePlayMode PlayMode);
672  virtual int PlayVideo(const uchar *Data, int Length);
679  virtual int PlayAudio(const uchar *Data, int Length, uchar Id);
687  virtual int PlaySubtitle(const uchar *Data, int Length);
694  virtual int PlayPesPacket(const uchar *Data, int Length, bool VideoOnly = false);
699  virtual int PlayTsVideo(const uchar *Data, int Length);
707  virtual int PlayTsAudio(const uchar *Data, int Length);
715  virtual int PlayTsSubtitle(const uchar *Data, int Length);
723 public:
724  virtual int64_t GetSTC(void);
735  virtual bool IsPlayingVideo(void) const { return isPlayingVideo; }
738  virtual cRect CanScaleVideo(const cRect &Rect, int Alignment = taCenter) { return cRect::Null; }
759  virtual void ScaleVideo(const cRect &Rect = cRect::Null) {}
767  virtual bool HasIBPTrickSpeed(void) { return false; }
770  virtual void TrickSpeed(int Speed, bool Forward);
781  virtual void Clear(void);
785  virtual void Play(void);
788  virtual void Freeze(void);
790  virtual void Mute(void);
794  virtual void StillPicture(const uchar *Data, int Length);
800  virtual bool Poll(cPoller &Poller, int TimeoutMs = 0);
805  virtual bool Flush(int TimeoutMs = 0);
811  virtual int PlayPes(const uchar *Data, int Length, bool VideoOnly = false);
821  virtual int PlayTs(const uchar *Data, int Length, bool VideoOnly = false);
837  bool Replaying(void) const;
839  bool Transferring(void) const;
841  void StopReplay(void);
843  bool AttachPlayer(cPlayer *Player);
845  void Detach(cPlayer *Player);
847 
848 // Receiver facilities
849 
850 private:
853 public:
854  int Priority(bool IgnoreOccupied = false) const;
858 protected:
859  virtual bool OpenDvr(void);
862  virtual void CloseDvr(void);
864  virtual bool GetTSPacket(uchar *&Data);
871 public:
872  bool Receiving(bool Dummy = false) const;
874  bool AttachReceiver(cReceiver *Receiver);
876  void Detach(cReceiver *Receiver, bool ReleaseCam = true);
881  void DetachAll(int Pid);
883  virtual void DetachAllReceivers(void);
885  };
886 
894 
895 class cTSBuffer : public cThread {
896 private:
897  int f;
901  virtual void Action(void);
902 public:
903  cTSBuffer(int File, int Size, int DeviceNumber);
904  virtual ~cTSBuffer();
905  uchar *Get(int *Available = NULL, bool CheckAvailable = false);
916  void Skip(int Count);
923  };
924 
925 #endif //__DEVICE_H
#define MAXLANGCODE2
Definition: channels.h:37
Definition: ci.h:232
int Number(void) const
Definition: channels.h:181
virtual bool DeviceProvidesEIT(const cDevice *Device) const
Returns true if the given Device can provide EIT data.
Definition: device.c:61
cDeviceHook(void)
Creates a new device hook object.
Definition: device.c:51
virtual bool DeviceProvidesTransponder(const cDevice *Device, const cChannel *Channel) const
Returns true if the given Device can provide the given Channel's transponder.
Definition: device.c:56
cCamSlot * camSlot
Definition: device.h:485
cPlayer * player
Definition: device.h:657
static int NextCardIndex(int n=0)
Calculates the next card index.
Definition: device.c:155
int Occupied(int Priority=MINPRIORITY) const
Returns the number of seconds this device is still occupied for with a priority >= Priority.
Definition: device.c:983
virtual cString DeviceName(void) const
Returns a string identifying the name of this device.
Definition: device.c:181
static cList< cDeviceHook > deviceHooks
Definition: device.h:246
bool Replaying(void) const
Returns true if we are currently replaying.
Definition: device.c:1373
virtual bool Poll(cPoller &Poller, int TimeoutMs=0)
Returns true if the device itself or any of the file handles in Poller is ready for further action.
Definition: device.c:1430
void SetKeepTracks(bool KeepTracks)
Controls whether the current audio and subtitle track settings shall be kept as they currently are,...
Definition: device.h:617
int currentAudioTrackMissingCount
Definition: device.h:565
void StopSectionHandler(void)
A device that has called StartSectionHandler() must call this function (typically in its destructor) ...
Definition: device.c:681
int Priority(bool IgnoreOccupied=false) const
Returns the priority of the current receiving session (-MAXPRIORITY..MAXPRIORITY),...
Definition: device.c:1695
virtual bool SignalStats(int &Valid, double *Strength=NULL, double *Cnr=NULL, double *BerPre=NULL, double *BerPost=NULL, double *Per=NULL, int *Status=NULL) const
Returns statistics about the currently received signal (if available).
Definition: device.c:785
virtual void SetSubtitleTrackDevice(eTrackType Type)
Sets the current subtitle track to the given value.
Definition: device.c:1043
virtual int GetAudioChannelDevice(void)
Gets the current audio channel, which is stereo (0), mono left (1) or mono right (2).
Definition: device.c:1022
virtual int PlayVideo(const uchar *Data, int Length)
Plays the given data block as video.
Definition: device.c:1440
cSectionHandler * sectionHandler
Definition: device.h:447
static bool UseDevice(int n)
Tells whether the device with the given card index shall be used in this instance of VDR.
Definition: device.h:141
bool SetCurrentSubtitleTrack(eTrackType Type, bool Manual=false)
Sets the current subtitle track to the given Type.
Definition: device.c:1186
virtual bool HasInternalCam(void)
Returns true if this device handles encrypted channels itself without VDR assistance.
Definition: device.h:491
virtual uchar * GrabImage(int &Size, bool Jpeg=true, int Quality=-1, int SizeX=-1, int SizeY=-1)
Grabs the currently visible screen image.
Definition: device.c:474
virtual void GetVideoSize(int &Width, int &Height, double &VideoAspect)
Returns the Width, Height and VideoAspect ratio of the currently displayed video material.
Definition: device.c:533
bool GrabImageFile(const char *FileName, bool Jpeg=true, int Quality=-1, int SizeX=-1, int SizeY=-1)
Calls GrabImage() and stores the resulting image in a file with the given name.
Definition: device.c:479
eSetChannelResult SetChannel(const cChannel *Channel, bool LiveView)
Sets the device to the given channel (general setup).
Definition: device.c:879
bool mute
Definition: device.h:625
virtual bool HasLock(int TimeoutMs=0) const
Returns true if the device has a lock on the requested transponder.
Definition: device.c:1011
const cPatPmtParser * PatPmtParser(void) const
Returns a pointer to the patPmtParser, so that a derived device can use the stream information from i...
Definition: device.h:664
void StartSectionHandler(void)
A derived device that provides section data must call this function (typically in its constructor) to...
Definition: device.c:670
virtual bool IsPlayingVideo(void) const
Returns true if the currently attached player has delivered any video packets.
Definition: device.h:735
ePidType
Definition: device.h:416
@ ptTeletext
Definition: device.h:416
@ ptPcr
Definition: device.h:416
@ ptOther
Definition: device.h:416
@ ptDolby
Definition: device.h:416
@ ptAudio
Definition: device.h:416
@ ptVideo
Definition: device.h:416
cMutex mutexCurrentAudioTrack
Definition: device.h:563
virtual const cPositioner * Positioner(void) const
Returns a pointer to the positioner (if any) this device has used to move the satellite dish to the r...
Definition: device.c:780
virtual int NumProvidedSystems(void) const
Returns the number of individual "delivery systems" this device provides.
Definition: device.c:775
int NumSubtitleTracks(void) const
Returns the number of subtitle tracks that are currently available.
Definition: device.c:1163
bool keepTracks
Definition: device.h:567
virtual ~cDevice()
Definition: device.c:122
virtual int PlayPes(const uchar *Data, int Length, bool VideoOnly=false)
Plays all valid PES packets in Data with the given Length.
Definition: device.c:1555
cMutex mutexReceiver
Definition: device.h:851
virtual bool ProvidesSource(int Source) const
Returns true if this device can provide the given source.
Definition: device.c:724
void ReleaseCamSlot(void)
Releases the CAM slot if it is currently not used.
Definition: device.c:448
static int useDevice
Definition: device.h:125
cDvbSubtitleConverter * dvbSubtitleConverter
Definition: device.h:255
bool HasPid(int Pid) const
Returns true if this device is currently receiving the given PID.
Definition: device.c:550
virtual void SetAudioTrackDevice(eTrackType Type)
Sets the current audio track to the given value.
Definition: device.c:1039
virtual bool SetPid(cPidHandle *Handle, int Type, bool On)
Does the actual PID setting on this device.
Definition: device.c:656
static int nextCardIndex
Definition: device.h:188
cTsToPes tsToPesAudio
Definition: device.h:660
cNitFilter * nitFilter
Definition: device.h:451
bool autoSelectPreferredSubtitleLanguage
Definition: device.h:566
static bool WaitForAllDevicesReady(int Timeout=0)
Waits until all devices have become ready, or the given Timeout (seconds) has expired.
Definition: device.c:133
void SetCamSlot(cCamSlot *CamSlot)
Sets the given CamSlot to be used with this device.
Definition: device.c:459
static cDevice * ActualDevice(void)
Returns the actual receiving device in case of Transfer Mode, or the primary device otherwise.
Definition: device.c:222
static void SetUseDevice(int n)
Sets the 'useDevice' flag of the given device.
Definition: device.c:149
virtual bool MaySwitchTransponder(const cChannel *Channel) const
Returns true if it is ok to switch to the Channel's transponder on this device, without disturbing an...
Definition: device.c:810
eTrackType currentSubtitleTrack
Definition: device.h:562
eTrackType GetCurrentSubtitleTrack(void) const
Definition: device.h:603
static cDevice * GetDevice(int Index)
Gets the device with the given Index.
Definition: device.c:230
static void Shutdown(void)
Closes down all devices.
Definition: device.c:465
cPatFilter * patFilter
Definition: device.h:449
eTrackType GetCurrentAudioTrack(void) const
Definition: device.h:599
cDevice(void)
Definition: device.c:79
bool DeviceHooksProvidesEIT(void) const
Definition: device.c:740
bool SwitchChannel(const cChannel *Channel, bool LiveView)
Switches the device to the given Channel, initiating transfer mode if necessary.
Definition: device.c:825
virtual int PlayTsVideo(const uchar *Data, int Length)
Plays the given data block as video.
Definition: device.c:1584
int DeviceNumber(void) const
Returns the number of this device (0 ... numDevices - 1).
Definition: device.c:167
virtual void SetPowerSaveMode(bool On)
Puts the device into power save mode, if applicable.
Definition: device.c:815
cEitFilter * eitFilter
Definition: device.h:448
virtual bool ProvidesEIT(void) const
Returns true if this device provides EIT data and thus wants to be tuned to the channels it can recei...
Definition: device.c:770
virtual void SetAudioChannelDevice(int AudioChannel)
Sets the audio channel to stereo (0), mono left (1) or mono right (2).
Definition: device.c:1027
cReceiver * receiver[MAXRECEIVERS]
Definition: device.h:852
void DelPid(int Pid, ePidType PidType=ptOther)
Deletes a PID from the set of PIDs this device shall receive.
Definition: device.c:625
bool AttachReceiver(cReceiver *Receiver)
Attaches the given receiver to this device.
Definition: device.c:1815
static int CurrentChannel(void)
Returns the number of the current channel on the primary device.
Definition: device.h:371
bool IsPrimaryDevice(bool CheckDecoder=true) const
Definition: device.h:223
virtual bool AvoidRecording(void) const
Returns true if this device should only be used for recording if no other device is available.
Definition: device.h:239
static cDevice * primaryDevice
Definition: device.h:127
static bool SetPrimaryDevice(int n)
Sets the primary device to 'n'.
Definition: device.c:194
bool Receiving(bool Dummy=false) const
Returns true if we are currently receiving. The parameter has no meaning (for backwards compatibility...
Definition: device.c:1715
bool Transferring(void) const
Returns true if we are currently in Transfer Mode.
Definition: device.c:1378
virtual int PlayTsAudio(const uchar *Data, int Length)
Plays the given data block as audio.
Definition: device.c:1603
time_t occupiedTimeout
Definition: device.h:266
void StopReplay(void)
Stops the current replay session (if any).
Definition: device.c:1421
virtual void MakePrimaryDevice(bool On)
Informs a device that it will be the primary device.
Definition: device.c:186
virtual bool ProvidesTransponderExclusively(const cChannel *Channel) const
Returns true if this is the only device that is able to provide the given channel's transponder.
Definition: device.c:756
void DetachAll(int Pid)
Detaches all receivers from this device for this pid.
Definition: device.c:1899
virtual bool ProvidesChannel(const cChannel *Channel, int Priority=IDLEPRIORITY, bool *NeedsDetachReceivers=NULL) const
Returns true if this device can provide the given channel.
Definition: device.c:765
bool IsMute(void) const
Definition: device.h:640
virtual cRect CanScaleVideo(const cRect &Rect, int Alignment=taCenter)
Asks the output device whether it can scale the currently shown video in such a way that it fits into...
Definition: device.h:738
int cardIndex
Definition: device.h:189
virtual int SignalQuality(void) const
Returns the "quality" of the currently received signal.
Definition: device.c:795
virtual int SignalStrength(void) const
Returns the "strength" of the currently received signal.
Definition: device.c:790
virtual void Play(void)
Sets the device into play mode (after a previous trick mode).
Definition: device.c:1295
int GetAudioChannel(void)
Gets the current audio channel, which is stereo (0), mono left (1) or mono right (2).
Definition: device.c:1064
cPidHandle pidHandles[MAXPIDHANDLES]
Definition: device.h:425
void EnsureAudioTrack(bool Force=false)
Makes sure an audio track is selected that is actually available.
Definition: device.c:1214
void Detach(cFilter *Filter)
Detaches the given filter from this device.
Definition: device.c:718
cTsToPes tsToPesVideo
Definition: device.h:659
eTrackType currentAudioTrack
Definition: device.h:561
virtual bool SetPlayMode(ePlayMode PlayMode)
Sets the device into the given play mode.
Definition: device.c:1274
virtual bool OpenDvr(void)
Opens the DVR of this device and prepares it to deliver a Transport Stream for use in a cReceiver.
Definition: device.c:1801
const tTrackId * GetTrack(eTrackType Type)
Returns a pointer to the given track id, or NULL if Type is not less than ttMaxTrackTypes.
Definition: device.c:1143
static void SetCurrentChannel(int ChannelNumber)
Sets the number of the current channel on the primary device, without actually switching to it.
Definition: device.h:379
void SetVolume(int Volume, bool Absolute=false)
Sets the volume to the given value, either absolutely or relative to the current volume.
Definition: device.c:1076
virtual void TrickSpeed(int Speed, bool Forward)
Sets the device into a mode where replay is done slower.
Definition: device.c:1284
cLiveSubtitle * liveSubtitle
Definition: device.h:254
virtual void Mute(void)
Turns off audio while replaying.
Definition: device.c:1309
cSectionHandler * SectionHandler(void) const
Definition: device.h:480
virtual bool HasCi(void)
Returns true if this device has a Common Interface.
Definition: device.c:454
virtual cString DeviceType(void) const
Returns a string identifying the type of this device (like "DVB-S").
Definition: device.c:176
virtual const cChannel * GetCurrentlyTunedTransponder(void) const
Returns a pointer to the currently tuned transponder.
Definition: device.c:800
virtual void Freeze(void)
Puts the device into "freeze frame" mode.
Definition: device.c:1302
void SetAudioChannel(int AudioChannel)
Sets the audio channel to stereo (0), mono left (1) or mono right (2).
Definition: device.c:1070
static int NumDevices(void)
Returns the total number of devices.
Definition: device.h:129
virtual int64_t GetSTC(void)
Gets the current System Time Counter, which can be used to synchronize audio, video and subtitles.
Definition: device.c:1279
virtual bool IsBonded(void) const
Returns true if this device is bonded to an other device.
Definition: device.h:217
time_t occupiedFrom
Definition: device.h:265
virtual void SetVideoDisplayFormat(eVideoDisplayFormat VideoDisplayFormat)
Sets the video display format to the given one (only useful if this device has an MPEG decoder).
Definition: device.c:506
bool isPlayingVideo
Definition: device.h:662
virtual bool Flush(int TimeoutMs=0)
Returns true if the device's output buffers are empty, i.
Definition: device.c:1435
virtual bool HasDecoder(void) const
Tells whether this device has an MPEG decoder.
Definition: device.c:212
virtual int PlayTsSubtitle(const uchar *Data, int Length)
Plays the given data block as a subtitle.
Definition: device.c:1619
virtual void SetVideoFormat(bool VideoFormat16_9)
Sets the output video format to either 16:9 or 4:3 (only useful if this device has an MPEG decoder).
Definition: device.c:529
virtual void CloseDvr(void)
Shuts down the DVR.
Definition: device.c:1806
virtual void CloseFilter(int Handle)
Closes a file handle that has previously been opened by OpenFilter().
Definition: device.c:707
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView)
Sets the device to the given channel (actual physical setup).
Definition: device.c:1006
bool AttachPlayer(cPlayer *Player)
Attaches the given player to this device.
Definition: device.c:1383
void ClrAvailableTracks(bool DescriptionsOnly=false, bool IdsOnly=false)
Clears the list of currently available tracks.
Definition: device.c:1091
virtual bool HasProgramme(void) const
Returns true if the device is currently showing any programme to the user, either through replaying o...
Definition: device.c:1016
virtual void ScaleVideo(const cRect &Rect=cRect::Null)
Scales the currently shown video in such a way that it fits into the given Rect.
Definition: device.h:759
int volume
Definition: device.h:626
void EnsureSubtitleTrack(void)
Makes sure one of the preferred language subtitle tracks is selected.
Definition: device.c:1247
static int CurrentVolume(void)
Definition: device.h:652
virtual void DetachAllReceivers(void)
Detaches all receivers from this device.
Definition: device.c:1912
virtual bool IsTunedToTransponder(const cChannel *Channel) const
Returns true if this device is currently tuned to the given Channel's transponder.
Definition: device.c:805
virtual bool CanReplay(void) const
Returns true if this device can currently start a replay session.
Definition: device.c:1269
int NumTracks(eTrackType FirstTrack, eTrackType LastTrack) const
Returns the number of tracks in the given range that are currently available.
Definition: device.c:1148
static cDevice * PrimaryDevice(void)
Returns the primary device.
Definition: device.h:148
void AttachFilter(cFilter *Filter)
Attaches the given filter to this device.
Definition: device.c:712
virtual cSpuDecoder * GetSpuDecoder(void)
Returns a pointer to the device's SPU decoder (or NULL, if this device doesn't have an SPU decoder).
Definition: device.c:217
virtual bool HasIBPTrickSpeed(void)
Returns true if this device can handle all frames in 'fast forward' trick speeds.
Definition: device.h:767
virtual bool Ready(void)
Returns true if this device is ready.
Definition: device.c:1710
cMutex mutexChannel
Definition: device.h:264
static cDevice * GetDeviceForTransponder(const cChannel *Channel, int Priority)
Returns a device that is not currently "occupied" and can be tuned to the transponder of the given Ch...
Definition: device.c:427
virtual void GetOsdSize(int &Width, int &Height, double &PixelAspect)
Returns the Width, Height and PixelAspect ratio the OSD should use to best fit the resolution of the ...
Definition: device.c:540
tTrackId availableTracks[ttMaxTrackTypes]
Definition: device.h:560
virtual bool GetTSPacket(uchar *&Data)
Gets exactly one TS packet from the DVR of this device and returns a pointer to it in Data.
Definition: device.c:1810
virtual void Clear(void)
Clears all video and audio data from the device.
Definition: device.c:1288
const cSdtFilter * SdtFilter(void) const
Definition: device.h:479
cTsToPes tsToPesSubtitle
Definition: device.h:661
int CardIndex(void) const
Returns the card index of this device (0 ... MAXDEVICES - 1).
Definition: device.h:224
bool SetAvailableTrack(eTrackType Type, int Index, uint16_t Id, const char *Language=NULL, const char *Description=NULL)
Sets the track of the given Type and Index to the given values.
Definition: device.c:1114
void SetOccupied(int Seconds, int Priority=MINPRIORITY, time_t From=0)
Sets the occupied timeout for this device to the given number of Seconds, This can be used to tune a ...
Definition: device.c:991
static int numDevices
Definition: device.h:124
int NumAudioTracks(void) const
Returns the number of audio tracks that are currently available.
Definition: device.c:1158
virtual int PlayPesPacket(const uchar *Data, int Length, bool VideoOnly=false)
Plays the single PES packet in Data with the given Length.
Definition: device.c:1457
bool ToggleMute(void)
Turns the volume off or on and returns the new mute state.
Definition: device.c:1047
void SetPowerSaveIfUnused(void)
Sets this device into a power save mode if it is not currently used and has implemented SetPowerSaveM...
Definition: device.c:819
void DelLivePids(void)
Deletes the live viewing PIDs.
Definition: device.c:661
static int currentChannel
Definition: device.h:269
virtual int PlayTs(const uchar *Data, int Length, bool VideoOnly=false)
Plays the given TS packet.
Definition: device.c:1632
cPatPmtParser patPmtParser
Definition: device.h:658
bool AddPid(int Pid, ePidType PidType=ptOther, int StreamType=0)
Adds a PID to the set of PIDs this device shall receive.
Definition: device.c:560
cMutex mutexCurrentSubtitleTrack
Definition: device.h:564
int pre_1_3_19_PrivateStream
Definition: device.h:568
bool DeviceHooksProvidesTransponder(const cChannel *Channel) const
Definition: device.c:729
virtual int ReadFilter(int Handle, void *Buffer, size_t Length)
Reads data from a handle for the given filter.
Definition: device.c:702
virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask)
Opens a file handle for the given filter data.
Definition: device.c:697
cSdtFilter * sdtFilter
Definition: device.h:450
static cDevice * device[MAXDEVICES]
Definition: device.h:126
int occupiedPriority
Definition: device.h:267
void ForceTransferMode(void)
Forces the device into transfermode for the current channel.
Definition: device.c:972
virtual int PlayAudio(const uchar *Data, int Length, uchar Id)
Plays the given data block as audio.
Definition: device.c:1445
cMutex mutexPids
Definition: device.h:413
bool SetCurrentAudioTrack(eTrackType Type)
Sets the current audio track to the given Type.
Definition: device.c:1168
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
Definition: device.c:1729
virtual bool ProvidesTransponder(const cChannel *Channel) const
Returns true if this device can provide the transponder of the given Channel (which implies that it c...
Definition: device.c:751
virtual void SetDigitalAudioDevice(bool On)
Tells the output device that the current audio track is Dolby Digital.
Definition: device.c:1035
cCamSlot * CamSlot(void) const
Returns the CAM slot that is currently used with this device, or NULL if no CAM slot is in use.
Definition: device.h:499
virtual void StillPicture(const uchar *Data, int Length)
Displays the given I-frame as a still picture.
Definition: device.c:1314
virtual int PlaySubtitle(const uchar *Data, int Length)
Plays the given data block as a subtitle.
Definition: device.c:1450
virtual void SetVolumeDevice(int Volume)
Sets the audio volume on this device (Volume = 0...255).
Definition: device.c:1031
Definition: eit.h:48
Definition: filter.h:80
Definition: thread.h:67
Definition: nit.h:16
Definition: pat.h:21
Definition: player.h:16
Definition: tools.h:434
A steerable satellite dish generally points to the south on the northern hemisphere,...
Definition: positioner.h:31
Definition: osd.h:352
static const cRect Null
Definition: osd.h:357
Definition: sdt.h:16
Definition: tools.h:178
Derived cDevice classes that can receive channels will have to provide Transport Stream (TS) packets ...
Definition: device.h:895
cTSBuffer(int File, int Size, int DeviceNumber)
Definition: device.c:1922
int delivered
Definition: device.h:899
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
Definition: device.c:1940
uchar * Get(int *Available=NULL, bool CheckAvailable=false)
Returns a pointer to the first TS packet in the buffer.
Definition: device.c:1963
cRingBufferLinear * ringBuffer
Definition: device.h:900
void Skip(int Count)
If after a call to Get() more or less than TS_SIZE of the available data has been processed,...
Definition: device.c:1993
int deviceNumber
Definition: device.h:898
virtual ~cTSBuffer()
Definition: device.c:1934
int f
Definition: device.h:897
Definition: thread.h:79
#define MINPRIORITY
Definition: config.h:44
#define IDLEPRIORITY
Definition: config.h:47
#define MAXPIDHANDLES
Definition: device.h:30
eVideoDisplayFormat
Definition: device.h:58
@ vdfLetterBox
Definition: device.h:59
@ vdfCenterCutOut
Definition: device.h:60
@ vdfPanAndScan
Definition: device.h:58
ePlayMode
Definition: device.h:39
@ pmAudioOnlyBlack
Definition: device.h:42
@ pmNone
Definition: device.h:39
@ pmVideoOnly
Definition: device.h:43
@ pmAudioOnly
Definition: device.h:41
@ pmAudioVideo
Definition: device.h:40
@ pmExtern_THIS_SHOULD_BE_AVOIDED
Definition: device.h:44
#define MAXDEVICES
Definition: device.h:29
eTrackType
Definition: device.h:63
@ ttSubtitle
Definition: device.h:70
@ ttMaxTrackTypes
Definition: device.h:73
@ ttDolbyLast
Definition: device.h:69
@ ttAudioLast
Definition: device.h:66
@ ttDolby
Definition: device.h:67
@ ttAudioFirst
Definition: device.h:65
@ ttSubtitleLast
Definition: device.h:72
@ ttDolbyFirst
Definition: device.h:68
@ ttSubtitleFirst
Definition: device.h:71
@ ttAudio
Definition: device.h:64
@ ttNone
Definition: device.h:63
#define MAXRECEIVERS
Definition: device.h:31
eSetChannelResult
Definition: device.h:36
@ scrOk
Definition: device.h:36
@ scrNotAvailable
Definition: device.h:36
@ scrFailed
Definition: device.h:36
@ scrNoTransfer
Definition: device.h:36
unsigned char u_char
Definition: headers.h:24
@ taCenter
Definition: osd.h:158
char language[MAXLANGCODE2]
Definition: device.h:82
char description[32]
Definition: device.h:83
uint16_t id
Definition: device.h:81
unsigned char uchar
Definition: tools.h:31