diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 16889e05..58045fc9 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1246,6 +1246,7 @@ Reinhard Nissl for increasing the value of MAXFRAMESIZE to better suit HD recordings for improving handling frames at the beginning and end of a recording in cDvbPlayer for devices with large buffers + for implementing cDeviceHook Richard Robson for reporting freezing replay if a timer starts while in Transfer Mode from the diff --git a/HISTORY b/HISTORY index cfd60e71..12b411f3 100644 --- a/HISTORY +++ b/HISTORY @@ -6319,3 +6319,5 @@ Video Disk Recorder Revision History "EPG scan" is active (suggested by Halim Sahim). - Improved handling frames at the beginning and end of a recording in cDvbPlayer for devices with large buffers (thanks to Reinhard Nissl). +- Implemented cDeviceHook to allow plugins more control over which device can + provide which transponder (thanks to Reinhard Nissl). diff --git a/PLUGINS.html b/PLUGINS.html index 9167a4b9..05fb7ed0 100644 --- a/PLUGINS.html +++ b/PLUGINS.html @@ -1970,6 +1970,46 @@ shut down (delete) all devices when the program terminates. It is therefore important that the devices are created on the heap, using the new operator! +
+

+Device hooks +

+VDR has builtin facilities that select which device is able to provide a given +transponder. However, there may be situations where the setup is so special +that it requires considerations that exceed the scope of the core VDR code. +This is where device hooks can be used. + +

+class cMyDeviceHook : public cDeviceHook {
+public:
+  cMyDeviceHook(void);
+  virtual bool DeviceProvidesTransponder(const cDevice *Device, const cChannel *Channel) const;
+  };
+

+ +In its DeviceProvidesTransponder() function the device hook can take +whatever actions are necessary to determine whether the given Device can +provide the given Channel's transponder, as in + +

+void cMyDeviceHook::DeviceProvidesTransponder(const cDevice *Device, const cChannel *Channel) const
+{
+  if (condition where Device can't provide Channel)
+     return false;
+  return true;
+}
+

+ +A plugin that creates a derived cDeviceHook shall do so in its Initialize() +function, as in + +

+new cMyDeviceHook;
+

+ +and shall not delete this object. It will be automatically deleted when the program ends. +

+

Audio

"The stereo effect may only be experienced if stereo equipment is used!"

diff --git a/device.c b/device.c index cb31b834..88c46736 100644 --- a/device.c +++ b/device.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.c 2.32 2010/01/30 11:06:51 kls Exp $ + * $Id: device.c 2.33 2010/02/06 13:55:50 kls Exp $ */ #include "device.h" @@ -44,6 +44,18 @@ void cLiveSubtitle::Receive(uchar *Data, int Length) cDevice::PrimaryDevice()->PlayTs(Data, Length); } +// --- cDeviceHook ----------------------------------------------------------- + +cDeviceHook::cDeviceHook(void) +{ + cDevice::deviceHooks.Add(this); +} + +bool cDeviceHook::DeviceProvidesTransponder(const cDevice *Device, const cChannel *Channel) const +{ + return true; +} + // --- cDevice --------------------------------------------------------------- // The default priority for non-primary devices: @@ -59,6 +71,7 @@ int cDevice::currentChannel = 1; cDevice *cDevice::device[MAXDEVICES] = { NULL }; cDevice *cDevice::primaryDevice = NULL; cDevice *cDevice::avoidDevice = NULL; +cList cDevice::deviceHooks; cDevice::cDevice(void) :patPmtParser(true) @@ -570,6 +583,17 @@ bool cDevice::ProvidesSource(int Source) const return false; } +bool cDevice::DeviceHooksProvidesTransponder(const cChannel *Channel) const +{ + cDeviceHook *Hook = deviceHooks.First(); + while (Hook) { + if (!Hook->DeviceProvidesTransponder(this, Channel)) + return false; + Hook = deviceHooks.Next(Hook); + } + return true; +} + bool cDevice::ProvidesTransponder(const cChannel *Channel) const { return false; diff --git a/device.h b/device.h index 897de2af..9318bb1b 100644 --- a/device.h +++ b/device.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.h 2.19 2010/01/01 15:04:27 kls Exp $ + * $Id: device.h 2.20 2010/02/06 13:55:41 kls Exp $ */ #ifndef __DEVICE_H @@ -88,10 +88,18 @@ class cPlayer; class cReceiver; class cLiveSubtitle; +class cDeviceHook : public cListObject { +public: + cDeviceHook(void); + virtual bool DeviceProvidesTransponder(const cDevice *Device, const cChannel *Channel) const; + ///< Returns true if the given Device can provide the given Channel's transponder. + }; + /// The cDevice class is the base from which actual devices can be derived. class cDevice : public cThread { friend class cLiveSubtitle; + friend class cDeviceHook; private: static int numDevices; static int useDevice; @@ -187,6 +195,13 @@ public: virtual bool HasDecoder(void) const; ///< Tells whether this device has an MPEG decoder. +// Device hooks + +private: + static cList deviceHooks; +protected: + bool DeviceHooksProvidesTransponder(const cChannel *Channel) const; + // SPU facilities private: diff --git a/dvbdevice.c b/dvbdevice.c index 07e2dbb1..05b89fc1 100644 --- a/dvbdevice.c +++ b/dvbdevice.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbdevice.c 2.24 2010/01/04 14:06:24 kls Exp $ + * $Id: dvbdevice.c 2.25 2010/02/06 13:44:08 kls Exp $ */ #include "dvbdevice.h" @@ -608,10 +608,12 @@ bool cDvbDevice::ProvidesTransponder(const cChannel *Channel) const if (!ProvidesSource(Channel->Source())) return false; // doesn't provide source if (!cSource::IsSat(Channel->Source())) - return true; // source is sufficient for non sat + return DeviceHooksProvidesTransponder(Channel); // source is sufficient for non sat if (frontendType == SYS_DVBS && Channel->System() == SYS_DVBS2) return false; // requires modulation system which frontend doesn't provide - return !Setup.DiSEqC || Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization()); + if (!Setup.DiSEqC || Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization())) + return DeviceHooksProvidesTransponder(Channel); + return false; } bool cDvbDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const