-
Notifications
You must be signed in to change notification settings - Fork 314
/
fastscan.h
260 lines (218 loc) · 7.22 KB
/
fastscan.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#ifndef _lib_dvb_fastscan_h
#define _lib_dvb_fastscan_h
#include <lib/base/object.h>
#include <lib/dvb/idvb.h>
#ifndef SWIG
#include <lib/dvb/idemux.h>
#include <lib/dvb/esection.h>
#include <dvbsi++/long_crc_section.h>
#include <dvbsi++/service_descriptor.h>
#include <dvbsi++/network_name_descriptor.h>
#include <dvbsi++/service_list_descriptor.h>
#include <dvbsi++/satellite_delivery_system_descriptor.h>
#include <dvbsi++/s2_satellite_delivery_system_descriptor.h>
/* HACK: fastscan table uses a nonstandard version of the LogicalChannel descriptor, with 14bit channel numbers (instead of 10bit), and a nonstandard definition of a 'hidden' flag */
class FastScanLogicalChannel
{
protected:
unsigned serviceId : 16;
unsigned hiddenFlag : 1;
unsigned logicalChannelNumber : 14;
public:
FastScanLogicalChannel(const uint8_t *const buffer);
~FastScanLogicalChannel(void);
uint16_t getServiceId(void) const;
uint8_t getHiddenFlag(void) const;
uint16_t getLogicalChannelNumber(void) const;
};
typedef std::list<FastScanLogicalChannel *> FastScanLogicalChannelList;
typedef FastScanLogicalChannelList::iterator FastScanLogicalChannelListIterator;
typedef FastScanLogicalChannelList::const_iterator FastScanLogicalChannelListConstIterator;
class FastScanLogicalChannelDescriptor : public Descriptor
{
protected:
FastScanLogicalChannelList channelList;
public:
FastScanLogicalChannelDescriptor(const uint8_t *const buffer);
~FastScanLogicalChannelDescriptor(void);
const FastScanLogicalChannelList *getChannelList(void) const;
};
class FastScanService : public ServiceDescriptor
{
protected:
unsigned originalNetworkId : 16;
unsigned transportStreamId : 16;
unsigned serviceId : 16;
unsigned defaultVideoPid : 16;
unsigned defaultAudioPid : 16;
unsigned defaultVideoEcmPid : 16;
unsigned defaultAudioEcmPid : 16;
unsigned defaultPcrPid : 16;
unsigned descriptorLoopLength : 16;
public:
FastScanService(const uint8_t *const buffer);
~FastScanService(void);
uint16_t getOriginalNetworkId(void) const;
uint16_t getTransportStreamId(void) const;
uint16_t getServiceId(void) const;
uint16_t getDefaultVideoPid(void) const;
uint16_t getDefaultAudioPid(void) const;
uint16_t getDefaultVideoEcmPid(void) const;
uint16_t getDefaultAudioEcmPid(void) const;
uint16_t getDefaultPcrPid(void) const;
};
typedef std::list<FastScanService*> FastScanServiceList;
typedef FastScanServiceList::iterator FastScanServiceListIterator;
typedef FastScanServiceList::const_iterator FastScanServiceListConstIterator;
class FastScanServicesSection : public LongCrcSection
{
protected:
unsigned versionNumber : 5;
FastScanServiceList services;
public:
FastScanServicesSection(const uint8_t * const buffer);
~FastScanServicesSection(void);
static const uint16_t LENGTH = 4096;
static const int TID = 0xBD;
static const uint32_t TIMEOUT = 5000;
uint8_t getVersion(void) const;
const FastScanServiceList *getServices(void) const;
};
class FastScanTransportStream
{
protected:
unsigned transportStreamId : 16;
unsigned originalNetworkId : 16;
unsigned descriptorLoopLength : 16;
SatelliteDeliverySystemDescriptor *deliverySystem;
ServiceListDescriptor *serviceList;
FastScanLogicalChannelDescriptor *logicalChannels;
public:
FastScanTransportStream(const uint8_t *const buffer);
~FastScanTransportStream(void);
uint16_t getOriginalNetworkId(void) const;
uint16_t getTransportStreamId(void) const;
uint16_t getOrbitalPosition(void) const;
int32_t getFrequency(void) const;
uint8_t getPolarization(void) const;
uint8_t getRollOff(void) const;
uint8_t getModulationSystem(void) const;
uint8_t getModulation(void) const;
int32_t getSymbolRate(void) const;
uint8_t getFecInner(void) const;
const ServiceListItemList *getServiceList(void) const;
const FastScanLogicalChannelList *getLogicalChannelList(void) const;
};
typedef std::list<FastScanTransportStream *> FastScanTransportStreamList;
typedef FastScanTransportStreamList::iterator FastScanTransportStreamListIterator;
typedef FastScanTransportStreamList::const_iterator FastScanTransportStreamListConstIterator;
class FastScanNetworkSection : public LongCrcSection, public NetworkNameDescriptor
{
protected:
unsigned versionNumber : 5;
FastScanTransportStreamList transportStreams;
public:
FastScanNetworkSection(const uint8_t * const buffer);
~FastScanNetworkSection(void);
static const uint16_t LENGTH = 4096;
static const int TID = 0xBC;
static const uint32_t TIMEOUT = 5000;
uint8_t getVersion(void) const;
const FastScanTransportStreamList *getTransportStreams(void) const;
};
class eDVBFastScanServicesSpec
{
eDVBTableSpec m_spec;
public:
eDVBFastScanServicesSpec(int pid)
{
m_spec.pid = pid;
m_spec.tid = FastScanServicesSection::TID;
m_spec.timeout = FastScanServicesSection::TIMEOUT;
m_spec.flags = eDVBTableSpec::tfAnyVersion |
eDVBTableSpec::tfHaveTID | eDVBTableSpec::tfCheckCRC | eDVBTableSpec::tfHaveTimeout;
}
operator eDVBTableSpec &()
{
return m_spec;
}
};
class eDVBFastScanNetworkSpec
{
eDVBTableSpec m_spec;
public:
eDVBFastScanNetworkSpec(int pid)
{
m_spec.pid = pid;
m_spec.tid = FastScanNetworkSection::TID;
m_spec.timeout = FastScanNetworkSection::TIMEOUT;
m_spec.flags = eDVBTableSpec::tfAnyVersion |
eDVBTableSpec::tfHaveTID | eDVBTableSpec::tfCheckCRC | eDVBTableSpec::tfHaveTimeout;
}
operator eDVBTableSpec &()
{
return m_spec;
}
};
template <class Section>
class eFastScanTable : public eTable<Section>
{
std::set<int> seen;
public:
int createTable(unsigned int nr, const uint8_t *data, unsigned int max)
{
seen.insert(nr);
tableProgress(seen.size(), max);
return eTable<Section>::createTable(nr, data, max);
}
Signal2<void, int, int> tableProgress;
};
template <class Section>
class eFastScanFileTable : public eFastScanTable<Section>
{
public:
void readFile(FILE *file)
{
if (!file) return;
unsigned char buffer[4096];
while (1)
{
if (fread(buffer, 3, 1, file) < 1) break;
unsigned int sectionsize = ((buffer[1]) & 0xf) * 256 + buffer[2];
if (fread(&buffer[3], sectionsize, 1, file) < 1) break;
if (eFastScanTable<Section>::createTable(buffer[6], buffer, buffer[7] + 1) > 0) break;
}
}
};
#endif /* no SWIG */
class eFastScan: public Object, public iObject
{
DECLARE_REF(eFastScan);
#ifndef SWIG
eUsePtr<iDVBChannel> m_channel;
ePtr<iDVBDemux> m_demux;
eDVBFrontendParametersSatellite transponderParameters;
bool originalNumbering;
bool useFixedServiceInfo;
int versionNumber;
std::string providerName, bouquetFilename;
int m_pid;
ePtr<eFastScanTable<FastScanServicesSection> > m_ServicesTable;
ePtr<eFastScanTable<FastScanNetworkSection> > m_NetworkTable;
void servicesTableProgress(int size, int max);
void networkTableProgress(int size, int max);
void servicesTableReady(int error);
void networkTableReady(int error);
void fillBouquet(eBouquet *bouquet, std::map<int, eServiceReferenceDVB> &numbered_channels);
void parseResult();
#endif /* no SWIG */
public:
eFastScan(int pid, const char *providername, eDVBFrontendParametersSatellite transponderparameters, bool originalnumbering = false, bool fixedserviceinfo = false);
~eFastScan();
void start(int frontendid = 0);
void startFile(const char *fnt, const char *fst);
int getVersion();
PSignal1<void, int> scanProgress;
PSignal1<void, int> scanCompleted;
};
#endif