2002-08-04 14:57:29 +02:00
|
|
|
/*
|
2009-12-31 15:38:18 +01:00
|
|
|
* dvbdevice.h: The DVB device tuner interface
|
2002-08-04 14:57:29 +02:00
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2010-02-28 12:19:50 +01:00
|
|
|
* $Id: dvbdevice.h 2.13 2010/02/21 14:06:08 kls Exp $
|
2002-08-04 14:57:29 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DVBDEVICE_H
|
|
|
|
#define __DVBDEVICE_H
|
|
|
|
|
2009-06-01 11:33:12 +02:00
|
|
|
#include <sys/mman.h> // FIXME: workaround for broken linux-dvb header files
|
2002-08-10 14:58:25 +02:00
|
|
|
#include <linux/dvb/frontend.h>
|
2002-11-03 12:31:51 +01:00
|
|
|
#include <linux/dvb/version.h>
|
2002-08-04 14:57:29 +02:00
|
|
|
#include "device.h"
|
|
|
|
|
2009-10-25 13:58:20 +01:00
|
|
|
#if DVB_API_VERSION < 5
|
|
|
|
#error VDR requires Linux DVB driver API version 5.0 or higher!
|
2002-11-03 12:31:51 +01:00
|
|
|
#endif
|
|
|
|
|
2007-02-25 12:25:57 +01:00
|
|
|
#define MAXDVBDEVICES 8
|
2002-09-04 17:26:02 +02:00
|
|
|
|
2009-12-31 15:38:18 +01:00
|
|
|
#define DEV_VIDEO "/dev/video"
|
|
|
|
#define DEV_DVB_ADAPTER "/dev/dvb/adapter"
|
|
|
|
#define DEV_DVB_OSD "osd"
|
|
|
|
#define DEV_DVB_FRONTEND "frontend"
|
|
|
|
#define DEV_DVB_DVR "dvr"
|
|
|
|
#define DEV_DVB_DEMUX "demux"
|
|
|
|
#define DEV_DVB_VIDEO "video"
|
|
|
|
#define DEV_DVB_AUDIO "audio"
|
|
|
|
#define DEV_DVB_CA "ca"
|
|
|
|
|
2010-02-28 12:19:50 +01:00
|
|
|
struct tDvbParameterMap {
|
|
|
|
int userValue;
|
|
|
|
int driverValue;
|
|
|
|
const char *userString;
|
|
|
|
};
|
|
|
|
|
|
|
|
int MapToUser(int Value, const tDvbParameterMap *Map, const char **String = NULL);
|
|
|
|
int MapToDriver(int Value, const tDvbParameterMap *Map);
|
|
|
|
int UserIndex(int Value, const tDvbParameterMap *Map);
|
|
|
|
int DriverIndex(int Value, const tDvbParameterMap *Map);
|
|
|
|
|
|
|
|
extern const tDvbParameterMap InversionValues[];
|
|
|
|
extern const tDvbParameterMap BandwidthValues[];
|
|
|
|
extern const tDvbParameterMap CoderateValues[];
|
|
|
|
extern const tDvbParameterMap ModulationValues[];
|
|
|
|
extern const tDvbParameterMap SystemValues[];
|
|
|
|
extern const tDvbParameterMap TransmissionValues[];
|
|
|
|
extern const tDvbParameterMap GuardValues[];
|
|
|
|
extern const tDvbParameterMap HierarchyValues[];
|
|
|
|
extern const tDvbParameterMap RollOffValues[];
|
|
|
|
|
|
|
|
class cDvbTransponderParameters {
|
|
|
|
friend class cDvbSourceParam;
|
|
|
|
private:
|
|
|
|
char polarization;
|
|
|
|
int inversion;
|
|
|
|
int bandwidth;
|
|
|
|
int coderateH;
|
|
|
|
int coderateL;
|
|
|
|
int modulation;
|
|
|
|
int system;
|
|
|
|
int transmission;
|
|
|
|
int guard;
|
|
|
|
int hierarchy;
|
|
|
|
int rollOff;
|
|
|
|
int PrintParameter(char *p, char Name, int Value) const;
|
|
|
|
const char *ParseParameter(const char *s, int &Value, const tDvbParameterMap *Map);
|
|
|
|
public:
|
|
|
|
cDvbTransponderParameters(const char *Parameters = NULL);
|
|
|
|
char Polarization(void) const { return polarization; }
|
|
|
|
int Inversion(void) const { return inversion; }
|
|
|
|
int Bandwidth(void) const { return bandwidth; }
|
|
|
|
int CoderateH(void) const { return coderateH; }
|
|
|
|
int CoderateL(void) const { return coderateL; }
|
|
|
|
int Modulation(void) const { return modulation; }
|
|
|
|
int System(void) const { return system; }
|
|
|
|
int Transmission(void) const { return transmission; }
|
|
|
|
int Guard(void) const { return guard; }
|
|
|
|
int Hierarchy(void) const { return hierarchy; }
|
|
|
|
int RollOff(void) const { return rollOff; }
|
|
|
|
void SetPolarization(char Polarization) { polarization = Polarization; }
|
|
|
|
void SetInversion(int Inversion) { inversion = Inversion; }
|
|
|
|
void SetBandwidth(int Bandwidth) { bandwidth = Bandwidth; }
|
|
|
|
void SetCoderateH(int CoderateH) { coderateH = CoderateH; }
|
|
|
|
void SetCoderateL(int CoderateL) { coderateL = CoderateL; }
|
|
|
|
void SetModulation(int Modulation) { modulation = Modulation; }
|
|
|
|
void SetSystem(int System) { system = System; }
|
|
|
|
void SetTransmission(int Transmission) { transmission = Transmission; }
|
|
|
|
void SetGuard(int Guard) { guard = Guard; }
|
|
|
|
void SetHierarchy(int Hierarchy) { hierarchy = Hierarchy; }
|
|
|
|
void SetRollOff(int RollOff) { rollOff = RollOff; }
|
|
|
|
cString ToString(char Type) const;
|
|
|
|
bool Parse(const char *s);
|
|
|
|
};
|
|
|
|
|
2002-12-08 09:55:26 +01:00
|
|
|
class cDvbTuner;
|
|
|
|
|
2002-12-15 15:36:02 +01:00
|
|
|
/// The cDvbDevice implements a DVB device which can be accessed through the Linux DVB driver API.
|
|
|
|
|
2002-08-04 14:57:29 +02:00
|
|
|
class cDvbDevice : public cDevice {
|
2009-12-31 15:38:18 +01:00
|
|
|
protected:
|
2010-01-04 14:16:11 +01:00
|
|
|
static cString DvbName(const char *Name, int Adapter, int Frontend);
|
|
|
|
static int DvbOpen(const char *Name, int Adapter, int Frontend, int Mode, bool ReportError = false);
|
2002-08-04 14:57:29 +02:00
|
|
|
private:
|
2010-01-04 14:16:11 +01:00
|
|
|
static bool Exists(int Adapter, int Frontend);
|
|
|
|
///< Checks whether the given adapter/frontend exists.
|
|
|
|
static bool Probe(int Adapter, int Frontend);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Probes for existing DVB devices.
|
2002-08-04 14:57:29 +02:00
|
|
|
public:
|
|
|
|
static bool Initialize(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Initializes the DVB devices.
|
|
|
|
///< Must be called before accessing any DVB functions.
|
|
|
|
///< \return True if any devices are available.
|
2010-01-04 14:16:11 +01:00
|
|
|
protected:
|
|
|
|
int adapter, frontend;
|
2002-08-04 14:57:29 +02:00
|
|
|
private:
|
2008-12-13 12:22:36 +01:00
|
|
|
dvb_frontend_info frontendInfo;
|
2008-04-12 13:39:12 +02:00
|
|
|
int numProvidedSystems;
|
2008-12-13 12:22:36 +01:00
|
|
|
fe_delivery_system frontendType;
|
2009-12-31 15:38:18 +01:00
|
|
|
int fd_dvr, fd_ca;
|
2002-08-04 14:57:29 +02:00
|
|
|
public:
|
2010-01-04 14:16:11 +01:00
|
|
|
cDvbDevice(int Adapter, int Frontend);
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual ~cDvbDevice();
|
2005-08-21 08:56:49 +02:00
|
|
|
virtual bool Ready(void);
|
2002-08-04 14:57:29 +02:00
|
|
|
|
2007-01-07 14:46:14 +01:00
|
|
|
// Common Interface facilities:
|
|
|
|
|
|
|
|
private:
|
|
|
|
cCiAdapter *ciAdapter;
|
|
|
|
|
2002-08-04 14:57:29 +02:00
|
|
|
// Channel facilities
|
|
|
|
|
|
|
|
private:
|
2002-12-08 09:55:26 +01:00
|
|
|
cDvbTuner *dvbTuner;
|
2002-08-04 14:57:29 +02:00
|
|
|
public:
|
2002-10-06 10:25:42 +02:00
|
|
|
virtual bool ProvidesSource(int Source) const;
|
2004-01-04 12:30:00 +01:00
|
|
|
virtual bool ProvidesTransponder(const cChannel *Channel) const;
|
2002-09-29 13:40:45 +02:00
|
|
|
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) const;
|
2008-04-12 13:39:12 +02:00
|
|
|
virtual int NumProvidedSystems(void) const;
|
2010-02-06 14:43:42 +01:00
|
|
|
virtual const cChannel *GetCurrentlyTunedTransponder(void) const;
|
2006-04-09 09:12:47 +02:00
|
|
|
virtual bool IsTunedToTransponder(const cChannel *Channel);
|
2002-09-04 17:26:02 +02:00
|
|
|
protected:
|
|
|
|
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
|
2004-01-04 12:30:00 +01:00
|
|
|
public:
|
2004-10-30 15:10:50 +02:00
|
|
|
virtual bool HasLock(int TimeoutMs = 0);
|
2002-08-04 14:57:29 +02:00
|
|
|
|
|
|
|
// PID handle facilities
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
// Section filter facilities
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
|
2007-10-14 13:11:23 +02:00
|
|
|
virtual void CloseFilter(int Handle);
|
2007-01-13 12:14:51 +01:00
|
|
|
|
|
|
|
// Common Interface facilities:
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual bool HasCi(void);
|
2003-12-22 13:29:24 +01:00
|
|
|
|
2002-10-12 14:29:46 +02:00
|
|
|
// Audio facilities
|
2002-08-04 14:57:29 +02:00
|
|
|
|
|
|
|
protected:
|
2009-12-31 15:38:18 +01:00
|
|
|
static int setTransferModeForDolbyDigital;
|
2005-02-13 14:26:37 +01:00
|
|
|
public:
|
2009-12-31 15:38:18 +01:00
|
|
|
static void SetTransferModeForDolbyDigital(int Mode); // needs to be here for backwards compatibilty
|
2006-05-20 10:17:44 +02:00
|
|
|
///< Controls how the DVB device handles Transfer Mode when replaying
|
|
|
|
///< Dolby Digital audio.
|
|
|
|
///< 0 = don't set "audio bypass" in driver/firmware, don't force Transfer Mode
|
|
|
|
///< 1 = set "audio bypass" in driver/firmware, force Transfer Mode (default)
|
|
|
|
///< 2 = don't set "audio bypass" in driver/firmware, force Transfer Mode
|
2002-08-04 14:57:29 +02:00
|
|
|
|
|
|
|
// Receiver facilities
|
|
|
|
|
2002-09-08 09:03:10 +02:00
|
|
|
private:
|
|
|
|
cTSBuffer *tsBuffer;
|
2002-08-04 14:57:29 +02:00
|
|
|
protected:
|
|
|
|
virtual bool OpenDvr(void);
|
|
|
|
virtual void CloseDvr(void);
|
2002-09-08 09:03:10 +02:00
|
|
|
virtual bool GetTSPacket(uchar *&Data);
|
2002-08-04 14:57:29 +02:00
|
|
|
};
|
|
|
|
|
2009-12-31 15:38:18 +01:00
|
|
|
// A plugin that implements a DVB device derived from cDvbDevice needs to create
|
|
|
|
// a cDvbDeviceProbe derived object on the heap in order to have its Probe()
|
|
|
|
// function called, where it can actually create the appropriate device.
|
|
|
|
// The cDvbDeviceProbe object must be created in the plugin's constructor,
|
|
|
|
// and deleted in its destructor.
|
|
|
|
|
|
|
|
class cDvbDeviceProbe : public cListObject {
|
|
|
|
public:
|
|
|
|
cDvbDeviceProbe(void);
|
|
|
|
virtual ~cDvbDeviceProbe();
|
2010-01-04 14:16:11 +01:00
|
|
|
virtual bool Probe(int Adapter, int Frontend) = 0;
|
2009-12-31 15:38:18 +01:00
|
|
|
///< Probes for a DVB device at the given Adapter and creates the appropriate
|
|
|
|
///< object derived from cDvbDevice if applicable.
|
|
|
|
///< Returns true if a device has been created.
|
|
|
|
};
|
|
|
|
|
|
|
|
extern cList<cDvbDeviceProbe> DvbDeviceProbes;
|
|
|
|
|
2002-08-04 14:57:29 +02:00
|
|
|
#endif //__DVBDEVICE_H
|