File indexing completed on 2025-01-05 04:29:34
0001 /* 0002 * dvbbackenddevice.h 0003 * 0004 * Copyright (C) 2007-2011 Christoph Pfister <christophpfister@gmail.com> 0005 * 0006 * This program is free software; you can redistribute it and/or modify 0007 * it under the terms of the GNU General Public License as published by 0008 * the Free Software Foundation; either version 2 of the License, or 0009 * (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License along 0017 * with this program; if not, write to the Free Software Foundation, Inc., 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 0019 */ 0020 0021 #ifndef DVBBACKENDDEVICE_H 0022 #define DVBBACKENDDEVICE_H 0023 0024 #include <QtGlobal> 0025 0026 class DvbTransponder; 0027 0028 class DvbDeviceBase 0029 { 0030 public: 0031 enum TransmissionType { 0032 Nothing = 0, 0033 DvbC = (1 << 0), 0034 DvbS = (1 << 1), 0035 DvbS2 = (1 << 2), 0036 DvbT = (1 << 3), 0037 DvbT2 = (1 << 4), 0038 Atsc = (1 << 5), 0039 IsdbT = (1 << 6), 0040 }; 0041 0042 Q_DECLARE_FLAGS(TransmissionTypes, TransmissionType) 0043 0044 enum Capability { 0045 None = 0, 0046 DvbTModulationAuto = (1 << 0), 0047 DvbTFecAuto = (1 << 1), 0048 DvbTTransmissionModeAuto = (1 << 2), 0049 DvbTGuardIntervalAuto = (1 << 3) 0050 }; 0051 0052 Q_DECLARE_FLAGS(Capabilities, Capability) 0053 0054 enum SecTone { 0055 ToneOff = 0, 0056 ToneOn = 1 0057 }; 0058 0059 enum SecVoltage { 0060 Voltage13V = 0, 0061 Voltage18V = 1 0062 }; 0063 0064 enum SecBurst { 0065 BurstMiniA = 0, 0066 BurstMiniB = 1 0067 }; 0068 0069 protected: 0070 DvbDeviceBase() { } 0071 virtual ~DvbDeviceBase() { } 0072 }; 0073 0074 class DvbDataBuffer 0075 { 0076 public: 0077 DvbDataBuffer(char *data_, int bufferSize_) : data(data_), bufferSize(bufferSize_) { } 0078 ~DvbDataBuffer() { } 0079 0080 char *data; 0081 int dataSize; // must be a multiple of 188 0082 int bufferSize; // must be a multiple of 188 0083 }; 0084 0085 class DvbPidFilter 0086 { 0087 public: 0088 virtual void processData(const char data[188]) = 0; 0089 0090 protected: 0091 DvbPidFilter() { } 0092 virtual ~DvbPidFilter() { } 0093 }; 0094 0095 class DvbSectionFilter 0096 { 0097 public: 0098 // the crc is either valid or has appeared at least twice 0099 virtual void processSection(const char *data, int size) = 0; 0100 0101 protected: 0102 DvbSectionFilter() { } 0103 virtual ~DvbSectionFilter() { } 0104 }; 0105 0106 class DvbFrontendDevice : public DvbDeviceBase 0107 { 0108 public: 0109 virtual bool addPidFilter(int pid, DvbPidFilter *filter) = 0; 0110 virtual bool addSectionFilter(int pid, DvbSectionFilter *filter) = 0; 0111 virtual void removePidFilter(int pid, DvbPidFilter *filter) = 0; 0112 virtual void removeSectionFilter(int pid, DvbSectionFilter *filter) = 0; 0113 0114 // these two functions are thread-safe 0115 virtual DvbDataBuffer getBuffer() = 0; 0116 virtual void writeBuffer(const DvbDataBuffer &dataBuffer) = 0; 0117 0118 protected: 0119 DvbFrontendDevice() { } 0120 virtual ~DvbFrontendDevice() { } 0121 }; 0122 0123 // Those definitions are pretty much identical to what's there 0124 // at libdvbv5 dvb-sat.h header. However, due to the abstract 0125 // model, we should re-define it here. 0126 0127 struct lnbFreqRange { 0128 unsigned int low, high; 0129 }; 0130 0131 struct lnbSat { 0132 QString name, alias; 0133 unsigned int lowFreq, highFreq, rangeSwitch; 0134 struct lnbFreqRange freqRange[2]; 0135 }; 0136 0137 class DvbBackendDevice : public DvbDeviceBase 0138 { 0139 public: 0140 enum Scale { 0141 NotSupported = 0, 0142 Percentage = 1, 0143 Decibel = 2, 0144 dBuV = 3, 0145 }; 0146 virtual QString getDeviceId() = 0; 0147 virtual QString getFrontendName() = 0; 0148 virtual TransmissionTypes getTransmissionTypes() = 0; 0149 virtual Capabilities getCapabilities() = 0; 0150 virtual void setFrontendDevice(DvbFrontendDevice *frontend) = 0; 0151 virtual void setDeviceEnabled(bool enabled) = 0; 0152 virtual bool acquire() = 0; 0153 virtual bool setHighVoltage(int higherVoltage) = 0; 0154 virtual bool sendMessage(const char *message, int length) = 0; 0155 virtual bool sendBurst(SecBurst burst) = 0; 0156 virtual bool satSetup(QString lnbModel, int satNumber, int bpf) = 0; 0157 virtual bool tune(const DvbTransponder &transponder) = 0; // discards obsolete data 0158 virtual bool getProps(DvbTransponder &transponder) = 0; 0159 virtual bool isTuned() = 0; 0160 virtual float getSignal(Scale &scale) = 0; 0161 virtual float getSnr(Scale &scale) = 0; 0162 virtual float getFrqMHz() = 0; 0163 virtual bool addPidFilter(int pid) = 0; 0164 virtual void removePidFilter(int pid) = 0; 0165 virtual void startDescrambling(const QByteArray &pmtSectionData) = 0; 0166 virtual void stopDescrambling(int serviceId) = 0; 0167 virtual void release() = 0; 0168 virtual void enableDvbDump() = 0; 0169 QList<lnbSat> getLnbSatModels() const { return lnbSatModels; }; 0170 0171 0172 protected: 0173 DvbBackendDevice() { } 0174 virtual ~DvbBackendDevice() { } 0175 0176 QList<lnbSat> lnbSatModels; 0177 }; 0178 0179 /* 0180 0181 class DvbXXXDeviceManager : public QObject 0182 { 0183 Q_OBJECT 0184 public: 0185 DvbXXXDeviceManager(); 0186 ~DvbXXXDeviceManager(); 0187 0188 public slots: 0189 void doColdPlug(); 0190 0191 signals: 0192 void requestBuiltinDeviceManager(QObject *&builtinDeviceManager); 0193 void deviceAdded(DvbBackendDevice *device); 0194 void deviceRemoved(DvbBackendDevice *device); 0195 }; 0196 0197 */ 0198 0199 #endif /* DVBBACKENDDEVICE_H */