From a4246cfd9aa7f3c5a02145815a1e26dcace09327 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 28 Jul 2002 11:29:32 +0200 Subject: Fixed PID handling for cReceiver --- HISTORY | 3 +- PLUGINS.html | 90 ++++++++++++++++++++++++++++++++++++++++++++---------------- device.c | 20 ++++---------- device.h | 4 +-- receiver.c | 4 ++- receiver.h | 5 +++- 6 files changed, 84 insertions(+), 42 deletions(-) diff --git a/HISTORY b/HISTORY index d59d6ccd..420329f5 100644 --- a/HISTORY +++ b/HISTORY @@ -1379,7 +1379,7 @@ Video Disk Recorder Revision History for pointing out this one). - Disabled channels on Transponder 12070 in 'channels.conf', which apparently no longer transmits. -2002-07-27: Version 1.1.6 +2002-07-28: Version 1.1.6 - Re-visited the race condition fix in the cDvbPlayer (thanks again to Andreas Schultz). @@ -1387,3 +1387,4 @@ Video Disk Recorder Revision History to set it when compiling a new version of VDR to at least see their recordings made with VFAT enabled (thanks to Christian Rienecker). - Added some missing teletext PIDs (thanks to Joerg Riechardt). +- Fixed PID handling for cReceiver. diff --git a/PLUGINS.html b/PLUGINS.html index 3d450c25..2a66e88d 100644 --- a/PLUGINS.html +++ b/PLUGINS.html @@ -12,7 +12,7 @@ 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 is divided into two parts, the first one describing the outside interface of the plugin system, and the second one describing the @@ -23,18 +23,18 @@ The inside interface provides the plugin code access to VDR's internal da structures and allows it to hook itself into specific areas to perform special actions.

-
  -Important modifications introduced in version 1.1.2 are marked like this. -
-
  +
  Important modifications introduced in version 1.1.3 are marked like this.
-
  +
  Important modifications introduced in version 1.1.4 are marked like this.
-
  +
  Important modifications introduced in version 1.1.5 are marked like this.
+
  +Important modifications introduced in version 1.1.6 are marked like this. +

Part I - The Outside Interface

@@ -131,15 +131,12 @@ from the web, it will typically have a name like

and will unpack into a directory named

-
  hello-0.0.1 -

To use the plugins and plugins-clean targets from the VDR Makefile you need to unpack such an archive into the VDR/PLUGINS/src directory and create a symbolic link with the basic plugin name, as in -
 


ln -s hello-0.0.1 hello

@@ -149,7 +146,6 @@ of only lowercase characters and digits, it will only follow the symbolic links, should lead to the current version of the plugin you want to use. This way you can have several different versions of a plugin source (like hello-0.0.1 and hello-0.0.2) and define which one to actually use through the symbolic link. -


Initializing a new plugin directory

@@ -422,11 +418,9 @@ If a plugin implements a function that runs in the background (presumably in a thread of its own), or wants to make use of internationalization, it needs to implement the function -
 


virtual bool Start(void);

-

which is called once for each plugin at program startup. Inside this function the plugin must set up everything necessary to perform @@ -434,12 +428,10 @@ its task. This may, for instance, be a thread that collects data from the DVB stream, which is later presented to the user via a function that is available from the main menu.

-
  A return value of false indicates that something has gone wrong and the plugin will not be able to perform its task. In that case, the plugin should write a proper error message to the log file. The first plugin that returns false from its Start() function will cause VDR to exit. -

If the plugin doesn't implement any background functionality or internationalized texts, it doesn't need to implement this function. @@ -498,7 +490,6 @@ interaction is possible. If a specific action takes longer than a few seconds, the plugin should launch a separate thread to do this. -
 

Housekeeping

Chores, chores...

@@ -523,7 +514,6 @@ as possible! As long as the program stays inside this function, no other user interaction is possible. If a specific action takes longer than a few seconds, the plugin should launch a separate thread to do this. -


Setup parameters

@@ -656,7 +646,6 @@ You can first assign the temporary values to the global variables and then do th your setup parameters and use that one to copy all parameters with one single statement (like VDR does with its cSetup class). -
 

Configuration files

I want my own stuff!

@@ -711,7 +700,6 @@ plugin class, by writing


const char *MyConfigDir = cPlugin::ConfigDirectory();

-


Internationalization

@@ -826,7 +814,7 @@ and display their help and/or version information in addition to its own output. If you want to make your plugin available to other VDR users, you'll need to make a package that can be easily distributed. -
  +
  The Makefile that has been created by the call to newplugin provides the target dist, which does this for you. @@ -848,7 +836,7 @@ 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

@@ -925,7 +913,7 @@ member functions are available in cStatus. You only need to implement the functions you actually want to use.
-
  +
 

Players

Play it again, Sam!

@@ -1076,7 +1064,63 @@ that they already know. If you absolutely want to do things differently, just go ahead - it's your show...

-
  +
  +

Receivers

+ +
Tapping into the stream...

+ +In order to receive any kind of data from a cDevice, a plugin must set up an +object derived from the cReceiver class: + +


