diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2010-02-06 14:23:03 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2010-02-06 14:23:03 +0100 |
commit | 644a9f07f26df58b7d79cea8ea961c2232a092be (patch) | |
tree | 3f47c7be9bdb0af8ac5db55e2932c3e9cd0b153b | |
parent | 2517b2ee8df0a10ae03135a62a9356d4aebdfe64 (diff) | |
download | vdr-644a9f07f26df58b7d79cea8ea961c2232a092be.tar.gz vdr-644a9f07f26df58b7d79cea8ea961c2232a092be.tar.bz2 |
Implemented cDeviceHook
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | HISTORY | 2 | ||||
-rw-r--r-- | PLUGINS.html | 40 | ||||
-rw-r--r-- | device.c | 26 | ||||
-rw-r--r-- | device.h | 17 | ||||
-rw-r--r-- | dvbdevice.c | 8 |
6 files changed, 89 insertions, 5 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 16889e05..58045fc9 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1246,6 +1246,7 @@ Reinhard Nissl <rnissl@gmx.de> 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 <richard_robson@beeb.net> for reporting freezing replay if a timer starts while in Transfer Mode from the @@ -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 <tt>new</tt> operator! +<div class="modified"> +<p> +<b>Device hooks</b> +<p> +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 <i>device hooks</i> can be used. + +<p><table><tr><td class="code"><pre> +class cMyDeviceHook : public cDeviceHook { +public: + cMyDeviceHook(void); + virtual bool DeviceProvidesTransponder(const cDevice *Device, const cChannel *Channel) const; + }; +</pre></td></tr></table><p> + +In its <tt>DeviceProvidesTransponder()</tt> 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 + +<p><table><tr><td class="code"><pre> +void cMyDeviceHook::DeviceProvidesTransponder(const cDevice *Device, const cChannel *Channel) const +{ + if (<i>condition where Device can't provide Channel</i>) + return false; + return true; +} +</pre></td></tr></table><p> + +A plugin that creates a derived cDeviceHook shall do so in its <tt>Initialize()</tt> +function, as in + +<p><table><tr><td class="code"><pre> +new cMyDeviceHook; +</pre></td></tr></table><p> + +and shall not delete this object. It will be automatically deleted when the program ends. +</div modified> + <hr><h2><a name="Audio">Audio</a></h2> <div class="blurb">"The stereo effect may only be experienced if stereo equipment is used!"</div><p> @@ -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<cDeviceHook> 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; @@ -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<cDeviceHook> 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 |