1 /* 2 * dvbscan.h 3 * 4 * Copyright (C) 2008-2011 Christoph Pfister <christophpfister@gmail.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License along 17 * with this program; if not, write to the Free Software Foundation, Inc., 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 */ 20 21 #ifndef DVBSCAN_H 22 #define DVBSCAN_H 23 24 #include "dvbchannel.h" 25 26 class AtscVctSection; 27 class DvbDescriptor; 28 class DvbDevice; 29 class DvbNitSection; 30 class DvbPatEntry; 31 class DvbPatSection; 32 class DvbPmtSection; 33 class DvbScanFilter; 34 class DvbSdtEntry; 35 class DvbSdtSection; 36 37 class DvbPreviewChannel : public DvbChannel 38 { 39 public: DvbPreviewChannel()40 DvbPreviewChannel() : snr(-1) { } ~DvbPreviewChannel()41 ~DvbPreviewChannel() { } 42 43 /* 44 * assigned when reading PMT 45 */ 46 47 // QString source; 48 // DvbTransponder transponder; 49 // int transportStreamId; 50 // int pmtPid; 51 // QByteArray pmtSectionData; 52 // int serviceId; 53 // int audioPid; // may be -1 (not present) 54 // bool hasVideo; 55 56 QString snr; 57 58 /* 59 * assigned when reading SDT 60 */ 61 62 // QString name; 63 // int networkId; // may be -1 (not present); ATSC meaning: source id 64 // bool isScrambled; 65 QString provider; 66 67 /* 68 * assigned when adding channel to the main list 69 */ 70 71 // int number; 72 }; 73 74 class DvbScan : public QObject 75 { 76 friend class DvbScanFilter; 77 Q_OBJECT 78 public: 79 DvbScan(DvbDevice *device_, const QString &source_, const DvbTransponder &transponder_, bool useOtherNit); 80 DvbScan(DvbDevice *device_, const QString &source_, 81 const QList<DvbTransponder> &transponders_, bool useOtherNit); 82 DvbScan(DvbDevice *device_, const QString &source_, const QString &autoScanSource, bool useOtherNit); 83 ~DvbScan(); 84 85 void start(); 86 87 signals: 88 void foundChannels(const QList<DvbPreviewChannel> &channels); 89 void scanProgress(int percentage); 90 void scanFinished(); 91 92 private slots: 93 void deviceStateChanged(); 94 95 private: 96 enum FilterType 97 { 98 PatFilter, 99 PmtFilter, 100 SdtFilter, 101 VctFilter, 102 NitFilter 103 }; 104 105 enum State 106 { 107 ScanPat, 108 ScanNit, 109 ScanSdt, 110 ScanPmt, 111 ScanTune, 112 ScanTuning 113 }; 114 115 bool startFilter(int pid, FilterType type); 116 void updateState(); 117 118 void processPat(const DvbPatSection §ion); 119 void processPmt(const DvbPmtSection §ion, int pid); 120 void processSdt(const DvbSdtSection §ion); 121 void processVct(const AtscVctSection §ion); 122 void processNit(const DvbNitSection §ion); 123 void processNitDescriptor(const DvbDescriptor &descriptor); 124 void filterFinished(DvbScanFilter *filter); 125 126 DvbDevice *device; 127 QString source; 128 DvbTransponder transponder; 129 bool isLive; 130 bool isAuto; 131 bool useOtherNit; 132 133 // only used if isLive is false 134 QList<DvbTransponder> transponders; 135 int transponderIndex; 136 137 State state; 138 QList<DvbPatEntry> patEntries; 139 int patIndex; 140 QList<DvbSdtEntry> sdtEntries; 141 QList<DvbPreviewChannel> channels; 142 143 DvbBackendDevice::Scale scale; 144 float snr; 145 int transportStreamId; 146 147 QList<DvbScanFilter *> filters; 148 int activeFilters; 149 }; 150 151 #endif /* DVBSCAN_H */ 152