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 <QMap>
12#include <QObject>
13#include <QString>
14
17
18#include "diseqc.h"
19#include "dtvchannel.h"
20#include "dtvconfparserhelpers.h" // for DTVTunerType
22
23class TVRec;
24class DVBCam;
25class DVBRecorder;
26class DVBChannel;
27
28using IsOpenMap = QMap<const DVBChannel*,bool>;
29
30class DVBChannel : public DTVChannel
31{
32 public:
33 explicit DVBChannel(QString device, TVRec *parent = nullptr);
34 ~DVBChannel() override;
35
36 bool Open(void) override // ChannelBase
37 { return Open(this); }
38 void Close(void) override // ChannelBase
39 { Close(this); }
40
41 bool Init(QString &startchannel, bool setchan) override; // ChannelBase
42
43 // Sets
44 void SetPMT(const ProgramMapTable *pmt);
45 void SetTimeOffset(double offset);
46 void SetSlowTuning(std::chrono::milliseconds how_slow)
47 { m_tuningDelay = how_slow; }
48
49 // Gets
50 bool IsOpen(void) const override; // ChannelBase
51 int GetFd(void) const override // ChannelBase
52 { return m_fdFrontend; }
53 bool IsTuningParamsProbeSupported(void) const;
54
55 QString GetDevice(void) const override // ChannelBase
56 { return m_device; }
58 QString GetCardNum(void) const { return m_device; };
60 QString GetFrontendName(void) const { return m_frontendName; }
61 bool IsMaster(void) const override; // DTVChannel
63 bool HasCRCBug(void) const { return m_hasCrcBug; }
64 std::chrono::milliseconds GetMinSignalMonitorDelay(void) const { return m_sigMonDelay; }
66 const DiSEqCDevRotor *GetRotor(void) const;
67
69 bool HasLock(bool *ok = nullptr) const;
71 double GetSignalStrength(bool *ok = nullptr) const;
79 double GetSNR(bool *ok = nullptr) const;
81 double GetBitErrorRate(bool *ok = nullptr) const;
83 double GetUncorrectedBlockCount(bool *ok = nullptr) const;
84 uint64_t GetCapabilities(void) const { return m_capabilities; }
85 bool CanDo(uint64_t capability) const { return (m_capabilities & capability) != 0; }
86
87 // Commands
88 bool SwitchToInput(int newcapchannel, bool setstarting);
89 using DTVChannel::Tune;
90 bool Tune(const DTVMultiplex &tuning) override; // DTVChannel
91 bool Tune(const DTVMultiplex &tuning,
92 bool force_reset = false, bool same_input = false);
93 bool Retune(void) override; // ChannelBase
94
95 bool ProbeTuningParams(DTVMultiplex &tuning) const;
96
97 int GetChanID(void) const override; // ChannelBase
98
99 protected:
100 void CheckOptions(DTVMultiplex &t) const override; // DTVChannel
101
102 private:
103 bool Open(DVBChannel *who);
104 void Close(DVBChannel *who);
105
106 void CheckFrequency(uint64_t frequency) const;
107 bool CheckModulation(DTVModulation modulation) const;
108 bool CheckCodeRate(DTVCodeRate rate) const;
109
110 DVBChannel *GetMasterLock(void) const;
111 static void ReturnMasterLock(DVBChannel* &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 void DrainDVBEvents(void);
133 bool WaitForBackend(std::chrono::milliseconds timeout_ms);
134
135 private:
137
138 // Data
141 DVBCam *m_dvbCam {nullptr}; // Used to decrypt encrypted streams
142
143 // Device info
145 uint64_t m_capabilities {0};
146 uint64_t m_extModulations {0};
147 uint64_t m_frequencyMinimum {0};
148 uint64_t m_frequencyMaximum {0};
151
152 uint m_version {0}; // DVB API version
153 bool m_legacyFe {false}; // Use legacy DVBv3 API
154 bool m_hasV5Stats {false}; // Use DVBv5 API for statistics
155 DTVModulationSystem m_currentSys; // Currently configured modulation system
156 QList<DTVModulationSystem> m_sysList; // List of supported modulation systems
157
158 // Tuning State
159 mutable QMutex m_tuneLock;
160 mutable QRecursiveMutex m_hwLock;
161
162 DTVMultiplex m_desiredTuning; // Last tuning options Tune() attempted to send to hardware
163 DTVMultiplex m_prevTuning; // Last tuning options Tune() succesfully sent to hardware
164
166
167 std::chrono::milliseconds m_tuningDelay { 0ms}; // Extra delay to add for broken drivers
168 std::chrono::milliseconds m_sigMonDelay {25ms}; // Minimum delay between FE_LOCK checks
169 bool m_firstTune {true}; // Used to force hardware reset
170
171 // Other State
172 int m_fdFrontend {-1}; // File descriptor for tuning hardware
173 QString m_device; // DVB Device
174 QString m_key; // master lock key
175 bool m_hasCrcBug {false}; // true iff our driver munges PMT
176
177 static std::chrono::milliseconds s_lastTuning; // Time of last tuning
179};
180
181#endif
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:34
virtual bool Tune(const DTVMultiplex &tuning)=0
This performs the actual frequency tuning and in some cases input switching.
Definition: dvbcam.h:23
Provides interface to the tuning hardware when using DVB drivers.
Definition: dvbchannel.h:31
void CheckOptions(DTVMultiplex &t) const override
Checks tuning for problems, and tries to fix them.
Definition: dvbchannel.cpp:577
bool Open(void) override
Opens the channel changing hardware for use.
Definition: dvbchannel.h:36
bool CheckModulation(DTVModulation modulation) const
Return true iff modulation is supported modulation on the frontend.
Definition: dvbchannel.cpp:703
bool m_hasCrcBug
Definition: dvbchannel.h:175
~DVBChannel() override
Definition: dvbchannel.cpp:108
DTVMultiplex m_desiredTuning
Definition: dvbchannel.h:162
bool Retune(void) override
Definition: dvbchannel.cpp:982
QString GetFrontendName(void) const
Returns frontend name as reported by driver.
Definition: dvbchannel.h:60
bool IsTuningParamsProbeSupported(void) const
Returns true iff tuning info probing is working.
Definition: dvbchannel.cpp:990
std::chrono::milliseconds m_sigMonDelay
Definition: dvbchannel.h:168
uint64_t m_capabilities
Definition: dvbchannel.h:145
QMutex m_tuneDelayLock
Definition: dvbchannel.h:178
DTVModulationSystem m_currentSys
Definition: dvbchannel.h:155
QString m_key
Definition: dvbchannel.h:174
int GetFd(void) const override
Returns file descriptor, -1 if it does not exist.
Definition: dvbchannel.h:51
QList< DTVModulationSystem > m_sysList
Definition: dvbchannel.h:156
uint m_symbolRateMaximum
Definition: dvbchannel.h:150
const DiSEqCDevRotor * GetRotor(void) const
Returns rotor object if it exists, nullptr otherwise.
bool m_legacyFe
Definition: dvbchannel.h:153
uint64_t m_frequencyMaximum
Definition: dvbchannel.h:148
uint m_lastLnbDevId
Definition: dvbchannel.h:165
uint64_t m_extModulations
Definition: dvbchannel.h:146
void DrainDVBEvents(void)
bool Init(QString &startchannel, bool setchan) override
Definition: dvbchannel.cpp:554
int GetChanID(void) const override
Returns Channel ID.
void SetSlowTuning(std::chrono::milliseconds how_slow)
Definition: dvbchannel.h:46
void SetPMT(const ProgramMapTable *pmt)
Tells the Conditional Access Module which streams we wish to decode.
Definition: dvbchannel.cpp:726
QString m_device
Definition: dvbchannel.h:173
bool WaitForBackend(std::chrono::milliseconds timeout_ms)
Waits for backend to get tune message.
DVBChannel(QString device, TVRec *parent=nullptr)
Definition: dvbchannel.cpp:82
QString m_frontendName
Definition: dvbchannel.h:144
DVBCam * m_dvbCam
Definition: dvbchannel.h:141
QRecursiveMutex m_hwLock
Definition: dvbchannel.h:160
bool CanDo(uint64_t capability) const
Definition: dvbchannel.h:85
uint64_t m_frequencyMinimum
Definition: dvbchannel.h:147
void SetTimeOffset(double offset)
Tells the Conditional Access Module the offset from the computers utc time to dvb time.
Definition: dvbchannel.cpp:738
bool IsMaster(void) const override
Returns true if this is the first of a number of multi-rec devs.
bool m_firstTune
Definition: dvbchannel.h:169
double GetUncorrectedBlockCount(bool *ok=nullptr) const
Returns # of uncorrected blocks since last call. First call undefined.
std::chrono::milliseconds GetMinSignalMonitorDelay(void) const
Definition: dvbchannel.h:64
static std::chrono::milliseconds s_lastTuning
Definition: dvbchannel.h:177
bool HasCRCBug(void) const
Returns true iff we have a faulty DVB driver that munges PMT.
Definition: dvbchannel.h:63
bool HasLock(bool *ok=nullptr) const
Returns true iff we have a signal carrier lock.
double GetBitErrorRate(bool *ok=nullptr) const
Returns # of corrected bits since last call. First call undefined.
void CheckFrequency(uint64_t frequency) const
Checks tuning frequency.
Definition: dvbchannel.cpp:565
bool m_hasV5Stats
Definition: dvbchannel.h:154
void Close(void) override
Closes the channel changing hardware to use.
Definition: dvbchannel.h:38
uint m_symbolRateMinimum
Definition: dvbchannel.h:149
int m_fdFrontend
Definition: dvbchannel.h:172
double GetSNR(bool *ok=nullptr) const
Returns signal/noise in the range [0..1.0].
DiSEqCDevTree * m_diseqcTree
Definition: dvbchannel.h:140
DTVMultiplex m_prevTuning
Definition: dvbchannel.h:163
uint64_t GetCapabilities(void) const
Definition: dvbchannel.h:84
bool ProbeTuningParams(DTVMultiplex &tuning) const
Fetches DTVMultiplex params from driver.
QString GetDevice(void) const override
Returns String representing device, useful for debugging.
Definition: dvbchannel.h:55
QMutex m_tuneLock
Definition: dvbchannel.h:159
uint m_version
Definition: dvbchannel.h:152
IsOpenMap m_isOpen
Definition: dvbchannel.h:136
DVBChannel * GetMasterLock(void) const
double GetSignalStrengthDVBv5(bool *ok) const
Get Signal strength from the DVBv5 interface [0-1.0] It is transformed to a linear relative scale if ...
double GetUncorrectedBlockCountDVBv5(bool *ok) const
Get Uncorrected Block Count from the DVBv5 interface.
bool CheckCodeRate(DTVCodeRate rate) const
Return true iff rate is supported rate on the frontend.
Definition: dvbchannel.cpp:684
bool Tune(const DTVMultiplex &tuning) override
This performs the actual frequency tuning and in some cases input switching.
Definition: dvbchannel.cpp:744
double GetSignalStrength(bool *ok=nullptr) const
Returns signal strength in the range [0.0..1.0] (non-calibrated).
QString GetCardNum(void) const
Returns DVB device number, used to construct filenames for DVB devices.
Definition: dvbchannel.h:58
DiSEqCDevSettings m_diseqcSettings
Definition: dvbchannel.h:139
bool IsOpen(void) const override
Reports whether channel is already open.
Definition: dvbchannel.cpp:546
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 ...
static void ReturnMasterLock(DVBChannel *&dvbm)
bool SwitchToInput(int newcapchannel, bool setstarting)
std::chrono::milliseconds m_tuningDelay
Definition: dvbchannel.h:167
double GetBitErrorRateDVBv5(bool *ok) const
Get Bit Error Rate from the DVBv5 interface.
This is a specialization of DTVRecorder used to handle streams from DVB drivers.
Definition: dvbrecorder.h:22
Rotor class.
Definition: diseqc.h:303
DVB-S device settings class.
Definition: diseqc.h:37
DVB-S device tree class.
Definition: diseqc.h:75
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:676
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:142
unsigned int uint
Definition: compat.h:60
QMap< const DVBChannel *, bool > IsOpenMap
Definition: dvbchannel.h:28