+#include <vdr/receiver.h> + +class cMyReceiver : public cReceiver, cThread { +protected: + virtual void Activate(bool On); + virtual void Receive(uchar *Data, int Length); +public: + cMyReceiver(int Pid); + }; + +cMyReceiver::cMyReceiver(int Pid) +:cReceiver(0, -1, 1, Pid) +{ +} + +void cMyReceiver::Activate(bool On) +{ + // start your own thread for processing the received data +} + +void cMyReceiver::Receive(uchar *Data, int Length) +{ + // buffer the data for processing in a separate thread +} +

+ +See the comments in VDR/receiver.h for details about the various +member functions of cReceiver. +

+The above example sets up a receiver that wants to receive data from only one +PID (for example the Teletext PID). In order to not interfere with other recording +operations, it sets its priority to -1 (any negative value will allow +a cReceiver to be detached from its cDevice at any time. +

+Once a cReceiver has been created, it needs to be attached to +a cDevice: + +


+cMyReceiver *Receiver = new cMyReceiver(123); + +cDevice::PrimaryDevice()->AttachReceiver(Receiver); +

+ +If the cReceiver isn't needed any more, it may simply be deleted +and will automatically detach itself from the cDevice. +

+ +
 

The On Screen Display

Express yourself

diff --git a/device.c b/device.c index c85cd450..9e707515 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 1.5 2002/06/23 12:51:24 kls Exp $ + * $Id: device.c 1.6 2002/07/28 11:03:53 kls Exp $ */ #include "device.h" @@ -882,7 +882,7 @@ int cDevice::ProvidesCa(int Ca) bool cDevice::Receiving(void) { for (int i = 0; i < MAXRECEIVERS; i++) { - if (receiver[i]) + if (receiver[i] && receiver[i]->priority > 0) // cReceiver with priority < 0 doesn't count return true; } return false; @@ -964,12 +964,8 @@ bool cDevice::AttachReceiver(cReceiver *Receiver) for (int i = 0; i < MAXRECEIVERS; i++) { if (!receiver[i]) { //siProcessor->SetStatus(false);//XXX+ - for (int n = 0; n < MAXRECEIVEPIDS; n++) { - if (Receiver->pids[n]) - AddPid(Receiver->pids[n]);//XXX+ retval! - else - break; - } + for (int n = 0; n < MAXRECEIVEPIDS; n++) + AddPid(Receiver->pids[n]);//XXX+ retval! Receiver->Activate(true); Lock(); Receiver->device = this; @@ -995,12 +991,8 @@ void cDevice::Detach(cReceiver *Receiver) receiver[i] = NULL; Receiver->device = NULL; Unlock(); - for (int n = 0; n < MAXRECEIVEPIDS; n++) { - if (Receiver->pids[n]) - DelPid(Receiver->pids[n]); - else - break; - } + for (int n = 0; n < MAXRECEIVEPIDS; n++) + DelPid(Receiver->pids[n]); } else if (receiver[i]) receiversLeft = true; diff --git a/device.h b/device.h index 6f2a34fd..124dcdc3 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 1.3 2002/06/23 11:50:24 kls Exp $ + * $Id: device.h 1.4 2002/07/28 10:48:12 kls Exp $ */ #ifndef __DEVICE_H @@ -89,7 +89,7 @@ private: public: cDevice(int n); virtual ~cDevice(); - bool IsPrimaryDevice(void) { return this == primaryDevice; } + bool IsPrimaryDevice(void) const { return this == primaryDevice; } int CardIndex(void) const { return cardIndex; } // Returns the card index of this device (0 ... MAXDEVICES - 1). int ProvidesCa(int Ca); diff --git a/receiver.c b/receiver.c index 6ddbaa64..8f94c1a1 100644 --- a/receiver.c +++ b/receiver.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: receiver.c 1.1 2002/06/10 16:30:00 kls Exp $ + * $Id: receiver.c 1.2 2002/07/28 10:48:42 kls Exp $ */ #include @@ -16,6 +16,8 @@ cReceiver::cReceiver(int Ca, int Priority, int NumPids, ...) device = NULL; ca = Ca; priority = Priority; + for (int i = 0; i < MAXRECEIVEPIDS; i++) + pids[i] = 0; if (NumPids) { va_list ap; va_start(ap, NumPids); diff --git a/receiver.h b/receiver.h index 87fe9b86..8ad8bc06 100644 --- a/receiver.h +++ b/receiver.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: receiver.h 1.1 2002/06/10 16:30:00 kls Exp $ + * $Id: receiver.h 1.2 2002/07/28 11:22:01 kls Exp $ */ #ifndef __RECEIVER_H @@ -42,6 +42,9 @@ public: // the given Priority. NumPids defines the number of PIDs that follow // this parameter. If any of these PIDs are 0, they will be silently ignored. // The total number of non-zero PIDs must not exceed MAXRECEIVEPIDS. + // Priority may be any value in the range 0..99. Negative values indicate + // that this cReceiver may be detached at any time (without blocking the + // cDevice it is attached to). virtual ~cReceiver(); }; -- cgit v1.2.3