From 9f9d6a8a9354960eb9c42f9c45ed507f05804ff4 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 19 May 2002 15:50:11 +0200 Subject: Implemented cStatusMonitor to allow plugins to set up a status monitor --- PLUGINS.html | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 3 deletions(-) (limited to 'PLUGINS.html') diff --git a/PLUGINS.html b/PLUGINS.html index 6caff0e8..f531f361 100644 --- a/PLUGINS.html +++ b/PLUGINS.html @@ -4,7 +4,7 @@ -

The VDR Plugin System

+

The VDR Plugin System

VDR provides an easy to use plugin interface that allows additional functionality to be added to the program by implementing a dynamically loadable library file. @@ -12,9 +12,16 @@ This interface allows programmers to develop additional functionality for VDR co separate from the core VDR source, without the need of patching the original VDR code (and all the problems of correlating various patches).

-This document describes the "outside" interface of the plugin system. -It handles everything necessary for a plugin to get hooked into the core +
  +This document is divided into two parts, the first one describing the +outside interface +of the plugin system, and the second one describing the +inside interface. +The outside interface handles everything necessary for a plugin to get hooked into the core VDR program and present itself to the user. +The inside interface provides the plugin code access to VDR's internal data +structures and allows it to hook itself into specific areas to perform special actions. +

  Important modifications introduced in version 1.1.1 are marked like this. @@ -27,6 +34,8 @@ Important modifications introduced in version 1.1.3 are marked like this.
+


Part I - The Outside Interface

+

Quick start

Can't wait, can't wait!

@@ -840,5 +849,82 @@ vdr-hello-0.0.1.tgz in your source directory, where hello will be replaced with your actual plugin's name, and 0.0.1 will be your plugin's current version number. +
  +

Part II - The Inside Interface

+ +

Status monitor

+ +
A piece of the action

+ +If a plugin wants to get informed on various events in VDR, it can derive a class from +cStatusMonitor, as in + +


+#include <vdr/status.h> + +class cMyStatusMonitor : public cStatusMonitor { +protected: + virtual void ChannelSwitch(const cDvbApi *DvbApi, int ChannelNumber); + }; + +void cMyStatusMonitor::ChannelSwitch(const cDvbApi *DvbApi, int ChannelNumber) +{ + if (ChannelNumber) + dsyslog("channel switched to %d on DVB %d", ChannelNumber, DvbApi->CardIndex()); + else + dsyslog("about to switch channel on DVB %d", DvbApi->CardIndex()); +} +

+ +An object of this class will be informed whenever the channel is switched on one of +the DVB devices. It could be used in a plugin like this: + +


+#include <vdr/plugin.h> + +class cPluginStatus : public cPlugin { +private: + cMyStatusMonitor *statusMonitor; +public: + cPluginStatus(void); + virtual ~cPluginStatus(); + ... + virtual bool Start(void); + ... + }; + +cPluginStatus::cPluginStatus(void) +{ + statusMonitor = NULL; +} + +cPluginStatus::~cPluginStatus() +{ + delete statusMonitor; +} + +bool cPluginStatus::Start(void) +{ + statusMonitor = new cMyStatusMonitor; + return true; +} +

+ +Note that the actual object is created in the Start() function, not in the +constructor! It is also important to delete the object in the destructor, in order to +avoid memory leaks. +

+A Plugin can implement any number of cStatusMonitor derived objects, and once +the plugin has been started it may create and delete them as necessary. +No further action apart from creating an object derived from cStatusMonitor +is necessary. VDR will automatically hook it into a list of status monitors, with +their individual virtual member functions being called in the same sequence as the +objects were created. +

+See the file status.h for detailed information on which status monitor +member functions are available in cStatusMonitor. You only need to implement +the functions you actually want to use. +

+ -- cgit v1.2.3