File indexing completed on 2024-05-12 04:52:11
0001 /* 0002 * dvbdevice.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 DVBDEVICE_H 0022 #define DVBDEVICE_H 0023 0024 #include <QExplicitlySharedDataPointer> 0025 #include <QMap> 0026 #include <QMutex> 0027 #include <QTimer> 0028 #include "dvbbackenddevice.h" 0029 #include "dvbtransponder.h" 0030 0031 class DvbConfigBase; 0032 class DvbDataDumper; 0033 class DvbDeviceDataBuffer; 0034 class DvbFilterInternal; 0035 class DvbSectionFilterInternal; 0036 0037 class DvbDummyPidFilter : public DvbPidFilter 0038 { 0039 public: 0040 DvbDummyPidFilter() { } 0041 ~DvbDummyPidFilter() { } 0042 0043 void processData(const char [188]) override { } 0044 }; 0045 0046 class DvbDummySectionFilter : public DvbSectionFilter 0047 { 0048 public: 0049 DvbDummySectionFilter() { } 0050 ~DvbDummySectionFilter() { } 0051 0052 void processSection(const char *, int) override { } 0053 }; 0054 0055 // FIXME make DvbDevice shared ... 0056 class DvbDevice : public QObject, public DvbFrontendDevice 0057 { 0058 Q_OBJECT 0059 public: 0060 enum DeviceState 0061 { 0062 DeviceReleased, 0063 DeviceIdle, 0064 DeviceRotorMoving, 0065 DeviceTuning, 0066 DeviceTuned 0067 // FIXME introduce a TuningFailed state 0068 }; 0069 0070 DvbDevice(DvbBackendDevice *backend_, QObject *parent); 0071 ~DvbDevice(); 0072 0073 const DvbBackendDevice *getBackendDevice() const 0074 { 0075 return backend; 0076 } 0077 0078 DeviceState getDeviceState() const 0079 { 0080 return deviceState; 0081 } 0082 0083 QList<lnbSat> getLnbSatModels() const 0084 { 0085 return backend->getLnbSatModels(); 0086 } 0087 0088 TransmissionTypes getTransmissionTypes() const; 0089 QString getDeviceId() const; 0090 QString getFrontendName() const; 0091 0092 void tune(const DvbTransponder &transponder); 0093 void autoTune(const DvbTransponder &transponder); 0094 bool addPidFilter(int pid, DvbPidFilter *filter) override; 0095 bool addSectionFilter(int pid, DvbSectionFilter *filter) override; 0096 void removePidFilter(int pid, DvbPidFilter *filter) override; 0097 void removeSectionFilter(int pid, DvbSectionFilter *filter) override; 0098 void startDescrambling(const QByteArray &pmtSectionData, QObject *user); 0099 void stopDescrambling(const QByteArray &pmtSectionData, QObject *user); 0100 bool isTuned() const; 0101 bool getProps(DvbTransponder &transponder) const; 0102 float getSignal(DvbBackendDevice::Scale &scale) const; 0103 float getSnr(DvbBackendDevice::Scale &scale) const; 0104 DvbTransponder getAutoTransponder() const; 0105 0106 /* 0107 * management functions (must be only called by DvbManager) 0108 */ 0109 0110 bool acquire(const DvbConfigBase *config_); 0111 void reacquire(const DvbConfigBase *config_); 0112 void release(); 0113 void enableDvbDump(); 0114 0115 signals: 0116 void stateChanged(); 0117 0118 private slots: 0119 void frontendEvent(); 0120 0121 private: 0122 void setDeviceState(DeviceState newState); 0123 void discardBuffers(); 0124 void stop(); 0125 0126 void processData(const char data[188]); 0127 DvbDataBuffer getBuffer() override; 0128 void writeBuffer(const DvbDataBuffer &dataBuffer) override; 0129 void customEvent(QEvent *) override; 0130 0131 DvbBackendDevice *backend; 0132 DeviceState deviceState; 0133 QExplicitlySharedDataPointer<const DvbConfigBase> config; 0134 0135 int frontendTimeout; 0136 QTimer frontendTimer; 0137 QMap<int, DvbFilterInternal> filters; 0138 QMap<int, DvbSectionFilterInternal> sectionFilters; 0139 DvbDummyPidFilter dummyPidFilter; 0140 DvbDummySectionFilter dummySectionFilter; 0141 DvbDataDumper *dataDumper; 0142 bool cleanUpFilters; 0143 QMultiMap<int, QObject *> descramblingServices; 0144 0145 bool isAuto; 0146 DvbTransponder autoTransponder; 0147 Capabilities capabilities; 0148 0149 DvbDeviceDataBuffer *unusedBuffersHead; 0150 DvbDeviceDataBuffer *usedBuffersHead; 0151 DvbDeviceDataBuffer *usedBuffersTail; 0152 QMutex dataChannelMutex; 0153 }; 0154 0155 #endif /* DVBDEVICE_H */