mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Implemented cDeviceHook
This commit is contained in:
parent
2517b2ee8d
commit
644a9f07f2
@ -1246,6 +1246,7 @@ Reinhard Nissl <rnissl@gmx.de>
|
|||||||
for increasing the value of MAXFRAMESIZE to better suit HD recordings
|
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 improving handling frames at the beginning and end of a recording in cDvbPlayer
|
||||||
for devices with large buffers
|
for devices with large buffers
|
||||||
|
for implementing cDeviceHook
|
||||||
|
|
||||||
Richard Robson <richard_robson@beeb.net>
|
Richard Robson <richard_robson@beeb.net>
|
||||||
for reporting freezing replay if a timer starts while in Transfer Mode from the
|
for reporting freezing replay if a timer starts while in Transfer Mode from the
|
||||||
|
2
HISTORY
2
HISTORY
@ -6319,3 +6319,5 @@ Video Disk Recorder Revision History
|
|||||||
"EPG scan" is active (suggested by Halim Sahim).
|
"EPG scan" is active (suggested by Halim Sahim).
|
||||||
- Improved handling frames at the beginning and end of a recording in cDvbPlayer for
|
- Improved handling frames at the beginning and end of a recording in cDvbPlayer for
|
||||||
devices with large buffers (thanks to Reinhard Nissl).
|
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).
|
||||||
|
40
PLUGINS.html
40
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>
|
important that the devices are created on the heap, using the <tt>new</tt>
|
||||||
operator!
|
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>
|
<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>
|
<div class="blurb">"The stereo effect may only be experienced if stereo equipment is used!"</div><p>
|
||||||
|
26
device.c
26
device.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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"
|
#include "device.h"
|
||||||
@ -44,6 +44,18 @@ void cLiveSubtitle::Receive(uchar *Data, int Length)
|
|||||||
cDevice::PrimaryDevice()->PlayTs(Data, 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 ---------------------------------------------------------------
|
// --- cDevice ---------------------------------------------------------------
|
||||||
|
|
||||||
// The default priority for non-primary devices:
|
// The default priority for non-primary devices:
|
||||||
@ -59,6 +71,7 @@ int cDevice::currentChannel = 1;
|
|||||||
cDevice *cDevice::device[MAXDEVICES] = { NULL };
|
cDevice *cDevice::device[MAXDEVICES] = { NULL };
|
||||||
cDevice *cDevice::primaryDevice = NULL;
|
cDevice *cDevice::primaryDevice = NULL;
|
||||||
cDevice *cDevice::avoidDevice = NULL;
|
cDevice *cDevice::avoidDevice = NULL;
|
||||||
|
cList<cDeviceHook> cDevice::deviceHooks;
|
||||||
|
|
||||||
cDevice::cDevice(void)
|
cDevice::cDevice(void)
|
||||||
:patPmtParser(true)
|
:patPmtParser(true)
|
||||||
@ -570,6 +583,17 @@ bool cDevice::ProvidesSource(int Source) const
|
|||||||
return false;
|
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
|
bool cDevice::ProvidesTransponder(const cChannel *Channel) const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
17
device.h
17
device.h
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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
|
#ifndef __DEVICE_H
|
||||||
@ -88,10 +88,18 @@ class cPlayer;
|
|||||||
class cReceiver;
|
class cReceiver;
|
||||||
class cLiveSubtitle;
|
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.
|
/// The cDevice class is the base from which actual devices can be derived.
|
||||||
|
|
||||||
class cDevice : public cThread {
|
class cDevice : public cThread {
|
||||||
friend class cLiveSubtitle;
|
friend class cLiveSubtitle;
|
||||||
|
friend class cDeviceHook;
|
||||||
private:
|
private:
|
||||||
static int numDevices;
|
static int numDevices;
|
||||||
static int useDevice;
|
static int useDevice;
|
||||||
@ -187,6 +195,13 @@ public:
|
|||||||
virtual bool HasDecoder(void) const;
|
virtual bool HasDecoder(void) const;
|
||||||
///< Tells whether this device has an MPEG decoder.
|
///< Tells whether this device has an MPEG decoder.
|
||||||
|
|
||||||
|
// Device hooks
|
||||||
|
|
||||||
|
private:
|
||||||
|
static cList<cDeviceHook> deviceHooks;
|
||||||
|
protected:
|
||||||
|
bool DeviceHooksProvidesTransponder(const cChannel *Channel) const;
|
||||||
|
|
||||||
// SPU facilities
|
// SPU facilities
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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"
|
#include "dvbdevice.h"
|
||||||
@ -608,10 +608,12 @@ bool cDvbDevice::ProvidesTransponder(const cChannel *Channel) const
|
|||||||
if (!ProvidesSource(Channel->Source()))
|
if (!ProvidesSource(Channel->Source()))
|
||||||
return false; // doesn't provide source
|
return false; // doesn't provide source
|
||||||
if (!cSource::IsSat(Channel->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)
|
if (frontendType == SYS_DVBS && Channel->System() == SYS_DVBS2)
|
||||||
return false; // requires modulation system which frontend doesn't provide
|
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
|
bool cDvbDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const
|
||||||
|
Loading…
Reference in New Issue
Block a user