MythTV  master
dvbchannel.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 /*
3  * Copyright (C) Kenneth Aafloy 2003
4  *
5  * Copyright notice is in dvbchannel.cpp of the MythTV project.
6  */
7 
8 #ifndef DVBCHANNEL_H
9 #define DVBCHANNEL_H
10 
11 #include <QObject>
12 #include <QString>
13 #include <QMap>
14 
15 #include "mythcontext.h"
16 #include "mythdbcon.h"
17 #include "dtvchannel.h"
18 #include "dtvconfparserhelpers.h" // for DTVTunerType
19 #include "streamlisteners.h"
20 #include "diseqc.h"
21 
22 class TVRec;
23 class DVBCam;
24 class DVBRecorder;
25 class DVBChannel;
26 
27 typedef QMap<const DVBChannel*,bool> IsOpenMap;
28 
29 class DVBChannel : public DTVChannel
30 {
31  public:
32  DVBChannel(const QString &device, TVRec *parent = nullptr);
33  ~DVBChannel();
34 
35  bool Open(void) override // ChannelBase
36  { return Open(this); }
37  void Close(void) override // ChannelBase
38  { Close(this); }
39 
40  bool Init(QString &startchannel, bool setchan) override; // ChannelBase
41 
42  // Sets
43  void SetPMT(const ProgramMapTable*);
44  void SetTimeOffset(double offset);
45  void SetSlowTuning(uint how_slow_in_ms)
46  { m_tuning_delay = how_slow_in_ms; }
47 
48  // Gets
49  bool IsOpen(void) const override; // ChannelBase
50  int GetFd(void) const override // ChannelBase
51  { return m_fd_frontend; }
52  bool IsTuningParamsProbeSupported(void) const;
53 
54  QString GetDevice(void) const override // ChannelBase
55  { return m_device; }
57  QString GetCardNum(void) const { return m_device; };
59  QString GetFrontendName(void) const { return m_frontend_name; }
60  bool IsMaster(void) const override; // DTVChannel
62  bool HasCRCBug(void) const { return m_has_crc_bug; }
65  const DiSEqCDevRotor *GetRotor(void) const;
66 
68  bool HasLock(bool *ok = nullptr) const;
70  double GetSignalStrength(bool *ok = nullptr) const;
78  double GetSNR(bool *ok = nullptr) const;
80  double GetBitErrorRate(bool *ok = nullptr) const;
82  double GetUncorrectedBlockCount(bool *ok = nullptr) const;
83 
84  // Commands
85  bool SwitchToInput(int newcapchannel, bool setstarting);
86  using DTVChannel::Tune;
87  bool Tune(const DTVMultiplex &tuning) override; // DTVChannel
88  bool Tune(const DTVMultiplex &tuning,
89  bool force_reset = false, bool same_input = false);
90  bool Retune(void) override; // ChannelBase
91 
92  bool ProbeTuningParams(DTVMultiplex &tuning) const;
93 
94  private:
95  bool Open(DVBChannel*);
96  void Close(DVBChannel*);
97 
98  int GetChanID(void) const override; // ChannelBase
99 
100  void CheckOptions(DTVMultiplex &t) const override; // DTVChannel
101  void CheckFrequency(uint64_t frequency) const;
102  bool CheckModulation(DTVModulation modulation) const;
103  bool CheckCodeRate(DTVCodeRate rate) const;
104 
106  DVBChannel *GetMasterLock(void);
107  static void ReturnMasterLock(DVBChannelP &dvbm);
108 
109  typedef const DVBChannel* DVBChannelCP;
110  const DVBChannel *GetMasterLock(void) const;
111  static void ReturnMasterLock(DVBChannelCP &dvbm);
112 
117  double GetSignalStrengthDVBv5(bool *ok) const;
122  double GetSNRDVBv5(bool *ok) const;
126  double GetBitErrorRateDVBv5(bool *ok) const;
130  double GetUncorrectedBlockCountDVBv5(bool *ok) const;
131 
132  private:
134 
135  // Data
140  DVBCam *m_dvbcam {nullptr};
141 
142  // Device info
144  uint64_t m_capabilities {0};
145  uint64_t m_ext_modulations {0};
146  uint64_t m_frequency_minimum {0};
147  uint64_t m_frequency_maximum {0};
150 
151  // Tuning State
152  mutable QMutex m_tune_lock;
153  mutable QMutex m_hw_lock {QMutex::Recursive};
158 
160 
166  bool m_first_tune {true};
167 
168  // Other State
170  int m_fd_frontend {-1};
171  QString m_device;
172  bool m_has_crc_bug {false};
174 
175  static QDateTime s_last_tuning;
177 };
178 
179 #endif
double GetSignalStrength(bool *ok=nullptr) const
Returns signal strength in the range [0.0..1.0] (non-calibrated).
double GetBitErrorRate(bool *ok=nullptr) const
Returns # of corrected bits since last call. First call undefined.
uint64_t m_frequency_maximum
Definition: dvbchannel.h:147
bool IsMaster(void) const override
Returns true if this is the first of a number of multi-rec devs.
DVB-S device settings class.
Definition: diseqc.h:35
int m_fd_frontend
File descriptor for tuning hardware.
Definition: dvbchannel.h:170
uint64_t m_capabilities
Definition: dvbchannel.h:144
int GetChanID(void) const override
Returns Channel ID.
Definition: dvbchannel.cpp:954
This is a specialization of DTVRecorder used to handle streams from DVB drivers.
Definition: dvbrecorder.h:21
uint m_last_lnb_dev_id
Definition: dvbchannel.h:159
void CheckFrequency(uint64_t frequency) const
Checks tuning frequency.
Definition: dvbchannel.cpp:333
double GetSignalStrengthDVBv5(bool *ok) const
Get Signal strength from the DVBv5 interface [0-1.0] It is transformed to a linear relative scale if ...
void SetPMT(const ProgramMapTable *)
Tells the Conditional Access Module which streams we wish to decode.
Definition: dvbchannel.cpp:495
QString m_frontend_name
Definition: dvbchannel.h:143
uint64_t m_ext_modulations
Definition: dvbchannel.h:145
int GetFd(void) const override
Returns file descriptor, -1 if it does not exist.
Definition: dvbchannel.h:50
unsigned int uint
Definition: compat.h:140
Provides interface to the tuning hardware when using DVB drivers.
Definition: dvbchannel.h:29
const DVBChannel * DVBChannelCP
Definition: dvbchannel.h:109
double GetUncorrectedBlockCountDVBv5(bool *ok) const
Get Uncorrected Block Count from the DVBv5 interface.
QMutex m_hw_lock
Definition: dvbchannel.h:153
DiSEqCDev m_diseqc_dev
Definition: dvbchannel.h:136
uint64_t m_frequency_minimum
Definition: dvbchannel.h:146
QMutex m_tune_lock
Definition: dvbchannel.h:152
DiSEqCDevTree * m_diseqc_tree
Definition: dvbchannel.h:138
const DiSEqCDevRotor * GetRotor(void) const
Returns rotor object if it exists, nullptr otherwise.
Definition: dvbchannel.cpp:999
bool Retune(void) override
Definition: dvbchannel.cpp:842
void SetTimeOffset(double offset)
Tells the Conditional Access Module the offset from the computers utc time to dvb time.
Definition: dvbchannel.cpp:507
Definition: dvbcam.h:23
double GetUncorrectedBlockCount(bool *ok=nullptr) const
Returns # of uncorrected blocks since last call. First call undefined.
void SetSlowTuning(uint how_slow_in_ms)
Definition: dvbchannel.h:45
bool Open(void) override
Opens the channel changing hardware for use.
Definition: dvbchannel.h:35
static void ReturnMasterLock(DVBChannelP &dvbm)
double GetSNRDVBv5(bool *ok) const
Get SNR from the DVBv5 interface [0-1.0] It is transformed to a linear relative scale if provided in ...
uint m_tuning_delay
Extra delay to add for broken drivers.
Definition: dvbchannel.h:162
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:34
bool HasLock(bool *ok=nullptr) const
Returns true iff we have a signal carrier lock.
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:150
DTVMultiplex m_desired_tuning
Last tuning options Tune() attempted to send to hardware.
Definition: dvbchannel.h:155
bool m_first_tune
Used to force hardware reset.
Definition: dvbchannel.h:166
QString GetFrontendName(void) const
Returns frontend name as reported by driver.
Definition: dvbchannel.h:59
unsigned char t
Definition: ParseText.cpp:329
bool ProbeTuningParams(DTVMultiplex &tuning) const
Fetches DTVMultiplex params from driver.
Definition: dvbchannel.cpp:896
Rotor class.
Definition: diseqc.h:293
QString m_device
DVB Device.
Definition: dvbchannel.h:171
bool m_has_crc_bug
true iff our driver munges PMT
Definition: dvbchannel.h:173
DVBChannel * DVBChannelP
Definition: dvbchannel.h:105
uint GetMinSignalMonitorDelay(void) const
Definition: dvbchannel.h:63
bool IsOpen(void) const override
Reports whether channel is already open.
Definition: dvbchannel.cpp:314
virtual bool Tune(const DTVMultiplex &tuning)=0
This performs the actual frequency tuning and in some cases input switching.
uint m_symbol_rate_maximum
Definition: dvbchannel.h:149
static QDateTime s_last_tuning
Definition: dvbchannel.h:175
QString GetCardNum(void) const
Returns DVB device number, used to construct filenames for DVB devices.
Definition: dvbchannel.h:57
static int x0
Definition: mythsocket.cpp:59
bool Tune(const DTVMultiplex &tuning) override
This performs the actual frequency tuning and in some cases input switching.
Definition: dvbchannel.cpp:513
uint m_symbol_rate_minimum
Definition: dvbchannel.h:148
QMutex m_tune_delay_lock
Definition: dvbchannel.h:176
double GetSNR(bool *ok=nullptr) const
Returns signal/noise in the range [0..1.0].
bool CheckModulation(DTVModulation modulation) const
Return true iff modulation is supported modulation on the frontend.
Definition: dvbchannel.cpp:470
bool Init(QString &startchannel, bool setchan) override
Definition: dvbchannel.cpp:322
QString GetDevice(void) const override
Returns String representing device, useful for debugging.
Definition: dvbchannel.h:54
DVBChannel * GetMasterLock(void)
bool IsTuningParamsProbeSupported(void) const
Returns true iff tuning info probing is working.
Definition: dvbchannel.cpp:850
void Close(void) override
Closes the channel changing hardware to use.
Definition: dvbchannel.h:37
DVBChannel(const QString &device, TVRec *parent=nullptr)
Definition: dvbchannel.cpp:75
bool CheckCodeRate(DTVCodeRate rate) const
Return true iff rate is supported rate on the frontend.
Definition: dvbchannel.cpp:451
double GetBitErrorRateDVBv5(bool *ok) const
Get Bit Error Rate from the DVBv5 interface.
void CheckOptions(DTVMultiplex &t) const override
Checks tuning for problems, and tries to fix them.
Definition: dvbchannel.cpp:346
DTVMultiplex m_prev_tuning
Last tuning options Tune() succesfully sent to hardware.
Definition: dvbchannel.h:157
IsOpenMap m_is_open
Definition: dvbchannel.h:133
QMap< const DVBChannel *, bool > IsOpenMap
Definition: dvbchannel.h:25
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:656
DVB-S device tree class.
Definition: diseqc.h:73
bool SwitchToInput(int newcapchannel, bool setstarting)
DVBCam * m_dvbcam
Used to decrypt encrypted streams.
Definition: dvbchannel.h:140
bool HasCRCBug(void) const
Returns true iff we have a faulty DVB driver that munges PMT.
Definition: dvbchannel.h:62
DiSEqCDevSettings m_diseqc_settings
Definition: dvbchannel.h:137
uint m_sigmon_delay
Minimum delay between FE_LOCK checks.
Definition: dvbchannel.h:164
Main DVB-S device interface.
Definition: diseqc.h:50