1 //*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#* DTAPI.h *#*#*#*#*#*#*#*#*#* (C) 2000-2018 DekTec
2 //
3 // DTAPI - C++ API for DekTec PCI/PCI-Express cards, USB adapters and network devices
4 //
5 
6 #ifndef __DTAPI_H
7 #define __DTAPI_H
8 
9 // DTAPI version
10 #define DTAPI_VERSION_MAJOR        5
11 #define DTAPI_VERSION_MINOR        30
12 #define DTAPI_VERSION_BUGFIX       0
13 #define DTAPI_VERSION_BUILD        108
14 
15 //-.-.-.-.-.-.-.-.-.-.-.-.- Additional Libraries to be Linked In -.-.-.-.-.-.-.-.-.-.-.-.-
16 
17 #ifdef _WIN32
18 
19 #ifndef _LIB  // Do not link libraries into DTAPI itself
20 #pragma comment(lib, "iphlpapi.lib")
21 #pragma comment(lib, "ws2_32.lib")
22 #pragma comment(lib, "setupapi.lib")
23 #pragma comment(lib, "comctl32.lib")
24 #pragma comment(lib, "wbemuuid.lib")
25 #endif
26 
27 #ifndef _DTAPI_DISABLE_AUTO_LINK
28     // Are we using multi-threaded-DLL or static runtime libraries?
29     #ifdef _DLL
30         // Link with DLL runtime version (/MD)
31         #ifdef _DEBUG
32             #ifdef _WIN64
33                 #pragma comment(lib, "DTAPI64MDd.lib")  // Debug 64bit
34                 #pragma message("Automatically linking with DTAPI64MDd.lib")
35             #else
36                 #pragma comment(lib, "DTAPIMDd.lib")    // Debug 32bit
37                 #pragma message("Automatically linking with DTAPIMDd.lib")
38             #endif
39         #else
40             #ifdef _WIN64
41                 #pragma comment(lib, "DTAPI64MD.lib")   // Release 64bit
42                 #pragma message("Automatically linking with DTAPI64MD.lib")
43             #else
44                 #pragma comment(lib, "DTAPIMD.lib")     // Release 32bit
45                 #pragma message("Automatically linking with DTAPIMD.lib")
46             #endif
47         #endif
48     #else
49         // Link to static runtime version (/MT)
50         #ifdef _DEBUG
51             #ifdef _WIN64
52                 #pragma comment(lib, "DTAPI64MTd.lib")  // Debug 64bit
53                 #pragma message("Automatically linking with DTAPI64MTd.lib")
54             #else
55                 #pragma comment(lib, "DTAPIMTd.lib")    // Debug 32bit
56                 #pragma message("Automatically linking with DTAPIMTd.lib")
57             #endif
58         #else
59             #ifdef _WIN64
60                 #pragma comment(lib, "DTAPI64MT.lib")   // Release 64bit
61                 #pragma message("Automatically linking with DTAPI64MT.lib")
62             #else
63                 #pragma comment(lib, "DTAPIMT.lib")     // Release 32bit
64                 #pragma message("Automatically linking with DTAPIMT.lib")
65             #endif
66         #endif
67     #endif
68 #endif
69 #endif    // #ifdef _WIN32
70 
71 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- Includes -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
72 
73 #ifndef _WIN32
74     // Linux specific includes: For NULL type definition
75     #include </usr/include/linux/stddef.h>
76     // For intptr_t
77     #include <stdint.h>
78 #endif
79 
80 // STL includes
81 #include <list>
82 #include <map>
83 #include <string>
84 #include <vector>
85 #include <limits>
86 
87 // When creating a DLL under Windows, disable warnings related to exporting STL
88 // instantiations in classes.
89 // See also: http://support.microsoft.com/kb/q168958/
90 #ifdef _MSC_VER
91     #pragma warning(disable: 4251)
92 #endif
93 
94 // Macro used to mark functions as deprecated. Using deprecated functions will generate
95 // a compiler warning, pushing API users to stop using these functions.
96 #ifdef __GNUC__
97 #define DTAPI_DEPRECATED(func, msg)  func __attribute__ ((deprecated))
98 #elif defined(_MSC_VER)
99 #define DTAPI_DEPRECATED(func, msg)  __declspec(deprecated(msg)) func
100 #else
101 #define DTAPI_DEPRECATED(func, msg) func
102 #endif
103 
104 //.-.-.-.-.-.-.-.-.-.-.- Unsupported Visual Studio Versions -.-.-.-.-.-.-.-.-.-.-.-.-.-.-
105 
106 #ifdef _MSC_VER
107 #if (_MSC_VER<1500)
108     #pragma message("ERROR: This version of Visual Studio is not supported")
109 #endif
110 #if (_MSC_VER==1500)
111     #pragma message("WARNING: Visual Studio 2008 support will be deprecated in 2018")
112 #endif
113 #if (_MSC_VER==1600)
114     #pragma message("WARNING: Visual Studio 2010 support will be deprecated in 2018")
115 #endif
116 #endif
117 
118 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- Support Types -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
119 
120 #ifdef _WIN32
121     typedef unsigned __int64 __uint64;
122 #else
123     typedef signed long long __int64;
124     typedef unsigned long long __uint64;
125 #endif
126 
127 // All DTAPI code lives in namespace Dtapi
128 namespace Dtapi
129 {
130 
131 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- Forward declarations -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
132 
133 class AdvDemod;
134 class DtaPlusDevice;
135 class DtAtsc3Pars;
136 class DtDemodPars;
137 class DtDevice;
138 class DtDvbT2Pars;
139 class DteDevice;
140 class DtMxAudioService;
141 class DtMxAudioChannel;
142 class DtOutpChannel;
143 class DtSdiUtility;
144 class FrameBufImpl;
145 class IDevice;
146 class IDtDemodEvent;
147 class InpChannel;
148 class IXpMutex;
149 class MplpHelper;
150 class OutpChannel;
151 class SdiMatrixImpl;
152 class AvInputStatus;
153 struct DtAtscStreamSelPars;
154 struct DtAtsc3DemodL1Data;
155 struct DtAtsc3TxIdInfo;
156 struct DtAtsc3StreamSelPars;
157 struct DtDabEnsembleInfo;
158 struct DtDabEtiStreamSelPars;
159 struct DtDabStreamSelPars;
160 struct DtDabTransmitterIdInfo;
161 struct DtDemodParsAtsc3;
162 struct DtDemodParsAtsc;
163 struct DtDemodParsDab;
164 struct DtDemodParsDvbC2;
165 struct DtDemodParsDvbS;
166 struct DtDemodParsDvbS2;
167 struct DtDemodParsDvbT;
168 struct DtDemodParsDvbT2;
169 struct DtDemodParsIq;
170 struct DtDemodParsIq2131;
171 struct DtDemodParsIsdbt;
172 struct DtDemodParsQam;
173 struct DtDemodLdpcStats;
174 struct DtDemodMaLayerData;
175 struct DtDemodMaLayerStats;
176 struct DtDemodPlpBlocks;
177 struct DtDvbC2DemodL1Part2Data;
178 struct DtDvbC2DemodL1PlpSigData;
179 struct DtDvbC2ModStatus;
180 struct DtDvbC2Pars;
181 struct DtDvbC2PlpPars;
182 struct DtDvbC2StreamSelPars;
183 struct DtDvbC2XFecFrameHeader;
184 struct DtDvbCidPars;
185 struct DtDvbS2ModStatus;
186 struct DtDvbS2ModCod;
187 struct DtDvbS2Pars;
188 struct DtDemodParsDvbS2Adv;
189 struct DtDvbTStreamSelPars;
190 struct DtDvbTTpsInfo;
191 struct DtDvbT2DemodL1Data;
192 struct DtDvbT2ModStatus;
193 struct DtDvbT2StreamSelPars;
194 struct DtDvbT2TransmitterIdInfo;
195 struct DtFractionInt;
196 struct DtIsdbtStreamSelPars;
197 struct DtIsdbTmmPars;
198 struct DtPar;
199 struct DtPlpInpPars;
200 struct DtQamStreamSelPars;
201 struct DtStatistic;
202 struct DtT2MiStreamSelPars;
203 struct DtVirtualOutData;
204 struct DtRsDecStats;
205 struct DtVitDecStats;
206 
207 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
208 //=+=+=+=+=+=+=+=+=+=+=+=+ DTAPI HELPER CLASSES AND HELPER TYPES +=+=+=+=+=+=+=+=+=+=+=+=+
209 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
210 
211 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DTAPI_RESULT -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
212 
213 // Type returned by most API calls
214 typedef unsigned int  DTAPI_RESULT;
215 
216 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtExc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
217 //
218 // Exception object thrown from API calls (if API call throws an exception)
219 //
220 class DtExc
221 {
222 public:
223     const DTAPI_RESULT  m_Error;    // DTAPI result code (i.e. reason of exception)
224 
225 public:
DtExc(DTAPI_RESULT e)226     DtExc(DTAPI_RESULT e) : m_Error(e) {}
~DtExc()227     virtual ~DtExc() {}
228 };
229 
230 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtBufferInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
231 //
232 struct DtBufferInfo
233 {
234     int  m_VidStd;                  // Video standard
235     int  m_NumColumns;              // Number of columns
236     __int64  m_NumReceived;         // Number of frames received
237     __int64  m_NumDropped;          // Number of frames dropped
238     __int64  m_NumTransmitted;      // Number of frames transmitted
239     __int64  m_NumDuplicated;       // Number of frames duplicated
240 };
241 
242 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtCaps - Capabilities -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
243 //
244 // Scalable type for storing (combinations of) capability flags.
245 // It can be used with bitwise operators for testing and setting of capabilities.
246 //
247 class DtCaps
248 {
249     // Number of 64-bit integers used to represent a capability
250     static const int  DTCAPS_SIZE = 4;
251 
252 public:
253     DtCaps();
254     DtCaps(int BitNr);
255     DtCaps(__int64 F1, __int64 F2, __int64 F3,  __int64 F4);
256 
257 public:
258     int  GetCapIndex() const;
259     std::string  ToString() const;
260     DtCaps  operator & (const DtCaps& Caps) const;
261     DtCaps&  operator &= (const DtCaps& Caps);
262     DtCaps  operator | (const DtCaps& Caps) const;
263     DtCaps&  operator |= (const DtCaps& Caps);
264     bool  operator == (const DtCaps& Caps) const;
265     bool  operator == (const int Zero) const;
266     bool  operator != (const DtCaps& Caps) const;
267     bool  operator != (const int Zero) const;
268     bool  operator < (const DtCaps& Caps) const;
269     bool  operator > (const DtCaps& Caps) const;
270     __int64  operator [] (const int n) const;
271     DtCaps  operator ~ () const;
272     // Implementation data
273 private:
274     __int64  m_Flags[DTCAPS_SIZE];
275 };
276 
277 // Capabilities
278 #define DTAPI_CAP_EMPTY        Dtapi::DtCaps()   // DtCaps without any capability flags
279 
280 // Capability group APPS - Applications
281 #define DTAPI_CAP_C2X         Dtapi::DtCaps(0)   // C2Xpert
282 #define DTAPI_CAP_DP          Dtapi::DtCaps(1)   // DtGrabber+ and DtTV
283 #define DTAPI_CAP_DTTV        Dtapi::DtCaps(2)   // DtTV
284 #define DTAPI_CAP_E           Dtapi::DtCaps(3)   // DtEncode
285 #define DTAPI_CAP_J           Dtapi::DtCaps(4)   // DtJitter
286 #define DTAPI_CAP_J2K         Dtapi::DtCaps(5)   // J2K engine
287 #define DTAPI_CAP_MR          Dtapi::DtCaps(6)   // MuxXpert runtime
288 #define DTAPI_CAP_MS          Dtapi::DtCaps(7)   // MuxXpert SDK
289 #define DTAPI_CAP_MX          Dtapi::DtCaps(8)   // MuxXpert
290 #define DTAPI_CAP_RC          Dtapi::DtCaps(9)   // StreamXpress remote control
291 #define DTAPI_CAP_RX          Dtapi::DtCaps(10)  // RFXpert
292 #define DTAPI_CAP_SL          Dtapi::DtCaps(11)  // StreamXpert Lite
293 #define DTAPI_CAP_SP          Dtapi::DtCaps(12)  // StreamXpress stream player
294 #define DTAPI_CAP_SPNIC       Dtapi::DtCaps(13)  // StreamXpress through local NIC
295 #define DTAPI_CAP_SX          Dtapi::DtCaps(14)  // StreamXpert analyzer
296 #define DTAPI_CAP_SXNIC       Dtapi::DtCaps(15)  // StreamXpert via local NIC (dongled)
297 #define DTAPI_CAP_SY          Dtapi::DtCaps(16)  // SdEye
298 #define DTAPI_CAP_T2X         Dtapi::DtCaps(17)  // T2Xpert
299 #define DTAPI_CAP_VR          Dtapi::DtCaps(18)  // VF-REC
300 #define DTAPI_CAP_VRDGL       Dtapi::DtCaps(19)  // VF-REC (dongled)
301 #define DTAPI_CAP_XP          Dtapi::DtCaps(20)  // Xpect
302 #define DTAPI_CAP_XPRT        Dtapi::DtCaps(21)  // Advanced RF measurement
303 
304 // Capability group AUDENC - Supported audio standards
305 #define DTAPI_CAP_ENC_AAC     Dtapi::DtCaps(22)  // AAC audio encoder
306 #define DTAPI_CAP_ENC_AC3     Dtapi::DtCaps(23)  // AC3 audio encoder
307 #define DTAPI_CAP_ENC_AG      Dtapi::DtCaps(24)  // GOLD for audio encoder
308 #define DTAPI_CAP_ENC_AG2     Dtapi::DtCaps(25)  // GOLD for two audio encoders
309 #define DTAPI_CAP_ENC_MP1L2   Dtapi::DtCaps(26)  // MPEG1-layer II audio encoder
310 
311 // Capability group BOOLIO - Boolean I/O capabilities
312 #define DTAPI_CAP_BW          Dtapi::DtCaps(27)  // DEPRECATED, do not use
313 #define DTAPI_CAP_FAILSAFE    Dtapi::DtCaps(28)  // A fail-over relay is available
314 #define DTAPI_CAP_FRACMODE    Dtapi::DtCaps(29)  // Fractional mode is supported
315 #define DTAPI_CAP_GENLOCKED   Dtapi::DtCaps(30)  // Locked to a genlock reference
316 #define DTAPI_CAP_GENREF      Dtapi::DtCaps(31)  // Genlock reference input
317 #define DTAPI_CAP_SWS2APSK    Dtapi::DtCaps(32)  // DVB-S2 APSK mode
318 
319 // Capability group DEMODPROPS - Demodulation properties
320 #define DTAPI_CAP_ANTPWR      Dtapi::DtCaps(33)  // Antenna power
321 #define DTAPI_CAP_LNB         Dtapi::DtCaps(34)  // LNB
322 #define DTAPI_CAP_RX_ADV      Dtapi::DtCaps(35)  // Advanced demodulation
323 #define DTAPI_CAP_RX_ADV_A3   Dtapi::DtCaps(36)  // Basic and ATSC3 advanced demodulation
324 #define DTAPI_CAP_RX_ADV_BASIC Dtapi::DtCaps(37) // Basic advanced demodulation
325 #define DTAPI_CAP_RX_ADV_T2   Dtapi::DtCaps(38)  // Basic and DVB-T2 advanced demodulation
326 
327 // Capability group FREQBAND - Frequency band
328 #define DTAPI_CAP_LBAND       Dtapi::DtCaps(39)  // L-band 950-2150MHz
329 #define DTAPI_CAP_VHF         Dtapi::DtCaps(40)  // VHF-band 47-470MHz
330 #define DTAPI_CAP_UHF         Dtapi::DtCaps(41)  // UHF-band 400-862MHz
331 
332 // Capability group HDMISTD - HDMI standard
333 #define DTAPI_CAP_HDMI1_4     Dtapi::DtCaps(42)  // HDMI 1.4
334 #define DTAPI_CAP_HDMI2_0     Dtapi::DtCaps(43)  // HDMI 2.0
335 
336 // Capability group IODIR - I/O direction
337 #define DTAPI_CAP_DISABLED    Dtapi::DtCaps(44)  // Port is disabled
338 #define DTAPI_CAP_INPUT       Dtapi::DtCaps(45)  // Uni-directional input
339 #define DTAPI_CAP_INTINPUT    Dtapi::DtCaps(46)  // Internal input port
340 #define DTAPI_CAP_MONITOR     Dtapi::DtCaps(47)  // Monitor of input or output
341 #define DTAPI_CAP_OUTPUT      Dtapi::DtCaps(48)  // Uni-directional output
342 
343 // Subcapabilities of IODIR, DTAPI_CAP_INPUT
344 #define DTAPI_CAP_SHAREDANT   Dtapi::DtCaps(49)  // Get antenna signal from another port
345 
346 // Subcapabilities of IODIR, DTAPI_CAP_OUTPUT
347 #define DTAPI_CAP_DBLBUF      Dtapi::DtCaps(50)  // Double buffered output
348 #define DTAPI_CAP_LOOPS2L3    Dtapi::DtCaps(51)  // Loop-through of DVB-S2 in L3-frames
349 #define DTAPI_CAP_LOOPS2TS    Dtapi::DtCaps(52)  // Loop-through of an DVB-S(2) input
350 #define DTAPI_CAP_LOOPTHR     Dtapi::DtCaps(53)  // Loop-through of another input
351 
352 // Capability group IOPROPS - Miscellaneous I/O properties
353 #define DTAPI_CAP_ASIPOL      Dtapi::DtCaps(54)  // ASI output signal can be inverted
354 #define DTAPI_CAP_GENREFSLAVE Dtapi::DtCaps(55)  // Slaved genlock reference
355 #define DTAPI_CAP_HUFFMAN     Dtapi::DtCaps(56)  // Huffman coding for SDI
356 #define DTAPI_CAP_IPPAIR      Dtapi::DtCaps(57)  // Network port supports failover
357 #define DTAPI_CAP_L3MODE      Dtapi::DtCaps(58)  // L3-frame mode
358 #define DTAPI_CAP_MATRIX      Dtapi::DtCaps(59)  // Matrix API support
359 #define DTAPI_CAP_MATRIX2     Dtapi::DtCaps(60)  // High-level Matrix API support
360 #define DTAPI_CAP_RAWASI      Dtapi::DtCaps(61)  // Raw ASI
361 #define DTAPI_CAP_SDI10BNBO   Dtapi::DtCaps(62)  // 10-bit network byte order
362 #define DTAPI_CAP_SDITIME     Dtapi::DtCaps(63)  // SDI timestamping
363 #define DTAPI_CAP_TIMESTAMP64 Dtapi::DtCaps(64)  // 64-bit timestamping
364 #define DTAPI_CAP_TRPMODE     Dtapi::DtCaps(65)  // Transparent mode
365 #define DTAPI_CAP_TS          Dtapi::DtCaps(66)  // MPEG-2 transport stream
366 #define DTAPI_CAP_TXONTIME    Dtapi::DtCaps(67)  // Transmit on timestamp
367 #define DTAPI_CAP_VIRTUAL     Dtapi::DtCaps(68)  // Virtual port, no physical connection
368 
369 // Capability group IOSTD - I/O standard
370 #define DTAPI_CAP_12GSDI      Dtapi::DtCaps(69)  // 12G-SDI
371 #define DTAPI_CAP_3GSDI       Dtapi::DtCaps(70)  // 3G-SDI
372 #define DTAPI_CAP_6GSDI       Dtapi::DtCaps(71)  // 6G-SDI
373 #define DTAPI_CAP_ASI         Dtapi::DtCaps(72)  // DVB-ASI transport stream
374 #define DTAPI_CAP_AVENC       Dtapi::DtCaps(73)  // Audio/video encoder
375 #define DTAPI_CAP_DEMOD       Dtapi::DtCaps(74)  // Demodulation
376 #define DTAPI_CAP_GPSTIME     Dtapi::DtCaps(75)  // 1PPS and 10MHz GPS-clock input
377 #define DTAPI_CAP_HDMI        Dtapi::DtCaps(76)  // HDMI
378 #define DTAPI_CAP_HDSDI       Dtapi::DtCaps(77)  // HD-SDI
379 #define DTAPI_CAP_IFADC       Dtapi::DtCaps(78)  // IF A/D converter
380 #define DTAPI_CAP_IP          Dtapi::DtCaps(79)  // Transport stream over IP
381 #define DTAPI_CAP_MOD         Dtapi::DtCaps(80)  // Modulator output
382 #define DTAPI_CAP_PHASENOISE  Dtapi::DtCaps(81)  // Phase noise injection
383 #define DTAPI_CAP_RS422       Dtapi::DtCaps(82)  // RS422 port
384 #define DTAPI_CAP_SDIRX       Dtapi::DtCaps(83)  // SDI receiver
385 #define DTAPI_CAP_SDI         Dtapi::DtCaps(84)  // SD-SDI
386 #define DTAPI_CAP_SPI         Dtapi::DtCaps(85)  // DVB-SPI transport stream
387 #define DTAPI_CAP_SPISDI      Dtapi::DtCaps(86)  // SD-SDI on a parallel port
388 
389 // Subcapabilities of IOSTD, DTAPI_CAP_12GSDI
390 #define DTAPI_CAP_2160P50     Dtapi::DtCaps(87)  // 2160p/50 lvl A
391 #define DTAPI_CAP_2160P50B    Dtapi::DtCaps(88)  // 2160p/50 lvl B
392 #define DTAPI_CAP_2160P59_94  Dtapi::DtCaps(89)  // 2160p/59.94 lvl A
393 #define DTAPI_CAP_2160P59_94B Dtapi::DtCaps(90)  // 2160p/59.94 lvl B
394 #define DTAPI_CAP_2160P60     Dtapi::DtCaps(91)  // 2160p/60 lvl A
395 #define DTAPI_CAP_2160P60B    Dtapi::DtCaps(92)  // 2160p/60 lvl B
396 
397 // Subcapabilities of IOSTD, DTAPI_CAP_3GSDI
398 #define DTAPI_CAP_1080P50     Dtapi::DtCaps(93)  // 1080p/50 lvl A
399 #define DTAPI_CAP_1080P50B    Dtapi::DtCaps(94)  // 1080p/50 lvl B
400 #define DTAPI_CAP_1080P59_94  Dtapi::DtCaps(95)  // 1080p/59.94 lvl A
401 #define DTAPI_CAP_1080P59_94B Dtapi::DtCaps(96)  // 1080p/59.94 lvl B
402 #define DTAPI_CAP_1080P60     Dtapi::DtCaps(97)  // 1080p/60 lvl A
403 #define DTAPI_CAP_1080P60B    Dtapi::DtCaps(98)  // 1080p/60 lvl B
404 
405 // Subcapabilities of IOSTD, DTAPI_CAP_6GSDI
406 #define DTAPI_CAP_2160P23_98  Dtapi::DtCaps(99)  // 2160p/23.98
407 #define DTAPI_CAP_2160P24     Dtapi::DtCaps(100) // 2160p/24
408 #define DTAPI_CAP_2160P25     Dtapi::DtCaps(101) // 2160p/25
409 #define DTAPI_CAP_2160P29_97  Dtapi::DtCaps(102) // 2160p/29.97
410 #define DTAPI_CAP_2160P30     Dtapi::DtCaps(103) // 2160p/30
411 
412 // Subcapabilities of IOSTD, DTAPI_CAP_HDSDI
413 #define DTAPI_CAP_1080I50     Dtapi::DtCaps(104) // 1080i/50
414 #define DTAPI_CAP_1080I59_94  Dtapi::DtCaps(105) // 1080i/59.94
415 #define DTAPI_CAP_1080I60     Dtapi::DtCaps(106) // 1080i/60
416 #define DTAPI_CAP_1080P23_98  Dtapi::DtCaps(107) // 1080p/23.98
417 #define DTAPI_CAP_1080P24     Dtapi::DtCaps(108) // 1080p/24
418 #define DTAPI_CAP_1080P25     Dtapi::DtCaps(109) // 1080p/25
419 #define DTAPI_CAP_1080P29_97  Dtapi::DtCaps(110) // 1080p/29.97
420 #define DTAPI_CAP_1080P30     Dtapi::DtCaps(111) // 1080p/30
421 #define DTAPI_CAP_1080PSF23_98 Dtapi::DtCaps(112) // 1080psf/23.98
422 #define DTAPI_CAP_1080PSF24   Dtapi::DtCaps(113) // 1080psf/24
423 #define DTAPI_CAP_1080PSF25   Dtapi::DtCaps(114) // 1080psf/25
424 #define DTAPI_CAP_1080PSF29_97 Dtapi::DtCaps(115) // 1080psf/29.97
425 #define DTAPI_CAP_1080PSF30   Dtapi::DtCaps(116) // 1080psf/30
426 #define DTAPI_CAP_720P23_98   Dtapi::DtCaps(117) // 720p/23.98
427 #define DTAPI_CAP_720P24      Dtapi::DtCaps(118) // 720p/24
428 #define DTAPI_CAP_720P25      Dtapi::DtCaps(119) // 720p/25
429 #define DTAPI_CAP_720P29_97   Dtapi::DtCaps(120) // 720p/29.97
430 #define DTAPI_CAP_720P30      Dtapi::DtCaps(121) // 720p/30
431 #define DTAPI_CAP_720P50      Dtapi::DtCaps(122) // 720p/50
432 #define DTAPI_CAP_720P59_94   Dtapi::DtCaps(123) // 720p/59.94
433 #define DTAPI_CAP_720P60      Dtapi::DtCaps(124) // 720p/60
434 
435 // Subcapabilities of IOSTD, DTAPI_CAP_SDI
436 #define DTAPI_CAP_525I59_94   Dtapi::DtCaps(125) // 525i/59.94
437 #define DTAPI_CAP_625I50      Dtapi::DtCaps(126) // 625i/50
438 
439 // Subcapabilities of IOSTD, DTAPI_CAP_SPISDI
440 #define DTAPI_CAP_SPI525I59_94 Dtapi::DtCaps(127) // SPI 525i/59.94
441 #define DTAPI_CAP_SPI625I50   Dtapi::DtCaps(128) // SPI 625i/50
442 
443 // Capability group PWRMODE - Power mode
444 #define DTAPI_CAP_MODHQ       Dtapi::DtCaps(129) // High-quality modulation
445 #define DTAPI_CAP_LOWPWR      Dtapi::DtCaps(130) // Low-power mode
446 
447 // Capability group MODSTD - Modulation standards
448 #define DTAPI_CAP_TX_ATSC     Dtapi::DtCaps(131) // ATSC 8-VSB modulation
449 #define DTAPI_CAP_TX_ATSC3    Dtapi::DtCaps(132) // ATSC3.0 modulation
450 #define DTAPI_CAP_TX_CMMB     Dtapi::DtCaps(133) // CMMB modulation
451 #define DTAPI_CAP_TX_DAB      Dtapi::DtCaps(134) // DAB modulation
452 #define DTAPI_CAP_TX_DTMB     Dtapi::DtCaps(135) // DTMB modulation
453 #define DTAPI_CAP_TX_DVBC2    Dtapi::DtCaps(136) // DVB-C2 modulation
454 #define DTAPI_CAP_TX_DVBS     Dtapi::DtCaps(137) // DVB-S modulation
455 #define DTAPI_CAP_TX_DVBS2    Dtapi::DtCaps(138) // DVB-S2 modulation
456 #define DTAPI_CAP_TX_DVBS2X   Dtapi::DtCaps(139) // DVB-S2X modulation
457 #define DTAPI_CAP_TX_DVBT     Dtapi::DtCaps(140) // DVB-T modulation
458 #define DTAPI_CAP_TX_DVBT2    Dtapi::DtCaps(141) // DVB-T2 modulation
459 #define DTAPI_CAP_TX_GOLD     Dtapi::DtCaps(142) // GOLD for modulators
460 #define DTAPI_CAP_TX_HW8CH    Dtapi::DtCaps(143) // Eight-channel HW modulation
461 #define DTAPI_CAP_TX_IQ       Dtapi::DtCaps(144) // I/Q sample modulation
462 #define DTAPI_CAP_TX_ISDBS    Dtapi::DtCaps(145) // ISDB-S modulation
463 #define DTAPI_CAP_TX_ISDBS3   Dtapi::DtCaps(146) // ISDB-S3 modulation
464 #define DTAPI_CAP_TX_ISDBT    Dtapi::DtCaps(147) // ISDB-T modulation
465 #define DTAPI_CAP_TX_ISDBTMM  Dtapi::DtCaps(148) // ISDB-Tmm modulation
466 #define DTAPI_CAP_TX_MH       Dtapi::DtCaps(149) // ATSC-MH modulation
467 #define DTAPI_CAP_TX_QAMA     Dtapi::DtCaps(150) // QAM-A modulation
468 #define DTAPI_CAP_TX_QAMB     Dtapi::DtCaps(151) // QAM-B modulation
469 #define DTAPI_CAP_TX_QAMC     Dtapi::DtCaps(152) // QAM-C modulation
470 #define DTAPI_CAP_TX_SWMC     Dtapi::DtCaps(153) // SW multi-channel modulation
471 #define DTAPI_CAP_TX_T2MI     Dtapi::DtCaps(154) // T2MI transmission
472 #define DTAPI_CAP_TX_T2SPLP   Dtapi::DtCaps(155) // DVB-T2 single PLP modulation
473 
474 // Capability group MODPROPS - Modulation properties
475 #define DTAPI_CAP_ADJLVL      Dtapi::DtCaps(156) // Adjustable output level
476 #define DTAPI_CAP_CM          Dtapi::DtCaps(157) // Channel simulation
477 #define DTAPI_CAP_CW          Dtapi::DtCaps(158) // Continuous wave
478 #define DTAPI_CAP_DIGIQ       Dtapi::DtCaps(159) // Digital I/Q sample output
479 #define DTAPI_CAP_DVBCID      Dtapi::DtCaps(160) // DVB carrier ID
480 #define DTAPI_CAP_IF          Dtapi::DtCaps(161) // IF output
481 #define DTAPI_CAP_MUTE        Dtapi::DtCaps(162) // Mute RF output signal
482 #define DTAPI_CAP_ROLLOFF     Dtapi::DtCaps(163) // Adjustable roll-off factor
483 #define DTAPI_CAP_S2APSK      Dtapi::DtCaps(164) // DVB-S2 16-APSK/32-APSK
484 #define DTAPI_CAP_SNR         Dtapi::DtCaps(165) // AWGN insertion
485 #define DTAPI_CAP_TX_16MHZ    Dtapi::DtCaps(166) // 16MHz bandwidth mode
486 #define DTAPI_CAP_TX_SFN      Dtapi::DtCaps(167) // SNF operation
487 
488 // Capability group RFCLKSEL - RF clock source selection
489 #define DTAPI_CAP_RFCLKEXT    Dtapi::DtCaps(168) // External RF clock input
490 #define DTAPI_CAP_RFCLKINT    Dtapi::DtCaps(169) // Internal RF clock reference
491 
492 // Capability group RXSTD - Receiver standards
493 #define DTAPI_CAP_RX_ATSC     Dtapi::DtCaps(170) // ATSC 8-VSB reception
494 #define DTAPI_CAP_RX_ATSC3    Dtapi::DtCaps(171) // ATSC3.0 reception
495 #define DTAPI_CAP_RX_CMMB     Dtapi::DtCaps(172) // CMMB reception
496 #define DTAPI_CAP_RX_DAB      Dtapi::DtCaps(173) // DAB reception
497 #define DTAPI_CAP_RX_DTMB     Dtapi::DtCaps(174) // DTMB reception
498 #define DTAPI_CAP_RX_DVBC2    Dtapi::DtCaps(175) // DVB-C2 reception
499 #define DTAPI_CAP_RX_DVBS     Dtapi::DtCaps(176) // DVB-S reception
500 #define DTAPI_CAP_RX_DVBS2    Dtapi::DtCaps(177) // DVB-S2 reception
501 #define DTAPI_CAP_RX_DVBT     Dtapi::DtCaps(178) // DVB-T reception
502 #define DTAPI_CAP_RX_DVBT2    Dtapi::DtCaps(179) // DVB-T2 reception
503 #define DTAPI_CAP_RX_GOLD     Dtapi::DtCaps(180) // GOLD for receivers
504 #define DTAPI_CAP_RX_IQ       Dtapi::DtCaps(181) // I/Q sample reception
505 #define DTAPI_CAP_RX_ISDBS    Dtapi::DtCaps(182) // ISDB-S reception
506 #define DTAPI_CAP_RX_ISDBT    Dtapi::DtCaps(183) // ISDB-T reception
507 #define DTAPI_CAP_RX_MH       Dtapi::DtCaps(184) // ATSC-MH reception
508 #define DTAPI_CAP_RX_QAMA     Dtapi::DtCaps(185) // QAM-A reception
509 #define DTAPI_CAP_RX_QAMB     Dtapi::DtCaps(186) // QAM-B reception
510 #define DTAPI_CAP_RX_QAMC     Dtapi::DtCaps(187) // QAM-C reception
511 #define DTAPI_CAP_RX_T2MI     Dtapi::DtCaps(188) // T2MI reception
512 
513 // Capability group SPICLKSEL - Parallel port clock source selection
514 #define DTAPI_CAP_SPICLKEXT   Dtapi::DtCaps(189) // External clock input
515 #define DTAPI_CAP_SPICLKINT   Dtapi::DtCaps(190) // Internal clock reference
516 
517 // Capability group SPIMODE - Parallel port mode
518 #define DTAPI_CAP_SPIFIXEDCLK Dtapi::DtCaps(191) // SPI fixed clock with valid signal
519 #define DTAPI_CAP_SPIDVBMODE  Dtapi::DtCaps(192) // SPI DVB mode
520 #define DTAPI_CAP_SPISER8B    Dtapi::DtCaps(193) // SPI serial 8-bit mode
521 #define DTAPI_CAP_SPISER10B   Dtapi::DtCaps(194) // SPI serial 10-bit mode
522 
523 // Capability group SPISTD - Parallel port I/O standard
524 #define DTAPI_CAP_SPILVDS1    Dtapi::DtCaps(195) // LVDS1
525 #define DTAPI_CAP_SPILVDS2    Dtapi::DtCaps(196) // LVDS2
526 #define DTAPI_CAP_SPILVTTL    Dtapi::DtCaps(197) // LVTTL
527 
528 // Capability group TSRATESEL - Transport-stream rate selection
529 #define DTAPI_CAP_EXTTSRATE   Dtapi::DtCaps(198) // External TS rate clock input
530 #define DTAPI_CAP_EXTRATIO    Dtapi::DtCaps(199) // External TS rate clock with ratio
531 #define DTAPI_CAP_INTTSRATE   Dtapi::DtCaps(200) // Internal TS rate clock reference
532 #define DTAPI_CAP_LOCK2INP    Dtapi::DtCaps(201) // Lock TS rate to input port
533 
534 // Capability group VIDENC - Supported video standards
535 #define DTAPI_CAP_ENC_H264    Dtapi::DtCaps(202) // H.264 video encoder
536 #define DTAPI_CAP_ENC_MP2V    Dtapi::DtCaps(203) // MPEG2 video encoder
537 
538 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtCmmbPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
539 //
540 // CMMB Modulation Parameters
541 //
542 struct DtCmmbPars
543 {
544     int  m_Bandwidth;               // CMMB Bandwitdh
545     int  m_TsRate;                  // CMMB TS rate in bps
546     int  m_TsPid;                   // PID on which the CMMB stream is found
547     int  m_AreaId;                  // Area ID (0..127)
548     int  m_TxId;                    // Transmitter ID (128..255)
549 
550 public:
551     DtCmmbPars();
552     DTAPI_RESULT  RetrieveTsRateFromTs(char* pBuffer, int NumBytes);
553     bool  operator == (DtCmmbPars& Rhs);
554     bool  operator != (DtCmmbPars& Rhs);
555 };
556 
557 // DtOutpChannel::SetModControl - Bandwidth
558 #define DTAPI_CMMB_BW_2MHZ          0x00000000
559 #define DTAPI_CMMB_BW_8MHZ          0x00000001
560 
561 //-.-.-.-.-.-.-.-.-.-.-.- DtCmPars - Channel Modelling Parameters -.-.-.-.-.-.-.-.-.-.-.-.
562 
563 // Maximum number of fading paths
564 #define DTAPI_CM_MAX_PATHS          32
565 
566 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtCmPath -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
567 //
568 // This structure describes the fading parameters for a single path in a
569 // multi-path simulation.
570 //
571 struct DtCmPath
572 {
573     enum Type
574     {
575         CONSTANT_DELAY,             // Constant delay/phase
576         CONSTANT_DOPPLER,           // Constant frequency shift
577         RAYLEIGH_JAKES,             // Rayleigh fading with Jakes power spectral density
578                                     // (mobile path model)
579         RAYLEIGH_GAUSSIAN           // Rayleigh fading with Gaussian power spectral
580                                     // density (ionospheric path model)
581     };
582     Type  m_Type;                   // Type of path fading
583     double  m_Attenuation;          // Attenuation in dB
584     double  m_Delay;                // Delay in us
585     double  m_Phase;                // Phase shift in degrees for CONSTANT_DELAY paths
586     double  m_Doppler;              // Doppler frequency in Hz
587 
588     // Constructor - Gives parameters a default value
DtCmPathDtCmPath589     DtCmPath() :
590         m_Type(CONSTANT_DELAY),
591         m_Attenuation(0.0), m_Delay(0.0), m_Phase(0.0), m_Doppler(0.0)
592     {}
593     // Operators
594     bool  operator == (DtCmPath& Rhs);
595 };
596 
597 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtCmPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
598 //
599 // This structure describes channel-modeling parameters. It\92s used to simulate the
600 // transmission distortions that may occur in the channel between a transmitter and
601 // a receiver.
602 //
603 struct DtCmPars
604 {
605     bool  m_EnableAwgn;             // Enable white Gaussian noise (AWGN) injection
606     double  m_Snr;                  // Signal-to-noise ratio in dB
607     bool  m_EnablePaths;            // Enable multi-path simulation
608     std::vector<DtCmPath>  m_Paths; // Parameters per path
609 
610     // Constructor and operators
611     DtCmPars();
612     bool  operator == (DtCmPars&);
613     bool  operator != (DtCmPars& Rhs) { return !(*this == Rhs); }
614 };
615 
616 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtConstelPoint -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
617 //
618 // This structure describes a constellation point in a receiver constellation diagram
619 //
620 struct DtConstelPoint
621 {
622     int  m_X, m_Y;                  // X and Y coordinates
623 };
624 
625 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- IDtDemodEvent -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
626 //
627 // Callback event interface for demodulators
628 //
629 class IDtDemodEvent
630 {
631 public:
TuningFreqHasChanged(__int64,__int64)632     virtual void  TuningFreqHasChanged(__int64 /*OldFreqHz*/, __int64 /*NewFreqHz*/) {}
TuningParsHaveChanged(__int64,int,int[3],__int64,int,int[3])633     virtual void  TuningParsHaveChanged(
634                  __int64 /*OldFreqHz*/, int  /*OldModType*/, int[3]  /*OldParXtra[3]*/,
635                  __int64 /*NewFreqHz*/, int  /*NewModType*/, int[3]  /*NewParXtra[3]*/) {}
636 };
637 
638 
639 // Maximum number of IpV6 addresses per interface
640 #define MAX_IPV6_ADDR               3
641 
642 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDeviceDesc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
643 //
644 // This structure describes a DekTec device
645 //
646 struct DtDeviceDesc
647 {
648     int  m_Category;                // Device category (DTAPI_CAT_XXX)
649     __int64  m_Serial;              // Unique serial number of the device
650     int  m_PciBusNumber;            // PCI-bus number
651     int  m_SlotNumber;              // PCI-slot number
652     int  m_UsbAddress;              // USB address
653     int  m_TypeNumber;              // Device type number
654     int  m_SubType;                 // Device subtype (0=none, 1=A, ...)
655     int  m_DeviceId;                // Device ID
656     int  m_VendorId;                // Vendor ID
657     int  m_SubsystemId;             // Subsystem ID
658     int  m_SubVendorId;             // Subsystem Vendor ID
659     int  m_NumHwFuncs;              // Number of hardware funtions hosted by device
660     int  m_HardwareRevision;        // Hardware revision (e.g. 302 = 3.2)
661     int  m_FirmwareVersion;         // Firmware version
662     int  m_FirmwareVariant;         // Firmware variant
663     int  m_FwPackageVersion;        // Firmware package version (-1 if not applicable)
664     int  m_NumDtInpChan;            // Number of input channels (max)
665     int  m_NumDtOutpChan;           // Number of output channels (max)
666     int  m_NumPorts;                // Number of physical ports
667     unsigned char  m_Ip[4];         // IP address (only valid for DTE-31xx devices)
668     unsigned char  m_IpV6[MAX_IPV6_ADDR][16];
669                                     // IP address (only valid for DTE-31xx devices)
670     unsigned char  m_MacAddr[6];    // MAC address (only valid for DTE-31xx devices)
671     int  m_PcieNumLanes;            // Number of allocated PCIe lanes
672     int  m_PcieMaxLanes;            // Maximum number of PCIe lanes
673     int  m_PcieLinkSpeed;           // Current PCIe link speed (GEN1, 2 or 3)
674     int  m_PcieMaxSpeed;            // Maximum PCIe link speed (GEN1, 2 or 3)
675 };
676 
677 // Device categories
678 #define DTAPI_CAT_PCI               0            // PCI or PCI-Express device
679 #define DTAPI_CAT_USB               1            // USB-2 or USB-3 device
680 #define DTAPI_CAT_NW                2            // Network device
681 #define DTAPI_CAT_IP                3            // Network appliance: DTE-31xx
682 #define DTAPI_CAT_NIC               4            // Non-DekTec network card
683 #define DTAPI_CAT_NWAP              5            // Network Advanced Protocol(VLAN device)
684 
685 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDtaPlusDeviceDesc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
686 //
687 // This structure describes a DekTec DTA-plus device
688 //
689 struct DtDtaPlusDeviceDesc
690 {
691     __int64  m_Serial;              // Unique serial number of the device
692     std::string  m_DevicePath;      // Path of file to open to interface with the device
693 };
694 
695 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtDvbCidPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
696 //
697 // Structure for specifying the DVB channel identification for satellite (DVB-S2)
698 // ETSI TS 103 129
699 //
700 struct DtDvbCidPars
701 {
702     bool  m_Enable;             // Enable DVB-CID signalling
703     bool  m_MuteDvbS2;          // Mute the satellite signal
704     bool  m_OverrideGuid;       // Use user specified GUID.
705     unsigned int  m_GuidHigh;   // DVB-CID Global Unique Identifier MSBs
706     unsigned int  m_GuidLow;    // DVB-CID Global Unique Identifier LSBs
707 
708     // CID content. Key: Content ID (0...31); Value: Content information (24-bit)
709     // Content ID 0 (carrier ID format) shall have the value 0x0001
710     std::map<int, int>  m_Content;
711 
DtDvbCidParsDtDvbCidPars712     DtDvbCidPars() : m_MuteDvbS2(false), m_OverrideGuid(false) {};
713     DTAPI_RESULT  CheckValidity();
714     DTAPI_RESULT  GetGuid(DtDevice* pDevice, int PortNr=1);
715 };
716 
717 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEventArgs -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
718 //
719 // Details for a specific event
720 //
721 struct DtEventArgs
722 {
DtEventArgsDtEventArgs723     DtEventArgs() : m_Value1(0), m_Value2(0), m_pContext(0) {};
724 
725     int  m_HwCat;                   // Hardware category: DTAPI_CAT_XXX
726     __int64  m_Serial;              // Serial number of device causing event
727     int  m_Value1;                  // Event value #1
728     int  m_Value2;                  // Event value #2
729     void*  m_pContext;              // Context-specific pointer
730 };
731 
732 // Event call back function
733 typedef void (*pDtEventCallback)(int Event, const DtEventArgs* pArgs);
734 
735 // Global events
736 #define DT_EVENT_TYPE_ADD           0x00000001
737 #define DT_EVENT_TYPE_REMOVE        0x00000002
738 // Device events
739 #define DT_EVENT_TYPE_POWER         0x00000004
740 #define DT_EVENT_TYPE_GENLOCK       0x00000008
741 #define DT_EVENT_TYPE_IOCONFIG      0x00000010
742 #define DT_EVENT_TYPE_TEST          0x80000000
743 // Network events
744 #define DT_EVENT_IP_CHANGED         0x01000000
745 #define DT_EVENT_ADMINST_CHANGED    0x02000000
746 
747 #define DT_EVENT_TYPE_ALL           0xFFFFFFFF
748 
749 // Event values
750 #define DT_EVENT_VALUE1_POWER_UP    1
751 #define DT_EVENT_VALUE1_POWER_DOWN  2
752 #define DT_EVENT_VALUE1_NO_LOCK     1
753 #define DT_EVENT_VALUE1_LOCKED      2
754 #define DT_EVENT_VALUE2_XXX         1
755 
756 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtFiltCoeff -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
757 //
758 // A single FIR filter coefficient
759 //
760 struct DtFiltCoeff
761 {
762     int  m_TapIdx;                  // Tap number
763     double  m_Coeff;                // FIR coefficient
764 };
765 
766 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtFilterPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
767 //
768 // Filter coefficients for use in a FIR filter
769 //
770 struct DtFilterPars
771 {
772     std::vector<DtFiltCoeff>  m_FiltCoeffs;
773 };
774 
775 // Maximum number of filter coefficients
776 #define DTAPI_MAX_NUM_COEFFS   64
777 
778 #define DTAPI_FRAME_STATUS_OK                0
779 #define DTAPI_FRAME_STATUS_ERR_NO_SIGNAL     1
780 #define DTAPI_FRAME_STATUS_ERR_STD_MISMATCH  2
781 
782 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtFractionInt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
783 //
784 // A rational number, expressed as the quotient of two integers
785 //
786 struct DtFractionInt
787 {
788     int  m_Num, m_Den;
DtFractionIntDtFractionInt789     DtFractionInt()                  { m_Num = 0;  m_Den = 1; }
DtFractionIntDtFractionInt790     DtFractionInt(int Num, int Den)  { m_Num = Num;  m_Den = Den; }
791 };
792 
793 
794 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtFrameInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
795 //
796 struct DtFrameInfo
797 {
798     int  m_VidStd;                  // Video standard
799     __int64  m_Timestamp;           // 64-bit timestamp
800     __int64  m_FrameNumber;         // 64-bit frame number
801     __int64  m_Rp188;               // RP188 timestamp
802     int  m_RxMode;                  // RX mode at the time this frame was received
803     int  m_Status;                  // One of DTAPI_FRAME_STATUS_*
804 };
805 
806 //-.-.-.-.-.-.-.-.-.-.- DtHwFuncDesc - Hardware Function Descriptor -.-.-.-.-.-.-.-.-.-.-.
807 //
808 // Structure describing a hardware function
809 //
810 struct DtHwFuncDesc
811 {
812     DtDeviceDesc  m_DvcDesc;        // Device descriptor
813     int  m_ChanType;                // Channel type (OR-able)
814     DtCaps  m_Flags;                // Capability flags (OR-able)
815     int  m_IndexOnDvc;              // Relative index of hardware function
816     int  m_Port;                    // Physical port number
817     unsigned char  m_Ip[4];         // IP V4 address (TS-over-IP functions only)
818     unsigned char  m_IpV6[MAX_IPV6_ADDR][16];
819                                     // IP V6 address (TS-over-IP functions only)
820     unsigned char  m_MacAddr[6];    // MAC address (TS-over-IP functions only)
821 };
822 
823 // Hardware Function - Channel types
824 // For IP hardware functions, both DTAPI_CHAN_INPUT and DTAPI_CHAN_OUTPUT are set
825 #define DTAPI_CHAN_DISABLED         0            // Channel is disabled
826 #define DTAPI_CHAN_INPUT            1            // Input channel
827 #define DTAPI_CHAN_OUTPUT           2            // Output channel
828 #define DTAPI_CHAN_DBLBUF           4            // Double-buffered copy of an output
829 #define DTAPI_CHAN_LOOPTHR          8            // Loop-through copy of another port
830 
831 //.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIoConfig - I/O Configuration -.-.-.-.-.-.-.-.-.-.-.-.-.-.
832 //
833 // Stores the I/O configuration parameters for one I/O port configuration
834 //
835 struct DtIoConfig
836 {
837     int  m_Port;                    // Port number
838     int  m_Group;                   // Config group, linked to I/O capability groups
839     int  m_Value;                   // Config value, linked to I/O capabilities
840     int  m_SubValue;                // Config sub value, linked to I/O sub capabilities
841     __int64  m_ParXtra[2];          // Extra parameters, e.g. source port number
842 
843     // Constructor - Gives parameters a default value
DtIoConfigDtIoConfig844     DtIoConfig()
845     {
846         m_Port = -1;
847         m_Group = -1;
848         m_Value = m_SubValue = -1;
849         m_ParXtra[0] = m_ParXtra[1] = -1;
850     }
DtIoConfigDtIoConfig851     DtIoConfig(int  Port, int  Group)
852     {
853         m_Port = Port;
854         m_Group = Group;
855         m_Value = m_SubValue = -1;
856         m_ParXtra[0] = m_ParXtra[1] = -1;
857     }
858 };
859 
860 // I/O configuration groups
861 #define DTAPI_IOCONFIG_IODIR       0             // I/O direction
862 #define DTAPI_IOCONFIG_IOSTD       1             // I/O standard
863 #define DTAPI_IOCONFIG_PWRMODE     2             // Power mode
864 #define DTAPI_IOCONFIG_RFCLKSEL    3             // RF clock source selection
865 #define DTAPI_IOCONFIG_SPICLKSEL   4             // Parallel port clock source selection
866 #define DTAPI_IOCONFIG_SPIMODE     5             // Parallel port mode
867 #define DTAPI_IOCONFIG_SPISTD      6             // Parallel port I/O standard
868 #define DTAPI_IOCONFIG_TSRATESEL   7             // Transport-stream rate selection
869 
870 // I/O configuration groups - Boolean I/O
871 #define DTAPI_IOCONFIG_BW          8             // DEPRECATED, do not use
872 #define DTAPI_IOCONFIG_FAILSAFE    9             // A fail-over relay is available
873 #define DTAPI_IOCONFIG_FRACMODE    10            // Fractional mode is supported
874 #define DTAPI_IOCONFIG_GENLOCKED   11            // Locked to a genlock reference
875 #define DTAPI_IOCONFIG_GENREF      12            // Genlock reference input
876 #define DTAPI_IOCONFIG_SWS2APSK    13            // DVB-S2 APSK mode
877 
878 // Values for boolean I/O configuration options
879 #define DTAPI_IOCONFIG_TRUE        14            // Turn I/O capability on
880 #define DTAPI_IOCONFIG_FALSE       15            // Turn I/O capability off
881 
882 // Values for group IO_CONFIG_IODIR (I/O direction)
883 #define DTAPI_IOCONFIG_DISABLED    16            // Port is disabled
884 #define DTAPI_IOCONFIG_INPUT       17            // Uni-directional input
885 #define DTAPI_IOCONFIG_INTINPUT    18            // Internal input port
886 #define DTAPI_IOCONFIG_MONITOR     19            // Monitor of input or output
887 #define DTAPI_IOCONFIG_OUTPUT      20            // Uni-directional output
888 
889 // SubValues for group DTAPI_IOCONFIG_IODIR, value DTAPI_IOCONFIG_INPUT
890 #define DTAPI_IOCONFIG_SHAREDANT   21            // Get antenna signal from another port
891 
892 // SubValues for group DTAPI_IOCONFIG_IODIR, value DTAPI_IOCONFIG_OUTPUT
893 #define DTAPI_IOCONFIG_DBLBUF      22            // Double buffered output
894 #define DTAPI_IOCONFIG_LOOPS2L3    23            // Loop-through of DVB-S2 in L3-frames
895 #define DTAPI_IOCONFIG_LOOPS2TS    24            // Loop-through of an DVB-S(2) input
896 #define DTAPI_IOCONFIG_LOOPTHR     25            // Loop-through of another input
897 
898 // Values for group IO_CONFIG_IOSTD (I/O standard)
899 #define DTAPI_IOCONFIG_12GSDI      26            // 12G-SDI
900 #define DTAPI_IOCONFIG_3GSDI       27            // 3G-SDI
901 #define DTAPI_IOCONFIG_6GSDI       28            // 6G-SDI
902 #define DTAPI_IOCONFIG_ASI         29            // DVB-ASI transport stream
903 #define DTAPI_IOCONFIG_AVENC       30            // Audio/video encoder
904 #define DTAPI_IOCONFIG_DEMOD       31            // Demodulation
905 #define DTAPI_IOCONFIG_GPSTIME     32            // 1PPS and 10MHz GPS-clock input
906 #define DTAPI_IOCONFIG_HDMI        33            // HDMI
907 #define DTAPI_IOCONFIG_HDSDI       34            // HD-SDI
908 #define DTAPI_IOCONFIG_IFADC       35            // IF A/D converter
909 #define DTAPI_IOCONFIG_IP          36            // Transport stream over IP
910 #define DTAPI_IOCONFIG_MOD         37            // Modulator output
911 #define DTAPI_IOCONFIG_PHASENOISE  38            // Phase noise injection
912 #define DTAPI_IOCONFIG_RS422       39            // RS422 port
913 #define DTAPI_IOCONFIG_SDIRX       40            // SDI receiver
914 #define DTAPI_IOCONFIG_SDI         41            // SD-SDI
915 #define DTAPI_IOCONFIG_SPI         42            // DVB-SPI transport stream
916 #define DTAPI_IOCONFIG_SPISDI      43            // SD-SDI on a parallel port
917 
918 // SubValues for group DTAPI_IOCONFIG_IOSTD, value DTAPI_IOCONFIG_12GSDI
919 #define DTAPI_IOCONFIG_2160P50     44            // 2160p/50 lvl A
920 #define DTAPI_IOCONFIG_2160P50B    45            // 2160p/50 lvl B
921 #define DTAPI_IOCONFIG_2160P59_94  46            // 2160p/59.94 lvl A
922 #define DTAPI_IOCONFIG_2160P59_94B 47            // 2160p/59.94 lvl B
923 #define DTAPI_IOCONFIG_2160P60     48            // 2160p/60 lvl A
924 #define DTAPI_IOCONFIG_2160P60B    49            // 2160p/60 lvl B
925 
926 // SubValues for group DTAPI_IOCONFIG_IOSTD, value DTAPI_IOCONFIG_3GSDI
927 #define DTAPI_IOCONFIG_1080P50     50            // 1080p/50 lvl A
928 #define DTAPI_IOCONFIG_1080P50B    51            // 1080p/50 lvl B
929 #define DTAPI_IOCONFIG_1080P59_94  52            // 1080p/59.94 lvl A
930 #define DTAPI_IOCONFIG_1080P59_94B 53            // 1080p/59.94 lvl B
931 #define DTAPI_IOCONFIG_1080P60     54            // 1080p/60 lvl A
932 #define DTAPI_IOCONFIG_1080P60B    55            // 1080p/60 lvl B
933 
934 // SubValues for group DTAPI_IOCONFIG_IOSTD, value DTAPI_IOCONFIG_6GSDI
935 #define DTAPI_IOCONFIG_2160P23_98  56            // 2160p/23.98
936 #define DTAPI_IOCONFIG_2160P24     57            // 2160p/24
937 #define DTAPI_IOCONFIG_2160P25     58            // 2160p/25
938 #define DTAPI_IOCONFIG_2160P29_97  59            // 2160p/29.97
939 #define DTAPI_IOCONFIG_2160P30     60            // 2160p/30
940 
941 // SubValues for group DTAPI_IOCONFIG_IOSTD, value DTAPI_IOCONFIG_HDSDI
942 #define DTAPI_IOCONFIG_1080I50     61            // 1080i/50
943 #define DTAPI_IOCONFIG_1080I59_94  62            // 1080i/59.94
944 #define DTAPI_IOCONFIG_1080I60     63            // 1080i/60
945 #define DTAPI_IOCONFIG_1080P23_98  64            // 1080p/23.98
946 #define DTAPI_IOCONFIG_1080P24     65            // 1080p/24
947 #define DTAPI_IOCONFIG_1080P25     66            // 1080p/25
948 #define DTAPI_IOCONFIG_1080P29_97  67            // 1080p/29.97
949 #define DTAPI_IOCONFIG_1080P30     68            // 1080p/30
950 #define DTAPI_IOCONFIG_1080PSF23_98 69           // 1080psf/23.98
951 #define DTAPI_IOCONFIG_1080PSF24   70            // 1080psf/24
952 #define DTAPI_IOCONFIG_1080PSF25   71            // 1080psf/25
953 #define DTAPI_IOCONFIG_1080PSF29_97 72           // 1080psf/29.97
954 #define DTAPI_IOCONFIG_1080PSF30   73            // 1080psf/30
955 #define DTAPI_IOCONFIG_720P23_98   74            // 720p/23.98
956 #define DTAPI_IOCONFIG_720P24      75            // 720p/24
957 #define DTAPI_IOCONFIG_720P25      76            // 720p/25
958 #define DTAPI_IOCONFIG_720P29_97   77            // 720p/29.97
959 #define DTAPI_IOCONFIG_720P30      78            // 720p/30
960 #define DTAPI_IOCONFIG_720P50      79            // 720p/50
961 #define DTAPI_IOCONFIG_720P59_94   80            // 720p/59.94
962 #define DTAPI_IOCONFIG_720P60      81            // 720p/60
963 
964 // SubValues for group DTAPI_IOCONFIG_IOSTD, value DTAPI_IOCONFIG_SDI
965 #define DTAPI_IOCONFIG_525I59_94   82            // 525i/59.94
966 #define DTAPI_IOCONFIG_625I50      83            // 625i/50
967 
968 // SubValues for group DTAPI_IOCONFIG_IOSTD, value DTAPI_IOCONFIG_SPISDI
969 #define DTAPI_IOCONFIG_SPI525I59_94 84           // SPI 525i/59.94
970 #define DTAPI_IOCONFIG_SPI625I50   85            // SPI 625i/50
971 
972 // Values for group IO_CONFIG_PWRMODE (Power mode)
973 #define DTAPI_IOCONFIG_MODHQ       86            // High-quality modulation
974 #define DTAPI_IOCONFIG_LOWPWR      87            // Low-power mode
975 
976 // Values for group IO_CONFIG_RFCLKSEL (RF clock source selection)
977 #define DTAPI_IOCONFIG_RFCLKEXT    88            // External RF clock input
978 #define DTAPI_IOCONFIG_RFCLKINT    89            // Internal RF clock reference
979 
980 // Values for group IO_CONFIG_SPICLKSEL (Parallel port clock source selection)
981 #define DTAPI_IOCONFIG_SPICLKEXT   90            // External clock input
982 #define DTAPI_IOCONFIG_SPICLKINT   91            // Internal clock reference
983 
984 // Values for group IO_CONFIG_SPIMODE (Parallel port mode)
985 #define DTAPI_IOCONFIG_SPIFIXEDCLK 92            // SPI fixed clock with valid signal
986 #define DTAPI_IOCONFIG_SPIDVBMODE  93            // SPI DVB mode
987 #define DTAPI_IOCONFIG_SPISER8B    94            // SPI serial 8-bit mode
988 #define DTAPI_IOCONFIG_SPISER10B   95            // SPI serial 10-bit mode
989 
990 // Values for group IO_CONFIG_SPISTD (Parallel port I/O standard)
991 #define DTAPI_IOCONFIG_SPILVDS1    96            // LVDS1
992 #define DTAPI_IOCONFIG_SPILVDS2    97            // LVDS2
993 #define DTAPI_IOCONFIG_SPILVTTL    98            // LVTTL
994 
995 // Values for group IO_CONFIG_TSRATESEL (Transport-stream rate selection)
996 #define DTAPI_IOCONFIG_EXTTSRATE   99            // External TS rate clock input
997 #define DTAPI_IOCONFIG_EXTRATIO    100           // External TS rate clock with ratio
998 #define DTAPI_IOCONFIG_INTTSRATE   101           // Internal TS rate clock reference
999 #define DTAPI_IOCONFIG_LOCK2INP    102           // Lock TS rate to input port
1000 
1001 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIqData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1002 //
1003 // Structure representing an I/Q data sample
1004 //
1005 struct DtIqData
1006 {
1007     int  m_I, m_Q;                  // I/Q sample pair
1008 };
1009 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIqDirectPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
1010 //
1011 // Direct-IQ Modulation Parameters
1012 //
1013 struct DtIqDirectPars
1014 {
1015     DtFractionInt  m_SampleRate;    // Sample rate
1016     int  m_IqPacking;               // IQ-Packing;  None, Auto, 10- or 12-bit packing
1017     int  m_ChanFilter;              // Channel filter
1018     int  m_Interpolation;           // Interpolation method
1019 
1020 
1021 public:
1022     DTAPI_RESULT  CheckValidity(void);
1023 };
1024 
1025 
1026 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIsdbsLayerPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1027 //
1028 // DtIsdbsLayerPars
1029 //
1030 struct DtIsdbsLayerPars
1031 {
1032     int  m_NumSlots;                // Number of slots
1033     int  m_ModCod;                  // Modulation method and Code rate
1034 };
1035 
1036 // Number of slots per ISDB-S frame
1037 #define DTAPI_ISDBS_SLOTS_PER_FRAME 48
1038 
1039 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIsdbsPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
1040 //
1041 // ISDB-S parameters including per-layer parameters
1042 //
1043 struct DtIsdbsPars
1044 {
DtIsdbsParsDtIsdbsPars1045     DtIsdbsPars() : m_DoMux(false), m_B15Mode(false) {}
1046 
1047     bool  m_DoMux;                  // Hierarchical multiplexing yes/no
1048 
1049     // Parameters for when m_DoMux==false
1050     bool  m_B15Mode;                // ARIB B.15 mode (true) or TMCC in sync bytes (false)
1051 
1052     // Parameters for when m_DoMux==true
1053     int   m_Emergency;              // Switch-on control for emergency broadcast
1054     int   m_RelTs2TsId[8];          // Relative TS to TS-ID mapping
1055     // Slot to relative TS mapping
1056     int   m_Slot2RelTs[DTAPI_ISDBS_SLOTS_PER_FRAME];
1057     // Modulation parameters per hierarchical layer
1058     DtIsdbsLayerPars  m_LayerPars[4];
1059 
1060     DTAPI_RESULT  CheckValidity(void);
1061     void  Init(void);
1062     bool  operator == (DtIsdbsPars& Rhs);
1063     bool  operator != (DtIsdbsPars& Rhs);
1064 };
1065 
1066 // ISDB-S modulation method and code rate
1067 #define DTAPI_ISDBS_MODCOD_BPSK_1_2 1
1068 #define DTAPI_ISDBS_MODCOD_QPSK_1_2 2
1069 #define DTAPI_ISDBS_MODCOD_QPSK_2_3 3
1070 #define DTAPI_ISDBS_MODCOD_QPSK_3_4 4
1071 #define DTAPI_ISDBS_MODCOD_QPSK_5_6 5
1072 #define DTAPI_ISDBS_MODCOD_QPSK_7_8 6
1073 #define DTAPI_ISDBS_MODCOD_8PSK_2_3 7
1074 #define DTAPI_ISDBS_MODCOD_NOT_ALLOC 15
1075 
1076 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIsdbS3Pars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1077 //
1078 // ISDB-S3 parameters
1079 //
1080 struct DtIsdbS3Pars
1081 {
DtIsdbS3ParsDtIsdbS3Pars1082     DtIsdbS3Pars() : m_SymRate(33756100){}
1083     int  m_SymRate;                 // Symbol rate in baud
1084 
1085     DTAPI_RESULT  CheckValidity(void);
1086     bool  operator == (DtIsdbS3Pars& Rhs);
1087     bool  operator != (DtIsdbS3Pars& Rhs);
1088 };
1089 
1090 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIsdbtLayerData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1091 //
1092 // Parameters per hierarchical ISDB-T layer used for statistic: DTAPI_STAT_ISDBT_PARSDATA
1093 //
1094 struct DtIsdbtLayerData
1095 {
1096     int  m_NumSegments;             // Number of segments
1097     int  m_Modulation;              // Modulation type
1098     int  m_CodeRate;                // Code rate
1099     int  m_TimeInterleave;          // Time interleaving 0..4 (new spec limits the
1100                                     // maximum value to 3 instead of 4).
1101                                     // Time interleaving I = 0 if ti = 0 or
1102                                     // I = (1 << (ti + 2 - mode)) if ti != 0
1103     DtIsdbtLayerData();
1104 
1105     // Serialisation
1106     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
1107     DTAPI_RESULT  ToXml(std::wstring& XmlString);
1108 };
1109 
1110 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIsdbtLayerPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1111 //
1112 // Parameters per hierarchical ISDB-T layer
1113 //
1114 struct DtIsdbtLayerPars
1115 {
1116     int  m_NumSegments;             // Number of segments
1117     int  m_Modulation;              // Modulation type
1118     int  m_CodeRate;                // Code rate
1119     int  m_TimeInterleave;          // Time interleaving
1120     // Derived:
1121     int  m_BitRate;                 // Bits per second assuming 6 MHz channel
1122 };
1123 
1124 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIsdbtParamsData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
1125 //
1126 // ISDB-T parameters including per-layer parameters used for statistic:
1127 // DTAPI_STAT_ISDBT_PARSDATA
1128 //
1129 struct DtIsdbtParamsData
1130 {
1131     int  m_BType;                   // Broadcast type
1132     int  m_Mode;                    // Transmission mode: 1, 2 or 3
1133     int  m_Guard;                   // Guard interval
1134     int  m_PartialRx;               // Use first layer for partial reception.
1135                                     // Ignored for radio broadcasts
1136     // Layer-A/B/C parameters
1137     DtIsdbtLayerData  m_LayerPars[3];
1138 
1139     DtIsdbtParamsData();
1140 
1141     // Serialisation
1142     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
1143     DTAPI_RESULT  ToXml(std::wstring& XmlString);
1144 };
1145 
1146 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIsdbtPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
1147 //
1148 // ISDB-T parameters including per-layer parameters
1149 //
1150 struct DtIsdbtPars
1151 {
1152     bool  m_DoMux;                  // Hierarchical multiplexing yes/no
1153     bool  m_FilledOut;              // Members have been given a value
1154     int  m_ParXtra0;                // #Segments, bandwidth, sample rate, sub channel
1155     int  m_BType;                   // Broadcast type
1156     int  m_Mode;                    // Transmission mode
1157     int  m_Guard;                   // Guard interval
1158     int  m_PartialRx;               // Partal reception
1159     int  m_Emergency;               // Switch-on control for emergency broadcast
1160     int  m_IipPid;                  // PID used for multiplexing IIP packet
1161     int  m_LayerOther;              // Other PIDs are mapped to this layer
1162     int  m_Virtual13Segm;           // Virtual 13-segment mode
1163 
1164     // Layer-A/B/C parameters
1165     DtIsdbtLayerPars  m_LayerPars[3];
1166 
1167     // PID-to-layer mapping
1168     std::map<int, int>  m_Pid2Layer;
1169 
1170     // Derived:
1171     bool  m_Valid;                  // The parameter set is valid
1172     int  m_TotalBitrate;            // Bitrate of entire stream
1173 
1174     // Member function
1175     DtIsdbtPars();
1176     static bool  BTypeCompat(int BType, int NumSegm);
1177     DTAPI_RESULT  CheckValidity(int& ResultCode);
1178     DTAPI_RESULT  ComputeRates(void);
1179     void  MakeConsistent();
1180     void  MakeNumSegmConsistent();
1181     int  NumSegm();
1182     DTAPI_RESULT  RetrieveParsFromTs(char* pBuffer, int NumBytes);
1183     bool  operator == (DtIsdbtPars& Rhs);
1184     bool  operator != (DtIsdbtPars& Rhs);
1185 };
1186 
1187 
1188 // ISDB-T layer selection used for demodulation
1189 #define DTAPI_ISDBT_LAYER_NONE     -1
1190 #define DTAPI_ISDBT_LAYER_AUTO     -2
1191 
1192 // PID-to-layer mapping
1193 #define DTAPI_ISDBT_LAYER_A         1
1194 #define DTAPI_ISDBT_LAYER_B         2
1195 #define DTAPI_ISDBT_LAYER_C         4
1196 
1197 // DtIsdbtPars.m_BType - Broadcast type
1198 #define DTAPI_ISDBT_BTYPE_TV        0            // 1/3/13-segment TV broadcast
1199 #define DTAPI_ISDBT_BTYPE_RAD1      1            // 1-segment radio broadcast
1200 #define DTAPI_ISDBT_BTYPE_RAD3      2            // 3-segment radio broadcast
1201 
1202 // DtIsdbtPars.m_Guard - Guard interval
1203 #define DTAPI_ISDBT_GUARD_1_32      0
1204 #define DTAPI_ISDBT_GUARD_1_16      1
1205 #define DTAPI_ISDBT_GUARD_1_8       2
1206 #define DTAPI_ISDBT_GUARD_1_4       3
1207 
1208 // DtIsdbtLayerPars.m_Modulation - Modulation type
1209 #define DTAPI_ISDBT_MOD_DQPSK       0
1210 #define DTAPI_ISDBT_MOD_QPSK        1
1211 #define DTAPI_ISDBT_MOD_QAM16       2
1212 #define DTAPI_ISDBT_MOD_QAM64       3
1213 
1214 // DtIsdbtLayerPars.m_CodeRate - Code rate
1215 #define DTAPI_ISDBT_RATE_1_2        0
1216 #define DTAPI_ISDBT_RATE_2_3        1
1217 #define DTAPI_ISDBT_RATE_3_4        2
1218 #define DTAPI_ISDBT_RATE_5_6        3
1219 #define DTAPI_ISDBT_RATE_7_8        4
1220 
1221 // DtOutpChannel::SetModControl - Initial Total Number of Segments
1222 #define DTAPI_ISDBT_SEGM_1          0x00000001
1223 #define DTAPI_ISDBT_SEGM_3          0x00000003
1224 #define DTAPI_ISDBT_SEGM_13         0x0000000D
1225 #define DTAPI_ISDBT_SEGM_MSK        0x0000000F
1226 
1227 // DtOutpChannel::SetModControl - Bandwidth
1228 #define DTAPI_ISDBT_BW_5MHZ         0x00000010
1229 #define DTAPI_ISDBT_BW_6MHZ         0x00000020
1230 #define DTAPI_ISDBT_BW_7MHZ         0x00000030
1231 #define DTAPI_ISDBT_BW_8MHZ         0x00000040
1232 #define DTAPI_ISDBT_BW_MSK          0x000000F0
1233 
1234 // DtOutpChannel::SetModControl - Sample Rate
1235 #define DTAPI_ISDBT_SRATE_1_1       0x00000100
1236 #define DTAPI_ISDBT_SRATE_1_2       0x00000200
1237 #define DTAPI_ISDBT_SRATE_1_4       0x00000300
1238 #define DTAPI_ISDBT_SRATE_1_8       0x00000400
1239 #define DTAPI_ISDBT_SRATE_27_32     0x00000500
1240 #define DTAPI_ISDBT_SRATE_135_64    0x00000600
1241 #define DTAPI_ISDBT_SRATE_MSK       0x00000F00
1242 
1243 // DtOutpChannel::SetModControl - Sub Channel
1244 #define DTAPI_ISDBT_SUBCH_MSK       0x0003F000
1245 #define DTAPI_ISDBT_SUBCH_SHIFT     12
1246 
1247 // Result codes for DtIsdbtPars::CheckValidity
1248 #define DTAPI_ISDBT_OK              0
1249 #define DTAPI_ISDBT_E_BTYPE         1
1250 #define DTAPI_ISDBT_E_NSEGM         2
1251 #define DTAPI_ISDBT_E_PARTIAL       3
1252 #define DTAPI_ISDBT_E_NOT_FILLED    4
1253 #define DTAPI_ISDBT_E_SUBCHANNEL    5
1254 #define DTAPI_ISDBT_E_SRATE         6
1255 #define DTAPI_ISDBT_E_BANDWIDTH     7
1256 #define DTAPI_ISDBT_E_MODE          8
1257 #define DTAPI_ISDBT_E_GUARD         9
1258 
1259 
1260 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtMatrixInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1261 //
1262 struct  DtMatrixInfo
1263 {
1264     int  m_VidStd;                  // Video standard
1265     int  m_Scaling;                 // Scaled frame format
1266     int  m_NumColumns;              // Number of columns
1267 };
1268 
1269 // Maximum number of fading paths, used in DtModPars
1270 #define DTAPI_MAX_OUTPUTS           16
1271 
1272 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtModPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1273 //
1274 // Structure for storing a complete set of modulation parameters.
1275 //
1276 // NOTE FOR ISDB-T: DtModPars.m_ParXtra0 is never used, all ISDB-T parameters are stored
1277 // in DtIsdbtPars (in *m_pXtraPars).
1278 //
1279 struct DtModPars
1280 {
1281     // Modulation parameters
1282     int  m_ModType;                 // Modulation type; -1 = not set
1283     int  m_ParXtra0;                // ParXtra0 (Code Rate / J.83 Annex); -1 = not set
1284     int  m_ParXtra1;                // ParXtra1; -1 = not set
1285     int  m_ParXtra2;                // ParXtra2; -1 = not set
1286     void*  m_pXtraPars;             // Extra CMMB/ISDB-S/ISDB-T/DVB-C2/DVB-T2 parameters
1287 
1288     // Single Frequency Network parameters
1289     int  m_SfnMode;                 // SFN-operation mode DTAPI_SFN_MODE_XXXX
1290     int  m_SfnTimeOffset;           // SFN time offset in nano seconds
1291     int  m_SfnAllowedTimeDiff;      // Maximum allowed time difference in nano-seconds
1292 
1293     // Rates; Set to -1 (not set) by SetModControl, except for symbol rate which is set
1294     // to a default value for modulation types that support a symbol rate.
1295     // If both symbol and TS rate are set, TS rate takes precedence.
1296     int  m_SymRate;                 // Symbol rate in baud
1297     DtFractionInt  m_TsRate;        // Transport-stream rate in bps
1298 
1299     // Channel modelling per output channel
1300     bool  m_IsCmEnable[DTAPI_MAX_OUTPUTS];
1301                                     // Channel modelling is enabled yes/no
1302     DtCmPars  m_CmPars[DTAPI_MAX_OUTPUTS];
1303                                     // Channel modelling parameters
1304 
1305     bool  m_IsChanAttenEnable;      // Channel attenuation is enable yes/no
1306     double m_ChanAtten;             // Channel attenuation
1307 
1308     // Custom roll-off roll
1309     bool  m_IsRoEnable;             // Custom roll-off filter enable yes/no
1310     DtFilterPars  m_RollOffFilter;  // Custom roll-off filter parameters
1311 
1312     // Miscellaneous
1313     int  m_OutputLevel;             // Output level; -9999 = not set
1314     double  m_RfFreqHz;             // RF frequency in Hz
1315     unsigned char  m_S2PlHdrScrSeq[12];
1316                                     // DVB-S2 PL header scrambling sequence
1317     DtDvbCidPars  m_DvbCidPars;     // DVB carrier identification for satellite
1318     int  m_TxMode;                  // Transmit mode; Included here because packet
1319                                     // size affects the modulation process
1320     int  m_StuffMode;               // Stuffing mode
1321 
1322     // Operations
1323     DTAPI_RESULT  CheckPars();
1324     DTAPI_RESULT  SetModControl(int ModType, int, int, int, void* pXtraPars);
1325 
1326     // Member functions
pAtsc3ParsDtModPars1327     DtAtsc3Pars*  pAtsc3Pars()    { return (DtAtsc3Pars*)m_pXtraPars; }
pCmmbParsDtModPars1328     DtCmmbPars*  pCmmbPars()    { return (DtCmmbPars*)m_pXtraPars; }
pDvbC2ParsDtModPars1329     DtDvbC2Pars*  pDvbC2Pars()  { return (DtDvbC2Pars*)m_pXtraPars; }
pDvbS2ParsDtModPars1330     DtDvbS2Pars*  pDvbS2Pars()  { return (DtDvbS2Pars*)m_pXtraPars; }
pDvbT2ParsDtModPars1331     DtDvbT2Pars*  pDvbT2Pars()  { return (DtDvbT2Pars*)m_pXtraPars; }
pIqDirectParsDtModPars1332     DtIqDirectPars*  pIqDirectPars()  { return (DtIqDirectPars*)m_pXtraPars; }
pIsdbsParsDtModPars1333     DtIsdbsPars*  pIsdbsPars()  { return (DtIsdbsPars*)m_pXtraPars; }
pIsdbS3ParsDtModPars1334     DtIsdbS3Pars*  pIsdbS3Pars()  { return (DtIsdbS3Pars*)m_pXtraPars; }
pIsdbtParsDtModPars1335     DtIsdbtPars*  pIsdbtPars()  { return (DtIsdbtPars*)m_pXtraPars; }
pIsdbTmmParsDtModPars1336     DtIsdbTmmPars*  pIsdbTmmPars()  { return (DtIsdbTmmPars*)m_pXtraPars; }
1337 
1338     // Predicates
1339     bool  HasSymRate();
1340     bool  IsAdtbT(), IsAdtbtDtmb(), IsAtsc(), IsAtsc3(), IsAtscMh(), IsCmmb();
1341     bool  IsChanAttenEnable(), IsCmEnable(int i=0);
1342     bool  IsDab(), IsDtmb(), IsDvbC2(), IsDvbCidEnable(), IsDvbS(), IsDvbS2();
1343     bool  IsDvbS2Apsk(), IsDvbS2L3(), IsDvbS2X(), IsDvbS2XL3(), IsDvbS2Mux();
1344     bool  IsDvbT(), IsDvbT2(), IsIqDirect(), IsIsdbS(), IsIsdbS3(), IsIsdbT(), IsIsdbTmm();
1345     bool  IsModTypeSet(), IsOfdm(), IsQam(), IsQamA(), IsQamB(), IsQamC(), IsQamAC();
1346     bool  IsRoEnable(), IsSfnEnable(), IsT2Mi();
1347     bool  RequiresMplpMod();
1348 
1349     // Constructor, destructor
1350     DtModPars();
1351     ~DtModPars();
1352 private:
1353     // No implementation is provided for the copy constructor
1354     DtModPars(const DtModPars&);
1355 
1356 private:
1357     void  CleanUpXtraPars();
1358 };
1359 
1360 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtPar .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1361 //
1362 // Generic structure to represent a single parameter setting.
1363 // It is used in the advanced demodulator for setting and retrieving parameter settings.
1364 //
1365 struct DtPar
1366 {
1367     DtPar();
1368     DtPar(int ParId);               // Constructor with DTAPI_PAR_xxx initialization
1369     virtual ~DtPar();
1370 
1371     // Value types supported for parameters
1372     enum ParValueType
1373     {
1374         PAR_VT_UNDEFINED, PAR_VT_BOOL, PAR_VT_DOUBLE, PAR_VT_INT
1375     };
1376 
1377     DTAPI_RESULT  m_Result;         // Result of retrieving the parameters
1378     int  m_ParId;                   // Identifies the parameter: DTAPI_PAR_XXX
1379     int  m_IdXtra[4];               // Extra identification parameters
1380     ParValueType  m_ValueType;      // Value type of parameter: PAR_VT_XXX
1381     union {
1382         bool  m_ValueBool;          // Value if value type is PAR_VT_BOOL
1383         double  m_ValueDouble;      // Value if value type is PAR_VT_DOUBLE
1384         int  m_ValueInt;            // Value if value type is PAR_VT_INT
1385         void* m_pValue;             // Pointer for complex types
1386     };
1387     void  Cleanup();
1388     DTAPI_RESULT  GetName(const char*& pName, const char*& pShortName);
1389     DTAPI_RESULT  GetName(const wchar_t*& pName, const wchar_t*& pShortName);
1390     DTAPI_RESULT  GetValue(int &Value);
1391     DTAPI_RESULT  GetValue(double &Value);
1392     DTAPI_RESULT  GetValue(bool &Value);
1393     DTAPI_RESULT  SetId(int ParameterId);
1394     DTAPI_RESULT  SetValue(int Value);
1395     DTAPI_RESULT  SetValue(double Value);
1396     DTAPI_RESULT  SetValue(bool Value);
1397 
1398     // Serialisation
1399     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
1400     DTAPI_RESULT  ToXml(std::wstring& XmlString);
1401 
1402     // Serialisation of an array of parameters
1403     static DTAPI_RESULT  FromXml(const std::wstring&, DtPar*& pPars, int& Count);
1404     static DTAPI_RESULT  ToXml(DtPar* pPars, int Count, std::wstring& XmlString);
1405 
1406     // Assignment operator
1407     DtPar&  operator = (const DtPar&);
1408 
1409 private:
1410     // No implementation is provided for the copy constructor
1411     DtPar(const DtPar&);
1412 };
1413 
1414 // Integer parameters
1415 #define DTAPI_PAR_DEMOD_THREADS     0x001        // Number of Threads/CPU cores used for
1416                                                  // software demodulation: default 4
1417 #define DTAPI_PAR_DEMOD_LDPC_MAX    0x002        // LDPC maximum iterations: default 50
1418 #define DTAPI_PAR_DEMOD_LDPC_AVG    0x003        // LDPC average iterations limit, used
1419                                                  // to limit CPU load; default 16
1420 // Boolean parameters
1421 #define DTAPI_PAR_DEMOD_MER_ENA     0x004        // Enable MER calculation; default on
1422 // Undefined parameter
1423 #define DTAPI_PAR_UNDEFINED         0x000        // Value is not defined yet
1424 
1425 // Unsported item values
1426 #define DTAPI_PAR_UNSUP_INTITEM     0x80000000   // Unsupported integer item
1427 #define DTAPI_PAR_UNSUP_UINTITEM    0xFFFFFFFF   // Unsupported unsigned integer item
1428 
1429 
1430 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtPhaseNoisePars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1431 //
1432 // Structure for specifying the phase noise parameters
1433 //
1434 struct DtPhaseNoisePars
1435 {
1436     DtFractionInt  m_SampleRate;
1437 };
1438 
1439 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtRawIpHeader -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1440 //
1441 // Header placed in front of all IP Packets when DTAPI_RXMODE_IPRAW mode is used
1442 //
1443 struct DtRawIpHeader
1444 {
1445     unsigned short  m_Tag;          // 0x44A0h = \91D\92160
1446     unsigned short  m_Length;       // IP packet length
1447     unsigned int  m_TimeStamp;      // IP packet arrival/transmit timestamp
1448 };
1449 
1450 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtSdiIpFrameStat -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1451 //
1452 // Header placed in front of all SDI frames when the option DTAPI_RXMODE_SDI_STAT is used
1453 // with SDI over IP
1454 //
1455 struct DtSdiIpFrameStat
1456 {
1457     unsigned int  m_FrameCount;     // SDI frame counter
1458     unsigned int  m_Timestamp;      // RTP timestamp first IP packet this frame
1459     unsigned int  m_MinIpat;        // Min. IPAT of all IP packets this frame
1460     unsigned int  m_MaxIpat;        // Max. IPAT of all IP packets this frame
1461     __int64  m_Reserved1;
1462     __int64  m_Reserved2;
1463 };
1464 
1465 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtStatistic -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
1466 //
1467 struct DtStatistic
1468 {
1469     DtStatistic();
1470     DtStatistic(int StatisticId);   // Constructor with DTAPI_STAT_xxx initialization
1471     virtual ~DtStatistic();
1472 
1473     // Value types supported for statistics
1474     // NOTE: ALWAYS ADD NEW TYPES TO END OF LIST, FOR BACKWARDS COMPATIBILITY
1475     enum StatValueType
1476     {
1477         STAT_VT_UNDEFINED, STAT_VT_BOOL, STAT_VT_DOUBLE, STAT_VT_INT,
1478         STAT_VT_DVBC2_L1P2, STAT_VT_DVBC2_PLPSIG, STAT_VT_DVBT2_L1,
1479         STAT_VT_ISDBT_PARS, STAT_VT_LDPC_STATS, STAT_VT_MA_DATA,
1480         STAT_VT_MA_STATS, STAT_VT_PLP_BLOCKS, STAT_VT_VIT_STATS,
1481         STAT_VT_DAB_ENSEM, STAT_VT_RS_STATS, STAT_VT_DVBT_TPS, STAT_VT_DAB_TXID,
1482         STAT_VT_ATSC3_L1, STAT_VT_DVBT2_TXID, STAT_VT_ATSC3_TXID
1483     };
1484 
1485 
1486     DTAPI_RESULT  m_Result;         // Result of retrieving the statistic
1487     int  m_StatisticId;             // Identifies the statistic: DTAPI_STAT_XXX
1488     int  m_IdXtra[4];               // Extra identification parameters
1489     StatValueType  m_ValueType;     // Value type of statistic: STAT_VT_XXX
1490     union {
1491         bool  m_ValueBool;          // Value if value type is STAT_VT_BOOL
1492         double  m_ValueDouble;      // Value if value type is STAT_VT_DOUBLE
1493         int  m_ValueInt;            // Value if value type is STAT_VT_INT
1494         void*  m_pValue;            // Pointer if value type is STAT_VT_DVBC2_L1P2,
1495                                     // STAT_VT_DVBC2_PLPSIG, STAT_VT_DVBT_TPS,
1496                                     // STAT_VT_DVBT2_L1, STAT_VT_VIT_STATS
1497                                     // STAT_VT_DAB_ENSEM, STAT_VT_RS_STATS,
1498                                     // STAT_VT_DAB_TXID, STAT_VT_ATSC3_L1,
1499                                     // STAT_VT_DVBT2_TXID, STAT_VT_ATSC3_TXID
1500     };
1501     void  Cleanup();
1502     DTAPI_RESULT  GetName(const char*& pName, const char*& pShortName);
1503     DTAPI_RESULT  GetName(const wchar_t*& pName, const wchar_t*& pShortName);
1504     DTAPI_RESULT  GetValue(int &Value);
1505     DTAPI_RESULT  GetValue(double &Value);
1506     DTAPI_RESULT  GetValue(bool &Value);
1507     DTAPI_RESULT  GetValue(DtAtsc3DemodL1Data*& pValue);
1508     DTAPI_RESULT  GetValue(DtAtsc3TxIdInfo*& pValue);
1509     DTAPI_RESULT  GetValue(DtDabEnsembleInfo*& pValue);
1510     DTAPI_RESULT  GetValue(DtDabTransmitterIdInfo*& pValue);
1511     DTAPI_RESULT  GetValue(DtDvbC2DemodL1Part2Data*& pValue);
1512     DTAPI_RESULT  GetValue(DtDvbC2DemodL1PlpSigData*& pValue);
1513     DTAPI_RESULT  GetValue(DtDvbTTpsInfo*& pValue);
1514     DTAPI_RESULT  GetValue(DtDvbT2DemodL1Data*& pValue);
1515     DTAPI_RESULT  GetValue(DtDvbT2TransmitterIdInfo*& pValue);
1516     DTAPI_RESULT  GetValue(DtDemodLdpcStats*& pValue);
1517     DTAPI_RESULT  GetValue(DtDemodMaLayerData*& pValue);
1518     DTAPI_RESULT  GetValue(DtDemodMaLayerStats*& pValue);
1519     DTAPI_RESULT  GetValue(DtDemodPlpBlocks*& pValue);
1520     DTAPI_RESULT  GetValue(DtIsdbtParamsData*& pValue);
1521     DTAPI_RESULT  GetValue(DtRsDecStats*& pValue);
1522     DTAPI_RESULT  GetValue(DtVitDecStats*& pValue);
1523     DTAPI_RESULT  SetId(int StatisticId);
1524     DTAPI_RESULT  SetValue(int Value);
1525     DTAPI_RESULT  SetValue(double Value);
1526     DTAPI_RESULT  SetValue(bool Value);
1527     DTAPI_RESULT  SetValue(DtAtsc3DemodL1Data& pValue);
1528     DTAPI_RESULT  SetValue(DtAtsc3TxIdInfo& pValue);
1529     DTAPI_RESULT  SetValue(DtDabEnsembleInfo& pValue);
1530     DTAPI_RESULT  SetValue(DtDabTransmitterIdInfo& pValue);
1531     DTAPI_RESULT  SetValue(DtDvbC2DemodL1Part2Data& Value);
1532     DTAPI_RESULT  SetValue(DtDvbC2DemodL1PlpSigData& Value);
1533     DTAPI_RESULT  SetValue(DtDvbTTpsInfo& pValue);
1534     DTAPI_RESULT  SetValue(DtDvbT2DemodL1Data& Value);
1535     DTAPI_RESULT  SetValue(DtDvbT2TransmitterIdInfo& Value);
1536     DTAPI_RESULT  SetValue(DtDemodLdpcStats& Value);
1537     DTAPI_RESULT  SetValue(DtDemodMaLayerData& Value);
1538     DTAPI_RESULT  SetValue(DtDemodMaLayerStats& Value);
1539     DTAPI_RESULT  SetValue(DtDemodPlpBlocks& Value);
1540     DTAPI_RESULT  SetValue(DtIsdbtParamsData& Value);
1541     DTAPI_RESULT  SetValue(DtRsDecStats& pValue);
1542     DTAPI_RESULT  SetValue(DtVitDecStats& pValue);
1543 
1544     // Serialisation
1545     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
1546     DTAPI_RESULT  ToXml(std::wstring& XmlString);
1547 
1548     // Serialisation of an array of statistics
1549     static DTAPI_RESULT  FromXml(const std::wstring&, DtStatistic*&, int& Count);
1550     static DTAPI_RESULT  ToXml(DtStatistic* pStatistics, int Count, std::wstring&);
1551 
1552     // Assignment operator
1553     DtStatistic&  operator = (const DtStatistic&);
1554 
1555 private:
1556     // No implementation is given of the copy constructor
1557     DtStatistic(const DtStatistic&);
1558 };
1559 
1560 // Integer statistics
1561 #define DTAPI_STAT_ATSC3_L1B_ERR    0x01F        // Count L1-Basic error count
1562 #define DTAPI_STAT_ATSC3_L1D_ERR    0x020        // Count L1-Detail error count
1563 #define DTAPI_STAT_BADPCKCNT        0x003        // Count of uncorrected packets
1564 #define DTAPI_STAT_CNR              0x105        // Carrier-to-noise ratio in dB
1565 #define DTAPI_STAT_DVBC2_DSLICEDISC 0x010        // DVB-C2 Data slice discontinuity count
1566 #define DTAPI_STAT_DVBC2_L1HDR_ERR  0x00E        // DVB-C2 L1 Preamble header error count
1567 #define DTAPI_STAT_DVBC2_L1P2_ERR   0x00F        // DVB-C2 L1-Part 2 error count
1568 #define DTAPI_STAT_DVBT2_L1PRE_ERR  0x00C        // DVB-T2 L1-Pre error count
1569 #define DTAPI_STAT_DVBT2_L1POST_ERR 0x00D        // DVB-T2 L1-Post error count
1570 #define DTAPI_STAT_EBN0             0x111        // Eb/N0 in dB (estimated on MER)
1571 #define DTAPI_STAT_ESN0             0x110        // Es/N0 in dB (estimated on MER)
1572 #define DTAPI_STAT_LINKMARGIN       0x10F        // Link margin in dB
1573 #define DTAPI_STAT_MER              0x106        // Modulation error rate in dB
1574 #define DTAPI_STAT_MOD_SAT          0x004        // Modulator saturation count
1575 #define DTAPI_STAT_RELOCKCNT        0x00A        // Receiver re-lock count
1576 #define DTAPI_STAT_RFLVL_CHAN       0x005        // RF power level for channel bandwidth
1577 #define DTAPI_STAT_RFLVL_CHAN_QS    0x015        // Quick scan of channel level
1578 #define DTAPI_STAT_RFLVL_NARROW     0x006        // RF power level for a narrow bandwidth
1579 #define DTAPI_STAT_RFLVL_NARROW_QS  0x016        // Quick scan of channel level
1580 #define DTAPI_STAT_RS               0x008        // Reed-Solomon error counter
1581 #define DTAPI_STAT_SNR              0x107        // Signal-to-noise ratio in dB
1582 #define DTAPI_STAT_TEMP_TUNER       0x009        // Tuner temperature
1583 #define DTAPI_STAT_T2MI_OVFS        0x00B        // DVB-T2 T2-MI overflow count
1584 #define DTAPI_STAT_TEMP_ENCODER     0x017        // Encoder chip temperature
1585 #define DTAPI_STAT_VID_STATUS       0x018        // Status of video input
1586 #define DTAPI_STAT_VID_FRAMES_CAPT  0x019        // Number of video frames captured
1587 #define DTAPI_STAT_VID_FRAMES_ENC   0x01A        // Number of video frames encoded
1588 #define DTAPI_STAT_VID_BYTES_ENC    0x01B        // Number of video bytes encoded
1589 #define DTAPI_STAT_AUD_SAMPLES_ENC  0x01C        // Number of audio samples encoded
1590 #define DTAPI_STAT_AUD_FRAMES_ENC   0x01D        // Number of audio frames encoded
1591 #define DTAPI_STAT_MUX_NUM_BYTES    0x01E        // Number of bytes multiplexed
1592 
1593 // Double statistics
1594 #define DTAPI_STAT_BER_POSTBCH      0x100        // Post-BCH bit error rate
1595 #define DTAPI_STAT_BER_POSTLDPC     0x101        // Post-LDPC bit error rate
1596 #define DTAPI_STAT_BER_POSTVIT      0x102        // Post-Viterbi bit error rate
1597 #define DTAPI_STAT_BER_PREBCH       0x10D        // Pre-BCH bit error rate
1598 #define DTAPI_STAT_BER_PRELDPC      0x10E        // Pre-LDPC bit error rate
1599 #define DTAPI_STAT_BER_PRERS        0x103        // Pre-Reed-Solomon bit error rate
1600 #define DTAPI_STAT_BER_PREVIT       0x104        // Pre-Viterbi bit error rate
1601 #define DTAPI_STAT_FER_POSTBCH      0x116        // Post-BCH frame error rate
1602 #define DTAPI_STAT_FREQ_SHIFT       0x10B        // Input frequency shift (Hz)
1603 #define DTAPI_STAT_OCCUPIEDBW       0x112        // Occupied bandwidth
1604 #define DTAPI_STAT_PER              0x108        // Packet error rate
1605 #define DTAPI_STAT_ROLLOFF          0x113        // Roll-off factor in percentage
1606 #define DTAPI_STAT_SAMPRATE_OFFSET  0x10C        // Sample rate offset (ppm)
1607 
1608 // Boolean lock statistics
1609 #define DTAPI_STAT_CARRIER_LOCK     0x201        // Carrier lock
1610 #define DTAPI_STAT_FEC_LOCK         0x202        // FEC lock
1611 #define DTAPI_STAT_LOCK             0x200        // Overall lock status
1612 #define DTAPI_STAT_PACKET_LOCK      0x203        // Packet lock
1613 #define DTAPI_STAT_SPECTRUMINV      0x205        // Spectrum inversion
1614 #define DTAPI_STAT_VIT_LOCK         0x204        // Viterbi lock
1615 
1616 // Complex statistics
1617 #define DTAPI_STAT_DAB_ENSEM_INFO   0x308        // DAB ensemble information from the
1618                                                  // Fast Information Channel (FIC)
1619 #define DTAPI_STAT_ATSC3_L1DATA     0x30D        // ATSC3 Layer-1 data
1620 #define DTAPI_STAT_ATSC3_TXID_INFO  0x30F        // ATSC3 transmitter ID information
1621 #define DTAPI_STAT_DAB_TXID_INFO    0x30C        // DAB transmitter ID information
1622 #define DTAPI_STAT_DVBC2_L1P2DATA   0x300        // DVB-C2 Layer-1 Part 2 data
1623 #define DTAPI_STAT_DVBC2_PLPSIGDATA 0x301        // DVB-C2 Layer-1 PLP signalling data
1624 #define DTAPI_STAT_DVBT_TPS_INFO    0x30B        // DVB-T TPS information
1625 #define DTAPI_STAT_DVBT2_L1DATA     0x302        // DVB-T2 Layer-1 data
1626 #define DTAPI_STAT_DVBT2_TXID_INFO  0x30E        // DVB-T2 transmitter ID information
1627 #define DTAPI_STAT_ISDBT_PARSDATA   0x303        // ISDB-T parameters data
1628 #define DTAPI_STAT_LDPC_STATS       0x304        // DVB-C2/T2 LDPC statistics
1629 #define DTAPI_STAT_MA_DATA          0x305        // DVB-C2/T2 mode adaptation data
1630 #define DTAPI_STAT_MA_STATS         0x306        // DVB-C2/T2 mode adaptation statistics
1631 #define DTAPI_STAT_PLP_BLOCKS       0x307        // DVB-C2/T2 PLP number of FEC blocks
1632 #define DTAPI_STAT_RSDEC_STATS      0x30A        // Reed-Solomon decoder statistics
1633 #define DTAPI_STAT_VITDEC_STATS     0x309        // Viterbi decoder statistics
1634 
1635 // DekTec internal statistics
1636 #define DTAPI_STAT_AGC1             0x001        // First AGC value
1637 #define DTAPI_STAT_AGC2             0x002        // Second AGC value
1638 #define DTAPI_STAT_RFLVL_UNCALIB    0x007        // Uncalibrated RF power level
1639 #define DTAPI_STAT_RFLVL_UNCALIB_DBM 0x10A       // Uncalibrated RF power level in dBm
1640 #define DTAPI_STAT_SYNTAX_ERR_CNT   0x114        // Num syntax errors in usb bitstream
1641 #define DTAPI_STAT_OVERFLOW_CNT     0x115        // Number of dtapi<>kernel buf overflows
1642 
1643 // Unsupported item values
1644 #define DTAPI_STAT_UNDEFINED        0x000        // Value is not defined yet
1645 #define DTAPI_STAT_UNSUP_INTITEM    0x80000000   // Unsupported integer item
1646 #define DTAPI_STAT_UNSUP_UINTITEM   0xFFFFFFFF   // Unsupported unsigned integer item
1647 
1648 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIpQosStats -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
1649 //
1650 // Quality-of-Service related statistics for SDI/TS-over-IP channels, measured over a
1651 // certain period of time (the "time period").
1652 //
1653 // If the mode is "Seamless Protection Switching of IP Datagrams" (SMPTE 2022-7 mode),
1654 // QoS statistics are maintained for path 1, path 2, and for the reconstructed stream.
1655 // If the mode is not SMPTE 2022-7 ("single-path" mode), the QoS statistics are stored
1656 // in the members for path 1.
1657 //
1658 // This structure is contained in the DtIpStat structure, once with the statistics
1659 // measured over the last second, and once with statistics measured over the last minute.
1660 //
1661 struct DtIpQosStats
1662 {
1663     // Packet Error Rate (PER) for path 1, path 2 and for the reconstructed stream.
1664     // The PER is the number of lost IP packets per second.
1665     double  m_Per1, m_Per2, m_PerAfterFec;
1666 
1667     // Delay factor in microseconds for path 1 and path 2.
1668     // The delay factor is an indication of the jitter of the IP stream. It is defined
1669     // as the maximum difference between the actual arrival time of a UDP/RTP packet
1670     // and the ideal (jitterless) arrival time of that packet.
1671     double  m_DelayFactor1, m_DelayFactor2;
1672 
1673     // The skew is the minimal and maximal difference over the time period
1674     // (1 sec or 1 minute) in arrival time between IP packets on path 1 and on path 2.
1675     // If m_Skew is positive, path 1 has a longer delay than path 2; if m_Skew is
1676     // negative, path 2 has the longer delay.
1677     // Note: PD as defined in SMPTE 2022-7 is the absolute value of m_Skew.
1678     double  m_MinSkew;                 // Min. Skew between path 1 and path 2
1679     double  m_MaxSkew;                 // Max. Skew between path 1 and path 2
1680 
1681     //Inter Packet arrival time of Ip packet per port over time period (1 sec or 1 minute)
1682     double  m_MinIpat1, m_MinIpat2;    // Min. IPAT path1 and path2
1683     double  m_MaxIpat1, m_MaxIpat2;    // Max. IPAT path1 and path2
1684 };
1685 
1686 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. DtIpProfile -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
1687 //
1688 // Structure for describing the IP transmission "profile". It defines the maximum
1689 // bitrate and (in SMPTE 2022-7 mode only) the maximum skew between path 1 and path 2.
1690 // DtIpProfile is used to dimension buffer sizes at the receiver.
1691 //
1692 struct DtIpProfile
1693 {
1694     // m_Profile defines the maximum bitrate and the maximum path skew.
1695     // Member variables m_MaxBitrate and m_MaxSkew are used only if m_Profile is
1696     // DTAPI_IP_USER_DEFINED, otherwise m_Profile implicitly sets their values.
1697     int  m_Profile;                 // IP transmission profile
1698 
1699     // m_MaxBitrate is used for single paths and in SMPTE 2022-7 mode.
1700     unsigned int  m_MaxBitrate;     // Maximum bitrate in bps
1701 
1702     // m_MaxSkew is used only in SMPTE 2022-7 mode. It defines the maximum skew
1703     // between the two IP transmission paths.
1704     int  m_MaxSkew;                 // Maximum skew between path 1 and path 2 in ms
1705 
1706     // Set the video standard to transmit/receive.
1707     int  m_VideoStandard;           // DTAPI_VIDSTD_ defines.
1708 
1709 public:
1710     DtIpProfile&  operator = (const DtIpProfile&);
1711     bool  operator == (const DtIpProfile&) const;
1712     bool  operator != (const DtIpProfile&) const;
1713 };
1714 
1715 // IP tranmission profile (DtIpProfile::m_Profile)
1716 #define DTAPI_IP_PROF_NOT_DEFINED   0            // Not defined
1717 #define DTAPI_IP_USER_DEFINED       1            // Use m_MaxBitrate and m_MaxSkew
1718 // LBR (Low Bit Rate) profiles
1719 #define DTAPI_IP_LBR_LOW_SKEW       2            // m_MaxSkew=10ms, m_MaxBitrate=10Mbps
1720 #define DTAPI_IP_LBR_MODERATE_SKEW  3            // m_MaxSkew=50ms, m_MaxBitrate=10Mbps
1721 #define DTAPI_IP_LBR_HIGH_SKEW      4            // m_MaxSkew=450ms, m_MaxBitrate=10Mbps
1722 // SBR (Slower Bit Rate) profiles
1723 #define DTAPI_IP_SBR_LOW_SKEW       5            // m_MaxSkew=10ms, m_MaxBitrate=270Mbps
1724 #define DTAPI_IP_SBR_MODERATE_SKEW  6            // m_MaxSkew=50ms, m_MaxBitrate=270Mbps
1725 #define DTAPI_IP_SBR_HIGH_SKEW      7            // m_MaxSkew=450ms, m_MaxBitrate=270Mbps
1726 // HBR (High Bit Rate) profiles
1727 #define DTAPI_IP_HBR_LOW_SKEW       5            // m_MaxSkew=10ms, m_MaxBitrate=3Gbps
1728 #define DTAPI_IP_HBR_MODERATE_SKEW  6            // m_MaxSkew=50ms, m_MaxBitrate=3Gbps
1729 #define DTAPI_IP_HBR_HIGH_SKEW      7            // m_MaxSkew=150ms, m_MaxBitrate=3Gbps
1730 
1731 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIpPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
1732 //
1733 // Structure for storing SDI/TS-over-IP parameters
1734 //
1735 struct DtIpPars2;
1736 struct DtIpPars
1737 {
1738 public:
1739     // Primary link
1740     unsigned char  m_Ip[16];        // IP address (IPv4/IPv6)
1741     unsigned short  m_Port;         // Port number
1742     unsigned char  m_SrcFltIp[16];  // Source filter: IP address (IPv4/IPv6)
1743     unsigned short  m_SrcFltPort;   // Source filter: port number
1744     int  m_VlanId;                  // VLAN ID
1745     int  m_VlanPriority;            // VLAN priority
1746 
1747     // Redundant link (path 2 in SMPTE 2022-7 mode)
1748     unsigned char  m_Ip2[16];       // IP address (IPv4/IPv6)
1749     unsigned short  m_Port2;        // Port number
1750     unsigned char  m_SrcFltIp2[16]; // Source filter: IP address (IPv4/IPv6)
1751     unsigned short  m_SrcFltPort2;  // Source filter: port number
1752     int  m_VlanId2;                 // VLAN ID
1753     int  m_VlanPriority2;           // VLAN priority
1754 
1755     int  m_TimeToLive;              // Time-to-Live setting for IP Tx
1756     int  m_NumTpPerIp;              // Number of transport packets per IP packet
1757     int  m_Protocol;                // Protocol: DTAPI_PROTO_UDP/RTP
1758     int  m_DiffServ;                // Differentiated services
1759     int  m_FecMode;                 // Error correction mode: DTAPI_FEC_DISABLE/2D
1760     int  m_FecNumRows;              // 'D' = #rows in FEC matrix
1761     int  m_FecNumCols;              // 'L' = #columns in FEC matrix
1762 
1763     // Control and status flags: DTAPI_IP_V4, DTAPI_IP_V6, DTAPI_IP_TX_MANSRCPORT
1764     int  m_Flags;
1765 
1766     // Seamless Protection Switching of IP Datagrams (SMPTE 2022-7)
1767 
1768     // Transmission- or reception mode. It determines whether "seamless protection
1769     // switching of IP datagrams" according to SMPTE 2022-7 is applied.
1770     //  DTAPI_IP_NORMAL     Default value for non-redundant Rx or Tx.
1771     //  DTAPI_IP_TX_2022_7  Apply SMPTE 2022-7 for Tx. IP packets will be duplicated to
1772     //                      path 1 (primary link) and path 2 (redundant link)
1773     //  DTAPI_IP_RX_2022_7  Apply SMPTE 2022-7 for Rx. IP packets from path 1 and path 2
1774     //                      will be seamlessly combined into a single logical stream.
1775     int  m_Mode;
1776 
1777     // The IP transmission profile determines the maximum bitrate and the maximum skew
1778     // between transmission path 1 and path 2.
1779     DtIpProfile  m_IpProfile;
1780 public:
1781     DtIpPars();
1782     ~DtIpPars();
1783     void operator=(const DtIpPars2& IpPars);
1784     bool  operator == (const DtIpPars&) const;
1785     bool  operator != (const DtIpPars&) const;
1786 };
1787 
1788 // Legacy
1789 #define DtTsIpPars  DtIpPars
1790 
1791 typedef struct _DtIpSrcFlt
1792 {
1793 public:
1794     unsigned char  m_SrcFltIp[16];  // Source filter: IP address (IPv4/IPv6)
1795     unsigned short  m_SrcFltPort;   // Source filter: port number
1796 } DtIpSrcFlt;
1797 
1798 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIpPars2 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1799 //
1800 // Structure for storing SDI/TS-over-IP parameters
1801 //
1802 struct DtIpPars2
1803 {
1804 public:
1805     // Primary link
1806     unsigned char  m_Ip[16];        // IP address (IPv4/IPv6)
1807     unsigned short  m_Port;         // Port number
1808     unsigned char  m_Gateway[16];   // Override default gateway
1809     std::vector<DtIpSrcFlt>  m_SrcFlt;
1810                                     // Source filter
1811     int  m_VlanId;                  // VLAN ID
1812     int  m_VlanPriority;            // VLAN priority
1813 
1814     // Redundant link (path 2 in SMPTE 2022-7 mode)
1815     unsigned char  m_Ip2[16];       // IP address (IPv4/IPv6)
1816     unsigned short  m_Port2;        // Port number
1817     unsigned char  m_Gateway2[16];  // Override default gateway
1818     std::vector<DtIpSrcFlt>  m_SrcFlt2;
1819                                     // Source filter
1820 
1821     int  m_VlanId2;                 // VLAN ID
1822     int  m_VlanPriority2;           // VLAN priority
1823 
1824     int  m_TimeToLive;              // Time-to-Live setting for IP Tx
1825     int  m_NumTpPerIp;              // Number of transport packets per IP packet
1826     int  m_Protocol;                // Protocol: DTAPI_PROTO_UDP/RTP
1827     int  m_DiffServ;                // Differentiated services
1828     int  m_FecMode;                 // Error correction mode: DTAPI_FEC_DISABLE/2D
1829     int  m_FecNumRows;              // 'D' = #rows in FEC matrix
1830     int  m_FecNumCols;              // 'L' = #columns in FEC matrix
1831 
1832     // Control and status flags: DTAPI_IP_V4, DTAPI_IP_V6, DTAPI_IP_TX_MANSRCPORT
1833     int  m_Flags;
1834 
1835     // Seamless Protection Switching of IP Datagrams (SMPTE 2022-7)
1836 
1837     // Transmission- or reception mode. It determines whether "seamless protection
1838     // switching of IP datagrams" according to SMPTE 2022-7 is applied.
1839     //  DTAPI_IP_NORMAL     Default value for non-redundant Rx or Tx.
1840     //  DTAPI_IP_TX_2022_7  Apply SMPTE 2022-7 for Tx. IP packets will be duplicated to
1841     //                      path 1 (primary link) and path 2 (redundant link)
1842     //  DTAPI_IP_RX_2022_7  Apply SMPTE 2022-7 for Rx. IP packets from path 1 and path 2
1843     //                      will be seamlessly combined into a single logical stream.
1844     int  m_Mode;
1845 
1846     // The IP transmission profile determines the maximum bitrate and the maximum skew
1847     // between transmission path 1 and path 2.
1848     DtIpProfile  m_IpProfile;
1849 public:
1850     DtIpPars2();
1851     ~DtIpPars2();
1852     void Init();
1853     void operator=(const DtIpPars& IpPars);
1854 };
1855 
1856 // Error correction modes (DtIpPars::m_FecMode)
1857 #define DTAPI_FEC_DISABLE           0
1858 #define DTAPI_FEC_2D                1            // FEC reconstruction
1859 #define DTAPI_FEC_2D_M1             1            // Mode1: FECdT = DVBdT + .5 * DVBdT
1860 #define DTAPI_FEC_2D_M2             2            // Mode2: FECdT = DVBdT
1861 #define DTAPI_FEC_2D_M1_B           3            // Mode1: FECdT = DVBdT + .5 * DVBdT (BLOCK)
1862 #define DTAPI_FEC_2D_M2_B           4            // Mode2: FECdT = DVBdT (BLOCK)
1863 
1864 // Optional control/status flags (DtIpPars::m_Flags)
1865 #define DTAPI_IP_V4                 0x00
1866 #define DTAPI_IP_V6                 0x01
1867 #define DTAPI_IP_TX_MANSRCPORT      0x10
1868 #define DTAPI_IP_RX_DIFFSRCPORTFEC  0x20
1869 
1870 // Transmission/reception mode (DtIpPars::m_Mode)
1871 #define DTAPI_IP_NORMAL             0
1872 #define DTAPI_IP_TX_2022_7          1            // Dual-path SMPTE 2022-7 transmission
1873 #define DTAPI_IP_RX_2022_7          2            // Dual-path SMPTE 2022-7 reception
1874 // Legacy definitions
1875 #define DTAPI_IP_TX_DBLBUF          DTAPI_IP_TX_2022_7
1876 #define DTAPI_IP_RX_DBLBUF          DTAPI_IP_RX_2022_7
1877 
1878 // IP protocol (DtIpPars::m_Protocol)
1879 #define DTAPI_PROTO_UDP             0
1880 #define DTAPI_PROTO_RTP             1
1881 #define DTAPI_PROTO_AUTO            2
1882 #define DTAPI_PROTO_UNKN            2
1883 
1884 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. DtIpStat .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
1885 //
1886 // Structure for retrieving the IP statistics for an SDI/TS-over-IP channel.
1887 //
1888 // Counters start at zero, but counters are not reset after being read.
1889 // Counter wraps must be handled by the application.
1890 //
1891 // If the mode is "Seamless Protection Switching of IP Datagrams" (SMPTE 2022-7 mode),
1892 // counters are maintained for path 1, path 2, and for the reconstructed stream.
1893 // If this mode is not active, only path 1 counters are valid.
1894 //
1895 struct DtIpStat
1896 {
1897     // Total number of received or transmitted IP packets.This is the number of IP packets
1898     // that the stream should contain, so lost packets are included in this counter.
1899     unsigned int  m_TotNumIpPackets;
1900 
1901     // Number of IP packets lost before and after FEC.
1902     // In SMPTE 2022-7 mode, these counters apply to the reconstructed stream.
1903     unsigned int  m_LostIpPacketsBeforeFec, m_LostIpPacketsAfterFec;
1904 
1905     // Counters for the number of received and number of lost IP packets for path 1
1906     // and for path 2.
1907     //  m_NumIpPacketsLost1 = m_TotNumIpPackets - m_NumIpPacketsReceived1
1908     //  m_NumIpPacketsLost2 = m_TotNumIpPackets - m_NumIpPacketsReceived2
1909     unsigned int  m_NumIpPacketsReceived1, m_NumIpPacketsReceived2;
1910     unsigned int  m_NumIpPacketsLost1, m_NumIpPacketsLost2;
1911 
1912     // QoS statistics measured over the last second, and over the last minute.
1913     DtIpQosStats  m_QosStatsLastSec, m_QosStatsLastMin;
1914 };
1915 
1916 // Legacy
1917 #define DtTsIpStat DtIpStat
1918 
1919 
1920 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtTunePars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
1921 //
1922 // Structure for setting tuner specific parameters
1923 //
1924 struct DtTunePars
1925 {
1926     union {
1927         // DTA-2131 specific tuner parameters
1928         struct {
1929             int  m_TunerStandard;   // DTAPI_TUNMOD_xxx
1930             int  m_TunerBandwidth;  // Tuning bandwidth in Hz
1931             int  m_IfFrequency;     // IF frequency in Hz
1932                                     // (-1 according tuner standard)
1933             int  m_LpfCutOff;       // Low-pass filter cutoff; DTAPI_TUN31_LPF_x
1934             int  m_LpfOffset;       // Low-pass filter offset; DTAPI_TUN31_LPF_x
1935             int  m_HiPass;          // Hi Pass filter; DTAPI_TUN31_HPF_x
1936             int  m_DcNotchIfPpf;    // Enable DC notch IF PPF; DTAPI_TUN31_NOTCH_x
1937             int  m_IfNotch;         // Enable IF notch; DTAPI_TUN31_NOTCH_x
1938             int  m_IfNotchToRssi;   // Enable IF notch to RSSI; DTAPI_TUN31_NOTCH_x
1939         } m_Dta2131TunePars;
1940     } u;
1941 };
1942 
1943 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtVidStdInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
1944 //
1945 struct DtVidStdInfo
1946 {
1947     int  m_VidStd;                  // Video Standard
1948     int  m_LinkStd;                 // Link standard
1949     bool  m_IsHd;                   // true: is an HD format: false: is SD format
1950     bool  m_Is4k;                   // true: is a 4k resolution
1951 
1952     int  m_VidWidth;                // Width in pixels
1953     int  m_VidHeight;               // Height in number of lines
1954 
1955     // NOTE: for 4k the following members describe the properties of a single link
1956     bool  m_IsInterlaced;           // Is interlaced
1957     int  m_NumLines;                // Number of lines per frame
1958     double  m_Fps;                  // Frame rate
1959     double  m_Pps;                  // Picture rate
1960     bool  m_IsFractional;           // Fractional frame rate
1961 
1962     int  m_FrameNumSym;             // Size of frame (in # symbols)
1963     int  m_LineNumSym;              // # of symbol per line
1964     int  m_LineNumSymHanc;          // # of HANC symbols per line
1965     int  m_LineNumSymVanc;          // # of VANC symbols per line
1966     int  m_LineNumSymEav;           // # of EAV symbols per line
1967     int  m_LineNumSymSav;           // # of SAV symbols per line
1968 
1969     // Field 1
1970     int  m_Field1StartLine;         // Line # of first line for field 1
1971     int  m_Field1EndLine;           // Line # of last line for field 1
1972     int  m_Field1VidStartLine;      // Line # of first line containing active video
1973     int  m_Field1VidEndLine;        // Line # of last line containing active video
1974 
1975     // Field 2
1976     int  m_Field2StartLine;         // Line # of first line for field 2
1977     int  m_Field2EndLine;           // Line # of last line for field 2
1978     int  m_Field2VidStartLine;      // Line # of first line containing active video
1979     int  m_Field2VidEndLine;        // Line # of last line containing active video
1980 
1981     // Utility predicates
IsFrameRateDtVidStdInfo1982     bool  IsFrameRate(double R) { return R-1e-3<m_Fps && m_Fps<R+1e-3; }
1983 };
1984 
1985 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ DEMODULATION PARAMETERS +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
1986 
1987 //.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtDemodDvbS2ModCodSettings -.-.-.-.-.-.-.-.-.-.-.-.-.-
1988 //
1989 // Structure for storing the DVB-S2
1990 //
1991 struct DtDemodDvbS2ModCodSettings
1992 {
1993     bool  m_Enable;                 // Demodulation of this MODCOD (yes/no)
1994     int  m_SnrThreshold;            // SNR threshold of this MODCOD for automute algorithm
DtDemodDvbS2ModCodSettingsDtDemodDvbS2ModCodSettings1995     DtDemodDvbS2ModCodSettings() : m_Enable(false), m_SnrThreshold(0) {}
DtDemodDvbS2ModCodSettingsDtDemodDvbS2ModCodSettings1996     DtDemodDvbS2ModCodSettings(bool Enable, int SnrThreshold) :
1997                                          m_Enable(Enable), m_SnrThreshold(SnrThreshold) {}
1998 };
1999 
2000 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2001 //
2002 // Structure for storing a complete set of demodulation parameters
2003 //
2004 class DtDemodPars
2005 {
2006 public:
2007     DtDemodPars();
2008     DtDemodPars(const DtDemodPars&);
2009     ~DtDemodPars();
2010 public:
2011     DTAPI_RESULT CheckValidity();
2012     int  GetModType() const;
2013     DTAPI_RESULT  SetModType(int ModType);
2014     DtDemodParsAtsc*  Atsc() const;
2015     DtDemodParsAtsc3*  Atsc3() const;
2016     DtDemodParsDab*  Dab() const;
2017     DtDemodParsDvbC2*  DvbC2() const;
2018     DtDemodParsDvbS*  DvbS() const;
2019     DtDemodParsDvbS2*  DvbS2() const;
2020     DtDemodParsDvbS2Adv*  DvbS2Adv() const;
2021     DtDemodParsDvbT*  DvbT() const;
2022     DtDemodParsDvbT2*  DvbT2() const;
2023     DtDemodParsIq*  Iq() const;
2024     DtDemodParsIq2131*  Iq2131() const;
2025     DtDemodParsIsdbt*  Isdbt() const;
2026     DtDemodParsQam*  Qam() const;
2027 
2028     // Predicates
2029     bool IsAtsc() const, IsAtsc3() const, IsDab() const, IsDvbC2() const, IsDvbS() const,
2030         IsDvbS2() const, IsDvbT() const,IsDvbT2() const, IsIq() const, IsIq2131() const,
2031         IsIsdbt() const,  IsQam() const, IsQamAC() const, IsQamB() const;
2032 
2033     // Operators
2034     void  operator = (const DtDemodPars& Pars);
2035 
2036     // Serialisation
2037     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
2038     DTAPI_RESULT  ToXml(std::wstring& XmlString);
2039 
2040     // Conversion helper
2041     DTAPI_RESULT  FromOldStyle(int ModType, int ParXtra0, int ParXtra1, int ParXtra2);
2042     DTAPI_RESULT  ToOldStyle(int& ModType, int& ParXtra0, int& ParXtra1, int& ParXtra2);
2043 private:
2044     int  m_ModType;                 // Modulation type
2045     void*  m_pDemodPars;            // Demodulation parameters; Type depends on m_ModType
2046 private:
2047     void  CleanUpDemodPars();
2048 };
2049 
2050 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsAtsc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2051 //
2052 // Demodulation parameters for modulation type DTAPI_MOD_ATSC
2053 //
2054 struct DtDemodParsAtsc
2055 {
2056     int  m_Constellation;           // VSB constellation
2057 };
2058 
2059 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsAtsc3 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2060 //
2061 // Demodulation parameters for modulation type DTAPI_MOD_ATSC3
2062 //
2063 struct DtDemodParsAtsc3
2064 {
2065     int  m_Bandwidth;               // Bandwidth,  See DTAPI_ATSC3_xMHZ
2066     bool  m_AlpLenIncludesAhSi;     // If true ALP payload length includes additional
2067                                     // header for signaling information; default false
2068                                     // (2016 spec, Korean mode, non standard)
DtDemodParsAtsc3DtDemodParsAtsc32069     DtDemodParsAtsc3() :  m_AlpLenIncludesAhSi(false) {}
2070 };
2071 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsDab -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2072 //
2073 // Demodulation parameters for modulation type DTAPI_MOD_DAB
2074 //
2075 struct DtDemodParsDab
2076 {
2077 };
2078 
2079 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsDvbC2 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2080 //
2081 // Demodulation parameters for modulation type DTAPI_MOD_DVBC2
2082 //
2083 struct DtDemodParsDvbC2
2084 {
2085     int  m_Bandwidth;               // Bandwidth
2086     bool m_ScanL1Part2Data;         // Scan on each tune for full L1Part2Data
2087 };
2088 
2089 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsDvbS -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2090 //
2091 // Demodulation parameters for modulation type DTAPI_MOD_DVBS
2092 //
2093 struct DtDemodParsDvbS
2094 {
2095     int  m_CodeRate;                // DVB-S coderate
2096     int  m_SpecInv;                 // Spectral inversion (yes/no)
2097     int  m_SymRate;                 // Symbol rate in baud
2098 };
2099 
2100 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsDvbS2 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2101 //
2102 // Demodulation parameters for modulation type DTAPI_MOD_DVBS2
2103 //
2104 struct DtDemodParsDvbS2
2105 {
2106     int  m_CodeRate;                // Coderate
2107     int  m_Pilots;                  // Pilots (yes/no)
2108     int  m_SpecInv;                 // Spectral inversion (yes/no)
2109     int  m_FecFrame;                // Long or short FECFRAME
2110     int  m_SymRate;                 // Symbol rate in baud
2111 };
2112 
2113 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsDvbS2Adv -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2114 //
2115 // Advanced demodulation parameters for modulation type DTAPI_MOD_DVBS2
2116 //
2117 struct DtDemodParsDvbS2Adv : DtDemodParsDvbS2
2118 {
2119     bool  m_AutoMuteModCods;        // MODCODS with an SNR threshold above the current SNR
2120                                     // will not be demodulated
2121     int  m_HysteresisMargin;        // Margin to add on top of the SNR threshold before
2122                                     // re-enabling a certain modcod, in units of 0.1 dB
2123     std::map<DtDvbS2ModCod, DtDemodDvbS2ModCodSettings>  m_ModCods;
2124                                     // List with supported modcods
2125     DtDemodParsDvbS2Adv();
2126     DTAPI_RESULT  DeleteModCod(DtDvbS2ModCod ModCod);
2127     DTAPI_RESULT  InitSnrThreshold(int TypeNumber);
2128     DTAPI_RESULT  SetModCod(DtDvbS2ModCod ModCod, DtDemodDvbS2ModCodSettings &Settings);
2129 };
2130 
2131 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsDvbT -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2132 //
2133 // Demodulation parameters for modulation type DTAPI_MOD_DVBT
2134 //
2135 struct DtDemodParsDvbT
2136 {
2137     int  m_CodeRate;                // Coderate
2138     int  m_Bandwidth;               // Bandwidth
2139     int  m_Constellation;           // Constellation
2140     int  m_Guard;                   // Guard interval
2141     int  m_Interleaving;            // Interleaving
2142     int  m_Mode;                    // Transmission mode
2143 };
2144 
2145 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsDvbT2 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2146 //
2147 // Demodulation parameters for modulation type DTAPI_MOD_DVBT2
2148 //
2149 struct DtDemodParsDvbT2
2150 {
2151     int  m_Bandwidth;               // Bandwidth
2152     int  m_T2Profile;               // DVB-T2 profile (Base/Lite)
2153 };
2154 
2155 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsIq -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2156 //
2157 // Demodulation parameters for modulation type DTAPI_MOD_IQ
2158 //
2159 struct DtDemodParsIq
2160 {
2161     int  m_Bandwidth;               // Signal bandwidth in Hz
2162     int  m_IqDemodType;             // IQ demodulation type (DTAPI_DEMOD_QAM or
2163                                     // DTAPI_DEMOD_OFDM)
2164     int  m_SampleRate;              // Sample rate in Hz
2165 };
2166 
2167 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsIq2131 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2168 //
2169 // Demodulation parameters for modulation type DTAPI_MOD_IQ_2131 (DTA-2131 specific)
2170 //
2171 struct DtDemodParsIq2131
2172 {
2173     int  m_IqDemodFreq;             // IQ demodulation frequency in Hz
2174     DtFilterPars  m_LpfFilter;      // Anti-aliasing filter
2175     double  m_LpfScaleFactor;       // Scale factor after anti-aliasing filter
2176     int  m_SampleRate;              // Sample rate in Hz
2177     DtTunePars  m_TunePars;         // Tuning parameters
2178 };
2179 
2180 // IQ-demodulation type
2181 #define  DTAPI_DEMOD_OFDM   0       // OFDM IQ-demodulation type
2182 #define  DTAPI_DEMOD_QAM    1       // QAM IQ-demodulation type
2183 
2184 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsIsdbt .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2185 //
2186 // Demodulation parameters for modulation type DTAPI_MOD_ISDBT
2187 //
2188 struct DtDemodParsIsdbt
2189 {
2190     int  m_Bandwidth;               // Bandwidth DTAPI_ISDBT_BW_xMHZ
2191     int  m_SubChannel;              // Sub channel number, 0..41, default= 22
2192     int  m_NumberOfSegments;        // Number of segments DTAPI_ISDBT_SEGM_x
DtDemodParsIsdbtDtDemodParsIsdbt2193     DtDemodParsIsdbt() : m_SubChannel(22) {}
2194 };
2195 
2196 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodParsQam -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2197 //
2198 // Demodulation parameters for modulation type DTAPI_MOD_QAMxxx
2199 //
2200 struct DtDemodParsQam
2201 {
2202     int  m_Annex;                   // ITU-T J.83 Annex
2203     int  m_Interleaving;            // Interleaving; ignored for Annex A and C
2204     int  m_SymRate;                 // Symbol rate in baud
2205 };
2206 
2207 //+=+=+=+=+=+=+=+=+=+=+=+=+=+ Common Demodulation Structures  +=+=+=+=+=+=+=+=+=+=+=+=+=+=
2208 
2209 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodLdpcStats -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2210 //
2211 // LDCP statistic information for  ATSC3.0 DVB-T2 and DVB-C2
2212 //
2213 struct DtDemodLdpcStats
2214 {
2215     __int64  m_FecBlocksCount;      // #Decoded FEC blocks
2216     __int64  m_UncorrFecBlocksCount;// #Uncorrected FEC blocks after BCH (not exact)
2217     __int64  m_FecBlocksCount1;     // #Decoded FEC blocks, reset at the same time
2218                                     // as m_FecBlocksItCount/min/max
2219     __int64  m_FecBlocksItCount;    // Total #LDPC iterations
2220                                     // Average #LDPC iteration =
2221                                     //              m_FecBlocksItCount / m_FecBlocksCount1
2222     int  m_FecBlocksItMin;          // Minimum #LDPC iterations (-1 after reset)
2223     int  m_FecBlocksItMax;          // Maximum #LDPC iterations (-1 after reset)
2224     __int64  m_BchBitCount;         // #Decoded data bits, including BCH bits
2225     // Currently only data+BCH bits are taken into account (LDPC parity bits are ignored),
2226     // so the BER before LDPC is approximatively: m_BchBitErrorCount / m_BchBitCount
2227     // This is accurate only if there are no uncorrected blocks (m_UncorrFecBlocksCount=0)
2228     __int64  m_BchBitErrorCount;    // Bit error count before LDPC
2229 };
2230 
2231 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodMaLayerStats -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2232 //
2233 // LMode adaption layer statistics for DVB-T2 and DVB-C2
2234 //
2235 struct DtDemodMaLayerStats
2236 {
2237     __int64  m_HdrCrc8ErrorCount;   // #CRC8 errors for BBframe header
2238     __int64  m_PckCrc8ErrorCount;   // #CRC8 errors for packets (only for m_Hem = 0)
2239     __int64  m_FramingErrorCount;   // SYNCD/DFL/UPL consistency errors
2240     __int64  m_CommonPlpResyncCount;// Number of times a resynchronization between data
2241                                     // and common PLP was needed. It normally happens
2242                                     // only in case of receive errors. This field is only
2243                                     // updated in the corresponding data PLP.
2244 };
2245 
2246 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtRsDecStats -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2247 //
2248 // Reed-Solomon decoder info
2249 //
2250 struct DtRsDecStats
2251 {
2252     bool    m_Locked;               // Decoder is locked
2253     __int64  m_ByteSkipCount;       // Bytes skipped while looking for sync
2254     __int64  m_PacketCount;         // Decoded packets
2255     __int64  m_UncorrPacketCount;   // Uncorrected packets
2256     __int64  m_ByteErrorCount;      // Byte error count
2257     __int64  m_BitErrorCount;       // Bit error count
2258 };
2259 
2260 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtVitDecStats -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2261 //
2262 // Viterbi decoder info (pre-viterbi BER)
2263 //
2264 struct DtVitDecStats
2265 {
2266     __int64  m_BitCount;            // Input bit count
2267     __int64  m_BitErrorCount;       // Bit error count
2268 };
2269 
2270 
2271 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodMaLayerData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2272 //
2273 // Mode adaption layer info for DVB-T2 and DVB-C2
2274 struct DtDemodMaLayerData
2275 {
2276     bool  m_Hem;                    // High efficiency mode
2277     bool  m_Npd;                    // Null packet deletion
2278     int  m_Issy;                    // ISSY: mode, see DTAPI_DVBx2_ISSY_x
2279     int  m_IssyBufs;                // ISSY: current 'BUFS' value
2280     int  m_IssyTto;                 // ISSY: last 'TTO' value (DVB-T2 only)
2281     int  m_IssyBufStat;             // ISSY: last 'BUFSTAT' value (DVB-C2/S2 only)
2282 
2283     // Serialisation
2284     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
2285     DTAPI_RESULT  ToXml(std::wstring& XmlString);
2286 };
2287 
2288 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDemodPlpBlocks -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2289 //
2290 // Number of FEC blocks per frame
2291 //
2292 struct DtDemodPlpBlocks
2293 {
2294     int  m_NumBlocks;               // Last plp_num_blocks
2295     int  m_NumBlocksMin;            // Minimum plp_num_blocks (-1 = no new value since
2296                                     // reset)
2297     int  m_NumBlocksMax;            // Maximum plp_num_blocks
2298 
2299     // Serialisation
2300     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
2301     DTAPI_RESULT  ToXml(std::wstring& XmlString);
2302 };
2303 
2304 //+=+=+=+=+=+=+=+=+ Demodulator Blindscan and Spectrum scan definitions +=+=+=+=+=+=+=+=+=
2305 
2306 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtTransmitter -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2307 //
2308 // Structure describing a transmitter. Used by DtInpChannel::BlindScan to return the
2309 // transmitters found by scanning a frequency band.
2310 //
2311 struct DtTransmitter
2312 {
2313     __int64  m_FreqHz;              // Center frequency of the transmitter
2314     int  m_ModType;                 // Modulation type
2315     int  m_SymbolRate;              // Symbol rate
2316 };
2317 
2318 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtBsProgess -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2319 //
2320 // Structure describing the progress of an asynchronous BlindScan.
2321 // Used by asynchronous DtInpChannel::BlindScan to return current state and the
2322 // transmitters found by scanning a frequency band using the DtBsProgressFunc callback.
2323 //
2324 struct DtBsProgress
2325 {
2326     enum BsEvent
2327     {
2328         BS_STEP,                // One frequency step is completed
2329         BS_CANCELLED,           // Blindscan is cancelled
2330         BS_DONE                 // Blindscan is completed
2331     };
2332 
2333     __int64  m_FreqHz;          // Center frequency found
2334     DtDemodPars  m_DemodPars;   // Demodulator parameters found for this transmitter
2335     BsEvent  m_ProgressEvent;   // Progress event
2336     bool  m_ChannelFound;       // If set, the channel is found on the transmitter
2337                                 // frequency
2338     DTAPI_RESULT  m_Result;     // Result of the blindscan
2339 
2340     // Serialisation
2341     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
2342     DTAPI_RESULT  ToXml(std::wstring& XmlString);
2343 
2344 public:
2345     DtBsProgress();
2346     ~DtBsProgress();
2347 };
2348 
2349 // Function to receive asynchronous progess.
2350 typedef void  DtBsProgressFunc(DtBsProgress& Progress, void* pOpaque);
2351 
2352 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtRfLevel -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2353 //
2354 // Structure describing a RF-level on a frequency.
2355 // Used by DtInpChannel::SpectrumScan to return the RF-levels found by scanning a
2356 // frequency band.
2357 //
2358 struct DtRfLevel
2359 {
2360     __int64  m_FreqHz;          // Center frequency of the RF level
2361     int  m_RfLevel;             // RF level found in units of 0.1dBmV
2362 };
2363 
2364 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtSpsProgress -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2365 //
2366 // Structure describing the progress of an asynchronous SpectrumScan.
2367 // Used by DtInpChannel::SpectrumScan to return current state and the RF-Levels
2368 // found by scanning a frequency band using the DtSpsProgressFunc callback.
2369 //
2370 struct DtSpsProgress
2371 {
2372     enum SpsEvent
2373     {
2374         SPS_STEP,               // One frequency step is completed
2375         SPS_CANCELLED,          // SpectrumScan is cancelled
2376         SPS_DONE                // SpectrumScan is completed
2377     };
2378 
2379     DtRfLevel  m_DtRfLevel;     // A single level
2380     SpsEvent  m_ProgressEvent;  // Progress event
2381     DTAPI_RESULT  m_Result;     // Result of the spectrumscan
2382 
2383     //Serialisation
2384     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
2385     DTAPI_RESULT  ToXml(std::wstring& XmlString);
2386 
2387 public:
2388     DtSpsProgress();
2389     ~DtSpsProgress();
2390 };
2391 
2392 // Function to receive asynchronous spectrum scan progess.
2393 typedef void  DtSpsProgressFunc(DtSpsProgress& Progress, void* pOpaque);
2394 
2395 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAspectRatio -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2396 // Aspect ratio
2397 enum DtAspectRatio
2398 {
2399     DT_AR_UNKNOWN,              // Unknown aspect ratio
2400     DT_AR_4_3,                  // 4x3
2401     DT_AR_16_9,                 // 16x9
2402     DT_AR_14_9                  // 14x9
2403 };
2404 
2405 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtDetVidStd -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2406 //
2407 // Structure with information about the detected video standard on the input. Returned
2408 // by DtDevice::DetectVidStd(). This function is only available on ports with the
2409 // DTAPI_CAP_MATRIX2, DTAPI_CAP_SDIRX or DTAPI_CAP_HDMI capability.
2410 //
2411 struct DtDetVidStd
2412 {
2413     int  m_VidStd;                  // Detected video standard
2414     int  m_LinkStd;                 // Detected link standard
2415     int  m_LinkNr;                  // Link number, -1 for single-link standards
2416     unsigned int  m_Vpid;           // Raw VPID extracted from stream, 0 if not available
2417     unsigned int  m_Vpid2;          // Raw VPID from link 2, only for 3G level B signals
2418     DtAspectRatio  m_AspectRatio;   // Picture Aspect Ratio
2419 };
2420 
2421 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum DtAudChanContent -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2422 enum DtAudChanContent
2423 {
2424     DT_AUDCHANCONT_UNKNOWN,         // Channel content is unknown or not defined yet
2425     DT_AUDCHANCONT_PCM,             // Channel carries PCM samples
2426     DT_AUDCHANCONT_DATA,            // Channel carries data
2427     DT_AUDCHANCONT_UNSUPPORTED,     // Content detection is not supported
2428 };
2429 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtAudChanStatus -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2430 //
2431 struct DtAudChanStatus
2432 {
2433     int  m_ChanIdx;                 // Channel index in underlying audio/video stream
2434     bool  m_IsAsynchronous;         // Is channel asynchronous wrt video clock?
2435     int  m_SampleRate;              // Audio sample rate
2436     DtAudChanContent  m_Content;    // Channel content
2437     int  m_StatusWordNumValid;      // Number of valid bytes in m_ChanStat
2438     unsigned char  m_ChanStat[24];  // Raw channel-status word data
2439 
2440     bool operator == (const DtAudChanStatus&) const;
2441     bool operator != (const DtAudChanStatus& Rhs) const { return !(*this==Rhs); }
2442 };
2443 
2444 //.-.-.-.-.-.-.-.-.-.- Audio encoding parameters - Enumeration types -.-.-.-.-.-.-.-.-.-.-
2445 
2446 // Audio encoding standard
2447 enum DtAudEncStd
2448 {
2449     DT_AUDENCSTD_UNKNOWN,           // Unknown or not defined yet
2450     DT_AUDENCSTD_AAC,               // AAC (AAC-LC or HE-AAC)
2451     DT_AUDENCSTD_AC3,               // Dolby AC-3
2452     DT_AUDENCSTD_DOLBY_E,           // Dolby E (currently pass-through mode only)
2453     DT_AUDENCSTD_EAC3,              // Dolby E-AC-3 (currently pass-through mode only)
2454     DT_AUDENCSTD_MP1LII,            // MPEG-1 Layer II
2455     DT_AUDENCSTD_PCM                // PCM samples (SMPTE 302M)
2456 };
2457 
2458 //-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtDolbyECompleteMetadata -.-.-.-.-.-.-.-.-.-.-.-.-.-.
2459 //
2460 struct DtDolbyECompleteMetadata
2461 {
2462     int  m_ProgramConfig;
2463     int  m_FrameRateCode;
2464     int  m_PitchShiftCode;
2465     unsigned char  m_SmpteTimeCode[8];
2466     std::vector<unsigned char>  m_DescriptionText;
2467 
2468     bool operator == (const DtDolbyECompleteMetadata&) const;
2469     bool operator != (const DtDolbyECompleteMetadata& Rhs) const { return !(*this==Rhs); }
2470 };
2471 
2472 //-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtDolbyEEssentialMetadata -.-.-.-.-.-.-.-.-.-.-.-.-.-
2473 //
2474 struct DtDolbyEEssentialMetadata
2475 {
2476     int  m_ProgramConfig;
2477     int  m_FrameRateCode;
2478     int  m_PitchShiftCode;
2479 
2480     bool operator == (const DtDolbyEEssentialMetadata&) const;
2481     bool operator != (const DtDolbyEEssentialMetadata& Rhs) const
2482                                                                  { return !(*this==Rhs); }
2483 };
2484 
2485 //.-.-.-.-.-.-.-.-.-.-.-.- struct DtDolbyDigitalCompleteMetadata -.-.-.-.-.-.-.-.-.-.-.-.-
2486 //
2487 struct DtDolbyDigitalCompleteMetadata
2488 {
2489     int  m_ProgramId;               // Program id
2490     int  m_Datarate;                // Intended bitrate
2491     int  m_BsMod;                   // Bitstream mode
2492     int  m_AcMod;                   // Audio coding mode
2493     int  m_CMixLev;                 // Center mix level
2494     int  m_SurMixLev;               // Surround mix level
2495     int  m_DSurMod;                 // Dolby surround mode
2496     bool  m_LfeOn;                  // Enable Low Frequency Effect (LFE) channel
2497     int  m_DialNorm;                // Dialog normalization
2498     bool  m_LangCodeE;              // Language code exists
2499     int  m_LangCode;                // Language code
2500     bool  m_AudProdIE;              // Audio production info exists
2501     int  m_MixLevel;                // Mixing level
2502     int  m_RoomTyp;                 // Room type
2503     bool  m_CopyrightB;             // Copyright flag
2504     bool  m_OrigBs;                 // Original bitstream flag
2505     bool  m_Xbsi1e;                 // Enable alternative bitstream syntax
2506     int  m_DMixMod;                 // Preferred stereo downmix mode
2507     int  m_LtrtCMixLev;             // Lt/Rt center mix level
2508     int  m_LtrtSurMixLev;           // Lt/Rt surround mix level
2509     int  m_LoroCMixLev;             // Lo/Ro center mix level
2510     int  m_LoroSurMixLev;           // Lo/Ro surround mix level
2511     bool  m_Xbsi2e;                 // Extended bitstream indicator
2512     int  m_DSurExMod;               // Dolby surround EX mode
2513     int  m_DHeadPhonMod;            // Dolby headphone mode
2514     int  m_AdConvTyp;               // A/D converter type
2515     bool  m_HpFOn;                  // Enable DC filter
2516     bool  m_BwLpfOn;                // Enable bandwidth filter
2517     bool  m_LfeLpfOn;               // Enable LFE lowpass filter
2518     bool  m_Sur90On;                // Enable 90-degree phase shift for surround
2519     bool  m_SurAtton;               // 3dB surround attenuation flag
2520     bool  m_RfPremphOn;             // Enable digital deemphasis
2521     bool  m_ComprE;                 // Compression control word exists
2522     int  m_Compr1;                  // RF compression profile
2523     bool  m_DynRngE;                // Enable normal compression
2524     int  m_DynRng1;                 // Dynamic range control 1
2525     int  m_DynRng2;                 // Dynamic range control 2
2526     int  m_DynRng3;                 // Dynamic range control 3
2527     int  m_DynRng4;                 // Dynamic range control 4
2528 
2529     bool operator == (const DtDolbyDigitalCompleteMetadata&) const;
2530     bool operator != (const DtDolbyDigitalCompleteMetadata& Rhs) const
2531                                                                  { return !(*this==Rhs); }
2532 };
2533 
2534 //.-.-.-.-.-.-.-.-.-.-.-.- struct DtDolbyDigitalEssentialMetadata -.-.-.-.-.-.-.-.-.-.-.-.
2535 //
2536 struct DtDolbyDigitalEssentialMetadata
2537 {
2538     int  m_ProgramId;               // Program id
2539     int  m_Datarate;                // Intended bitrate
2540     int  m_BsMod;                   // Bitstream mode
2541     int  m_AcMod;                   // Audio coding mode
2542     bool  m_LfeOn;                  // Enable Low Frequency Effect (LFE) channel
2543     int  m_DialNorm;                // Dialog normalization
2544     bool  m_ComprE;                 // Compression control word exists
2545     int  m_Compr2;                  // Global compression profile
2546     bool  m_DynRngE;                // Enable normal compression
2547     int  m_DynRng5;                 // Dynamic range control 5
2548     int  m_DynRng6;                 // Dynamic range control 6
2549     int  m_DynRng7;                 // Dynamic range control 7
2550     int  m_DynRng8;                 // Dynamic range control 8
2551 
2552     bool operator == (const DtDolbyDigitalEssentialMetadata&) const;
2553     bool operator != (const DtDolbyDigitalEssentialMetadata& Rhs) const
2554                                                                  { return !(*this==Rhs); }
2555 };
2556 
2557 
2558 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtRdd6Data -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2559 //
2560 struct DtRdd6Data
2561 {
2562     int  m_FirstChannelIdx;         // Derived from ST2020 SDID. Can be -1 for unknown
2563     bool  m_DECompleteValid;
2564     DtDolbyECompleteMetadata  m_DEComplete;
2565     bool  m_DEEssentialValid;
2566     DtDolbyEEssentialMetadata  m_DEEssential;
2567     bool  m_DDCompleteValid;
2568     DtDolbyDigitalCompleteMetadata  m_DDComplete;
2569     bool  m_DDEssentialValid;
2570     DtDolbyDigitalEssentialMetadata  m_DDEssential;
2571 
2572     bool operator == (const DtRdd6Data&) const;
2573     bool operator != (const DtRdd6Data& Rhs) const { return !(*this==Rhs); }
2574 };
2575 
2576 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
2577 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ MAIN DTAPI CLASSES +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
2578 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
2579 
2580 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDevice -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2581 //
2582 // Class representing a DekTec Device
2583 //
2584 class DtDevice
2585 {
2586     // Constructor, destructor
2587 public:
2588     DtDevice();
2589     virtual ~DtDevice();
2590 private:
2591     // No implementation is provided for the copy constructor
2592     DtDevice(const DtDevice&);
2593 
2594     // Public access functions
2595 public:
2596     virtual int  Category(void);
2597     virtual int  ChanType(int Port);
2598     virtual int  FirmwareVersion(void);
2599     virtual int  FwPackageVersion();
2600     virtual bool  IsAttached(void);
2601     virtual int  TypeNumber(void);
2602     virtual bool  HasCaps(int  Port, const DtCaps  Caps) const;
2603 
2604     // Public member functions
2605 public:
2606     virtual DTAPI_RESULT  AttachToIpAddr(unsigned char Ip[4]);
2607     virtual DTAPI_RESULT  AttachToSerial(__int64 SerialNumber);
2608     virtual DTAPI_RESULT  AttachToSlot(int PciBusNumber, int SlotNumber);
2609     virtual DTAPI_RESULT  AttachToType(int TypeNumber, int DeviceNo=0);
2610     virtual DTAPI_RESULT  ClearGpsErrors();
2611     virtual DTAPI_RESULT  Detach(void);
2612     virtual DTAPI_RESULT  DetectIoStd(int  Port, int& Value, int& SubValue);
2613     DTAPI_DEPRECATED(virtual DTAPI_RESULT  DetectVidStd(int  Port, DtDetVidStd& Info),
2614               "Deprecated (will be removed!): Use DtAvInputStatus::DetectVidStd instead");
2615     virtual DTAPI_RESULT  FlashDisplay(int NumFlashes=5, int OnTime=100, int OffTime=100);
2616     virtual DTAPI_RESULT  GetAttribute(int AttrId, int& AttrValue);
2617     virtual DTAPI_RESULT  GetAttribute(int Port, int AttrId, int& AttrValue);
2618     virtual DTAPI_RESULT  GetAttribute(int Port, int AttrId, DtModPars& ModParVals,
2619                                                                           int& AttrValue);
2620     virtual DTAPI_RESULT  GetDescriptor(DtDeviceDesc& DvcDesc);
2621     virtual DTAPI_RESULT  GetDeviceDriverVersion(int& Major, int& Minor, int& BugFix,
2622                                                                               int& Build);
2623     virtual DTAPI_RESULT  GetDisplayName(wchar_t* pName);
2624     virtual DTAPI_RESULT  GetDisplayName(char* pName);
2625     virtual DTAPI_RESULT  GetFanSpeed(int Fan, int& Rpm);
2626     virtual DTAPI_RESULT  GetFirmwareVariant(int& FirmwareVariant);
2627     virtual DTAPI_RESULT  GetFirmwareVersion(int& FirmwareVersion);
2628     virtual DTAPI_RESULT  GetFwPackageVersion(int& FwPackVersion);
2629     virtual DTAPI_RESULT  GetTemperature(int TempSens, int& Temp);
2630     virtual DTAPI_RESULT  GetGenlockState(int& State, int& RefVidStd);
2631     virtual DTAPI_RESULT  GetGenlockState(int& State);
2632     virtual DTAPI_RESULT  GetGpsStatus(int& Status, int& Error);
2633     virtual DTAPI_RESULT  GetGpsTime(int& GpsTime);
2634     virtual DTAPI_RESULT  GetIoConfig(DtIoConfig& IoCfg);
2635     virtual DTAPI_RESULT  GetIoConfig(int Port, int Group, int& Value);
2636     virtual DTAPI_RESULT  GetIoConfig(int Port, int Group, int& Value, int& SubValue);
2637     virtual DTAPI_RESULT  GetIoConfig(int Port, int Group, int& Value, int& SubValue,
2638                                                                        __int64& ParXtra0);
2639     virtual DTAPI_RESULT  GetIoConfig(int Port, int Group, int& Value, int& SubValue,
2640                                                     __int64& ParXtra0, __int64& ParXtra1);
2641     virtual DTAPI_RESULT  GetNumLicensePoints(DtAudEncStd, int& NumPoints);
2642     virtual DTAPI_RESULT  GetNumLicensePoints(DtAudEncStd AudEncStd, int PortNr,
2643                                   int& NumPoints, int& NumUsedPoints, int& NumFreePoints);
2644     virtual DTAPI_RESULT  GetNwSpeed(int Port, bool& Enable, int& Speed);
2645     virtual DTAPI_RESULT  GetPowerStatus(int& Status);
2646     virtual DTAPI_RESULT  GetRefClkCnt(int& RefClkCnt);
2647     virtual DTAPI_RESULT  GetRefClkCnt(__uint64& RefClkCnt);
2648     virtual DTAPI_RESULT  GetRefClkCnt(int& RefClkCnt, int& RefClkFreqHz);
2649     virtual DTAPI_RESULT  GetRefClkCnt(__uint64& RefClkCnt, int& RefClkFreqHz);
2650     virtual DTAPI_RESULT  GetRefClkFreq(int&  RefClkFreqHz);
2651     virtual DTAPI_RESULT  GetStateFlags(int  Port, int  &StateFlags);
2652     virtual DTAPI_RESULT  GetUsbSpeed(int& UsbSpeed);
2653     virtual DTAPI_RESULT  GetVcxoState(bool& Enable, int& Lock, int& VcxoClkFreqHz);
2654     virtual DTAPI_RESULT  HwFuncScan(int NumEntries, int& NumEntriesResult,
2655                                                                   DtHwFuncDesc* pHwFuncs);
2656     virtual DTAPI_RESULT  LedControl(int LedControl);
2657     static  DTAPI_RESULT  RebootFirmware(__int64 SerialNumber);
2658     virtual DTAPI_RESULT  RegisterCallback(pDtEventCallback Callback, void* pContext,
2659                                                        int EventTypes, void** pId = NULL);
2660     virtual DTAPI_RESULT  SetDisplayName(wchar_t* pName);
2661     virtual DTAPI_RESULT  SetDisplayName (char* pName);
2662     static  DTAPI_RESULT  SetFirmwareVariant(__int64 SerialNumber, int FwVariant,
2663                                                                     bool CheckOnly=false);
2664     virtual DTAPI_RESULT  SetIoConfig(int Port, int Group, int Value, int SubValue = -1,
2665                                             __int64 ParXtra0 = -1, __int64 ParXtra1 = -1);
2666     virtual DTAPI_RESULT  SetIoConfig(DtIoConfig* pIoConfigs, int Count);
2667     virtual DTAPI_RESULT  SetLicenseFromFile(const std::wstring& LicFilename,
2668                                                                         bool Force=false);
2669     virtual DTAPI_RESULT  SetLicenseFromString(const std::wstring& LicString,
2670                                                                         bool Force=false);
2671     virtual DTAPI_RESULT  SetNwSpeed(int Port, bool Enable, int Speed);
2672     virtual DTAPI_RESULT  SetVcxoState(bool Enable, int Value);
2673     virtual DTAPI_RESULT  UnregisterCallback(void* pId);
2674     virtual DTAPI_RESULT  VpdDelete(const char* pTag);
2675     virtual DTAPI_RESULT  VpdDelete(const wchar_t* pTag);
2676     virtual DTAPI_RESULT  VpdRead(const char* pTag, char* pVpdItem);
2677     virtual DTAPI_RESULT  VpdRead(const wchar_t* pTag, wchar_t* pVpdItem);
2678     virtual DTAPI_RESULT  VpdRead(const char*  pTag, char* pVpdItem, int& ItemSize);
2679     virtual DTAPI_RESULT  VpdRead(const wchar_t*  pTag, char* pVpdItem, int& ItemSize);
2680     virtual DTAPI_RESULT  VpdWrite(const char* pTag, char* pVpdItem);
2681     virtual DTAPI_RESULT  VpdWrite(const wchar_t* pTag, wchar_t* pVpdItem);
2682     virtual DTAPI_RESULT  VpdWrite(const char* pTag, char* pVpdItem, int ItemSize);
2683     virtual DTAPI_RESULT  VpdWrite(const wchar_t* pTag, char* pVpdItem, int ItemSize);
2684 
2685 protected:
2686     virtual void  LoadDeviceData();
2687 private:
2688     static void  DtEventCallback(int Event, DtEventArgs* pArgs);
2689 
2690     // Public attributes
2691 public:
2692     DtDeviceDesc  m_DvcDesc;        // Device descriptor, initialized in attach
2693     DtHwFuncDesc*  m_pHwf;          // Hardware functions, initialized in attach
2694 
2695     // Implementation data
2696 private:
2697     std::list<void*>  m_EventSubscriberList;
2698 
2699     // Friends
2700     friend class  DtInpChannel;
2701     friend class  DtOutpChannel;
2702 
2703 public:                             // TODOSD should be protected
2704     IDevice*  m_pDev;
2705 };
2706 
2707 // Attribute identifiers
2708 #define DTAPI_ATTR_LEVEL_MAX        1
2709 #define DTAPI_ATTR_LEVEL_RANGE      2
2710 #define DTAPI_ATTR_LEVEL_STEPSIZE   3
2711 #define DTAPI_ATTR_RFFREQ_ABSMAX    4
2712 #define DTAPI_ATTR_RFFREQ_ABSMIN    5
2713 #define DTAPI_ATTR_RFFREQ_MAX       6
2714 #define DTAPI_ATTR_RFFREQ_MIN       7
2715 #define DTAPI_ATTR_SAMPRHW_ABSMAX   8
2716 #define DTAPI_ATTR_SAMPRHW_ABSMIN   9
2717 #define DTAPI_ATTR_SAMPRHW_HARDLIM  10
2718 #define DTAPI_ATTR_SAMPRHW_MAX      11
2719 #define DTAPI_ATTR_SAMPRHW_MIN      12
2720 #define DTAPI_ATTR_SAMPRATE_ABSMAX  13
2721 #define DTAPI_ATTR_SAMPRATE_ABSMIN  14
2722 #define DTAPI_ATTR_SAMPRATE_MAX     15
2723 #define DTAPI_ATTR_SAMPRATE_MIN     16
2724 #define DTAPI_ATTR_NUM_FANS         17
2725 #define DTAPI_ATTR_PCIE_REQ_BW      18
2726 #define DTAPI_ATTR_PCIE_AVAIL_BW    19
2727 #define DTAPI_ATTR_NUM_TEMP_SENS    20
2728 
2729 // Order in which devices should be listed by DtapiDeviceScan/DtapiHwFuncScan
2730 #define DTAPI_SCANORDER_ORIG        0    // Devices are returned in order determined by OS
2731 #define DTAPI_SCANORDER_SN          1    // Devices are sorted by serial number
2732 
2733 // String conversion - Device type number (e.g. "DTA-100", "DTA-102")
2734 #define DTAPI_DVC2STR_TYPE_NMB        0
2735 // String conversion - Device type number + location (e.g. "DTA-100 in slot 5")
2736 #define DTAPI_DVC2STR_TYPE_AND_LOC    1
2737 // String conversion - Device serial number in canonical form (e.g. "2180.000.022")
2738 #define DTAPI_DVC2STR_SN              2
2739 // String conversion - Device type number (e.g. "DTA-100", "DTA-102")
2740 #define DTAPI_HWF2STR_TYPE_NMB        0
2741 // String conversion - Device type number + optional port (e.g. "DTA-124 port 1"). Port
2742 // no is only added for bidirectional ports and/or when there is more than one port
2743 // configured with the same direction.
2744 #define DTAPI_HWF2STR_TYPE_AND_PORT   1
2745 // String conversion - Device type number + location (e.g. "DTA-100 in slot 5")
2746 #define DTAPI_HWF2STR_TYPE_AND_LOC    2
2747 // String conversion - Interface type (e.g. "DVB-ASI" or "DVB-C")
2748 #define DTAPI_HWF2STR_ITF_TYPE        3
2749 // String conversion - Short version of interface type (e.g. "ASI" instead "DVB-ASI")
2750 #define DTAPI_HWF2STR_ITF_TYPE_SHORT  4
2751 // String conversion - Device type number + port (e.g. "DTA-124 port 1"). Port no is
2752 // always added
2753 #define DTAPI_HWF2STR_TYPE_AND_PORT2  5
2754 // String conversion - Device serial number in canonical form (e.g. "2180.000.022")
2755 #define DTAPI_HWF2STR_SN              6
2756 
2757 // Current genlock state
2758 #define DTAPI_GENL_NO_REF           1
2759 #define DTAPI_GENL_LOCKING          2
2760 #define DTAPI_GENL_LOCKED           3
2761 
2762 // Status and error flags for GPS-Synchronisation
2763 #define DTAPI_GPS_1PPS_SYNC         0x000001
2764 #define DTAPI_GPS_10MHZ_SYNC        0x000002
2765 #define DTAPI_GPS_1PPS_ERROR        0x000001
2766 #define DTAPI_GPS_10MHZ_OUT_RANGE   0x000002
2767 #define DTAPI_GPS_10MHZ_NO_SIGNAL   0x000004
2768 
2769 // Constants for GetStateFlags() on port level
2770 #define DTAPI_STATE_FLAG_INSUFF_USB_BW  0x010000
2771 #define DTAPI_STATE_FLAG_SDI_NO_LOCK    0x020000
2772 #define DTAPI_STATE_FLAG_SDI_INVALID    0x040000
2773 // Constants for GetStateFlags() on device level
2774 #define DTAPI_STATE_FLAG_VPD_CORRUPT    0x000001
2775 #define DTAPI_STATE_FLAG_NO_SERIAL      0x000002
2776 #define DTAPI_STATE_FLAG_NO_USB3        0x000004
2777 #define DTAPI_STATE_FLAG_SLEEPING       0x000008
2778 
2779 // Status and error flags for power status
2780 #define DTAPI_POWER_STATUS_OK           0
2781 #define DTAPI_POWER_EXT_12V_ABSENT      0x000001
2782 
2783 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDtaPlusDevice -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2784 //
2785 // Class representing a DekTec DTA-plus Device
2786 //
2787 class DtDtaPlusDevice
2788 {
2789     // Constructor, destructor
2790 public:
2791     DtDtaPlusDevice();
2792     virtual ~DtDtaPlusDevice();
2793 private:
2794     // No implementation is provided for the copy constructor
2795     DtDtaPlusDevice(const DtDtaPlusDevice&);
2796 
2797     // Public access functions
2798 public:
2799     bool  IsAttached(void);
2800 
2801     // Public member functions
2802 public:
2803     DTAPI_RESULT  AttachToDevice(const DtDtaPlusDeviceDesc &DvcDesc);
2804     DTAPI_RESULT  AttachToSerial(__int64 SerialNumber);
2805     DTAPI_RESULT  Detach();
2806     DTAPI_RESULT  GetDeviceStatus(int &Status);
2807     DTAPI_RESULT  GetTempControlStatus(int &ControlStatus);
2808     DTAPI_RESULT  GetTemperature(int &Temperature);
2809     DTAPI_RESULT  GetSerialNumber(__int64 &SerialNumber);
2810     DTAPI_RESULT  SetRfOutLevel(int Level);
2811     DTAPI_RESULT  SetFreq(int Freq);
2812 
2813 private:
2814     DtaPlusDevice*  m_Dev;
2815 };
2816 
2817 // DTA-plus status codes
2818 #define DTAPI_DTAPLUS_STATUS_OFF              0  // DTA-Plus not ready for operation
2819 #define DTAPI_DTAPLUS_STATUS_ON               1  // DTA-Plus ready for operation
2820 #define DTAPI_DTAPLUS_STATUS_ATTN_FOLLOW_UP   2  // DTA-Plus attenuator ctrl following up
2821 #define DTAPI_DTAPLUS_STATUS_ATTN_FOLLOW_DOWN 3  //DTA-Plus attenuator ctrl following down
2822 #define DTAPI_DTAPLUS_STATUS_DAC_FOLLOW_UP    4  // DTA-Plus DAC control following up
2823 #define DTAPI_DTAPLUS_STATUS_DAC_FOLLOW_DOWN  5  // DTA-Plus DAC control following down
2824 #define DTAPI_DTAPLUS_STATUS_HOLD             6  // DTA-Plus has valid input signal
2825 #define DTAPI_DTAPLUS_STATUS_NO_SIGNAL        7  // DTA-Plus has no input signal
2826 #define DTAPI_DTAPLUS_STATUS_OVER_POWER       8  // DTA-Plus input signal is too high
2827 
2828 // DTA-plus temperature control states
2829 #define DTAPI_DTAPLUS_TEMP_CONTROL_OFF        0  // DTA-Plus temperature control is off
2830 #define DTAPI_DTAPLUS_TEMP_CONTROL_FAN_ON     1  // DTA-Plus fan is on
2831 #define DTAPI_DTAPLUS_TEMP_CONTROL_HEATER_ON  2  // DTA-Plus heater is on
2832 
2833 // Ethernet speed
2834 #define DTAPI_NWSPEED_AUTO          0            // Set
2835 #define DTAPI_NWSPEED_NOLIN         0            // Get
2836 #define DTAPI_NWSPEED_10MB_HALF     1
2837 #define DTAPI_NWSPEED_10MB_FULL     2
2838 #define DTAPI_NWSPEED_100MB_HALF    3
2839 #define DTAPI_NWSPEED_100MB_FULL    4
2840 #define DTAPI_NWSPEED_1GB_MASTER    5
2841 #define DTAPI_NWSPEED_1GB_SLAVE     6
2842 
2843 // Microcode upload states
2844 #define DTAPI_UCODE_NOT_LOADED      0
2845 #define DTAPI_UCODE_LOADING         1
2846 #define DTAPI_UCODE_LOADED          2
2847 
2848 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtInpChannel -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2849 //
2850 // Class to represent an input channel
2851 //
2852 class  DtInpChannel
2853 {
2854 public:
2855     DtInpChannel();
2856     virtual ~DtInpChannel();
2857 private:
2858     // No implementation is provided for the copy constructor
2859     DtInpChannel(const DtInpChannel&);
2860 
2861 public:
2862     DtHwFuncDesc  m_HwFuncDesc;     // Hardware function descriptor
2863 
2864     // Convenience functions
2865 public:
Category(void)2866     int  Category(void)         { return m_HwFuncDesc.m_DvcDesc.m_Category; }
FirmwareVersion(void)2867     int  FirmwareVersion(void)  { return m_HwFuncDesc.m_DvcDesc.m_FirmwareVersion; }
IsAttached(void)2868     bool  IsAttached(void)      { return m_pInp != NULL; }
TypeNumber(void)2869     int  TypeNumber(void)       { return m_HwFuncDesc.m_DvcDesc.m_TypeNumber; }
HasCaps(const DtCaps Caps)2870     bool  HasCaps(const DtCaps  Caps) const
2871     {
2872         return ((m_HwFuncDesc.m_Flags & Caps) == Caps);
2873     }
2874 
2875 public:
2876     DTAPI_RESULT  AttachToPort(DtDevice* pDtDvc, int Port,
2877                                                bool Exclusive=true, bool ProbeOnly=false);
2878     DTAPI_RESULT  BlindScan(int NumEntries, int& NumEntriesResult,
2879                               DtTransmitter* pScanResults, __int64 FreqHzSteps=10000000LL,
2880                               __int64 StartFreqHz=-1, __int64 EndFreqHz=-1);
2881     DTAPI_RESULT  BlindScan(DtBsProgressFunc* pCallback, void* pOpaque,
2882                                    const DtDemodPars& DemodPars,
2883                                    __int64 FreqHzSteps=10000000LL, __int64 StartFreqHz=-1,
2884                                    __int64 EndFreqHz=-1);
2885     DTAPI_RESULT  CancelBlindScan();
2886     DTAPI_RESULT  CancelSpectrumScan();
2887     DTAPI_RESULT  ClearFifo();
2888     DTAPI_RESULT  ClearFlags(int Latched);
2889     DTAPI_RESULT  Detach(int DetachMode);
2890     DTAPI_RESULT  DetectIoStd(int& Value, int& SubValue);
2891     DTAPI_RESULT  Equalise(int EqualiserSetting);
2892     DTAPI_RESULT  GetConstellationPoints(int NumPoints, DtConstelPoint* pPoint);
2893     DTAPI_RESULT  GetDemodControl(int& ModType,
2894                                              int& ParXtra0, int& ParXtra1, int& ParXtra2);
2895     DTAPI_RESULT  GetDemodControl(DtDemodPars* pDemodPars);
2896     DTAPI_RESULT  GetDescriptor(DtHwFuncDesc& HwFunDesc);
2897     DTAPI_RESULT  GetFifoLoad(int& FifoLoad);
2898     DTAPI_RESULT  GetFlags(int& Flags, int& Latched);
2899     DTAPI_RESULT  GetIoConfig(int Group, int& Value);
2900     DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue);
2901     DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue, __int64& ParXtra0);
2902     DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue,
2903                                                     __int64& ParXtra0, __int64& ParXtra1);
2904     DTAPI_RESULT  GetIpPars(DtIpPars* pIpPars);
2905     DTAPI_RESULT  GetIpPars(DtIpPars2* pIpPars);
2906     DTAPI_RESULT  GetIpStat(DtIpStat* pIpStat);
2907     DTAPI_RESULT  GetMaxFifoSize(int& MaxFifoSize);
2908     DTAPI_RESULT  GetPars(int Count, DtPar* pPars);
2909     DTAPI_RESULT  GetRxClkFreq(int& RxClkFreq);
2910     DTAPI_RESULT  GetRxControl(int& RxControl);
2911     DTAPI_RESULT  GetRxMode(int& RxMode);
2912     DTAPI_RESULT  GetStatistics(int Count, DtStatistic* pStatistics);
2913     DTAPI_RESULT  GetStatistic(int Type, int& Statistic);
2914     DTAPI_RESULT  GetStatistic(int Type, double& Statistic);
2915     DTAPI_RESULT  GetStatistic(int Type, bool& Statistic);
2916     DTAPI_RESULT  GetStatus(int& PacketSize, int& NumInv, int& ClkDet,
2917                                                   int& AsiLock, int& RateOk, int& AsiInv);
2918     DTAPI_RESULT  GetStreamSelection(DtAtsc3StreamSelPars& StreamSel);
2919     DTAPI_RESULT  GetStreamSelection(DtDabEtiStreamSelPars& StreamSel);
2920     DTAPI_RESULT  GetStreamSelection(DtDabStreamSelPars& StreamSel);
2921     DTAPI_RESULT  GetStreamSelection(DtDvbC2StreamSelPars& StreamSel);
2922     DTAPI_RESULT  GetStreamSelection(DtDvbTStreamSelPars& StreamSel);
2923     DTAPI_RESULT  GetStreamSelection(DtDvbT2StreamSelPars& StreamSel);
2924     DTAPI_RESULT  GetStreamSelection(DtIsdbtStreamSelPars& StreamSel);
2925     DTAPI_RESULT  GetStreamSelection(DtT2MiStreamSelPars& StreamSel);
2926     DTAPI_RESULT  GetSupportedStatistics(int& Count, DtStatistic* pStatistics);
2927     DTAPI_RESULT  GetTargetId(int& Present, int& TargetId);
2928     DTAPI_RESULT  GetTsRateBps(int& TsRate);
2929     DTAPI_RESULT  GetTunerFrequency(__int64& FreqHz, int TunerId=-1);
2930     DTAPI_RESULT  GetViolCount(int& ViolCount);
2931     DTAPI_RESULT  I2CLock(int TimeOut);
2932     DTAPI_RESULT  I2CUnlock(void);
2933     DTAPI_RESULT  I2CRead(int DvcAddr, char* pBuffer, int NumBytesToRead);
2934     DTAPI_RESULT  I2CWrite(int DvcAddr, char* pBuffer, int NumBytesToWrite);
2935     DTAPI_RESULT  I2CWriteRead(int DvcAddrWrite, char* pBufferWrite, int NumBytesToWrite,
2936                                   int DvcAddrRead, char* pBufferRead, int NumBytesToRead);
2937     DTAPI_RESULT  LedControl(int LedControl);
2938     DTAPI_RESULT  LnbEnable(bool Enable);
2939     DTAPI_RESULT  LnbEnableTone(bool Enable);
2940     DTAPI_RESULT  LnbSetVoltage(int Level);
2941     DTAPI_RESULT  LnbSendBurst(int BurstType);
2942     DTAPI_RESULT  LnbSendDiseqcMessage(const unsigned char* MsgOut, int NumBytesOut);
2943     DTAPI_RESULT  LnbSendDiseqcMessage(const unsigned char* MsgOut, int NumBytesOut,
2944                                                    unsigned char* MsgIn, int& NumBytesIn);
2945     DTAPI_RESULT  PolarityControl(int Polarity);
2946     DTAPI_RESULT  Read(char* pBuffer, int NumBytesToRead);
2947     DTAPI_RESULT  Read(char* pBuffer, int NumBytesToRead, int TimeOut);
2948     DTAPI_RESULT  ReadFrame(unsigned int* pFrame, int& FrameSize, int TimeOut=-1);
2949     DTAPI_RESULT  RegisterDemodCallback(IDtDemodEvent* pIEvent, __int64 Events=-1);
2950     DTAPI_RESULT  Reset(int ResetMode);
2951     DTAPI_RESULT  SetAdcSampleRate(int SampleRate);
2952     DTAPI_RESULT  SetAntPower(int AntPower);
2953     DTAPI_RESULT  SetDemodControl(int ModType, int ParXtra0, int ParXtra1, int ParXtra2);
2954     DTAPI_RESULT  SetDemodControl(DtDemodPars *pDemodPars);
2955     DTAPI_RESULT  SetErrorStatsMode(int ModType, int Mode);
2956     DTAPI_RESULT  SetFifoSize(int FifoSize);
2957     DTAPI_RESULT  SetIoConfig(int Group, int Value, int SubValue = -1,
2958                                             __int64 ParXtra0 = -1, __int64 ParXtra1 = -1);
2959     DTAPI_RESULT  SetIpPars(DtIpPars* pIpPars);
2960     DTAPI_RESULT  SetIpPars(DtIpPars2* pIpPars);
2961     DTAPI_RESULT  SetPars(int Count, DtPar* pPars);
2962     DTAPI_RESULT  SetRxControl(int RxControl);
2963     DTAPI_RESULT  SetRxMode(int RxMode);
2964     DTAPI_RESULT  SetStreamSelection(DtAtsc3StreamSelPars& StreamSel);
2965     DTAPI_RESULT  SetStreamSelection(DtDabEtiStreamSelPars& StreamSel);
2966     DTAPI_RESULT  SetStreamSelection(DtDabStreamSelPars& StreamSel);
2967     DTAPI_RESULT  SetStreamSelection(DtDvbC2StreamSelPars& StreamSel);
2968     DTAPI_RESULT  SetStreamSelection(DtDvbTStreamSelPars& StreamSel);
2969     DTAPI_RESULT  SetStreamSelection(DtDvbT2StreamSelPars& StreamSel);
2970     DTAPI_RESULT  SetStreamSelection(DtIsdbtStreamSelPars& StreamSel);
2971     DTAPI_RESULT  SetStreamSelection(DtT2MiStreamSelPars& StreamSel);
2972     DTAPI_RESULT  StatisticsPollingEnable(bool Enable);
2973     DTAPI_RESULT  SetTuningMode(int  Mode);
2974     DTAPI_RESULT  SetTunerFrequency(__int64 FreqHz, int TunerId=-1);
2975     DTAPI_RESULT  SpectrumScan(DtSpsProgressFunc* pCallback, void* pOpaque, int ScanType,
2976                                    __int64 FreqHzSteps=1000000LL, __int64 StartFreqHz=-1L,
2977                                    __int64 EndFreqHz=-1L);
2978     DTAPI_RESULT  Tune(__int64 FreqHz, int ModType,
2979                                                 int ParXtra0, int ParXtra1, int ParXtra2);
2980     DTAPI_RESULT  Tune(__int64 FreqHz, DtDemodPars *pDemodPars);
2981 
2982     // Encapsulated data
2983 private:
2984     IXpMutex*  m_pMTLock;           // Multi-threading lock for Get/Read functions
2985     void*  m_pDetachLockCount;
2986     int  m_Port;
2987     bool  m_WantToDetach;
2988 
2989 public:                             // TODOSD should be protected
2990     InpChannel*  m_pInp;            // Input channel implementation
2991 
2992 // Private helper functions
2993 private:
2994     DTAPI_RESULT  DetachLock(void);
2995     DTAPI_RESULT  DetachUnlock(void);
2996     DTAPI_RESULT  ReadAccessLock(void);
2997     DTAPI_RESULT  ReadAccessUnlock(void);
2998     DTAPI_RESULT  ReadWithTimeOut(char* pBuf, int NumBytesToRead, int TimeOut = -1);
2999 };
3000 
3001 // Tuner freq has changed
3002 #define DTAPI_EV_TUNE_FREQ_CHANGED  0x0000000000000001LL
3003 // Tuning parameters have changed
3004 #define DTAPI_EV_TUNE_PARS_CHANGED  0x0000000000000002LL
3005 
3006 #define DTAPI_ERRORSTATS_BER        0            // Bit error rate (default)
3007 #define DTAPI_ERRORSTATS_RS         1            // Reed-Solomon packet errors
3008 
3009 // Feature not supported
3010 #define DTAPI_NOT_SUPPORTED         -1
3011 
3012 // ASI Polarity-Control Status
3013 #define DTAPI_ASIINV_NORMAL         0
3014 #define DTAPI_ASIINV_INVERT         1
3015 
3016 // ASI Input-Clock Lock
3017 #define DTAPI_ASI_NOLOCK            0
3018 #define DTAPI_ASI_INLOCK            1
3019 
3020 // SDI Input-Clock Lock
3021 #define DTAPI_GENLOCK_NOLOCK        0
3022 #define DTAPI_GENLOCK_INLOCK        1
3023 
3024 // Clock Detector
3025 #define DTAPI_CLKDET_FAIL           0
3026 #define DTAPI_CLKDET_OK             1
3027 
3028 // Input Rate Ok
3029 #define DTAPI_INPRATE_LOW           0
3030 #define DTAPI_INPRATE_OK            1
3031 
3032 // #Invalid bytes per packet
3033 #define DTAPI_NUMINV_NONE           0
3034 #define DTAPI_NUMINV_16             1
3035 #define DTAPI_NUMINV_OTHER          2
3036 
3037 // Packet Size
3038 #define DTAPI_PCKSIZE_INV           0
3039 #define DTAPI_PCKSIZE_188           2
3040 #define DTAPI_PCKSIZE_204           3
3041 
3042 // SDI Mode
3043 #define DTAPI_SDIMODE_INV           0
3044 #define DTAPI_SDIMODE_525           1
3045 #define DTAPI_SDIMODE_625           2
3046 
3047 // Receive Control
3048 #define DTAPI_RXCTRL_IDLE           0
3049 #define DTAPI_RXCTRL_RCV            1
3050 
3051 // Receive mode for Transport Streams - Modes
3052 #define DTAPI_RXMODE_TS             0x10
3053 #define DTAPI_RXMODE_TS_MODE_BITS   0x0F
3054 #define DTAPI_RXMODE_ST188          (DTAPI_RXMODE_TS | 0x01)
3055 #define DTAPI_RXMODE_ST204          (DTAPI_RXMODE_TS | 0x02)
3056 #define DTAPI_RXMODE_STMP2          (DTAPI_RXMODE_TS | 0x03)
3057 #define DTAPI_RXMODE_STRAW          (DTAPI_RXMODE_TS | 0x04)
3058 #define DTAPI_RXMODE_STL3           (DTAPI_RXMODE_TS | 0x05)
3059 #define DTAPI_RXMODE_STL3FULL       (DTAPI_RXMODE_TS | 0x06)
3060 #define DTAPI_RXMODE_IPRAW          (DTAPI_RXMODE_TS | 0x07)
3061 #define DTAPI_RXMODE_RAWASI         (DTAPI_RXMODE_TS | 0x08)
3062 #define DTAPI_RXMODE_STTRP          (DTAPI_RXMODE_TS | 0x09)
3063 #define DTAPI_RXMODE_TS_MASK        (DTAPI_RXMODE_TS | DTAPI_RXMODE_TS_MODE_BITS)
3064 
3065 // Receive mode for SDI - Modes
3066 #define DTAPI_RXMODE_SDI            0x1000
3067 #define DTAPI_RXMODE_SDI_MODE_BITS  0x0F00
3068 #define DTAPI_RXMODE_SDI_FULL       (DTAPI_RXMODE_SDI | 0x100)
3069 #define DTAPI_RXMODE_SDI_ACTVID     (DTAPI_RXMODE_SDI | 0x200)
3070 #define DTAPI_RXMODE_SDI_MASK       (DTAPI_RXMODE_SDI | DTAPI_RXMODE_SDI_MODE_BITS)
3071 // Receive mode for SDI - Flags
3072 #define DTAPI_RXMODE_SDI_HUFFMAN    0x00002000
3073 #define DTAPI_RXMODE_SDI_10B        0x00004000
3074 #define DTAPI_RXMODE_SDI_16B        0x00008000
3075 #define DTAPI_RXMODE_SDI_10B_NBO    0x00010000
3076 #define DTAPI_RXMODE_SDI_STAT       0x00020000
3077 
3078 // Receive mode for SDI and Transport Streams - Common flags
3079 #define DTAPI_RXMODE_TIMESTAMP32    0x01000000
3080 #define DTAPI_RXMODE_TIMESTAMP64    0x02000000
3081 
3082 // Demodulation status flags - FEC lock
3083 #define DTAPI_DEMOD_FECLOCK_FAIL    0
3084 #define DTAPI_DEMOD_FECLOCK_OK      1
3085 // Demodulation status flags - Receiver lock
3086 #define DTAPI_DEMOD_RCVLOCK_FAIL    0
3087 #define DTAPI_DEMOD_RCVLOCK_OK      1
3088 
3089 // Channel bands
3090 #define DTAPI_BAND_BROADCAST_ONAIR  1
3091 #define DTAPI_BAND_FCC_CABLE        2
3092 #define DTAPI_BAND_IRC              3
3093 #define DTAPI_BAND_HRC              4
3094 
3095 // RF level bandwith
3096 #define DTAPI_RFLVL_CHANNEL         0
3097 #define DTAPI_RFLVL_NARROWBAND      1
3098 
3099 // ADC sampling rates
3100 #define DTAPI_ADCCLK_OFF            0            // Clock is off
3101 #define DTAPI_ADCCLK_20M647         20647059     // 20.647059 MHz clock
3102 #define DTAPI_ADCCLK_13M5           13500000     // 13.5 MHz clock
3103 #define DTAPI_ADCCLK_27M            27000000     // 27.0 MHz clock
3104 
3105 // LNB control values
3106 #define DTAPI_LNB_13V               0            // LNB power 13V
3107 #define DTAPI_LNB_18V               1            // LNB power 18V
3108 #define DTAPI_LNB_14V               2            // LNB power 14V
3109 #define DTAPI_LNB_19V               3            // LNB power 19V
3110 
3111 // LNB burst types
3112 #define DTAPI_LNB_BURST_A           0            // Burst A
3113 #define DTAPI_LNB_BURST_B           1            // Burst B
3114 
3115 // Tuner Parameters - Tuner standard
3116 #define DTAPI_TUNMOD_QAM            0x1
3117 #define DTAPI_TUNMOD_ATSC           0x2
3118 #define DTAPI_TUNMOD_ISDBT          0x3
3119 #define DTAPI_TUNMOD_DVBT           0x4
3120 #define DTAPI_TUNMOD_DMBT           0x5
3121 
3122 // Tuner Parameters - DTA-2131 specific - Value for automatic computation of parameters
3123 #define DTAPI_TUN31_AUTO            -1           // According to tuner standard
3124 
3125 // Tuner Parameters - DTA-2131 specific - Low-pass filter cutoff frequency
3126 #define DTAPI_TUN31_LPF_1_5MHZ      0            // 1.5 MHz low-pass filter
3127 #define DTAPI_TUN31_LPF_6MHZ        1            // 6 MHz low-pass filter
3128 #define DTAPI_TUN31_LPF_7MHZ        2            // 7 MHz low-pass filter
3129 #define DTAPI_TUN31_LPF_8MHZ        3            // 8 MHz low-pass filter
3130 #define DTAPI_TUN31_LPF_9MHZ        4            // 9 MHz low-pass filter
3131 
3132 // Tuner Parameters - DTA-2131 specific -  Low-pass filter offset
3133 #define DTAPI_TUN31_LPF_0PCT        0            // 0% low-pass filter offset
3134 #define DTAPI_TUN31_LPF_4PCT        1            // 4% low-pass filter offset
3135 #define DTAPI_TUN31_LPF_8PCT        2            // 8% low-pass filter offset
3136 #define DTAPI_TUN31_LPF_12PCT       3            // 12% low-pass filter offset
3137 
3138 // Tuner Parameters - DTA-2131 specific - IF hi-pass filter
3139 #define DTAPI_TUN31_HPF_DIS         0            // Disabled IF hi-pass filter
3140 #define DTAPI_TUN31_HPF_0_4MHZ      1            // 0.4 MHz IF hi-pass filter
3141 #define DTAPI_TUN31_HPF_0_85MHZ     2            // 0.85 MHz IF hi-pass filter
3142 #define DTAPI_TUN31_HPF_1MHZ        3            // 1 MHz IF hi-pass filter
3143 #define DTAPI_TUN31_HPF_1_5MHZ      4            // 1.5 MHz IF hi-pass filter
3144 
3145 // Tuner Parameters - DTA-2131 specific - Notch settings
3146 #define DTAPI_TUN31_NOTCH_DIS       0            // Disable
3147 #define DTAPI_TUN31_NOTCH_ENA       1            // Enable
3148 
3149 // Tuner Parameters - DTA-2139 specific - Agc specific
3150 #define DTAPI_AGC1_FREE             0
3151 #define DTAPI_AGC1_FROZEN           1
3152 
3153 // Tuning mode - DTU-236A/238 specific
3154 #define DTAPI_TUNING_NORMAL         0           // Standard tuning mode
3155 #define DTAPI_TUNING_INDEPENDENT    1           // Multiple tuners, tuned independently
3156 
3157 // Tuner ID - DTU-236A/238 specific
3158 #define DTAPI_TUNERID_ALL           -1          // ID for all tuners
3159 #define DTAPI_TUNERID_MAIN          0           // ID for main tuner
3160 #define DTAPI_TUNERID_MEASUREMENT   1           // ID for measurement tuner
3161 
3162 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtOutpChannel -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
3163 //
3164 // Class to represent a transport-stream or SDI output channel
3165 //
3166 class DtOutpChannel
3167 {
3168 public:
3169     DtOutpChannel();
3170     virtual ~DtOutpChannel();
3171 private:
3172     // No implementation is provided for the copy constructor
3173     DtOutpChannel(const DtOutpChannel&);
3174 
3175 public:
3176     DtHwFuncDesc  m_HwFuncDesc;     // Hardware function descriptor
3177 
3178     // Convenience functions
3179 public:
Category(void)3180     int  Category(void)         { return m_HwFuncDesc.m_DvcDesc.m_Category; }
FirmwareVersion(void)3181     int  FirmwareVersion(void)  { return m_HwFuncDesc.m_DvcDesc.m_FirmwareVersion; }
IsAttached(void)3182     bool  IsAttached(void)      { return m_pOutp != NULL; }
TypeNumber(void)3183     int  TypeNumber(void)       { return m_HwFuncDesc.m_DvcDesc.m_TypeNumber; }
HasCaps(const DtCaps Caps)3184     bool  HasCaps(const DtCaps  Caps) const
3185     {
3186         return ((m_HwFuncDesc.m_Flags & Caps) == Caps);
3187     }
3188 
3189 public:
3190     virtual DTAPI_RESULT  AttachToPort(DtDevice* pDtDvc, int Port, bool ProbeOnly=false);
3191     virtual DTAPI_RESULT  ClearFifo(void);
3192     virtual DTAPI_RESULT  ClearFlags(int Latched);
3193     virtual DTAPI_RESULT  ClearSfnErrors();
3194     virtual DTAPI_RESULT  Detach(int DetachMode);
3195     virtual DTAPI_RESULT  GetAttribute(int AttrId, int& AttrValue);
3196     virtual DTAPI_RESULT  GetAttribute(int AttrId, DtModPars& ModParVals, int& AttrValue);
3197     virtual DTAPI_RESULT  GetDescriptor(DtHwFuncDesc& HwFunDesc);
3198     virtual DTAPI_RESULT  GetExtClkFreq(int& ExtClkFreq);
3199     virtual DTAPI_RESULT  GetFailsafeAlive(bool& Alive);
3200     virtual DTAPI_RESULT  GetFailsafeConfig(bool& Enable, int& Timeout);
3201     virtual DTAPI_RESULT  GetFifoLoad(int& FifoLoad, int SubChan=0);
3202     virtual DTAPI_RESULT  GetFifoSize(int& FifoSize);
3203     virtual DTAPI_RESULT  GetFifoSizeMax(int& FifoSizeMax);
3204     virtual DTAPI_RESULT  GetFifoSizeTyp(int& FifoSizeTyp);
3205     virtual DTAPI_RESULT  GetFlags(int& Status, int& Latched);
3206     virtual DTAPI_RESULT  GetIoConfig(int Group, int& Value);
3207     virtual DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue);
3208     virtual DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue,
3209                                                                        __int64& ParXtra0);
3210     virtual DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue,
3211                                                     __int64& ParXtra0, __int64& ParXtra1);
3212     virtual DTAPI_RESULT  GetIpPars(DtIpPars* pIpPars);
3213     virtual DTAPI_RESULT  GetIpPars(DtIpPars2* pIpPars);
3214     virtual DTAPI_RESULT  GetMaxFifoSize(int& MaxFifoSize);
3215     virtual DTAPI_RESULT  GetModControl(int& ModType, int& ParXtra0, int& ParXtra1,
3216                                                          int& ParXtra2, void*& pXtraPars);
3217     virtual DTAPI_RESULT  GetOutputLevel(int& LeveldBm);
3218     virtual DTAPI_RESULT  GetRfControl(__int64& RfFreq, int& LockStatus);
3219     virtual DTAPI_RESULT  GetRfControl(int& RfFreq, int& LockStatus);
3220     virtual DTAPI_RESULT  GetRfControl(double& RfFreq, int& LockStatus);
3221     virtual DTAPI_RESULT  GetSfnMaxTimeDiff(int& TimeDiff);
3222     virtual DTAPI_RESULT  GetSfnModDelay(int& ModDelay);
3223     virtual DTAPI_RESULT  GetSfnStatus(int& Status, int& Error);
3224     virtual DTAPI_RESULT  GetSpiClk(int& SpiClk);
3225     virtual DTAPI_RESULT  GetTargetId(int& Present, int& TargetId);
3226     virtual DTAPI_RESULT  GetTsRateBps(int& TsRate);
3227     virtual DTAPI_RESULT  GetTsRateBps(DtFractionInt& TsRate);
3228     virtual DTAPI_RESULT  GetTxControl(int& TxControl);
3229     virtual DTAPI_RESULT  GetTxMode(int& TxMode, int& TxStuffMode);
3230     virtual DTAPI_RESULT  LedControl(int LedControl);
3231     virtual DTAPI_RESULT  Reset(int ResetMode);
3232     virtual DTAPI_RESULT  SetChannelModelling(bool CmEnable, DtCmPars& CmPars);
3233     virtual DTAPI_RESULT  SetCustomRollOff(bool Enable, DtFilterPars& Filter);
3234     virtual DTAPI_RESULT  SetFailsafeAlive();
3235     virtual DTAPI_RESULT  SetFailsafeConfig(bool Enable, int Timeout = 0);
3236     virtual DTAPI_RESULT  SetFifoSize(int FifoSize);
3237     virtual DTAPI_RESULT  SetFifoSizeMax(void);
3238     virtual DTAPI_RESULT  SetFifoSizeTyp(void);
3239     virtual DTAPI_RESULT  SetIoConfig(int Group, int Value, int SubValue = -1,
3240                                             __int64 ParXtra0 = -1, __int64 ParXtra1 = -1);
3241     virtual DTAPI_RESULT  SetIpPars(DtIpPars* pIpPars);
3242     virtual DTAPI_RESULT  SetIpPars(DtIpPars2* pIpPars);
3243     virtual DTAPI_RESULT  SetIsdbtCaptFile(void* IsdbtFile);
3244     virtual DTAPI_RESULT  SetModControl(DtAtsc3Pars&);
3245     virtual DTAPI_RESULT  SetModControl(DtCmmbPars&);
3246     virtual DTAPI_RESULT  SetModControl(DtDvbC2Pars&);
3247     virtual DTAPI_RESULT  SetModControl(DtDvbCidPars&);
3248     virtual DTAPI_RESULT  SetModControl(DtDvbS2Pars&);
3249     virtual DTAPI_RESULT  SetModControl(DtDvbT2Pars&);
3250     virtual DTAPI_RESULT  SetModControl(DtIqDirectPars&);
3251     virtual DTAPI_RESULT  SetModControl(DtIsdbsPars&);
3252     virtual DTAPI_RESULT  SetModControl(DtIsdbS3Pars&);
3253     virtual DTAPI_RESULT  SetModControl(DtIsdbtPars&);
3254     virtual DTAPI_RESULT  SetModControl(DtIsdbTmmPars&);
3255     virtual DTAPI_RESULT  SetModControl(int ModType, int ParXtra0, int ParXtra1,
3256                                                                             int ParXtra2);
3257     virtual DTAPI_RESULT  SetModControl(unsigned char*);
3258     virtual DTAPI_RESULT  SetMultiModConfig(int NumSubChan, int FreqSpacing);
3259     virtual DTAPI_RESULT  SetOutputLevel(int LeveldBm);
3260     virtual DTAPI_RESULT  SetPhaseNoiseControl(DtPhaseNoisePars& PnPars);
3261     virtual DTAPI_RESULT  SetPower(int Power);
3262     virtual DTAPI_RESULT  SetRfControl(__int64 RfFreq);
3263     virtual DTAPI_RESULT  SetRfControl(double RfFreq);
3264     virtual DTAPI_RESULT  SetRfControl(int RfFreq);
3265     virtual DTAPI_RESULT  SetRfMode(int RfMode);
3266     virtual DTAPI_RESULT  SetRfMode(int Sel, int Mode);
3267     virtual DTAPI_RESULT  SetSfnAllowedTimeDiff(int TimeDiff);
3268     virtual DTAPI_RESULT  SetSfnControl(int SnfMode, int TimeOffset);
3269     virtual DTAPI_RESULT  SetSnr(int Mode, int Snr);
3270     virtual DTAPI_RESULT  SetSpiClk(int SpiClk);
3271     virtual DTAPI_RESULT  SetTsRateBps(int TsRate);
3272     virtual DTAPI_RESULT  SetTsRateBps(DtFractionInt TsRate);
3273     virtual DTAPI_RESULT  SetTsRateRatio(int TsRate, int ClockRef);
3274     virtual DTAPI_RESULT  SetTxControl(int TxControl);
3275     virtual DTAPI_RESULT  SetTxMode(int TxMode, int StuffMode);
3276     virtual DTAPI_RESULT  SetTxPolarity(int TxPolarity);
3277     virtual DTAPI_RESULT  Write(char* pBuffer, int NumBytesToWrite, int SubChan=0);
3278     // Undocumented
3279     virtual DTAPI_RESULT  GetModBufLoads(bool&, int&, int&, int&);
3280 
3281 public:                             // TODOSD should be protected
3282     OutpChannel*  m_pOutp;          // Output channel implementation
3283 
3284 private:
3285     void*  m_pDetachLockCount;
3286     bool  m_WantToDetach;
3287     DTAPI_RESULT  DetachLock(void);
3288     DTAPI_RESULT  DetachUnlock(void);
3289 };
3290 
3291 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtMplpOutpChannel -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
3292 //
3293 class DtMplpOutpChannel : public DtOutpChannel
3294 {
3295 public:
3296     DtMplpOutpChannel();
3297     virtual ~DtMplpOutpChannel();
3298 private:
3299     // No implementation is provided for the copy constructor
3300     DtMplpOutpChannel(const DtMplpOutpChannel&);
3301 
3302 public:
3303     virtual bool IsAttached(void);
3304 
3305 public:
3306     virtual DTAPI_RESULT  AttachToPort(DtDevice* pDtDvc, int Port, bool ProbeOnly=false);
3307     virtual DTAPI_RESULT  ClearFifo(void);
3308     virtual DTAPI_RESULT  ClearFlags(int Latched);
3309     virtual DTAPI_RESULT  ClearSfnErrors();
3310     virtual DTAPI_RESULT  Detach(int DetachMode);
3311     virtual DTAPI_RESULT  GetAttribute(int AttrId, int& AttrValue);
3312     virtual DTAPI_RESULT  GetAttribute(int AttrId, DtModPars& ModParVals, int& AttrValue);
3313     virtual DTAPI_RESULT  GetDescriptor(DtHwFuncDesc& HwFunDesc);
3314     virtual DTAPI_RESULT  GetExtClkFreq(int& ExtClkFreq);
3315     virtual DTAPI_RESULT  GetFailsafeAlive(bool& Alive);
3316     virtual DTAPI_RESULT  GetFailsafeConfig(bool& Enable, int& Timeout);
3317     virtual DTAPI_RESULT  GetFifoLoad(int& FifoLoad, int SubChan=0);
3318     virtual DTAPI_RESULT  GetFifoSize(int& FifoSize);
3319     virtual DTAPI_RESULT  GetFifoSizeMax(int& FifoSizeMax);
3320     virtual DTAPI_RESULT  GetFifoSizeTyp(int& FifoSizeTyp);
3321     virtual DTAPI_RESULT  GetFlags(int& Status, int& Latched);
3322     virtual DTAPI_RESULT  GetIoConfig(int Group, int& Value);
3323     virtual DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue);
3324     virtual DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue,
3325                                                                        __int64& ParXtra0);
3326     virtual DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue,
3327                                                     __int64& ParXtra0, __int64& ParXtra1);
3328     virtual DTAPI_RESULT  GetIpPars(DtIpPars* pIpPars);
3329     virtual DTAPI_RESULT  GetMaxFifoSize(int& MaxFifoSize);
3330     virtual DTAPI_RESULT  GetModControl(int& ModType, int& CodeRate,
3331                                           int& ParXtra1, int& ParXtra2, void*& pXtraPars);
3332     virtual DTAPI_RESULT  GetOutputLevel(int& LeveldBm);
3333     virtual DTAPI_RESULT  GetRfControl(__int64& RfFreq, int& LockStatus);
3334     virtual DTAPI_RESULT  GetRfControl(int& RfFreq, int& LockStatus);
3335     virtual DTAPI_RESULT  GetRfControl(double& RfFreq, int& LockStatus);
3336     virtual DTAPI_RESULT  GetSfnMaxTimeDiff(int& TimeDiff);
3337     virtual DTAPI_RESULT  GetSfnModDelay(int& ModDelay);
3338     virtual DTAPI_RESULT  GetSfnStatus(int& Status, int& Error);
3339     virtual DTAPI_RESULT  GetSpiClk(int& SpiClk);
3340     virtual DTAPI_RESULT  GetTargetId(int& Present, int& TargetId);
3341     virtual DTAPI_RESULT  GetTsRateBps(int& TsRate);
3342     virtual DTAPI_RESULT  GetTsRateBps(DtFractionInt& TsRate);
3343     virtual DTAPI_RESULT  GetTxControl(int& TxControl);
3344     virtual DTAPI_RESULT  GetTxMode(int& TxMode, int& TxStuffMode);
3345     virtual DTAPI_RESULT  LedControl(int LedControl);
3346     virtual DTAPI_RESULT  Reset(int ResetMode);
3347     virtual DTAPI_RESULT  SetChannelModelling(bool CmEnable, DtCmPars& CmPars);
3348     virtual DTAPI_RESULT  SetCustomRollOff(bool Enable, DtFilterPars& Filter);
3349 
3350     virtual DTAPI_RESULT  SetFailsafeConfig(bool Enable, int Timeout = 0);
3351     virtual DTAPI_RESULT  SetFailsafeAlive();
3352     virtual DTAPI_RESULT  SetFifoSize(int FifoSize);
3353     virtual DTAPI_RESULT  SetFifoSizeMax(void);
3354     virtual DTAPI_RESULT  SetFifoSizeTyp(void);
3355     virtual DTAPI_RESULT  SetIoConfig(int Group, int Value, int SubValue = -1,
3356                                             __int64 ParXtra0 = -1, __int64 ParXtra1 = -1);
3357     virtual DTAPI_RESULT  SetIpPars(DtIpPars* pIpPars);
3358     virtual DTAPI_RESULT  SetIpPars(DtIpPars2* pIpPars);
3359     virtual DTAPI_RESULT  SetIsdbtCaptFile(void* IsdbtFile);
3360     virtual DTAPI_RESULT  SetModControl(DtAtsc3Pars&);
3361     virtual DTAPI_RESULT  SetModControl(DtCmmbPars&);
3362     virtual DTAPI_RESULT  SetModControl(DtDvbC2Pars&);
3363     virtual DTAPI_RESULT  SetModControl(DtDvbCidPars&);
3364     virtual DTAPI_RESULT  SetModControl(DtDvbS2Pars&);
3365     virtual DTAPI_RESULT  SetModControl(DtDvbT2Pars&);
3366     virtual DTAPI_RESULT  SetModControl(DtIqDirectPars&);
3367     virtual DTAPI_RESULT  SetModControl(DtIsdbsPars&);
3368     virtual DTAPI_RESULT  SetModControl(DtIsdbS3Pars&);
3369     virtual DTAPI_RESULT  SetModControl(DtIsdbtPars&);
3370     virtual DTAPI_RESULT  SetModControl(DtIsdbTmmPars&);
3371     virtual DTAPI_RESULT  SetModControl(int ModType, int ParXtra0, int ParXtra1,
3372                                                                             int ParXtra2);
3373     virtual DTAPI_RESULT  SetModControl(unsigned char*);
3374     virtual DTAPI_RESULT  SetMultiModConfig(int NumSubChan, int FreqSpacing);
3375     virtual DTAPI_RESULT  SetOutputLevel(int LeveldBm);
3376     virtual DTAPI_RESULT  SetPhaseNoiseControl(DtPhaseNoisePars& PnPars);
3377     virtual DTAPI_RESULT  SetPower(int Power);
3378     virtual DTAPI_RESULT  SetRfControl(__int64 RfFreq);
3379     virtual DTAPI_RESULT  SetRfControl(double RfFreq);
3380     virtual DTAPI_RESULT  SetRfControl(int RfFreq);
3381     virtual DTAPI_RESULT  SetRfMode(int RfMode);
3382     virtual DTAPI_RESULT  SetRfMode(int Sel, int Mode);
3383     virtual DTAPI_RESULT  SetSfnAllowedTimeDiff(int TimeDiff);
3384     virtual DTAPI_RESULT  SetSfnControl(int SnfMode, int TimeOffset);
3385     virtual DTAPI_RESULT  SetSnr(int Mode, int Snr);
3386     virtual DTAPI_RESULT  SetSpiClk(int SpiClk);
3387     virtual DTAPI_RESULT  SetTsRateBps(int TsRate);
3388     virtual DTAPI_RESULT  SetTsRateBps(DtFractionInt TsRate);
3389     virtual DTAPI_RESULT  SetTsRateRatio(int TsRate, int ClockRef);
3390     virtual DTAPI_RESULT  SetTxControl(int TxControl);
3391     virtual DTAPI_RESULT  SetTxMode(int TxMode, int TxStuffMode);
3392     virtual DTAPI_RESULT  SetTxPolarity(int TxPolarity);
3393     virtual DTAPI_RESULT  Write(char* pBuffer, int NumBytesToWrite, int SubChan=0);
3394     // Undocumented
3395     virtual DTAPI_RESULT  GetModBufLoads(bool&, int&, int&, int&);
3396 
3397     // IMplpModulator interface implementation
3398 public:
3399     virtual DTAPI_RESULT  AttachVirtual(DtDevice* pDtDvc,
3400                                   bool (*pFunc)(void*, DtVirtualOutData*), void* pOpaque);
3401     virtual DTAPI_RESULT  GetMplpFifoFree(int FifoIdx, int& FifoFree);
3402     virtual DTAPI_RESULT  GetMplpFifoLoad(int FifoIdx, int& FifoLoad);
3403     virtual DTAPI_RESULT  GetMplpFifoSize(int FifoIdx, int& FifoSize);
3404     virtual DTAPI_RESULT  GetMplpModStatus(DtDvbC2ModStatus* pMplpModStat);
3405     virtual DTAPI_RESULT  GetMplpModStatus(DtDvbS2ModStatus* pMplpModStat);
3406     virtual DTAPI_RESULT  GetMplpModStatus(DtDvbT2ModStatus* pMplpModStat);
3407     virtual DTAPI_RESULT  GetMplpModStatus(DtDvbT2ModStatus* pMplpModStat1,
3408                                                          DtDvbT2ModStatus* pMplpModStat2);
3409     virtual DTAPI_RESULT  SetMplpChannelModelling(bool CmEnable, DtCmPars&, int Chan=0);
3410     virtual DTAPI_RESULT  WriteMplp(int FifoIdx, char* pBuffer, int NumBytesToWrite);
3411     virtual DTAPI_RESULT  WriteMplpPacket(int FifoIdx, char* pPacket, int PacketSize);
3412     virtual DTAPI_RESULT  WriteMplpPacket(int FifoIdx, char* pPacket, int PacketSize,
3413                                                                  DtFractionInt  Duration);
3414 private:
3415     bool  m_IsAttachedToVirtual;
3416     MplpHelper*  m_pMplpHelper;
3417 };
3418 
3419 // Detach mode flags
3420 #define DTAPI_INSTANT_DETACH        1
3421 #define DTAPI_WAIT_UNTIL_SENT       2
3422 
3423 // Equaliser settings
3424 #define DTAPI_EQUALISER_OFF         0
3425 #define DTAPI_EQUALISER_ON          1
3426 
3427 // LED control
3428 #define DTAPI_LED_OFF               0
3429 #define DTAPI_LED_GREEN             1
3430 #define DTAPI_LED_RED               2
3431 #define DTAPI_LED_YELLOW            3
3432 #define DTAPI_LED_BLUE              4
3433 #define DTAPI_LED_HARDWARE          5
3434 
3435 // Noise modes
3436 #define DTAPI_NOISE_DISABLED        0            // No noise generation
3437 #define DTAPI_NOISE_WNG_HW          1            // White noise generator (hardware)
3438 
3439 // Polarity control
3440 #define DTAPI_POLARITY_AUTO         0
3441 #define DTAPI_POLARITY_NORMAL       2
3442 #define DTAPI_POLARITY_INVERT       3
3443 
3444 // Power mode
3445 #define DTAPI_POWER_OFF             0
3446 #define DTAPI_POWER_ON              1
3447 
3448 // Reset mode
3449 #define DTAPI_FIFO_RESET            0
3450 #define DTAPI_FULL_RESET            1
3451 
3452 // RF PLL lock status
3453 #define DTAPI_RFPLL_LOCK1           1            // RF PLL #1 is in lock
3454 #define DTAPI_RFPLL_LOCK2           2            // RF PLL #2 is in lock
3455 #define DTAPI_RFPLL_LOCK3           4            // RF PLL #3 is in lock
3456 
3457 // Receiver status flags
3458 #define DTAPI_RX_FIFO_OVF           0x0002
3459 #define DTAPI_RX_SYNC_ERR           0x0004
3460 #define DTAPI_RX_RATE_OVF           0x0008
3461 #define DTAPI_RX_TARGET_ERR         0x0010
3462 #define DTAPI_RX_LINK_ERR           0x0040
3463 #define DTAPI_RX_DATA_ERR           0x0080
3464 #define DTAPI_RX_DRV_BUF_OVF        0x0100
3465 #define DTAPI_RX_SYNTAX_ERR         0x0200
3466 
3467 // Single Frequency Network status andd error flags
3468 #define DTAPI_SFN_IN_SYNC           0x0001
3469 #define DTAPI_SFN_TOO_EARLY_ERR     0x0001
3470 #define DTAPI_SFN_TOO_LATE_ERR      0x0002
3471 #define DTAPI_SFN_ABSTIME_ERR       0x0004
3472 #define DTAPI_SFN_DISCTIME_ERR      0x0008
3473 #define DTAPI_SFN_NOTIME_ERR        0x0010
3474 #define DTAPI_SFN_START_ERR         0x0020
3475 
3476 // Single Frequency operation mode
3477 #define DTAPI_SFN_MODE_DISABLED     0x0000
3478 #define DTAPI_SFN_MODE_AT_1PPS      0x0001
3479 #define DTAPI_SFN_MODE_IQPCK        0x0002
3480 #define DTAPI_SFN_MODE_DVBT_MIP     0x0003
3481 #define DTAPI_SFN_MODE_T2MI         0x0004
3482 
3483 // Transmit status flags
3484 #define DTAPI_TX_FIFO_UFL           0x0002
3485 #define DTAPI_TX_SYNC_ERR           0x0004
3486 #define DTAPI_TX_READBACK_ERR       0x0008
3487 #define DTAPI_TX_TARGET_ERR         0x0010
3488 #define DTAPI_TX_MUX_OVF            0x0020
3489 #define DTAPI_TX_FIFO_OVF           0x0020
3490 #define DTAPI_TX_LINK_ERR           0x0040
3491 #define DTAPI_TX_DATA_ERR           0x0080
3492 #define DTAPI_TX_CPU_UFL            0x0100
3493 #define DTAPI_TX_DMA_UFL            0x0200
3494 
3495 // Target adapter present
3496 #define DTAPI_NO_CONNECTION         0
3497 #define DTAPI_DVB_SPI_SINK          1            // For output channels
3498 #define DTAPI_DVB_SPI_SOURCE        1            // For input channels
3499 #define DTAPI_TARGET_PRESENT        2
3500 #define DTAPI_TARGET_UNKNOWN        3
3501 
3502 // Transmit control
3503 #define DTAPI_TXCTRL_IDLE           1
3504 #define DTAPI_TXCTRL_HOLD           2
3505 #define DTAPI_TXCTRL_SEND           3
3506 
3507 // Transmit mode for Transport Streams - Modes
3508 #define DTAPI_TXMODE_TS             0x10
3509 #define DTAPI_TXMODE_TS_MODE_BITS   0x0F
3510 #define DTAPI_TXMODE_188            (DTAPI_TXMODE_TS | 0x01)
3511 #define DTAPI_TXMODE_192            (DTAPI_TXMODE_TS | 0x02)
3512 #define DTAPI_TXMODE_204            (DTAPI_TXMODE_TS | 0x03)
3513 #define DTAPI_TXMODE_ADD16          (DTAPI_TXMODE_TS | 0x04)
3514 #define DTAPI_TXMODE_MIN16          (DTAPI_TXMODE_TS | 0x05)
3515 #define DTAPI_TXMODE_IPRAW          (DTAPI_TXMODE_TS | 0x06)
3516 #define DTAPI_TXMODE_RAW            (DTAPI_TXMODE_TS | 0x07)
3517 #define DTAPI_TXMODE_RAWASI         (DTAPI_TXMODE_TS | 0x08)
3518 #define DTAPI_TXMODE_TS_MASK        (DTAPI_TXMODE_TS | DTAPI_TXMODE_TS_MODE_BITS)
3519 // Transmit mode for Transport Streams - DVB-ASI flags
3520 #define DTAPI_TXMODE_BURST          0x20
3521 #define DTAPI_TXMODE_TXONTIME       0x40
3522 
3523 // Transmit mode for SDI - Modes
3524 #define DTAPI_TXMODE_SDI            0x1000
3525 #define DTAPI_TXMODE_SDI_MODE_BITS  0x0F00
3526 #define DTAPI_TXMODE_SDI_FULL       (DTAPI_TXMODE_SDI | 0x100)
3527 #define DTAPI_TXMODE_SDI_ACTVID     (DTAPI_TXMODE_SDI | 0x200)
3528 #define DTAPI_TXMODE_SDI_MASK       (DTAPI_TXMODE_SDI | DTAPI_TXMODE_SDI_MODE_BITS)
3529 // Transmit mode for SDI - Flags
3530 #define DTAPI_TXMODE_SDI_HUFFMAN    0x00002000
3531 #define DTAPI_TXMODE_SDI_10B        0x00004000
3532 #define DTAPI_TXMODE_SDI_16B        0x00008000
3533 #define DTAPI_TXMODE_SDI_10B_NBO    0x00010000
3534 
3535 // Stuff mode - TS : Null-packet stuffing on/off; SDI: Black-frame stuffing on/off
3536 #define DTAPI_TXSTUFF_MODE_OFF      0
3537 #define DTAPI_TXSTUFF_MODE_ON       1
3538 
3539 // Transmit polarity
3540 #define DTAPI_TXPOL_NORMAL          0
3541 #define DTAPI_TXPOL_INVERTED        1
3542 
3543 // Upconverter RF modes
3544 #define DTAPI_UPCONV_MODE           0            // Selects NORMAL/MUTE/CW/CWI/CWQ
3545 #define DTAPI_UPCONV_MODE_MSK       0xF          // Mask for mode field
3546 #define DTAPI_UPCONV_NORMAL         0
3547 #define DTAPI_UPCONV_MUTE           1
3548 #define DTAPI_UPCONV_CW             2
3549 #define DTAPI_UPCONV_CWI            3
3550 #define DTAPI_UPCONV_CWQ            4
3551 #define DTAPI_UPCONV_SPECINV        0x100        // Can be OR-ed with other RF modes
3552 
3553 // USB speed modes
3554 #define DTAPI_USB_FULL_SPEED        0
3555 #define DTAPI_USB_HIGH_SPEED        1
3556 #define DTAPI_USB_SUPER_SPEED       2
3557 
3558 // PCIe standards
3559 #define DTAPI_PCIE_GEN_UNKNOWN      0       // PCIe Gen is unknown
3560 #define DTAPI_PCIE_GEN1             1       // PCIe Gen 1 (2.5Gbps per link)
3561 #define DTAPI_PCIE_GEN2             2       // PCIe Gen 2 (5.0Gbps per link)
3562 #define DTAPI_PCIE_GEN3             3       // PCIe Gen 3 (8.0Gbps per link)
3563 
3564 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- Modulation Parameters -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
3565 
3566 // Modulation types
3567 #define DTAPI_MOD_DVBS_QPSK         0            // Native DVB-S on DTA-107
3568 #define DTAPI_MOD_DVBS_BPSK         1
3569 #define DTAPI_MOD_QAM4              3
3570 #define DTAPI_MOD_QAM16             4
3571 #define DTAPI_MOD_QAM32             5
3572 #define DTAPI_MOD_QAM64             6
3573 #define DTAPI_MOD_QAM128            7
3574 #define DTAPI_MOD_QAM256            8
3575 #define DTAPI_MOD_DVBT              9
3576 #define DTAPI_MOD_ATSC              10
3577 #define DTAPI_MOD_DVBT2             11
3578 #define DTAPI_MOD_ISDBT             12
3579 #define DTAPI_MOD_ISDBS             13
3580 #define DTAPI_MOD_IQDIRECT          15
3581 #define DTAPI_MOD_IQ_2131           16           // DTA-2131 specific (de)modulation
3582 #define DTAPI_MOD_DVBS2_QPSK        32
3583 #define DTAPI_MOD_DVBS2_8PSK        33
3584 #define DTAPI_MOD_DVBS2_16APSK      34
3585 #define DTAPI_MOD_DVBS2_32APSK      35
3586 #define DTAPI_MOD_DVBS2_L3          36
3587 #define DTAPI_MOD_DVBS2             37
3588 #define DTAPI_MOD_DMBTH             48
3589 #define DTAPI_MOD_ADTBT             49
3590 #define DTAPI_MOD_CMMB              50
3591 #define DTAPI_MOD_T2MI              51
3592 #define DTAPI_MOD_DVBC2             52
3593 #define DTAPI_MOD_DAB               53
3594 #define DTAPI_MOD_QAM_AUTO          54
3595 #define DTAPI_MOD_ATSC_MH           55
3596 #define DTAPI_MOD_ISDBTMM           56
3597 // Modulation types DVB-S2X specific
3598 #define DTAPI_MOD_S2X_QPSK_VLSNR    57           // DVB-S2X, QPSK, very low SNR
3599 #define DTAPI_MOD_S2X_BPSK_VLSNR    58           // DVB-S2X, BPSK, very low SNR
3600 #define DTAPI_MOD_S2X_BPSK_S_VLSNR  59           // DVB-S2X, BPSK-S, very low SNR
3601 #define DTAPI_MOD_S2X_8APSK_L       60           // DVB-S2X, 8APSK-L
3602 #define DTAPI_MOD_S2X_16APSK_L      61           // DVB-S2X, 16APSK-L
3603 #define DTAPI_MOD_S2X_32APSK_L      62           // DVB-S2X, 32APSK-L
3604 #define DTAPI_MOD_S2X_64APSK        63           // DVB-S2X, 64APSK
3605 #define DTAPI_MOD_S2X_64APSK_L      64           // DVB-S2X, 64APSK-L
3606 #define DTAPI_MOD_S2X_128APSK       65           // DVB-S2X, 128APSK
3607 #define DTAPI_MOD_S2X_256APSK       66           // DVB-S2X, 256APSK-L
3608 #define DTAPI_MOD_S2X_256APSK_L     67           // DVB-S2X, 256APSK
3609 #define DTAPI_MOD_DVBS2X_L3         68           // L3 modulation with S2X support
3610 #define DTAPI_MOD_ATSC3             69           // ATSC 3.0
3611 #define DTAPI_MOD_ISDBS3            70           // ISDB-S3
3612 #define DTAPI_MOD_TYPE_AUTO         -1           // Auto detect modulation type
3613 #define DTAPI_MOD_TYPE_UNK          -1           // Unknown modulation type
3614 
3615 // Modulation parameters - Common - ParXtra2
3616 #define DTAPI_MOD_SYMRATE_AUTO      -1           // Auto detect symbol rate
3617 #define DTAPI_MOD_SYMRATE_UNK       -1           // Symbol rate if unknown
3618 
3619 // Modulation parameters - ATSC - ParXtra0
3620 #define DTAPI_MOD_ATSC_VSB8         0x00000000   // 8-VSB, 10.762MBd, 19.392Mbps
3621 #define DTAPI_MOD_ATSC_VSB16        0x00000001   // 16-VSB, 10.762MBd, 38.785Mbps
3622 #define DTAPI_MOD_ATSC_VSB_AUTO     0x00000003   // Auto detect constellation
3623 #define DTAPI_MOD_ATSC_VSB_UNK      0x00000003   // Unknown constellation
3624 #define DTAPI_MOD_ATSC_VSB_MSK      0x00000003   // Constellation mask
3625 
3626 // Modulation parameters - DTMB - Bandwidth
3627 #define DTAPI_MOD_DTMB_5MHZ         0x00000001
3628 #define DTAPI_MOD_DTMB_6MHZ         0x00000002
3629 #define DTAPI_MOD_DTMB_7MHZ         0x00000003
3630 #define DTAPI_MOD_DTMB_8MHZ         0x00000004
3631 #define DTAPI_MOD_DTMB_BW_AUTO      0x0000000F   // Auto detect
3632 #define DTAPI_MOD_DTMB_BW_UNK       0x0000000F   // Unknown
3633 #define DTAPI_MOD_DTMB_BW_MSK       0x0000000F
3634 
3635 // Modulation parameters - DTMB - Code rate
3636 #define DTAPI_MOD_DTMB_0_4          0x00000100   // 0.4
3637 #define DTAPI_MOD_DTMB_0_6          0x00000200   // 0.6
3638 #define DTAPI_MOD_DTMB_0_8          0x00000300   // 0.8
3639 #define DTAPI_MOD_DTMB_RATE_AUTO    0x00000F00   // Auto detect
3640 #define DTAPI_MOD_DTMB_RATE_UNK     0x00000F00   // Unknown
3641 #define DTAPI_MOD_DTMB_RATE_MSK     0x00000F00   // Mask
3642 
3643 // Modulation parameters - DTMB - Constellation
3644 #define DTAPI_MOD_DTMB_QAM4NR       0x00001000   // 4-QAM-NR
3645 #define DTAPI_MOD_DTMB_QAM4         0x00002000   // 4-QAM
3646 #define DTAPI_MOD_DTMB_QAM16        0x00003000   // 16-QAM
3647 #define DTAPI_MOD_DTMB_QAM32        0x00004000   // 32-QAM
3648 #define DTAPI_MOD_DTMB_QAM64        0x00005000   // 64-QAM
3649 #define DTAPI_MOD_DTMB_CO_AUTO      0x0000F000   // Auto detect
3650 #define DTAPI_MOD_DTMB_CO_UNK       0x0000F000   // Unknown
3651 #define DTAPI_MOD_DTMB_CO_MSK       0x0000F000   // Mask
3652 
3653 // Modulation parameters - DTMB - Frame header mode
3654 #define DTAPI_MOD_DTMB_PN420        0x00010000   // PN420
3655 #define DTAPI_MOD_DTMB_PN595        0x00020000   // PN595
3656 #define DTAPI_MOD_DTMB_PN945        0x00030000   // PN945
3657 #define DTAPI_MOD_DTMB_PN_AUTO      0x000F0000   // Auto detect
3658 #define DTAPI_MOD_DTMB_PN_UNK       0x000F0000   // Unknown
3659 #define DTAPI_MOD_DTMB_PN_MSK       0x000F0000   // Mask
3660 
3661 // Modulation parameters - DTMB - Interleaver mode
3662 #define DTAPI_MOD_DTMB_IL_1         0x00100000   // Interleaver mode 1: B=54, M=240
3663 #define DTAPI_MOD_DTMB_IL_2         0x00200000   // Interleaver mode 2: B=54, M=720
3664 #define DTAPI_MOD_DTMB_IL_NONE      0x00300000   // Interleaver mode none (non-standard)
3665 #define DTAPI_MOD_DTMB_IL_AUTO      0x00F00000   // Auto detect
3666 #define DTAPI_MOD_DTMB_IL_UNK       0x00F00000   // Unknown
3667 #define DTAPI_MOD_DTMB_IL_MSK       0x00F00000   // Mask
3668 
3669 // Modulation parameters - DTMB - pilots
3670 #define DTAPI_MOD_DTMB_NO_PILOTS    0x01000000   // No pilots
3671 #define DTAPI_MOD_DTMB_PILOTS       0x02000000   // Pilots, C=1 only
3672 #define DTAPI_MOD_DTMB_PIL_AUTO     0x0F000000   // Auto detect
3673 #define DTAPI_MOD_DTMB_PIL_UNK      0x0F000000   // Unknown
3674 #define DTAPI_MOD_DTMB_PIL_MSK      0x0F000000   // Mask
3675 
3676 // Modulation parameters - DTMB - Use frame numbering
3677 #define DTAPI_MOD_DTMB_NO_FRM_NO    0x10000000   // No frame numbering
3678 #define DTAPI_MOD_DTMB_USE_FRM_NO   0x20000000   // Use frame numbers
3679 #define DTAPI_MOD_DTMB_UFRM_AUTO    0xF0000000   // Auto detect
3680 #define DTAPI_MOD_DTMB_UFRM_UNK     0xF0000000   // Unknown
3681 #define DTAPI_MOD_DTMB_UFRM_MSK     0xF0000000   // Mask
3682 
3683 // Modulation parameters - DVB-S, DVB-S2
3684 #define DTAPI_MOD_1_2               0x0          // Code rate 1/2
3685 #define DTAPI_MOD_2_3               0x1          // Code rate 2/3
3686 #define DTAPI_MOD_3_4               0x2          // Code rate 3/4
3687 #define DTAPI_MOD_4_5               0x3          // Code rate 4/5
3688 #define DTAPI_MOD_5_6               0x4          // Code rate 5/6
3689 #define DTAPI_MOD_6_7               0x5          // Code rate 6/7
3690 #define DTAPI_MOD_7_8               0x6          // Code rate 7/8
3691 #define DTAPI_MOD_1_4               0x7          // Code rate 1/4
3692 #define DTAPI_MOD_1_3               0x8          // Code rate 1/3
3693 #define DTAPI_MOD_2_5               0x9          // Code rate 2/5
3694 #define DTAPI_MOD_3_5               0xA          // Code rate 3/5
3695 #define DTAPI_MOD_8_9               0xB          // Code rate 8/9
3696 #define DTAPI_MOD_9_10              0xC          // Code rate 9/10
3697 #define DTAPI_MOD_CR_AUTO           0xF          // Auto detect code rate
3698 #define DTAPI_MOD_CR_UNK            0xF          // Unknown code rate
3699 //Coderates DVB-S2X specific
3700 #define DTAPI_MOD_1_5               0x10         // Code rate 1/5
3701 #define DTAPI_MOD_2_9               0x11         // Code rate 2/9
3702 #define DTAPI_MOD_11_45             0x12         // Code rate 11/45
3703 #define DTAPI_MOD_4_15              0x13         // Code rate 4/15
3704 #define DTAPI_MOD_13_45             0x14         // Code rate 13/45
3705 #define DTAPI_MOD_14_45             0x15         // Code rate 14/45
3706 #define DTAPI_MOD_9_20              0x16         // Code rate 9/20
3707 #define DTAPI_MOD_7_15              0x17         // Code rate 7/15
3708 #define DTAPI_MOD_8_15              0x18         // Code rate 8/15
3709 #define DTAPI_MOD_11_20             0x19         // Code rate 11/20
3710 #define DTAPI_MOD_5_9               0x1A         // Code rate 5/9
3711 #define DTAPI_MOD_26_45             0x1B         // Code rate 26/45
3712 #define DTAPI_MOD_28_45             0x1C         // Code rate 28/45
3713 #define DTAPI_MOD_23_36             0x1D         // Code rate 23/36
3714 #define DTAPI_MOD_29_45             0x1E         // Code rate 29/45
3715 #define DTAPI_MOD_31_45             0x1F         // Code rate 31/45
3716 #define DTAPI_MOD_25_36             0x20         // Code rate 25/36
3717 #define DTAPI_MOD_32_45             0x21         // Code rate 32/45
3718 #define DTAPI_MOD_13_18             0x22         // Code rate 13/18
3719 #define DTAPI_MOD_11_15             0x23         // Code rate 11/15
3720 #define DTAPI_MOD_7_9               0x24         // Code rate 7/9
3721 #define DTAPI_MOD_77_90             0x25         // Code rate 77/90
3722 
3723 // Modulation parameters - DVB-S, DVB-S2 - ParXtra1
3724 #define DTAPI_MOD_S_S2_SPECNONINV   0x00         // No spectrum inversion detected
3725 #define DTAPI_MOD_S_S2_SPECINV      0x10         // Spectrum inversion detected
3726 #define DTAPI_MOD_S_S2_SPECINV_AUTO 0x30         // Auto detect spectral inversion
3727 #define DTAPI_MOD_S_S2_SPECINV_UNK  0x30         // Spectral inversion is unknown
3728 #define DTAPI_MOD_S_S2_SPECINV_MSK  0x30         // Mask for spectrum inversion field
3729 
3730 // Modulation parameters - DVB-S2 - ParXtra1 - Pilots
3731 #define DTAPI_MOD_S2_NOPILOTS       0x00         // Pilots disabled
3732 #define DTAPI_MOD_S2_PILOTS         0x01         // Pilots enabled
3733 #define DTAPI_MOD_S2_PILOTS_AUTO    0x03         // Auto detect pilots
3734 #define DTAPI_MOD_S2_PILOTS_UNK     0x03         // State of pilots unknown
3735 #define DTAPI_MOD_S2_PILOTS_MSK     0x03         // Mask for pilots field
3736 
3737 // Modulation parameters - DVB-S2 - ParXtra1 - FEC frame length
3738 #define DTAPI_MOD_S2_LONGFRM        0x00         // Long FECFRAME
3739 #define DTAPI_MOD_S2_MEDIUMFRM      0x04         // Medium FECFRAME
3740 #define DTAPI_MOD_S2_SHORTFRM       0x08         // Short FECFRAME
3741 #define DTAPI_MOD_S2_FRM_AUTO       0x0C         // Auto detect frame size
3742 #define DTAPI_MOD_S2_FRM_UNK        0x0C         // Frame size unknown
3743 #define DTAPI_MOD_S2_FRM_MSK        0x0C         // Mask for FECFRAME field
3744 
3745 // Modulation parameters - DVB-S2(X) - ParXtra1 - Constellation amplitude for 16-, 32-APSK
3746 #define DTAPI_MOD_S2_CONST_AUTO     0x00         // Default constellation amplitude
3747 #define DTAPI_MOD_S2_CONST_E_1      0x40         // E=1; Average symbol energy is constant
3748 #define DTAPI_MOD_S2_CONST_R_1      0x80         // R=1; Radius of outer ring is constant
3749 #define DTAPI_MOD_S2_CONST_MSK      0xC0         // Mask for constellation shape
3750 
3751 // Modulation parameters - ISDB-S - Input stream
3752 #define DTAPI_MOD_ISDBS_STREAMTYPE_RAW   0x00    // Raw stream with TMCC in sync bytes
3753 #define DTAPI_MOD_ISDBS_STREAMTYPE_B15   0x01    // TMCC data following each TS packet
3754 #define DTAPI_MOD_ISDBS_STREAMTYPE_AUTO  0x07    // Default (raw) isdb-s input stream
3755 #define DTAPI_MOD_ISDBS_STREAMTYPE_MASK  0x07    // Mask for input stream type
3756 
3757 // Modulation parameters - DVB-T - Bandwidth
3758 #define DTAPI_MOD_DVBT_5MHZ         0x00000001
3759 #define DTAPI_MOD_DVBT_6MHZ         0x00000002
3760 #define DTAPI_MOD_DVBT_7MHZ         0x00000003
3761 #define DTAPI_MOD_DVBT_8MHZ         0x00000004
3762 #define DTAPI_MOD_DVBT_BW_UNK       0x0000000F   // Unknown bandwidth
3763 #define DTAPI_MOD_DVBT_BW_MSK       0x0000000F
3764 
3765 // Modulation parameters - DVB-T - Constellation
3766 #define DTAPI_MOD_DVBT_QPSK         0x00000010
3767 #define DTAPI_MOD_DVBT_QAM16        0x00000020
3768 #define DTAPI_MOD_DVBT_QAM64        0x00000030
3769 #define DTAPI_MOD_DVBT_CO_AUTO      0x000000F0   // Auto detect constellation
3770 #define DTAPI_MOD_DVBT_CO_UNK       0x000000F0   // Unknown constellation
3771 #define DTAPI_MOD_DVBT_CO_MSK       0x000000F0
3772 
3773 // Modulation parameters - DVB-T - Guard interval
3774 #define DTAPI_MOD_DVBT_G_1_32       0x00000100
3775 #define DTAPI_MOD_DVBT_G_1_16       0x00000200
3776 #define DTAPI_MOD_DVBT_G_1_8        0x00000300
3777 #define DTAPI_MOD_DVBT_G_1_4        0x00000400
3778 #define DTAPI_MOD_DVBT_GU_AUTO      0x00000F00   // Auto detect guard interval
3779 #define DTAPI_MOD_DVBT_GU_UNK       0x00000F00   // Unknown guard interval
3780 #define DTAPI_MOD_DVBT_GU_MSK       0x00000F00
3781 
3782 // DVB-T TPS information - DVB-T Hierarchical layer
3783 #define DTAPI_MOD_DVBT_HARCHY_NONE  0x00000000
3784 #define DTAPI_MOD_DVBT_HARCHY_A1    0x01000000
3785 #define DTAPI_MOD_DVBT_HARCHY_A2    0x02000000
3786 #define DTAPI_MOD_DVBT_HARCHY_A4    0x03000000
3787 #define DTAPI_MOD_DVBT_HARCHY_MSK   0x0F000000
3788 // Modulation parameters - DVB-T - Interleaver mode
3789 #define DTAPI_MOD_DVBT_INDEPTH      0x00001000
3790 #define DTAPI_MOD_DVBT_NATIVE       0x00002000
3791 #define DTAPI_MOD_DVBT_IL_AUTO      0x0000F000   // Auto detect interleaver depth
3792 #define DTAPI_MOD_DVBT_IL_UNK       0x0000F000   // Unknown interleaver depth
3793 #define DTAPI_MOD_DVBT_IL_MSK       0x0000F000
3794 
3795 // Modulation parameters - DVB-T - FFT size
3796 #define DTAPI_MOD_DVBT_2K           0x00010000
3797 #define DTAPI_MOD_DVBT_4K           0x00020000
3798 #define DTAPI_MOD_DVBT_8K           0x00030000
3799 #define DTAPI_MOD_DVBT_MD_AUTO      0x000F0000   // Auto detect mode
3800 #define DTAPI_MOD_DVBT_MD_UNK       0x000F0000   // Unknown mode
3801 #define DTAPI_MOD_DVBT_MD_MSK       0x000F0000
3802 
3803 // Modulation parameters - DVB-T - s48
3804 #define DTAPI_MOD_DVBT_S48_OFF      0x00000000
3805 #define DTAPI_MOD_DVBT_S48          0x00100000
3806 #define DTAPI_MOD_DVBT_S48_MSK      0x00100000
3807 
3808 // Modulation parameters - DVB-T - s49
3809 #define DTAPI_MOD_DVBT_S49_OFF      0x00000000
3810 #define DTAPI_MOD_DVBT_S49          0x00200000
3811 #define DTAPI_MOD_DVBT_S49_MSK      0x00200000
3812 
3813 // Modulation parameters - DVB-T - s48s49
3814 #define DTAPI_MOD_DVBT_ENA4849      0x00000000
3815 #define DTAPI_MOD_DVBT_DIS4849      0x00400000
3816 #define DTAPI_MOD_DVBT_4849_MSK     0x00400000
3817 
3818 // Modulation parameters - IQ - ParXtra0
3819 #define DTAPI_MOD_INTERPOL_RAW      0            // Raw mode, no interpolation
3820 #define DTAPI_MOD_INTERPOL_OFDM     1            // Use OFDM interpolation
3821 #define DTAPI_MOD_INTERPOL_QAM      2            // Use QAM interpolation
3822 
3823 // Modulation parameters - IQ - ParXtra2 Packing
3824 #define DTAPI_MOD_IQPCK_AUTO        0x00000000   // Auto IQ-sample packin
3825 #define DTAPI_MOD_IQPCK_NONE        0x00000001   // No IQ-sample packing
3826 #define DTAPI_MOD_IQPCK_PCKD        0x00000002   // IQ-samples are already packed
3827 #define DTAPI_MOD_IQPCK_12B         0x00000003   // IQ-samples packed in 12-bit
3828 #define DTAPI_MOD_IQPCK_10B         0x00000004   // IQ-samples packed in 10-bit
3829 #define DTAPI_MOD_IQPCK_UNK         0x000000FF   // Unknown (= use auto)
3830 #define DTAPI_MOD_IQPCK_MSK         0x000000FF
3831 
3832 // Modulation parameters - Roll-off factor ParXtra1 (DVB-S2), ParXtra2 (IQ) and
3833 //                         Low pass filters ParXtra2 (IQ)
3834 #define DTAPI_MOD_ROLLOFF_AUTO      0x00000000   // Default roll-off factor
3835 #define DTAPI_MOD_ROLLOFF_NONE      0x00000100   // No roll-off
3836 #define DTAPI_MOD_ROLLOFF_3         0x00000200   // 3% roll-off for ISDB-S3
3837 #define DTAPI_MOD_ROLLOFF_5         0x00000300   // 5% roll-off for DVB-S2X
3838 #define DTAPI_MOD_ROLLOFF_10        0x00000400   // 10% roll-off for DVB-S2X
3839 #define DTAPI_MOD_ROLLOFF_15        0x00000500   // 15% roll-off for DVB-S2X
3840 #define DTAPI_MOD_ROLLOFF_20        0x00000600   // 20% roll-off for DVB-S2
3841 #define DTAPI_MOD_ROLLOFF_25        0x00000700   // 25% roll-off for DVB-S2
3842 #define DTAPI_MOD_ROLLOFF_35        0x00000800   // 35% roll-off for DVB-S/S2
3843 // Pre-defined low pass filters
3844 #define DTAPI_MOD_LPF_0_614         0x00000900   // Passband up to samplerate*0.614,
3845                                                  // used for 2MHz CMMB
3846 #define DTAPI_MOD_LPF_0_686         0x00000A00   // Passband up to samplerate*0.686,
3847                                                  // used for ISDB-T/Tmm/Tsb
3848 #define DTAPI_MOD_LPF_0_754         0x00000B00   // Passband up to samplerate*0.754,
3849                                                  // used for 8MHz CMMB, DAB
3850 #define DTAPI_MOD_LPF_0_833         0x00000C00   // Passband up to samplerate*0.833,
3851                                                  // used for DVB-C2/T/T2
3852 #define DTAPI_MOD_LPF_0_850         0x00000D00   // Passband up to samplerate*0.850,
3853                                                  // used for DVB-T2 extended bandwidth and
3854                                                  // ATSC 3.0
3855 #define DTAPI_MOD_ROLLOFF_UNK       0x0000FF00   // Unknown (= use default)
3856 #define DTAPI_MOD_ROLLOFF_MSK       0x0000FF00
3857 
3858 // Modulation parameters - DVB-T2-MI - ParXtra0 used for T2-MI bitrate
3859 
3860 // Modulation parameters - DVB-T2-MI - ParXtra1
3861 #define DTAPI_MOD_T2MI_PID1_MSK     0x1FFF
3862 #define DTAPI_MOD_T2MI_PID1_SHFT    0
3863 #define DTAPI_MOD_T2MI_PID2_MSK     0x1FFF0000
3864 #define DTAPI_MOD_T2MI_PID2_SHFT    16
3865 #define DTAPI_MOD_T2MI_MULT_DIS     0x00000000   // Single Profile
3866 #define DTAPI_MOD_T2MI_MULT_ENA     0x20000000   // Multi Profile
3867 #define DTAPI_MOD_T2MI_MULT_MSK     0x20000000   // Multi Profile mask
3868 
3869 // Modulation parameters - QAM - ParXtra0 - J.83 Annex
3870 #define DTAPI_MOD_J83_MSK           0x000F
3871 #define DTAPI_MOD_J83_UNK           0x000F       // Unknown annex
3872 #define DTAPI_MOD_J83_AUTO          0x000F       // Auto detect annex
3873 #define DTAPI_MOD_J83_A             0x0002       // J.83 annex A (DVB-C)
3874 #define DTAPI_MOD_J83_B             0x0003       // J.83 annex B (\93American QAM\94)
3875 #define DTAPI_MOD_J83_C             0x0001       // J.83 annex C (\93Japanese QAM\94)
3876 
3877 // Modulation parameters - QAM - ParXtra1 - QAM-B interleaver mode
3878 #define DTAPI_MOD_QAMB_I128_J1D     0x1
3879 #define DTAPI_MOD_QAMB_I64_J2       0x3
3880 #define DTAPI_MOD_QAMB_I32_J4       0x5
3881 #define DTAPI_MOD_QAMB_I16_J8       0x7
3882 #define DTAPI_MOD_QAMB_I8_J16       0x9
3883 #define DTAPI_MOD_QAMB_I128_J1      0x0
3884 #define DTAPI_MOD_QAMB_I128_J2      0x2
3885 #define DTAPI_MOD_QAMB_I128_J3      0x4
3886 #define DTAPI_MOD_QAMB_I128_J4      0x6
3887 #define DTAPI_MOD_QAMB_I128_J5      0x8
3888 #define DTAPI_MOD_QAMB_I128_J6      0xA
3889 #define DTAPI_MOD_QAMB_I128_J7      0xC
3890 #define DTAPI_MOD_QAMB_I128_J8      0xE
3891 #define DTAPI_MOD_QAMB_IL_UNK       0xF          // Unknown interleaver mode
3892 #define DTAPI_MOD_QAMB_IL_AUTO      0xF          // Auto detect interleaver mode
3893 #define DTAPI_MOD_QAMB_IL_MSK       0xF
3894 
3895 
3896 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtAvInputStatus -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
3897 //
3898 class DtAvInputStatus
3899 {
3900 public:
3901     DtAvInputStatus();
3902     virtual ~DtAvInputStatus();
3903 private:
3904     // No implementation is provided for the copy constructor
3905     DtAvInputStatus(const DtAvInputStatus&);
3906     DtAvInputStatus&  operator = (const DtAvInputStatus&);
3907 
3908 public:
3909     DtHwFuncDesc  m_HwFuncDesc;     // Hardware function descriptor
3910 
3911                                     // Convenience functions
3912 public:
Category()3913     int  Category()             { return m_HwFuncDesc.m_DvcDesc.m_Category; }
FirmwareVersion()3914     int  FirmwareVersion()      { return m_HwFuncDesc.m_DvcDesc.m_FirmwareVersion; }
IsAttached()3915     bool  IsAttached()          { return m_pInp != NULL; }
TypeNumber()3916     int  TypeNumber()           { return m_HwFuncDesc.m_DvcDesc.m_TypeNumber; }
HasCaps(const DtCaps Caps)3917     bool  HasCaps(const DtCaps  Caps) const
3918     {
3919         return ((m_HwFuncDesc.m_Flags & Caps) == Caps);
3920     }
3921 
3922 public:
3923     DTAPI_RESULT  AttachToPort(DtDevice* pDtDvc, int Port);
3924     DTAPI_RESULT  Detach();
3925     DTAPI_RESULT  DetectVidStd(DtDetVidStd& Info);
3926     DTAPI_RESULT  GetAudChanStatus(std::vector<DtAudChanStatus>& AudChns);
3927     DTAPI_RESULT  GetDolbyMetadata(std::vector<DtRdd6Data>& Metadata);
3928 
3929     // Encapsulated data
3930 private:
3931     void*  m_pDetachLockCount;
3932     AvInputStatus*  m_pInp;
3933 
3934     // Private helper functions
3935 private:
3936     DTAPI_RESULT  DetachLock();
3937     DTAPI_RESULT  DetachUnlock();
3938 };
3939 
3940 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ SDI +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
3941 
3942 // DtSdi - Table-of-content entry types
3943 #define DTAPI_SDI_TOC_ENTRY_UNKNOWN 0
3944 #define DTAPI_SDI_TOC_ENTRY_ACTVID  1
3945 #define DTAPI_SDI_TOC_ENTRY_HANC    2
3946 #define DTAPI_SDI_TOC_ENTRY_VANC    3
3947 
3948 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtSdiTocEntry -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
3949 //
3950 class DtSdiTocEntry
3951 {
3952     friend class DtSdiUtility;
3953 
3954 public:
AncDataBlockNum()3955     inline int  AncDataBlockNum() const
3956     {
3957         if (AncType() != 1)   return -1;
3958         else                  return m_SdidOrDbn;
3959     }
AncDataId()3960     inline int  AncDataId() const { return m_Did; }
AncNumUserWords()3961     inline int  AncNumUserWords() const { return m_NumUserWords; }
AncSecDataId()3962     inline int  AncSecDataId() const
3963     {
3964         if (AncType() != 2)   return -1;
3965         else                  return m_SdidOrDbn;
3966     }
AncType()3967     inline int  AncType() const { return m_AncType; }
3968 
Field()3969     inline int  Field() const { return m_Field; }
Line()3970     inline int  Line() const { return m_Line; }
NumSymbols()3971     inline int  NumSymbols() const { return m_NumSymbols; }
StartOffset()3972     inline int  StartOffset() const { return m_StartOffset; }
TocType()3973     inline int  TocType() const { return m_TocType; }
3974 
3975     // Encapsulated data
3976 protected:
3977     int  m_TocType;                 // Type of TOC entry
3978     int  m_Line;                    // Line number where data is located
3979     int  m_Field;                   // Field in where data is located
3980     int  m_StartOffset;             // Symbol offset relative to start of line, first data
3981     int  m_NumSymbols;              // Number of symbols
3982 
3983     // Following members are only valid if TOC type is DTAPI_SDI_TOC_ENTRY_HANC or
3984     // DTAPI_SDI_TOC_ENTRY_VANC
3985     int  m_AncType;                 // Ancillery data packet type (DTAPI_SDI_ANC_TYPE1 or
3986                                     // DTAPI_SDI_ANC_TYPE2)
3987     int  m_Did;                     // Ancillary packet data ID
3988     int  m_SdidOrDbn;               // Ancillary packet data block number (type 1 packet)
3989                                     // or secondary data ID (type 2 packet)
3990     int  m_NumUserWords;            // Number of ancillary data packet user words
3991 
3992     // Constructor, destructor
3993 public:
DtSdiTocEntry()3994     DtSdiTocEntry() : m_TocType(DTAPI_SDI_TOC_ENTRY_UNKNOWN), m_Line(0), m_Field(0),
3995                       m_StartOffset(0), m_NumSymbols(0) {}
~DtSdiTocEntry()3996     virtual ~DtSdiTocEntry() {};
3997 };
3998 
3999 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtSdi -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
4000 //
4001 // The DtSdi class provides helper functions for processing SDI data
4002 //
4003 class DtSdi
4004 {
4005     friend class DtSdiUtility;
4006 
4007 public:
4008     DtSdi();
4009     virtual ~DtSdi();
4010 
4011 public:
4012     DTAPI_RESULT  ConvertFrame(unsigned int* pInFrame, int& InFrameSize,
4013        int InFrameFormat, unsigned int* pOutFrame, int& OutFrameSize, int OutFrameFormat);
4014     DTAPI_RESULT  CreateBlackFrame(unsigned int* pFrame, int& FrameSize, int FrameFormat);
4015     DTAPI_RESULT  GetActiveVideo(const DtSdiTocEntry& TocEntry,
4016                                                  unsigned short* pVideo, int& NumSamples);
4017     DTAPI_RESULT  GetActiveVideo(unsigned short* pVideo, int& NumSamples,
4018                                                                 int Field, int Stride=-1);
4019     DTAPI_RESULT  GetAncillaryData(const DtSdiTocEntry& TocEntry,
4020                                                   unsigned short* pData, int& NumSamples);
4021     DTAPI_RESULT  GetAudio(int AudioGroup, int& Channel,
4022                                                  unsigned short* pAudio, int& NumSamples);
4023     DTAPI_RESULT  GetTableOfContents(const DtSdiTocEntry** ppToc, int& NumTocEntries);
4024     DTAPI_RESULT  ParseFrame(const unsigned int* pFrame, int FrameSize, int FrameFormat,
4025                          int ParseFlags, const DtSdiTocEntry** ppToc, int& NumTocEntries);
4026 
4027 protected:
4028     DtSdiUtility*  m_pSdiUtil;      // Internal utility class
4029 };
4030 
4031 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtSdi constants -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
4032 
4033 // Ancillary data packet types
4034 #define DTAPI_SDI_ANC_TYPE1         1            // Type 1 packet
4035 #define DTAPI_SDI_ANC_TYPE2         2            // Type 2 packet
4036 
4037 // Parse flags
4038 #define DTAPI_SDI_PARSE_ACTVID      0x0001       // Parse active video
4039 #define DTAPI_SDI_PARSE_HBLANK      0x0002       // Parse horizontal blanking
4040 #define DTAPI_SDI_PARSE_VBLANK      0x0004       // Parse vertical blanking
4041 
4042 #define DTAPI_SDI_PARSE_BLANK       (DTAPI_SDI_PARSE_HBLANK | DTAPI_SDI_PARSE_VBLANK)
4043 #define DTAPI_SDI_PARSE_ALL         (DTAPI_SDI_PARSE_ACTVID | DTAPI_SDI_PARSE_BLANK)
4044 
4045 // Field flags
4046 #define DTAPI_SDI_FIELD1            1
4047 #define DTAPI_SDI_FIELD2            2
4048 
4049 // Audio groups
4050 #define DTAPI_SDI_AUDIO_GROUP1      0x2FF
4051 #define DTAPI_SDI_AUDIO_GROUP2      0x1FD
4052 #define DTAPI_SDI_AUDIO_GROUP3      0x1FB
4053 #define DTAPI_SDI_AUDIO_GROUP4      0x2F9
4054 
4055 #define DTAPI_SDI_AUDIO_CHAN1       0x01
4056 #define DTAPI_SDI_AUDIO_CHAN2       0x02
4057 #define DTAPI_SDI_AUDIO_CHAN3       0x04
4058 #define DTAPI_SDI_AUDIO_CHAN4       0x08
4059 
4060 #define DTAPI_SDI_AUDIO_CH_PAIR1    (DTAPI_SDI_AUDIO_CHAN1 | DTAPI_SDI_AUDIO_CHAN2)
4061 #define DTAPI_SDI_AUDIO_CH_PAIR2    (DTAPI_SDI_AUDIO_CHAN3 | DTAPI_SDI_AUDIO_CHAN4)
4062 #define DTAPI_SDI_AUDIO_CH_MASK     (DTAPI_SDI_AUDIO_CH_PAIR1 | DTAPI_SDI_AUDIO_CH_PAIR2)
4063 
4064 // Conversions format
4065 #define DTAPI_SDI_FULL              0x001
4066 #define DTAPI_SDI_ACTVID            0x002
4067 #define DTAPI_SDI_HUFFMAN           0x004
4068 #define DTAPI_SDI_625               0x008
4069 #define DTAPI_SDI_525               0x010
4070 #define DTAPI_SDI_8B                0x020
4071 #define DTAPI_SDI_10B               0x040
4072 #define DTAPI_SDI_16B               0x080
4073 #define DTAPI_SDI_10B_NBO           0x100   // 10-bit packed in network-byte-order
4074 
4075 #define DTAPI_SDI_BIT_MASK          0x1E0
4076 
4077 // Video standards
4078 #define DTAPI_VIDSTD_UNKNOWN        -1
4079 #define DTAPI_VIDSTD_TS             0
4080 #define DTAPI_VIDSTD_525I59_94      DTAPI_IOCONFIG_525I59_94
4081 #define DTAPI_VIDSTD_625I50         DTAPI_IOCONFIG_625I50
4082 #define DTAPI_VIDSTD_720P23_98      DTAPI_IOCONFIG_720P23_98
4083 #define DTAPI_VIDSTD_720P24         DTAPI_IOCONFIG_720P24
4084 #define DTAPI_VIDSTD_720P25         DTAPI_IOCONFIG_720P25
4085 #define DTAPI_VIDSTD_720P29_97      DTAPI_IOCONFIG_720P29_97
4086 #define DTAPI_VIDSTD_720P30         DTAPI_IOCONFIG_720P30
4087 #define DTAPI_VIDSTD_720P50         DTAPI_IOCONFIG_720P50
4088 #define DTAPI_VIDSTD_720P59_94      DTAPI_IOCONFIG_720P59_94
4089 #define DTAPI_VIDSTD_720P60         DTAPI_IOCONFIG_720P60
4090 #define DTAPI_VIDSTD_1080P23_98     DTAPI_IOCONFIG_1080P23_98
4091 #define DTAPI_VIDSTD_1080P24        DTAPI_IOCONFIG_1080P24
4092 #define DTAPI_VIDSTD_1080P25        DTAPI_IOCONFIG_1080P25
4093 #define DTAPI_VIDSTD_1080P29_97     DTAPI_IOCONFIG_1080P29_97
4094 #define DTAPI_VIDSTD_1080P30        DTAPI_IOCONFIG_1080P30
4095 #define DTAPI_VIDSTD_1080PSF23_98   DTAPI_IOCONFIG_1080PSF23_98
4096 #define DTAPI_VIDSTD_1080PSF24      DTAPI_IOCONFIG_1080PSF24
4097 #define DTAPI_VIDSTD_1080PSF25      DTAPI_IOCONFIG_1080PSF25
4098 #define DTAPI_VIDSTD_1080PSF29_97   DTAPI_IOCONFIG_1080PSF29_97
4099 #define DTAPI_VIDSTD_1080PSF30      DTAPI_IOCONFIG_1080PSF30
4100 #define DTAPI_VIDSTD_1080I50        DTAPI_IOCONFIG_1080I50
4101 #define DTAPI_VIDSTD_1080I59_94     DTAPI_IOCONFIG_1080I59_94
4102 #define DTAPI_VIDSTD_1080I60        DTAPI_IOCONFIG_1080I60
4103 #define DTAPI_VIDSTD_1080P50        DTAPI_IOCONFIG_1080P50
4104 #define DTAPI_VIDSTD_1080P50B       DTAPI_IOCONFIG_1080P50B
4105 #define DTAPI_VIDSTD_1080P59_94     DTAPI_IOCONFIG_1080P59_94
4106 #define DTAPI_VIDSTD_1080P59_94B    DTAPI_IOCONFIG_1080P59_94B
4107 #define DTAPI_VIDSTD_1080P60        DTAPI_IOCONFIG_1080P60
4108 #define DTAPI_VIDSTD_1080P60B       DTAPI_IOCONFIG_1080P60B
4109 #define DTAPI_VIDSTD_2160P50        DTAPI_IOCONFIG_2160P50
4110 #define DTAPI_VIDSTD_2160P50B       DTAPI_IOCONFIG_2160P50B
4111 #define DTAPI_VIDSTD_2160P59_94     DTAPI_IOCONFIG_2160P59_94
4112 #define DTAPI_VIDSTD_2160P59_94B    DTAPI_IOCONFIG_2160P59_94B
4113 #define DTAPI_VIDSTD_2160P60        DTAPI_IOCONFIG_2160P60
4114 #define DTAPI_VIDSTD_2160P60B       DTAPI_IOCONFIG_2160P60B
4115 #define DTAPI_VIDSTD_2160P23_98     DTAPI_IOCONFIG_2160P23_98
4116 #define DTAPI_VIDSTD_2160P24        DTAPI_IOCONFIG_2160P24
4117 #define DTAPI_VIDSTD_2160P25        DTAPI_IOCONFIG_2160P25
4118 #define DTAPI_VIDSTD_2160P29_97     DTAPI_IOCONFIG_2160P29_97
4119 #define DTAPI_VIDSTD_2160P30        DTAPI_IOCONFIG_2160P30
4120 
4121 
4122 // The video standards above map 1-to-1 to an IOConfig value. The video formats below
4123 // are used for multi-link video standards. Start at a high value to make sure there
4124 // is no overlap.
4125 #define DTAPI_VIDSTD_BASE           1000
4126 #define DTAPI_VIDSTD_480P59_94      (DTAPI_VIDSTD_BASE + 0)
4127 #define DTAPI_VIDSTD_525P59_94      (DTAPI_VIDSTD_BASE + 1)
4128 #define DTAPI_VIDSTD_625P50         (DTAPI_VIDSTD_BASE + 2)
4129 
4130 // Video link standards.
4131 #define DTAPI_VIDLNK_4K_SMPTE425    0            // 4K mapping according to SMPTE 425
4132 #define DTAPI_VIDLNK_4K_SMPTE425B   1            // 4K mapping acc. to SMPTE 425 annex B
4133 #define DTAPI_VIDLNK_4K_SMPTE2081   2            // 4K over one 6G port
4134 #define DTAPI_VIDLNK_4K_SMPTE2082   3            // 4K over one 12G port
4135 
4136 // Audio standard
4137 #define DTAPI_SDI_AUDIO_SMPTE272A   1            // SMPTE-272 Level A, 48kHz, 20-bit audio
4138 
4139 // Audio formats
4140 #define DTAPI_SDI_AUDIO_PCM16       0
4141 #define DTAPI_SDI_AUDIO_PCM24       1
4142 #define DTAPI_SDI_AUDIO_PCM32       2
4143 
4144 // HANC/VANC/Video selection (can be OR-ed)
4145 //#define DTAPI_SDI_ACTVID               0x01
4146 #define DTAPI_SDI_HANC              0x02
4147 #define DTAPI_SDI_VANC              0x04
4148 #define DTAPI_SDI_ANC_MASK          (DTAPI_SDI_HANC | DTAPI_SDI_VANC)
4149 
4150 // Chrominace/luminance stream selection (can be OR-ed)
4151 #define DTAPI_SDI_CHROM_0           0x01
4152 #define DTAPI_SDI_LUM_0             0x02
4153 #define DTAPI_SDI_CHROM_1           0x04
4154 #define DTAPI_SDI_LUM_1             0x08
4155 #define DTAPI_SDI_CHROM_MASK        (DTAPI_SDI_CHROM_0 | DTAPI_SDI_CHROM_1)
4156 #define DTAPI_SDI_LUM_MASK          (DTAPI_SDI_LUM_0 | DTAPI_SDI_LUM_1)
4157 #define DTAPI_SDI_STREAM_MASK       (DTAPI_SDI_CHROM_MASK | DTAPI_SDI_LUM_MASK)
4158 // Old names
4159 #define DTAPI_SDI_CHROM             DTAPI_SDI_CHROM_0
4160 #define DTAPI_SDI_LUM               DTAPI_SDI_LUM_0
4161 
4162 // Anc-data operation mode
4163 #define DTAPI_ANC_MARK              0x0001
4164 #define DTAPI_ANC_DELETE            0x0002
4165 
4166 // Scalling factor
4167 #define DTAPI_SCALING_OFF           1
4168 #define DTAPI_SCALING_1_4           2
4169 #define DTAPI_SCALING_1_16          3
4170 
4171 // Symbol filter mode
4172 #define DTAPI_SYMFLT_ALL            0       // YCbCr sample (CbYCrY order)
4173 #define DTAPI_SYMFLT_LUM            1       // Luminance only (Y)
4174 #define DTAPI_SYMFLT_CHROM          2       // Chrominance only (CbCr)
4175 #define DTAPI_SYMFLT_SWAP           3       // Swap order of lum and chrom (i.e. YCbYCr)
4176 #define DTAPI_SYMFLT_RGB            4       // Convert to/from RGB
4177 
4178 // Ancillary filter mode
4179 #define DTAPI_ANCFLT_OFF            0
4180 #define DTAPI_ANCFLT_HANC_ALL       1
4181 #define DTAPI_ANCFLT_HANC_MIN       2
4182 #define DTAPI_ANCFLT_VANC_ALL       3
4183 #define DTAPI_ANCFLT_VANC_MIN       4
4184 
4185 // Receive mode hints for USB3 devices
4186 #define DTAPI_RXMODE_FRAMEBUFFER      0x10000
4187 #define DTAPI_RXMODE_ANC              (DTAPI_RXMODE_FRAMEBUFFER | 1)
4188 #define DTAPI_RXMODE_RAW              (DTAPI_RXMODE_FRAMEBUFFER | 2)
4189 #define DTAPI_RXMODE_FULL             (DTAPI_RXMODE_FRAMEBUFFER | 3)
4190 #define DTAPI_RXMODE_FULL8            (DTAPI_RXMODE_FRAMEBUFFER | 4)
4191 #define DTAPI_RXMODE_FULL8_SCALED4    (DTAPI_RXMODE_FRAMEBUFFER | 5)
4192 #define DTAPI_RXMODE_FULL8_SCALED16   (DTAPI_RXMODE_FRAMEBUFFER | 6)
4193 #define DTAPI_RXMODE_VIDEO            (DTAPI_RXMODE_FRAMEBUFFER | 7)
4194 #define DTAPI_RXMODE_VIDEO8           (DTAPI_RXMODE_FRAMEBUFFER | 8)
4195 #define DTAPI_RXMODE_VIDEO8_SCALED4   (DTAPI_RXMODE_FRAMEBUFFER | 9)
4196 #define DTAPI_RXMODE_VIDEO8_SCALED16  (DTAPI_RXMODE_FRAMEBUFFER | 10)
4197 #define DTAPI_RXMODE_RAW8             (DTAPI_RXMODE_FRAMEBUFFER | 15)
4198 #define DTAPI_RXMODE_FRMBUF_MASK      0x0F
4199 
4200 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
4201 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ HD-SDI CLASSES +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
4202 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
4203 
4204 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- AncPacket -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
4205 //
4206 class AncPacket
4207 {
4208 public:
4209     AncPacket();
4210     AncPacket(const AncPacket& s);
4211     virtual ~AncPacket();
4212 
4213 public:
4214     int  m_Did;                     // Data identifier
4215     int  m_SdidOrDbn;               // Secondary data identifier / Data block number
4216     int  m_Dc;                      // Data count
4217     int  m_Cs;                      // Check sum
4218     unsigned short*  m_pUdw;        // User data words
4219     int  m_Line;                    // Line number in which packet was found
4220 
4221     // Operations
4222 public:
4223     void  Create(unsigned short*  pUserWords, int  NumWords);
4224     void  Create(int  NumWords=256);
4225     void  Destroy();
Type()4226     int  Type() const  { return (m_Did & 0x80)==0 ? 2 : 1; }
Size()4227     int Size() const { return m_Size; }
4228 
4229     void  operator = (const AncPacket& s);
4230 
4231 private:
4232     int  m_Size;                    // Size of user data buffer (in # of words)
4233 };
4234 
4235 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtFrameBufTrPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
4236 //
4237 class DtFrameBufTrPars
4238 {
4239 public:
4240     enum ParsType { PT_VIDEO, PT_ANC, PT_RAW, PT_ANC2 };
4241 
4242 protected:
4243     DtFrameBufTrPars(ParsType  Type);
4244 public:
4245     virtual ~DtFrameBufTrPars();
4246 
4247     // Operations
4248 public:
4249     DTAPI_RESULT  SetCommon(__int64  Frame, unsigned char* pBuf,  int  BufSize,
4250                                     int  DataFormat, int  StartLine=1,  int  NumLines=-1);
4251 
GetType()4252     ParsType GetType() const { return m_Type; }
4253 
4254     virtual DtFrameBufTrPars*  Clone() = 0;
4255 
4256 public:
4257     __int64  m_Frame;           // Frame to transfer
4258     unsigned char* m_pBuf;      // Transfer buffer
4259     int  m_BufSize;             // [in] size of buffer / [out] actual #bytes transferred
4260     int  m_StartLine;           // [in] 1st line to transfer / [out] actual first line
4261     int  m_NumLines;            // [in] #lines to transfer / [out] actual #lines
4262     int  m_DataFormat;          // Format of data (8-, 10-, 16-bit)
4263 
4264 private:
4265     ParsType  m_Type;           // Parameter type
4266 };
4267 
4268 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtFrameBufTrParsVideo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
4269 //
4270 class DtFrameBufTrParsVideo : public DtFrameBufTrPars
4271 {
4272 public:
4273     DtFrameBufTrParsVideo(int  Field, int  Scaling=DTAPI_SCALING_OFF, int  Stride=-1,
4274                                                             int  SymFlt=DTAPI_SYMFLT_ALL);
4275     virtual ~DtFrameBufTrParsVideo();
4276 
4277     DtFrameBufTrParsVideo*  Clone();
4278 
4279 public:
4280     int  m_Field;               // Field to transfer (DTAPI_SDI_FIELD*)
4281     int  m_Scaling;             // Scaling mode (DTAPI_SCALING_*)
4282     int  m_Stride;              // -1 means no stride
4283     int  m_SymFlt;              // Symbol filter mode (DTAPI_SYMFLT_*)
4284 };
4285 
4286 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtFrameBufTrParsAnc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
4287 //
4288 class DtFrameBufTrParsAnc : public DtFrameBufTrPars
4289 {
4290 public:
4291     DtFrameBufTrParsAnc(int  HancVanc, int  AncFlt=DTAPI_ANCFLT_OFF);
4292     virtual ~DtFrameBufTrParsAnc();
4293 
4294     DtFrameBufTrParsAnc*  Clone();
4295 
4296 public:
4297     int  m_HancVanc;            // HANC or VANC
4298     int  m_AncFlt;              // Anc filter mode (DTAPI_ANCFLT_*)
4299 };
4300 
4301 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtFrameBufTrParsRaw -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
4302 //
4303 class DtFrameBufTrParsRaw : public DtFrameBufTrPars
4304 {
4305 public:
4306     DtFrameBufTrParsRaw(int  SymFlt=DTAPI_SYMFLT_ALL, int  Stride=-1);
4307     virtual ~DtFrameBufTrParsRaw();
4308 
4309     DtFrameBufTrParsRaw*  Clone();
4310 
4311 public:
4312     int  m_SymFlt;              // Symbol filter mode
4313     int  m_Stride;              // -1 means no stride
4314 };
4315 
4316 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtFrameBuffer -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
4317 //
4318 // Class to represent an frame buffer
4319 //
4320 class DtFrameBuffer
4321 {
4322 public:
4323     DtFrameBuffer();
4324     virtual ~DtFrameBuffer();
4325 private:
4326     // No implementation is provided for the copy constructor
4327     DtFrameBuffer(const DtFrameBuffer&);
4328 
4329 public:
4330     virtual DTAPI_RESULT  AncAddAudio(__int64 Frame, unsigned char* pBuf,
4331                                   int& BufSize, int Format, int Channels, int AudioGroup);
4332     virtual DTAPI_RESULT  AncAddAudioStatusWord(__int64 Frame, unsigned char  Status[24],
4333                                                           int  Channels, int  AudioGroup);
4334     // Old declaration of the AncAddPacket function. The AncPacket class has been extended
4335     // with a new m_Line member.
4336     DTAPI_DEPRECATED(virtual DTAPI_RESULT  AncAddPacket(__int64 Frame,
4337                                                      AncPacket&  AncPacket,
4338                                                      int Line, int HancVanc, int Stream),
4339                      "Deprecated (will be removed!): use overloaded AncAddPacket without "
4340                      "line argument, use AncPacket::m_Line instead");
4341     virtual DTAPI_RESULT  AncAddPacket(__int64 Frame, AncPacket&  AncPacket,
4342                                                                 int HancVanc, int Stream);
4343     virtual DTAPI_RESULT  AncClear(__int64 Frame, int HancVanc, int Stream);
4344     virtual DTAPI_RESULT  AncCommit(__int64 Frame);
4345     virtual DTAPI_RESULT  AncDelAudio(__int64 Frame, int AudioGroup, int Mode);
4346     virtual DTAPI_RESULT  AncDelPacket(__int64 Frame, int DID, int SDID, int StartLine,
4347                                         int NumLines, int HancVanc, int Stream, int Mode);
4348     virtual DTAPI_RESULT  AncGetAudio(__int64 Frame, unsigned char*  pBuf,
4349                            int&  BufSize, int DataFormat, int&  Channels, int AudioGroup);
4350     virtual DTAPI_RESULT  AncGetPacket(__int64 Frame, int DID, int SDID,
4351                                   AncPacket*, int&  NumPackets, int HancVanc, int Stream);
4352     virtual DTAPI_RESULT  AncReadRaw(__int64 Frame, unsigned char* pBuf,
4353                                 int&  BufSize, int DataFormat, int StartLine,
4354                                 int NumLines, int HancVanc, bool EnableAncFilter = false);
4355     virtual DTAPI_RESULT  AncReadRaw(DtFrameBufTrParsAnc&  TP);
4356     virtual DTAPI_RESULT  AncWriteRaw(__int64 Frame, unsigned char* pBuf,
4357                                 int&  BufSize, int Format, int StartLine,
4358                                 int NumLines, int HancVanc, bool EnableAncFilter = false);
4359     virtual DTAPI_RESULT  AncWriteRaw(DtFrameBufTrParsAnc&  TP);
4360     virtual DTAPI_RESULT  AttachToInput(DtDevice*, int Port);
4361     virtual DTAPI_RESULT  AttachToOutput(DtDevice*, int Port, int Delay);
4362     virtual DTAPI_RESULT  ClearFlags(int Latched);
4363     virtual DTAPI_RESULT  Detach();
4364     virtual DTAPI_RESULT  DetectIoStd(int& Value, int& SubValue);
4365     virtual DTAPI_RESULT  GetBufferInfo(DtBufferInfo&);
4366     virtual DTAPI_RESULT  GetCurFrame(__int64& CurFrame);
4367     virtual DTAPI_RESULT  GetFlags(int& Flags, int& Latched);
4368     virtual DTAPI_RESULT  GetFrameInfo(__int64 Frame, DtFrameInfo&);
4369     virtual DTAPI_RESULT  GetStatistics(int Count, DtStatistic* pStatistics);
4370     virtual DTAPI_RESULT  GetStatistic(int Type, int& Statistic);
4371     virtual DTAPI_RESULT  ReadSdiLines(__int64 Frame, unsigned char* pBuf,
4372                               int& BufSize, int DataFormat, int StartLine, int& NumLines);
4373     virtual DTAPI_RESULT  ReadSdiLines(DtFrameBufTrParsRaw&  TP);
4374     virtual DTAPI_RESULT  ReadSdiLines(__int64 Frame, unsigned char* pBuf,
4375                                                            int&  BufSize, int DataFormat);
4376     virtual DTAPI_RESULT  ReadVideo(__int64 Frame, unsigned char* pBuf,
4377                                            int& BufSize, int Field, int FullOrScaled,
4378                                            int DataFormat, int StartLine, int&  NumLines);
4379     virtual DTAPI_RESULT  ReadVideo(DtFrameBufTrParsVideo&  TP);
4380     virtual DTAPI_RESULT  SetRxMode(int  RxMode, __int64&  FirstFrame);
4381     virtual DTAPI_RESULT  Start(bool Start=true);
4382     virtual DTAPI_RESULT  SetIoConfig(int Group, int Value, int SubValue = -1,
4383                                             __int64 ParXtra0 = -1, __int64 ParXtra1 = -1);
4384     virtual DTAPI_RESULT  WaitFrame(__int64& LastFrame);
4385     virtual DTAPI_RESULT  WaitFrame(__int64& FirstFrame, __int64& LastFrame);
4386     virtual DTAPI_RESULT  WriteSdiLines(__int64 Frame, unsigned char* pBuf,
4387                                                             int& BufSize, int DataFormat);
4388     virtual DTAPI_RESULT  WriteSdiLines(__int64 Frame, unsigned char*  pBuf,
4389                             int&  BufSize, int DataFormat, int StartLine, int&  NumLines);
4390     virtual DTAPI_RESULT  WriteSdiLines(DtFrameBufTrParsRaw&  TP);
4391     virtual DTAPI_RESULT  WriteVideo(__int64 Frame, unsigned char*  pBuf, int&  BufSize,
4392                                 int Field, int DataFormat, int StartLine, int&  NumLines);
4393     virtual DTAPI_RESULT  WriteVideo(DtFrameBufTrParsVideo&  TP);
4394 
4395 protected:
4396     FrameBufImpl*  m_pImpl;         // Implementation class
4397 };
4398 
4399 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtSdiMatrix -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
4400 //
4401 class DtSdiMatrix
4402 {
4403 public:
4404     DtSdiMatrix();
4405     virtual ~DtSdiMatrix();
4406 private:
4407     // No implementation is provided for the copy constructor
4408     DtSdiMatrix(const DtSdiMatrix&);
4409 
4410 public:
4411     virtual DTAPI_RESULT  Attach(DtDevice*  pDvc, int&  MaxNumRows);
4412     virtual DTAPI_RESULT  Detach();
4413     virtual DTAPI_RESULT  GetMatrixInfo(DtMatrixInfo&  Info);
4414     virtual DtFrameBuffer&  Row(int n);
4415     virtual DTAPI_RESULT  Start(bool  Start=true);
4416     virtual DTAPI_RESULT  SetIoConfig(int Group, int Value, int SubValue = -1,
4417                                             __int64 ParXtra0 = -1, __int64 ParXtra1 = -1);
4418     virtual DTAPI_RESULT  WaitFrame(__int64&  LastFrame);
4419     virtual DTAPI_RESULT  WaitFrame(__int64&  FirstFrame, __int64&  LastFrame);
4420 
4421 private:
4422     SdiMatrixImpl*  m_pImpl;        // Implementation class
4423 };
4424 
4425 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- Return Codes -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
4426 //
4427 // NOTE: ERROR CODES 0x1100-0x12FF ARE RESERVED FOR USE IN THE DTAPIplus
4428 //
4429 #define DTAPI_OK                    0
4430 #define DTAPI_OK_FAILSAFE           1
4431 #define DTAPI_OK_PENDING            2
4432 #define DTAPI_OK_PARTIAL_DEV        3
4433 #define DTAPI_E                     0x1000
4434 #define DTAPI_E_ATTACHED            (DTAPI_E + 0)
4435 #define DTAPI_E_BUF_TOO_SMALL       (DTAPI_E + 1)
4436 #define DTAPI_E_DEV_DRIVER          (DTAPI_E + 2)
4437 #define DTAPI_E_EEPROM_FULL         (DTAPI_E + 3)
4438 #define DTAPI_E_EEPROM_READ         (DTAPI_E + 4)
4439 #define DTAPI_E_EEPROM_WRITE        (DTAPI_E + 5)
4440 #define DTAPI_E_EEPROM_FORMAT       (DTAPI_E + 6)
4441 #define DTAPI_E_FIFO_FULL           (DTAPI_E + 7)
4442 #define DTAPI_E_IN_USE              (DTAPI_E + 8)
4443 #define DTAPI_E_INVALID_BUF         (DTAPI_E + 9)
4444 #define DTAPI_E_INVALID_FLAGS       (DTAPI_E + 11)
4445 #define DTAPI_E_INVALID_MODE        (DTAPI_E + 12)
4446 #define DTAPI_E_INVALID_RATE        (DTAPI_E + 13)
4447 #define DTAPI_E_INVALID_SIZE        (DTAPI_E + 14)
4448 #define DTAPI_E_KEYWORD             (DTAPI_E + 15)
4449 #define DTAPI_E_NO_DEVICE           (DTAPI_E + 16)
4450 #define DTAPI_E_NO_LOOPBACK         (DTAPI_E + 17)
4451 #define DTAPI_E_NO_SUCH_DEVICE      (DTAPI_E + 18)
4452 #define DTAPI_E_NO_SUCH_OUTPUT      (DTAPI_E + 19)
4453 #define DTAPI_E_NO_DT_OUTPUT        (DTAPI_E + 20)
4454 #define DTAPI_E_NO_TS_OUTPUT        (DTAPI_E + 20)
4455 #define DTAPI_E_NOT_ATTACHED        (DTAPI_E + 21)
4456 #define DTAPI_E_NOT_FOUND           (DTAPI_E + 22)
4457 #define DTAPI_E_NOT_SUPPORTED       (DTAPI_E + 23)
4458 #define DTAPI_E_DEVICE              (DTAPI_E + 24)
4459 #define DTAPI_E_TOO_LONG            (DTAPI_E + 25)
4460 #define DTAPI_E_UNDERFLOW           (DTAPI_E + 26)
4461 #define DTAPI_E_NO_SUCH_INPUT       (DTAPI_E + 27)
4462 #define DTAPI_E_NO_DT_INPUT         (DTAPI_E + 28)
4463 #define DTAPI_E_NO_TS_INPUT         (DTAPI_E + 28)
4464 #define DTAPI_E_DRIVER_INCOMP       (DTAPI_E + 29)
4465 #define DTAPI_E_INTERNAL            (DTAPI_E + 30)
4466 #define DTAPI_E_OUT_OF_MEM          (DTAPI_E + 31)
4467 #define DTAPI_E_INVALID_J83ANNEX    (DTAPI_E + 32)
4468 #define DTAPI_E_IDLE                (DTAPI_E + 33)
4469 #define DTAPI_E_INSUF_LOAD          (DTAPI_E + 34)
4470 #define DTAPI_E_INVALID_BANDWIDTH   (DTAPI_E + 35)
4471 #define DTAPI_E_INVALID_CONSTEL     (DTAPI_E + 36)
4472 #define DTAPI_E_INVALID_GUARD       (DTAPI_E + 37)
4473 #define DTAPI_E_INVALID_INTERLVNG   (DTAPI_E + 38)
4474 #define DTAPI_E_INVALID_TRANSMODE   (DTAPI_E + 39)
4475 #define DTAPI_E_INVALID_TSTYPE      (DTAPI_E + 40)
4476 #define DTAPI_E_NO_IPPARS           (DTAPI_E + 41)
4477 #define DTAPI_E_NO_TSRATE           (DTAPI_E + 42)
4478 #define DTAPI_E_NOT_IDLE            (DTAPI_E + 43)
4479 #define DTAPI_E_INVALID_ARG         (DTAPI_E + 44)
4480 #define DTAPI_E_NW_DRIVER           (DTAPI_E + 45)
4481 #define DTAPI_E_DST_MAC_ADDR        (DTAPI_E + 46)
4482 #define DTAPI_E_NO_SUCH_PORT        (DTAPI_E + 47)
4483 #define DTAPI_E_WINSOCK             (DTAPI_E + 48)
4484 #define DTAPI_E_MULTICASTJOIN       (DTAPI_E + 49)
4485 #define DTAPI_E_EMBEDDED            (DTAPI_E + 50)
4486 #define DTAPI_E_LOCKED              (DTAPI_E + 51)
4487 #define DTAPI_E_NO_VALID_CALDATA    (DTAPI_E + 52)
4488 #define DTAPI_E_NO_LINK             (DTAPI_E + 53)
4489 #define DTAPI_E_INVALID_HEADER      (DTAPI_E + 54)
4490 #define DTAPI_E_INVALID_PARS        (DTAPI_E + 55)
4491 #define DTAPI_E_NOT_SDI_MODE        (DTAPI_E + 56)
4492 #define DTAPI_E_INCOMP_FRAME        (DTAPI_E + 57)
4493 #define DTAPI_E_UNSUP_CONV          (DTAPI_E + 58)
4494 #define DTAPI_E_OUTBUF_TOO_SMALL    (DTAPI_E + 59)
4495 #define DTAPI_E_CONFIG              (DTAPI_E + 60)
4496 #define DTAPI_E_TIMEOUT             (DTAPI_E + 61)
4497 #define DTAPI_E_INVALID_TIMEOUT     (DTAPI_E + 62)
4498 #define DTAPI_E_INVALID_FHMODE      (DTAPI_E + 63)
4499 #define DTAPI_E_INVALID_PILOTS      (DTAPI_E + 64)
4500 #define DTAPI_E_INVALID_USEFRAMENO  (DTAPI_E + 65)
4501 #define DTAPI_E_SYMRATE_REQD        (DTAPI_E + 66)
4502 #define DTAPI_E_NO_SYMRATE          (DTAPI_E + 67)
4503 #define DTAPI_E_INVALID_NUMSEGM     (DTAPI_E + 68)
4504 #define DTAPI_E_INVALID_NUMTAPS     (DTAPI_E + 69)
4505 #define DTAPI_E_COMMUNICATION       (DTAPI_E + 70)
4506 #define DTAPI_E_BIND                (DTAPI_E + 71)
4507 #define DTAPI_E_FRAME_INTERVAL      (DTAPI_E + 72)
4508 #define DTAPI_E_INVALID_BWT_EXT     (DTAPI_E + 73)
4509 #define DTAPI_E_INVALID_FFTMODE     (DTAPI_E + 74)
4510 #define DTAPI_E_INVALID_NUMDTSYM    (DTAPI_E + 75)
4511 #define DTAPI_E_INVALID_NUMT2FRM    (DTAPI_E + 76)
4512 #define DTAPI_E_INVALID_SUBCH       (DTAPI_E + 77)
4513 #define DTAPI_E_INVALID_TIME_IL     (DTAPI_E + 78)
4514 #define DTAPI_E_NUM_PLP             (DTAPI_E + 79)
4515 #define DTAPI_E_PLP_NUMBLOCKS       (DTAPI_E + 80)
4516 #define DTAPI_E_NUMPLPS_MUSTBE_1    (DTAPI_E + 81)
4517 #define DTAPI_E_INBAND              (DTAPI_E + 82)
4518 #define DTAPI_E_ISSY                (DTAPI_E + 83)
4519 #define DTAPI_E_OTHER_PLP_IN_BAND   (DTAPI_E + 84)
4520 #define DTAPI_E_CM_NUMPATHS         (DTAPI_E + 85)
4521 #define DTAPI_E_PILOT_PATTERN       (DTAPI_E + 86)
4522 #define DTAPI_E_SUBSLICES           (DTAPI_E + 87)
4523 #define DTAPI_E_NO_GENREF           (DTAPI_E + 88)
4524 #define DTAPI_E_TI_MEM_OVF          (DTAPI_E + 89)
4525 #define DTAPI_E_FEF                 (DTAPI_E + 90)
4526 #define DTAPI_E_UNSUP_FORMAT        (DTAPI_E + 91)
4527 #define DTAPI_E_OUT_OF_SYNC         (DTAPI_E + 92)
4528 #define DTAPI_E_NO_FRAME            (DTAPI_E + 93)
4529 #define DTAPI_E_NO_SUCH_DATA        (DTAPI_E + 94)
4530 #define DTAPI_E_INVALID_TYPE        (DTAPI_E + 95)
4531 #define DTAPI_E_INVALID_MODPARS     (DTAPI_E + 96)
4532 #define DTAPI_E_BIAS_BAL_CELLS      (DTAPI_E + 97)
4533 #define DTAPI_E_COMMON_PLP_COUNT    (DTAPI_E + 98)
4534 #define DTAPI_E_PLP_ID              (DTAPI_E + 99)
4535 #define DTAPI_E_BUFS                (DTAPI_E + 100)
4536 #define DTAPI_E_FIXED_CELL_PARS     (DTAPI_E + 101)
4537 #define DTAPI_E_CM_CHANNEL          (DTAPI_E + 102)
4538 #define DTAPI_E_INVALID_FIFO_IDX    (DTAPI_E + 103)
4539 #define DTAPI_E_INVALID_INP_TYPE    (DTAPI_E + 104)
4540 #define DTAPI_E_INVALID_OUTP_TYPE   (DTAPI_E + 105)
4541 #define DTAPI_E_INVALID_START_FREQ  (DTAPI_E + 106)
4542 #define DTAPI_E_DSLICE_TUNE_POS     (DTAPI_E + 107)
4543 #define DTAPI_E_DSLICE_OFFSETS      (DTAPI_E + 108)
4544 #define DTAPI_E_DSLICE_OVERLAP      (DTAPI_E + 109)
4545 #define DTAPI_E_NOTCH_OFFSETS       (DTAPI_E + 110)
4546 #define DTAPI_E_PLP_BUNDLED         (DTAPI_E + 111)
4547 #define DTAPI_E_BROADBAND_NOTCH     (DTAPI_E + 112)
4548 #define DTAPI_E_L1_PART2_TOO_LONG   (DTAPI_E + 113)
4549 #define DTAPI_E_DSLICE_T1_NDP       (DTAPI_E + 114)
4550 #define DTAPI_E_DSLICE_T1_TSRATE    (DTAPI_E + 115)
4551 #define DTAPI_E_CONNECT_TO_SERVICE  (DTAPI_E + 116)
4552 #define DTAPI_E_INVALID_SYMRATE     (DTAPI_E + 117)
4553 #define DTAPI_E_MODPARS_NOT_SET     (DTAPI_E + 118)
4554 #define DTAPI_E_SERVICE_INCOMP      (DTAPI_E + 119)
4555 #define DTAPI_E_INVALID_LEVEL       (DTAPI_E + 120)
4556 #define DTAPI_E_MODTYPE_UNSUP       (DTAPI_E + 121)
4557 #define DTAPI_E_I2C_LOCK_TIMEOUT    (DTAPI_E + 122)
4558 #define DTAPI_E_INVALID_FREQ        (DTAPI_E + 123)
4559 #define DTAPI_E_INVALID_TSRATESEL   (DTAPI_E + 124)
4560 #define DTAPI_E_INVALID_SPICLKSEL   (DTAPI_E + 125)
4561 #define DTAPI_E_INVALID_SPIMODE     (DTAPI_E + 126)
4562 #define DTAPI_E_NOT_INITIALIZED     (DTAPI_E + 127)
4563 #define DTAPI_E_NOT_LOCKED          (DTAPI_E + 128)
4564 #define DTAPI_E_NO_PERMISSION       (DTAPI_E + 129)
4565 #define DTAPI_E_CANCELLED           (DTAPI_E + 130)
4566 #define DTAPI_E_OUT_OF_RESOURCES    (DTAPI_E + 131)
4567 #define DTAPI_E_LISTEN              (DTAPI_E + 132)
4568 #define DTAPI_E_INVALID_STREAMFMT   (DTAPI_E + 133)
4569 #define DTAPI_E_EVENT_POWER         (DTAPI_E + 134)
4570 #define DTAPI_E_EVENT_REMOVAL       (DTAPI_E + 135)
4571 #define DTAPI_E_UNSUP_ROLLOFF       (DTAPI_E + 136)
4572 #define DTAPI_E_T2_LITE             (DTAPI_E + 137)
4573 #define DTAPI_E_COMP_OVERLAP        (DTAPI_E + 138)
4574 #define DTAPI_E_MULTI_COMPS         (DTAPI_E + 139)
4575 #define DTAPI_E_INVALID_ISI         (DTAPI_E + 140)
4576 #define DTAPI_E_FIRMW_INCOMP        (DTAPI_E + 141)
4577 #define DTAPI_E_INVALID_MODTYPE     (DTAPI_E + 142)
4578 #define DTAPI_E_NO_VIDSTD           (DTAPI_E + 143)
4579 #define DTAPI_E_INVALID_VIDSTD      (DTAPI_E + 144)
4580 #define DTAPI_E_INVALID_AUDSTD      (DTAPI_E + 145)
4581 #define DTAPI_E_INVALID_SCALING     (DTAPI_E + 146)
4582 #define DTAPI_E_INVALID_ROW         (DTAPI_E + 147)
4583 #define DTAPI_E_NOT_STARTED         (DTAPI_E + 148)
4584 #define DTAPI_E_STARTED             (DTAPI_E + 149)
4585 #define DTAPI_E_INVALID_LINE        (DTAPI_E + 150)
4586 #define DTAPI_E_INVALID_STREAM      (DTAPI_E + 151)
4587 #define DTAPI_E_INVALID_ANC         (DTAPI_E + 152)
4588 #define DTAPI_E_INVALID_FRAME       (DTAPI_E + 153)
4589 #define DTAPI_E_NOT_IMPLEMENTED     (DTAPI_E + 154)
4590 #define DTAPI_E_INVALID_CHANNEL     (DTAPI_E + 155)
4591 #define DTAPI_E_INVALID_GROUP       (DTAPI_E + 156)
4592 #define DTAPI_E_INVALID_FORMAT      (DTAPI_E + 157)
4593 #define DTAPI_E_INVALID_FIELD       (DTAPI_E + 158)
4594 #define DTAPI_E_BUF_TOO_LARGE       (DTAPI_E + 159)
4595 #define DTAPI_E_INVALID_DELAY       (DTAPI_E + 160)
4596 #define DTAPI_E_EXCL_MANDATORY      (DTAPI_E + 161)
4597 #define DTAPI_E_INVALID_ROLLOFF     (DTAPI_E + 162)
4598 #define DTAPI_E_CM_UNSUP            (DTAPI_E + 163)
4599 #define DTAPI_E_I2C                 (DTAPI_E + 164)
4600 #define DTAPI_E_STATE               (DTAPI_E + 165)
4601 #define DTAPI_E_NO_LOCK             (DTAPI_E + 166)
4602 #define DTAPI_E_RANGE               (DTAPI_E + 167)
4603 #define DTAPI_E_INVALID_T2PROFILE   (DTAPI_E + 168)
4604 #define DTAPI_E_DSLICE_ID           (DTAPI_E + 169)
4605 #define DTAPI_E_EXCL_ACCESS_REQD    (DTAPI_E + 170)
4606 #define DTAPI_E_CHAN_ALREADY_ADDED  (DTAPI_E + 171)
4607 #define DTAPI_E_LAYER_ID            (DTAPI_E + 172)
4608 #define DTAPI_E_INVALID_FECMODE     (DTAPI_E + 173)
4609 #define DTAPI_E_INVALID_PORT        (DTAPI_E + 174)
4610 #define DTAPI_E_INVALID_PROTOCOL    (DTAPI_E + 175)
4611 #define DTAPI_E_INVALID_FEC_MATRIX  (DTAPI_E + 176)
4612 #define DTAPI_E_INVALID_IP_ADDR     (DTAPI_E + 177)
4613 #define DTAPI_E_INVALID_SRCIP_ADDR  (DTAPI_E + 178)
4614 #define DTAPI_E_IPV6_NOT_SUPPORTED  (DTAPI_E + 179)
4615 #define DTAPI_E_INVALID_DIFFSERV    (DTAPI_E + 180)
4616 #define DTAPI_E_INVALID_FOR_ACM     (DTAPI_E + 181)
4617 #define DTAPI_E_NWAP_DRIVER         (DTAPI_E + 182)
4618 #define DTAPI_E_INIT_ERROR          (DTAPI_E + 183)
4619 #define DTAPI_E_NOT_USB3            (DTAPI_E + 184)
4620 #define DTAPI_E_INSUF_BW            (DTAPI_E + 185)
4621 #define DTAPI_E_NO_ANC_DATA         (DTAPI_E + 186)
4622 #define DTAPI_E_MATRIX_HALTED       (DTAPI_E + 187)
4623 #define DTAPI_E_VLAN_NOT_FOUND      (DTAPI_E + 188)
4624 #define DTAPI_E_NO_ADAPTER_IP_ADDR  (DTAPI_E + 189)
4625 #define DTAPI_E_INVALID_BTYPE       (DTAPI_E + 190)
4626 #define DTAPI_E_INVALID_PARTIAL     (DTAPI_E + 191)
4627 #define DTAPI_E_INVALID_NUMTS       (DTAPI_E + 192)
4628 #define DTAPI_E_INVALID             (DTAPI_E + 193)
4629 #define DTAPI_E_NO_RS422            (DTAPI_E + 194)
4630 #define DTAPI_E_FECFRAMESIZE        (DTAPI_E + 195)
4631 #define DTAPI_E_SFN_NOT_SUPPORTED   (DTAPI_E + 196)
4632 #define DTAPI_E_SFN_INVALID_MODE    (DTAPI_E + 197)
4633 #define DTAPI_E_SFN_INVALID_OFFSET  (DTAPI_E + 198)
4634 #define DTAPI_E_SFN_DISABLED        (DTAPI_E + 199)
4635 #define DTAPI_E_SFN_INVALID_TIMEDIFF (DTAPI_E + 200)
4636 #define DTAPI_E_NO_GPSCLKREF        (DTAPI_E + 201)
4637 #define DTAPI_E_NO_GPSSYNC          (DTAPI_E + 202)
4638 #define DTAPI_E_INVALID_PROFILE     (DTAPI_E + 203)
4639 #define DTAPI_E_INVALID_LINKSTD     (DTAPI_E + 204)
4640 #define DTAPI_E_FRAMERATE_MISMATCH  (DTAPI_E + 205)
4641 #define DTAPI_E_CID_INVALID_ID      (DTAPI_E + 206)
4642 #define DTAPI_E_CID_INVALID_INFO    (DTAPI_E + 207)
4643 #define DTAPI_E_CID_INVALID_FORMAT  (DTAPI_E + 208)
4644 #define DTAPI_E_CID_NOT_SUPPORTED   (DTAPI_E + 209)
4645 #define DTAPI_E_INVALID_SAMPRATE    (DTAPI_E + 210)
4646 #define DTAPI_E_MULTIMOD_UNSUP      (DTAPI_E + 211)
4647 #define DTAPI_E_NUM_CHAN            (DTAPI_E + 212)
4648 #define DTAPI_E_INVALID_TIME        (DTAPI_E + 213)
4649 #define DTAPI_E_INVALID_LINK        (DTAPI_E + 214)
4650 #define DTAPI_E_TUNING              (DTAPI_E + 215)
4651 #define DTAPI_E_BUSY                (DTAPI_E + 216)
4652 #define DTAPI_E_ENC_TYPE_NOTSET     (DTAPI_E + 217)
4653 #define DTAPI_E_INITIALIZING        (DTAPI_E + 218)
4654 #define DTAPI_E_INVALID_ENC_TYPE    (DTAPI_E + 219)
4655 #define DTAPI_E_LICENSE             (DTAPI_E + 220)
4656 #define DTAPI_E_NO_ENCODER          (DTAPI_E + 221)
4657 #define DTAPI_E_NO_POWER            (DTAPI_E + 222)
4658 #define DTAPI_E_PASSTHROUGH_INV     (DTAPI_E + 223)
4659 #define DTAPI_E_PASSTHROUGH_ONLY    (DTAPI_E + 224)
4660 #define DTAPI_E_RX_RATE_OVF         (DTAPI_E + 225)
4661 #define DTAPI_E_IN_ERROR_STATE      (DTAPI_E + 226)
4662 #define DTAPI_E_XML_SYNTAX          (DTAPI_E + 227)
4663 #define DTAPI_E_XML_ELEM            (DTAPI_E + 228)
4664 #define DTAPI_E_FAN_FAIL            (DTAPI_E + 229)
4665 #define DTAPI_E_RESTART_REQD        (DTAPI_E + 230)
4666 #define DTAPI_E_TOO_MANY_SEGM       (DTAPI_E + 231)
4667 #define DTAPI_E_FILE_OPEN           (DTAPI_E + 232)
4668 #define DTAPI_E_INVALID_EAS         (DTAPI_E + 233)
4669 #define DTAPI_E_INVALID_CRED        (DTAPI_E + 234)
4670 #define DTAPI_E_INVALID_PARITY      (DTAPI_E + 235)
4671 #define DTAPI_E_INVALID_PAPR        (DTAPI_E + 236)
4672 #define DTAPI_E_INVALID_FRAMEMODE   (DTAPI_E + 237)
4673 #define DTAPI_E_INVALID_FRAMELENGTH (DTAPI_E + 238)
4674 #define DTAPI_E_NUM_SUBFRAMES       (DTAPI_E + 239)
4675 #define DTAPI_E_PILOT_BOOST         (DTAPI_E + 240)
4676 #define DTAPI_E_NUM_SYMBOLS         (DTAPI_E + 241)
4677 #define DTAPI_E_INVALID_LAYER       (DTAPI_E + 242)
4678 #define DTAPI_E_INVALID_CODERATE    (DTAPI_E + 243)
4679 #define DTAPI_E_INVALID_FECTYPE     (DTAPI_E + 244)
4680 #define DTAPI_E_INVALID_NUM_INPUTS  (DTAPI_E + 245)
4681 #define DTAPI_E_INVALID_VERSION     (DTAPI_E + 246)
4682 #define DTAPI_E_INVALID_LDM_LEVEL   (DTAPI_E + 247)
4683 #define DTAPI_E_INVALID_MISO        (DTAPI_E + 248)
4684 #define DTAPI_E_INVALID_PLP_TYPE    (DTAPI_E + 249)
4685 #define DTAPI_E_NUM_SUBSLICES       (DTAPI_E + 250)
4686 #define DTAPI_E_SUBSLICE_INTERVAL   (DTAPI_E + 251)
4687 #define DTAPI_E_INVALID_HTI_PARS    (DTAPI_E + 252)
4688 #define DTAPI_E_PREAMBLE_PAR_COMBI  (DTAPI_E + 253)
4689 #define DTAPI_E_INVALID_PLP_SIZE    (DTAPI_E + 254)
4690 #define DTAPI_E_INVALID_PLP_START   (DTAPI_E + 255)
4691 #define DTAPI_E_INVALID_PLP_REF     (DTAPI_E + 256)
4692 #define DTAPI_E_INVALID_TXID_INJ    (DTAPI_E + 257)
4693 #define DTAPI_E_INVALID_TXID        (DTAPI_E + 258)
4694 #define DTAPI_E_INVALID_BSID        (DTAPI_E + 259)
4695 #define DTAPI_E_INVALID_BONDING     (DTAPI_E + 260)
4696 
4697 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
4698 //=+=+=+=+=+=+=+=+ DVB-C2, DVB-S2, DVB-T2, ISDB-Tmm Multi PLP Parameters +=+=+=+=+=+=+=+=+
4699 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
4700 
4701 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtBigTsSplitPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
4702 //
4703 // Class for specifying 'Big TS' splitting
4704 //
4705 struct DtBigTsSplitPars
4706 {
4707     bool  m_Enabled;                // Enable 'Big TS' splitting
4708     bool  m_IsCommonPlp;            // Is Common PLP or Layer
4709     bool  m_SplitSdtIn;             // SDT already split (e.g. BBC TS-files)
4710     std::vector<int>  m_Pids;       // Series of PIDs to include in the PLP
4711 
4712     // The parameters below are not used in case of a common PLP
4713     int  m_OnwId;                   // Original Network ID of the Big-TS
4714     int  m_TsId;                    // Transport Stream ID of the Big-TS
4715     int  m_ServiceId;               // ID of service to include in PLP
4716     int  m_PmtPid;                  // PID of the PMT-table
4717     int  m_NewTsId;                 // New Transport Stream ID
4718     int  m_SdtLoopDataLength;       // SDT loop data length. 0..168
4719                                     // Not used if m_SplitSdtIn == true
4720     // The SDT-Actual loop data
4721     unsigned char  m_SdtLoopData[168];
4722 
4723 public:
4724     // Methods
4725     void  Init(void);
4726 
4727     // Operators
4728     bool  operator == (DtBigTsSplitPars& TsSplitPars);
4729     bool  operator != (DtBigTsSplitPars& TsSplitPars);
4730     bool  IsEqual(DtBigTsSplitPars& TsSplitPars);
4731 };
4732 
4733 struct DtPlpInpPars
4734 {
4735     // PLP input data types
4736     enum InDataType
4737     {
4738         TS188,                      // 188-byte TS packets
4739         TS204,                      // 204-byte TS packets
4740         GSE,                        // Generic Stream Encapsulation
4741         ALP,                        // ATSC 3.0 Link-layer Protocol packets
4742         TLVIS3                      // TLV-packets; used for ISDB-S3 5810 byte packets
4743     };
4744 
4745 public:
4746     int  m_FifoIdx;                 // Fifo index used for the PLP
4747                                     // If Big TS file splitting is used, PLPs in a group
4748                                     // can share the input FIFO
4749     InDataType  m_DataType;         // TS188, TS204 byte, GSE or ALP packets
4750     DtBigTsSplitPars  m_BigTsSplit; // Big TS splitting (optional)
4751 
4752 public:
4753     // Methods
4754     void  Init(int Idx=0, InDataType DataType=TS188);
4755 
4756     // Operators
4757     bool  operator == (DtPlpInpPars& PlpInPars);
4758     bool  operator != (DtPlpInpPars& PlpInPars);
4759     bool  IsEqual(DtPlpInpPars& PlpInPars);
4760 
4761     // Serialization
4762     DTAPI_RESULT  FromXml(const std::wstring& XmlString, const std::wstring& Root);
4763     DTAPI_RESULT  ToXml(const std::wstring& Root, std::wstring& XmlString);
4764 };
4765 
4766 // Test point data format
4767 #define DTAPI_TP_FORMAT_HEX         0
4768 #define DTAPI_TP_FORMAT_BIT         1
4769 #define DTAPI_TP_FORMAT_CFLOAT32    2
4770 #define DTAPI_TP_FORMAT_INT64       3
4771 
4772 // Complex floating point type
4773 struct DtComplexFloat
4774 {
4775     float  m_Re, m_Im;              // Real, imaginary part
4776 };
4777 
4778 // Function to write test point data
4779 typedef void  DtTpWriteDataFunc(void* pOpaque, int TpIndex, int StreamIndex,
4780                   const void* Buffer, int Length, int Format, float Mult, int IsNewFrame);
4781 
4782 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtQamStreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
4783 //
4784 // This structure specifies the selection parameters for a QAM transport stream
4785 //
4786 struct DtQamStreamSelPars
4787 {
4788     // No selection parameters yet
4789 };
4790 
4791 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtTestPointOutPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
4792 //
4793 // Class for enabling the test point data output specifying a callback function
4794 //
4795 struct DtTestPointOutPars
4796 {
4797 public:
4798     bool  m_Enabled;                // Enable TP data output
4799     void*  m_pTpWriteDataOpaque;    // Opaque data pointer passed to TpWriteData
4800 
4801     // Callback function for writing test data
4802     DtTpWriteDataFunc*  m_pTpWriteDataFunc;
4803 
4804 public:
4805     // Methods
4806     void  Init(void);
4807 
4808     // Operators
4809     bool  operator == (DtTestPointOutPars& RbmPars);
4810     bool  operator != (DtTestPointOutPars& RbmPars);
4811     bool  IsEqual(DtTestPointOutPars& RbmPars);
4812 };
4813 
4814 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtVirtualOutData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
4815 //
4816 // Structure describing and containing the output data for a virtual output channel
4817 //
4818 struct DtVirtualOutData
4819 {
4820     // Virtual output data types
4821     enum OutDataType
4822     {
4823         IQ_INT16,                   // 16-bit I/Q samples
4824         IQ_FLOAT32,                 // 32 bit float I/Q samples
4825         T2MI_TS188,                 // 188 byte T2MI TS-packets
4826         DVBS2_L3,                   // L3 format for DVB-S2
4827     };
4828     OutDataType  m_DataType;        // Output data type
4829 
4830     // Output type dependent parameters
4831     union {
4832         // 16-bit int I/Q samples
4833         struct {
4834             // Array of buffers; Per output channel a buffer with samples
4835             const unsigned char**  m_pBuffer;
4836             int  m_NumBuffers;      // Number of buffers
4837             int  m_NumBytes;        // Number of bytes
4838         } IqSamplesInt16;
4839 
4840         // 32-bit float I/Q samples
4841         struct {
4842             // Array of buffers. Per output channel a buffer with samples
4843             const unsigned char**  m_pBuffer;
4844             int  m_NumBuffers;      // Number of buffers
4845             int  m_NumBytes;        // Number of bytes
4846         } IqSamplesFloat32;
4847 
4848         // 188-byte T2MI TS packets
4849         struct {
4850             // Pointer to T2MI TS-packet(s)
4851             const unsigned char*  m_pBuffer;
4852             int  m_NumBytes;        // Number of bytes
4853             __int64  m_T2MiFrameNr; // T2MI super frame number counter
4854         } T2MiTs188;
4855 
4856         // L3 frames
4857         struct {
4858             // Pointer to L3 frame(s)
4859             const unsigned char*  m_pBuffer;
4860             int  m_NumBytes;        // Number of bytes
4861         } DvbS2L3;
4862 
4863     } u;
4864 };
4865 
4866 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtVirtualOutPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
4867 //
4868 // Class for specifying the output type and level for a virtual output.
4869 // These parameters are only relevant when outputting to a virtual output channel.
4870 //
4871 struct DtVirtualOutPars
4872 {
4873     bool  m_Enabled;                // Enable virtual output parameters
4874     DtVirtualOutData::OutDataType  m_DataType;
4875                                     // Type of output data
4876     double  m_Gain;                 // The square root of the average power of
4877                                     // the generated signal
4878 public:
4879     void  Init(void);
4880     bool  IsEqual(DtVirtualOutPars& VirtOutPars);
4881     bool  operator == (DtVirtualOutPars& VirtOutPars);
4882     bool  operator != (DtVirtualOutPars& VirtOutPars);
4883     // Serialisation
4884     DTAPI_RESULT  FromXml(const std::wstring& XmlString, const std::wstring& Root);
4885     DTAPI_RESULT  ToXml(const std::wstring& Root, std::wstring& XmlString);
4886 };
4887 
4888 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ ATSC 3.0 Parameters +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
4889 
4890 // Maxima
4891 #define DTAPI_ATSC3_NUM_PLP_MAX     64          // Maximum number of PLPs
4892 #define DTAPI_ATSC3_NUM_RF_MAX      7           // Maximum number of RF output signals
4893 // PLP IDs
4894 #define DTAPI_ATSC3_PLP_ID_AUTO     -2          // Automatic PLP selection
4895 // Bandwidth
4896 #define DTAPI_ATSC3_6MHZ            0           // 6 MHz
4897 #define DTAPI_ATSC3_7MHZ            1           // 7 MHz
4898 #define DTAPI_ATSC3_8MHZ            2           // 8 MHz
4899 #define DTAPI_ATSC3_GT8MHZ          3           // Greater than 8 MHz
4900 // Guard interval
4901 #define DTAPI_ATSC3_GI_1_192        1           // GI1_192
4902 #define DTAPI_ATSC3_GI_2_384        2           // GI3_384
4903 #define DTAPI_ATSC3_GI_3_512        3           // GI3_512
4904 #define DTAPI_ATSC3_GI_4_768        4           // GI4_768
4905 #define DTAPI_ATSC3_GI_5_1024       5           // GI5_1024
4906 #define DTAPI_ATSC3_GI_6_1536       6           // GI6_1536
4907 #define DTAPI_ATSC3_GI_7_2048       7           // GI7_2048
4908 #define DTAPI_ATSC3_GI_8_2432       8           // GI8_2432
4909 #define DTAPI_ATSC3_GI_9_3072       9           // GI9_3072
4910 #define DTAPI_ATSC3_GI_10_3648      10          // GI10_3648
4911 #define DTAPI_ATSC3_GI_11_4096      11          // GI11_4096
4912 #define DTAPI_ATSC3_GI_12_4864      12          // GI12_4864
4913 // Scattered pilot patterns for SISO and MIMO
4914 #define DTAPI_ATSC3_PP_3_2          0           // SP3_2 / MP3_2
4915 #define DTAPI_ATSC3_PP_3_4          1           // SP3_4 / MP3_4
4916 #define DTAPI_ATSC3_PP_4_2          2           // SP4_2 / MP4_2
4917 #define DTAPI_ATSC3_PP_4_4          3           // SP4_4 / MP4_4
4918 #define DTAPI_ATSC3_PP_6_2          4           // SP6_2 / MP6_2
4919 #define DTAPI_ATSC3_PP_6_4          5           // SP6_4 / MP6_4
4920 #define DTAPI_ATSC3_PP_8_2          6           // SP8_2 / MP8_2
4921 #define DTAPI_ATSC3_PP_8_4          7           // SP8_4 / MP8_4
4922 #define DTAPI_ATSC3_PP_12_2         8           // SP12_2 / MP12_2
4923 #define DTAPI_ATSC3_PP_12_4         9           // SP12_4 / MP12_4
4924 #define DTAPI_ATSC3_PP_16_2         10          // SP16_2 / MP16_2
4925 #define DTAPI_ATSC3_PP_16_4         11          // SP16_4 / MP16_4
4926 #define DTAPI_ATSC3_PP_24_2         12          // SP24_2 / MP24_2
4927 #define DTAPI_ATSC3_PP_24_4         13          // SP24_4 / MP24_4
4928 #define DTAPI_ATSC3_PP_32_2         14          // SP32_2 / MP32_2
4929 #define DTAPI_ATSC3_PP_32_4         15          // SP32_4 / MP32_4
4930 // Preamble pilot
4931 #define DTAPI_ATSC3_PP_DX_3         0           // DX=3
4932 #define DTAPI_ATSC3_PP_DX_4         1           // DX=4
4933 #define DTAPI_ATSC3_PP_DX_6         2           // DX=6
4934 #define DTAPI_ATSC3_PP_DX_8         3           // DX=8
4935 #define DTAPI_ATSC3_PP_DX_12        4           // DX=12
4936 #define DTAPI_ATSC3_PP_DX_16        5           // DX=16
4937 #define DTAPI_ATSC3_PP_DX_24        6           // DX=24
4938 #define DTAPI_ATSC3_PP_DX_32        7           // DX=32
4939 // Modulation - constellation
4940 #define DTAPI_ATSC3_QPSK            0           // QPSK
4941 #define DTAPI_ATSC3_QAM16           1           // 16-QAM
4942 #define DTAPI_ATSC3_QAM64           2           // 64-QAM
4943 #define DTAPI_ATSC3_QAM256          3           // 256-QAM
4944 #define DTAPI_ATSC3_QAM1024         4           // 1024-QAM
4945 #define DTAPI_ATSC3_QAM4096         5           // 4096-QAM
4946 // Code rate
4947 #define DTAPI_ATSC3_COD_2_15        0           // 2/15
4948 #define DTAPI_ATSC3_COD_3_15        1           // 3/15
4949 #define DTAPI_ATSC3_COD_4_15        2           // 4/15
4950 #define DTAPI_ATSC3_COD_5_15        3           // 5/15
4951 #define DTAPI_ATSC3_COD_6_15        4           // 6/15
4952 #define DTAPI_ATSC3_COD_7_15        5           // 7/15
4953 #define DTAPI_ATSC3_COD_8_15        6           // 8/15
4954 #define DTAPI_ATSC3_COD_9_15        7           // 9/15
4955 #define DTAPI_ATSC3_COD_10_15       8           // 10/15
4956 #define DTAPI_ATSC3_COD_11_15       9           // 11/15
4957 #define DTAPI_ATSC3_COD_12_15       10          // 12/15
4958 #define DTAPI_ATSC3_COD_13_15       11          // 13/15
4959 
4960 // PLP FEC type
4961 // Inner code
4962 #define DTAPI_ATSC3_LDPC_16K        0           // 16K LDPC
4963 #define DTAPI_ATSC3_LDPC_64K        1           // 64K LDPC
4964 // Outer code
4965 #define DTAPI_ATSC3_OUTER_BCH       0           // BCH
4966 #define DTAPI_ATSC3_OUTER_CRC       1           // CRC
4967 #define DTAPI_ATSC3_OUTER_NONE      2           // None
4968 
4969 // ATSC 3.0 Layer
4970 #define DTAPI_ATSC3_LAYER_CORE      0           // Core layer
4971 #define DTAPI_ATSC3_LAYER_ENHANCED  1           // Enhanced layer
4972 // Time interleaving mode
4973 #define DTAPI_ATSC3_TIMODE_NONE     0           // No time interleaving mode
4974 #define DTAPI_ATSC3_TIMODE_CTI      1           // Convolutional time interleaving
4975 #define DTAPI_ATSC3_TIMODE_HTI      2           // Hybrid time interleaving
4976 // PLP-type
4977 #define DTAPI_ATSC3_PLPTYPE_NONDISP 0           // Non-dispersed PLP-type
4978 #define DTAPI_ATSC3_PLPTYPE_DISP    1           // Dispersed PLP-type
4979 // Convolutional time interleaver depth
4980 #define DTAPI_ATSC3_CTIDEPTH_512    0           // 512 rows
4981 #define DTAPI_ATSC3_CTIDEPTH_724    1           // 724 rows
4982 #define DTAPI_ATSC3_CTIDEPTH_887    2           // 887 rows or 1254 if extended IL
4983 #define DTAPI_ATSC3_CTIDEPTH_1024   3           // 1024 rows or 1448 if extended IL
4984 // MISO
4985 #define DTAPI_ATSC3_MISO_NONE       0           // No MISO
4986 #define DTAPI_ATSC3_MISO_64         1           // MISO with 64 coefficients
4987 #define DTAPI_ATSC3_MISO_256        2           // MISO with 256 coefficients
4988 // FFT size
4989 #define DTAPI_ATSC3_FFT_8K          0           // 8K FFT
4990 #define DTAPI_ATSC3_FFT_16K         1           // 16K FFT
4991 #define DTAPI_ATSC3_FFT_32K         2           // 32K FFT
4992 // TXID injection level
4993 #define DTAPI_ATSC3_TXID_INJ_OFF    0           // Tx-ID injection off
4994 #define DTAPI_ATSC3_TXID_INJ_45DB   1           // Tx-ID injection 45dB below preamble
4995 #define DTAPI_ATSC3_TXID_INJ_42DB   2           // Tx-ID injection 42dB below preamble
4996 #define DTAPI_ATSC3_TXID_INJ_39DB   3           // Tx-ID injection 39dB below preamble
4997 #define DTAPI_ATSC3_TXID_INJ_36DB   4           // Tx-ID injection 36dB below preamble
4998 #define DTAPI_ATSC3_TXID_INJ_33DB   5           // Tx-ID injection 33dB below preamble
4999 #define DTAPI_ATSC3_TXID_INJ_30DB   6           // Tx-ID injection 30dB below preamble
5000 #define DTAPI_ATSC3_TXID_INJ_27DB   7           // Tx-ID injection 27dB below preamble
5001 #define DTAPI_ATSC3_TXID_INJ_24DB   8           // Tx-ID injection 24dB below preamble
5002 #define DTAPI_ATSC3_TXID_INJ_21DB   9           // Tx-ID injection 21dB below preamble
5003 #define DTAPI_ATSC3_TXID_INJ_18DB   10          // Tx-ID injection 18dB below preamble
5004 #define DTAPI_ATSC3_TXID_INJ_15DB   11          // Tx-ID injection 15dB below preamble
5005 #define DTAPI_ATSC3_TXID_INJ_12DB   12          // Tx-ID injection 12dB below preamble
5006 #define DTAPI_ATSC3_TXID_INJ_9DB    13          // Tx-ID injection 9dB below preamble
5007 // PAPR - Peak to Average Power Reduction
5008 #define DTAPI_ATSC3_PAPR_NONE       0           // None
5009 #define DTAPI_ATSC3_PAPR_TR         1           // TR - PAPR using reserved carriers
5010 #define DTAPI_ATSC3_PAPR_ACE        2           // ACE - Active Constellation Extension
5011 #define DTAPI_ATSC3_PAPR_ACE_TR     3           // ACE and TR
5012 // Time information flag
5013 #define DTAPI_ATSC3_TIME_NONE       0           // No time information
5014 #define DTAPI_ATSC3_TIME_MS         1           // Time information with ms precision
5015 #define DTAPI_ATSC3_TIME_US         2           // Time information with us precision
5016 #define DTAPI_ATSC3_TIME_NS         3           // Time information with ns precision
5017 // Frame length mode
5018 #define DTAPI_ATSC3_ALIGN_TIME      0           // Frame length is time-aligned
5019 #define DTAPI_ATSC3_ALIGN_SYMBOL    1           // Frame length is symbol-aligned
5020 
5021 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. DtAtscStreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5022 //
5023 // This structure specifies the selection parameters for an ATSC stream
5024 //
5025 struct DtAtscStreamSelPars
5026 {
5027     // No selection parameters yet
5028 };
5029 
5030 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ ATSC 3.0 Modulation  +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
5031 
5032 // ATSC 3.0  Test points
5033 enum {
5034     DTAPI_ATSC3_TP04,   // Before baseband framer
5035     DTAPI_ATSC3_TP05,   // After baseband framer
5036     DTAPI_ATSC3_TP06,   // After scrambler
5037     DTAPI_ATSC3_TP07,   // After BCH
5038     DTAPI_ATSC3_TP08,   // After LDPC
5039     DTAPI_ATSC3_TP09,   // After bit interleaver
5040     DTAPI_ATSC3_TP10,   // After QAM mapper
5041     DTAPI_ATSC3_TP14,   // After time interleaver
5042     DTAPI_ATSC3_TP15,   // After framing
5043     DTAPI_ATSC3_TP21,   // After pilot and data framer
5044     DTAPI_ATSC3_TP22,   // After MISO
5045     DTAPI_ATSC3_TP26,   // Final
5046 
5047     DTAPI_ATSC3_TP30,   // L1 static data
5048     DTAPI_ATSC3_TP31,   // After scrambling
5049     DTAPI_ATSC3_TP32,   // After BCH
5050     DTAPI_ATSC3_TP34,   // After LDPC
5051     DTAPI_ATSC3_TP37,   // After zero removal
5052     DTAPI_ATSC3_TP39,   // After mapper
5053 
5054     DTAPI_ATSC3_TP40,   // L1 dynamic data
5055     DTAPI_ATSC3_TP42,   // After scrambling
5056     DTAPI_ATSC3_TP43,   // After BCH
5057     DTAPI_ATSC3_TP45,   // After LDPC
5058     DTAPI_ATSC3_TP48,   // After zero removal
5059     DTAPI_ATSC3_TP50,   // After mapper
5060 
5061     DTAPI_ATSC3_TP_COUNT,
5062 };
5063 
5064 // ATSC 3 test points
5065 extern const int DTAPI_ATSC3_TESTPOINTS[DTAPI_ATSC3_TP_COUNT];
5066 
5067 
5068 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3PlpPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5069 //
5070 // Class for specifying the PLP parameters
5071 //
5072 class DtAtsc3PlpPars
5073 {
5074 public:
5075     int  m_Id;                  // PLP-ID: 0..63
5076     bool  m_LlsFlag;            // PLP carries LLS signaling
5077     int  m_Layer;               // Core/Enhanced layer: DTAPI_ATSC3_LAYER_x
5078     int  m_Modulation;          // Modulation, see DTAPI_ATSC3_QAMx
5079     int  m_CodeRate;            // Code rate, see DTAPI_ATSC3_COD_x
5080     int  m_FecCodeLength;       // FEC LDPC code length, see DTAPI_ATSC3_LDPC_x
5081     int  m_FecOuterCode;        // FEC outer code type, see DTAPI_ATSC3_OUTER_x
5082     int  m_LdmInjectLevel;      // LDM injection level (only used in enhanced layer)
5083                                 // value <  10  gives injection level of -value/2.0 dB
5084                                 // value >= 10  gives injection level of 5.0-value dB
5085     bool  m_BbFrameCounter;     // Enable BB-frame counter
5086 
5087     // Folowing parameters are only used in core layer
5088     int  m_PlpType;             // L1D_plp_type; PLP-type, see DTAPI_ATSC3_PLPTYPE_x
5089     int  m_NumSubslices;        // Number of subslices: 1...16384, if PlpType is dispersed
5090     int  m_SubsliceInterval;    // Interval: 1.. 2^24-1, if PlpType is dispersed
5091     int  m_TiMode;              // Time interleaver mode, see DTAPI_ATSC3_TIMODE_x
5092     int  m_CtiDepth;            // Convolutional time interleaver depth,
5093                                 // see DTAPI_ATSC3_CTIDEPTH_xx, if TiMode=CTI
5094     bool  m_TiExtInterleaving;  // Enable extended interleaving
5095 
5096     // HTI interleaving parameters (only applicable if TiMode=HTI)
5097     bool  m_HtiInterSubframe;   // Enable inter-subframe interleaving
5098     int  m_HtiNumTiBlocks;      // If inter-subframe interleaving is disabled: the
5099                                 // number of TI blocks per interleaving frame.
5100                                 // If inter-subframe interleaving is enabled:
5101                                 // the number of subframes over which cells from
5102                                 // one TI block are carried. Range: 1..16
5103     int  m_HtiNumFecBlocksMax;  // The maximum number of FEC blocks per interleaving frame
5104                                 // for the current PLP: 1..4096
5105     bool  m_HtiCellInterleaver; // Enable the cell-interleaver
5106 
5107     // Channel bonding (only signaliing)
5108     int  m_NumChannelBonded;    // Number of frequencies, not including the present
5109                                 // channel, involved in channel bonding of this PLP:
5110                                 // 0..m_NumRf
5111     int  m_BondedRfId[DTAPI_ATSC3_NUM_RF_MAX+1];  // The RF-id(s) that are used for
5112                                 // channel bonding with this PLP
5113 
5114     // Scheduling parameters
5115     int  m_CoreLayerPlpId;      // If enhanced layer, the PLP ID of the corresponding
5116                                 // core layer. Currently the enhanced layer is scheduled
5117                                 // with the same number of cells as the core layer.
5118     int  m_HtiNumFecBlocks;     // Used when TiMode = HTI and core layer.
5119                                 // The number of FEC blocks per subframe,
5120                                 // range: 1..m_HtiNumFecBlocksMax
5121     int  m_PlpSize;             // For core layer: used when TiMode = NONE or CTI.
5122                                 // The number of cells per subframe, -1 means to use the
5123                                 // full subframe.
5124                                 // For enhanced layer: -1 means the complete size of the
5125                                 // first core PLP (identified by m_CoreLayerPlpId).
5126                                 // Otherwise it is the number of cells of the
5127                                 // enhanced layer PLP.
5128     int  m_PlpStart;            // If -1, plp_start is automatically set by allocating
5129                                 // PLPs by increasing PLP index assuming each PLP uses
5130                                 // m_PlpSize cells (plp_type=non-dispersed) or
5131                                 // ceil(m_PlpSize/m_NumSubslices) cells
5132                                 // (plp_type=dispersed).
5133                                 // For complex FDM allocations the previous automatic
5134                                 // algorithm is not sufficient so m_PlpStart must be set
5135                                 // manually.
5136                                 // For  enhanced layer: It is defined as the starting
5137                                 // cell counting from the start of core PLP
5138                                 // (identified by m_CoreLayerPlpId).
5139 public:
5140     DtAtsc3PlpPars();
5141     void  Init(int PlpId = 0);
5142     bool  IsEqual(DtAtsc3PlpPars& PlpPars);
5143     bool  operator == (DtAtsc3PlpPars& PlpPars);
5144     bool  operator != (DtAtsc3PlpPars& PlpPars);
5145 };
5146 
5147 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3SubframePars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5148 //
5149 // Class for specifying the subframe parameters
5150 //
5151 class DtAtsc3SubframePars
5152 {
5153 public:
5154     int  m_Miso;                // MISO type, see DTAPI_ATSC3_MISO_x
5155     int  m_MisoNumTx;           // Number of MISO transmitters: 2, 3 or 4
5156     int  m_MisoTxIndex;         // MISO tranmitter index, range: 0..m_MisoNumTx-1
5157     int  m_FftSize;             // FFT-size, see DTAPI_ATSC3_FFT_x
5158     int  m_ReducedCarriers;     // Carrier reduction coefficient, range 0..4
5159     int  m_GuardInterval;       // Guard interval see DTAPI_ATSC3_GI_x
5160     int  m_PilotPattern;        // Pilot pattern, see DTAPI_ATSC3_PP_x
5161     int   m_PilotBoost;         // Pilot power boost: 0..4
5162     bool  m_SbsFirst;           // First symbol of the subframe is a
5163                                 // subframe boundary symbol
5164     bool  m_SbsLast;            // Last symbol of the subframe is a
5165                                 // subframe boundary symbol
5166     int  m_NumOfdmSymbols;      // Number of payload OFDM symbols including
5167                                 // first and last boundary symbols
5168     bool  m_FreqInterleaver;    // Enable frequency interleaver
5169     // PLPs
5170     std::vector<DtAtsc3PlpPars>  m_Plps;
5171 public:
5172     DtAtsc3SubframePars();
5173     void  Init();
5174     bool  IsEqual(DtAtsc3SubframePars& SubframePars);
5175     bool  operator == (DtAtsc3SubframePars& SubframePars);
5176     bool  operator != (DtAtsc3SubframePars& SubframePars);
5177 };
5178 
5179 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3Pars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5180 //
5181 // Class for specifying the ATSC 3.0 modulation parameters
5182 //
5183 class DtAtsc3Pars
5184 {
5185 public:
5186     // System parameters
5187     int  m_Bandwidth;           // Bandwidth
5188 
5189     // Bootstrap parameters
5190     int  m_MinorVersion;        // Bootstrap minor version 0..7
5191     int  m_EasWakeup;           // Emergency alert wake up field, 0..3
5192 
5193     // Preamble (L1-Basic and L1-Detail) parameters
5194     int  m_PreambleFftSize;     // Preamble FFT size see DTAPI_ATSC3_FFT_x
5195     int  m_PreambleGuardInterval; // Preamble guard interval, see See DTAPI_ATSC3_GI_x
5196     int  m_PreamblePilotDx;     // Preamble pilot pattern Dx, see DTAPI_ATSC3_PP_DX_x
5197     int  m_PreambleReducedCarriers; // Preamble carrier reduction coefficient, range 0..4
5198     int  m_L1BasicFecMode;      // L1-Basic FEC-type mode 1..7
5199     int  m_L1DetailFecMode;     // L1 Detail FEC-type mode: 1..7
5200     int  m_L1DetailAddParity;   // L1-Detail aditional parity mode K: 0, 1 or 2
5201     int  m_L1DetailVersion;     // L1-Detail version 0 or 1
5202 
5203     int  m_TxIdInjectLevelCode; // Tx-ID injection level see DTAPI_ATSC3_TXIDLVL_xx
5204     int  m_TxIdAddress;         // Tx-ID address: 0..8191
5205 
5206     // Time information seconds elapsed since the PTP epoch on 1st January 1970
5207     int   m_TimeInfoFlag;       // Generation of time information: None, Millisecond,
5208                                 // Microsecond, Nanosecond precission,
5209                                 // see DTAPI_ATSC3_TIME_x
5210     int  m_TimeSeconds;         // Initial seconds component
5211     int  m_TimeNanoseconds;     // Initial nanoseconds component
5212     bool  m_LlsFlag;            // One or more PLPs carry low level signaling
5213     int  m_Papr;                // PAPR mode, see DTAPI_ATSC3_PAPR_x
5214 
5215     // Frame parameters
5216     int  m_FrameLengthMode;     // Frame length mode,time or frame aligned see
5217                                 // DTAPI_ATSC3_ALIGN_x
5218     int  m_FrameLength;         // If the frame length mode is time aligned
5219                                 // the framelength in units of 5ms
5220 
5221     // Channel bonding
5222     int  m_NumRf;               // Number of frequencies involved in channel
5223                                 // bonding
5224     int  m_BondedBsId[DTAPI_ATSC3_NUM_RF_MAX];
5225                                 // Broadcast Stream IDs of the bonded channels
5226     int  m_BsId;                // Broadcast Stream ID or -1 if not valid
5227 
5228     // Subframe parameters
5229     std::vector<DtAtsc3SubframePars>  m_Subframes;
5230 
5231     // PLP input
5232     int  m_NumPlpInputs;            // Number of PLPs
5233     DtPlpInpPars  m_PlpInputs[DTAPI_ATSC3_NUM_PLP_MAX];  // PLP inputs (Optional)
5234 
5235     DtVirtualOutPars  m_VirtOutput; // Virtual Output parameters(Optional)
5236     DtTestPointOutPars  m_TpOutput; // Test point data output parameters (Optional)
5237 
5238 public:
5239     DtAtsc3Pars();
5240     DTAPI_RESULT  CheckValidity(void);
5241     DTAPI_RESULT  CheckValidity(int& SubframeIdx, int& PlpIdx);
5242     DTAPI_RESULT  GetParamInfo(struct DtAtsc3ParamInfo& Atsc3Info);
5243     void Init();
5244     void  SetDefaultPars(void);
5245     bool  IsEqual(DtAtsc3Pars& Atsc3Pars);
5246     bool  operator == (DtAtsc3Pars& Atsc3Pars);
5247     bool  operator != (DtAtsc3Pars& Atsc3Pars);
5248     // Serialisation
5249     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
5250     DTAPI_RESULT  ToXml(std::wstring& XmlString);
5251 };
5252 
5253 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3PlpInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5254 //
5255 struct DtAtsc3PlpInfo
5256 {
5257     int  m_BbFramerate;             // Frame rate in BB-frames per second
5258     int  m_PlpBitrate;              // PLP bitrate in bits per second, excluding the
5259                                     // bbframe header, assuming a two byte position field.
5260 };
5261 
5262 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3SubframeInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5263 //
5264 struct DtAtsc3SubframeInfo
5265 {
5266     int  m_TotalNumDataCells;       // Total number of data cells available for PLPs
5267                                     // including the preamble PLP cells for the first
5268                                     // subframe
5269     int  m_NumCellsInDataSym;       // Number of cells in data symbols
5270     int  m_NumCellsInSbsSym;        // number of cells in SBS symbols
5271     std::vector<DtAtsc3PlpInfo> m_Plps;  // PLP information
5272 };
5273 
5274 
5275 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3ParamInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5276 //
5277 struct DtAtsc3ParamInfo
5278 {
5279     int  m_L1BasicNumDataCells;     // Number of L1-Basic data cells
5280     int  m_L1DetailNumDataCells;    // Number of L1-Detail data cells
5281     int  m_L1DetailNumBytes;        // Number of L1-Detail data cells
5282     int  m_PreambleNumSymbols;      // Number of preamble symbols
5283     int  m_NumCellsInFirstPreamble; // Number of cells in the first preamble symbol
5284     int  m_NumCellsInNextPreamble;  // Number of cells in the next preamble symbol
5285     int  m_NumPlpCellsInPreambles;  // Number of cells in the preamble available for PLPs
5286     int  m_FrameLength;             // Framelength in #samples, including bootstrap
5287 
5288     std::vector<DtAtsc3SubframeInfo> m_Subframes;   // Subframe information
5289 };
5290 
5291 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ ATSC 3.0 Demodulation  +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
5292 
5293 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3DemodL1PlpData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5294 //
5295 // ATSC3 PLP demodulation info from L1 Detail
5296 //
5297 struct DtAtsc3DemodL1PlpData
5298 {
5299     int  m_Id;                  // L1D_plp_id; PLP-ID: 0..63
5300     bool  m_LlsFlag;            // L1D_plp_lls_flag; PLP carrying LLS signalling
5301     int  m_Layer;               // L1D_plp_layer; Core/Enhanced layer: DTAPI_ATSC3_LAYER_x
5302     int  m_Start;               // L1D_plp_start; index of the PLP's first data cell
5303     int  m_Size;                // L1D_plp_size; number of data cells allocated
5304     int  m_ScramblerType;       // L1D_plp_scrambler_type;  0
5305     int  m_FecCodeLength;       // L1D_plp_fec_type (code length), see DTAPI_ATSC3_LDPC_x
5306     int  m_FecOuterCode;        // L1D_plp_fec_type (outer type), see DTAPI_ATSC3_OUTER_x
5307     int  m_Modulation;          // L1D_plp_mod; modulation, see DTAPI_ATSC3_QAMx
5308     int  m_CodeRate;            // L1D_plp_cod; code rate, see DTAPI_ATSC3_COD_x
5309     int  m_TiMode;              // L1D_plp_TI_mode; time interleaver mode,
5310                                 // see DTAPI_ATSC3_TIMODE_x
5311     int  m_FecFrameStart;       // L1D_plp_fecframe_start; start position
5312     int  m_CtiFecFrameStart;    // L1D_plp_CTI_fecframe_start; start position of the
5313                                 // first complete FEC frame for the current PLP leaving
5314                                 // the CTI in the current or subsequent subframes
5315     int  m_NumChannelBonded;    // Number of channels bonded (0 = no channel bounding)
5316     int  m_ChannelBondingFormat;  // Channel bonding format
5317     int  m_BondedRfId[DTAPI_ATSC3_NUM_RF_MAX + 1];  // Bonded RF-IDs
5318 
5319     // .....
5320     int  m_PlpType;             // L1D_plp_type; PLP-type, see DTAPI_ATSC3_PLPTYPE_x
5321     int  m_NumSubslices;        // L1D_plp_num_subslices+1; Number of subslices 1...16384
5322                                 // valid if plp_type=1
5323     int  m_SubsliceInterval;    // L1D_plp_subslice_interval+1; 1.. 2^24-1, valid if plp_type=1
5324     bool  m_TiExtInterleaving;  // L1D_plp_TI_extended_interleaving, extended IL is used
5325     int  m_CtiDepth;            // L1D_plp_CTI_depth; convolutional time interleaver
5326                                 // depth, see DTAPI_ATSC3_CTIDEPTH_x
5327     int   m_CtiStartRow;        // L1D_plp_CTI_start_row; position of the interleaver
5328                                 // selector at the start of the subframe
5329 
5330     // HTI interleaving parameters (only applicable if TiMode=HTI)
5331     bool  m_HtiInterSubframe;   // L1D_plp_HTI_inter_subframe; inter-subframe interleaving
5332                                 // is used.
5333     int  m_HtiNumTiBlocks;      // L1D_plp_HTI_num_ti_blocks; If inter-subframe
5334                                 // interleaving is disabled: the number of TI blocks per
5335                                 // interleaving frame.
5336                                 // If inter-subframe interleaving is enabled:
5337                                 // the number of subframes over which cells from
5338                                 // one TI block are carried. Range: 1..16
5339     int  m_HtiNumFecBlocksMax;  // L1D_plp_HTI_num_fec_blocks_max+1; The maximum number of
5340                                 // FEC blocks per interleaving frame for the current
5341                                 // PLP: 1..4096
5342     int  m_HtiNumFecBlocks[16]; // L1D_plp_HTI_num_fec_blocks+1; the number of FEC blocks
5343                                 // contained in the interleaving frames for the current
5344                                 // PLP
5345     bool m_HtiCellInterleaver;  // L1D_plp_HTI_cell_interleaver;  cell-interleaver is used
5346 
5347     int   m_LdmInjectLevel;     // L1D_plp_ldm_injection_level;
5348                                 // InjectLevel <  10 : InjectLevel/2.0 dB
5349                                 // InjectLevel >= 10 : InjectLevel - 5.0 dB
5350 };
5351 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3DemodL1SubframeData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5352 //
5353 // ATSC3 Subframe demodulation info from L1 Detail
5354 //
5355 struct DtAtsc3DemodL1SubframeData
5356 {
5357     bool  m_Mimo;               // L1D_mimo; MIMO is used
5358     int  m_Miso;                // L1D_miso; MISO type, see DTAPI_ATSC3_MISO_x
5359     int  m_FftSize;             // L1D_fft_size; FFT-size, see DTAPI_ATSC3_FFT_x
5360     int  m_ReducedCarriers;     // L1D_reduced_carriers; carrier reduction coefficient,
5361                                 // range 0..4
5362     int  m_GuardInterval;       // L1D_guard_interval; guard interval see DTAPI_ATSC3_GI_x
5363     int  m_NumOfdmSymbols;      // L1D_num_ofdm_symbols +1; number of data payload
5364                                 // OFDM symbols
5365     int  m_PilotPattern;        // L1D_scattered_pilot_pattern; pilot pattern, see
5366                                 // DTAPI_ATSC3_PP_x
5367     int   m_PilotBoost;         // L1D_scattered_pilot_boost; pilot power boost: 0..4
5368     bool  m_SbsFirst;           // L1D_sbs_first; first symbol of the subframe is a
5369                                 // subframe boundary symbol
5370     bool  m_SbsLast;            // L1D_sbs_last; last symbol of the subframe is a
5371                                 // subframe boundary symbol
5372     int  m_Multiplex;           // L1D_subframe_multiplex - 0=subframes time division
5373                                 // multiplexed, 1=not yet used
5374     bool  m_FreqInterleaver;    // L1D_frequency_interleaver - Frequency interleaver
5375                                 // enabled flag
5376     int  m_SbsNumNullCells;     // L1D_sbs_null_cells - The number of null cells in the
5377                                 // subframe boundary symbol(s)
5378    std::vector<DtAtsc3DemodL1PlpData>  m_Plps;  // PLPs
5379 };
5380 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3DemodL1BasicData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5381 //
5382 // ATSC3 demodulation info from L1 Basic
5383 //
5384 struct DtAtsc3DemodL1BasicData
5385 {
5386     int  m_Version;             // L1B_version; version: 0
5387     int  m_MimoScatPilotEnc;    // L1B_mimo_scattered_pilot_encoding - 0=No MIMO or Walsh
5388                                 // 1=Null pilots
5389     bool  m_LlsFlag;            // L1B_lls_flag - One or more PLPs carrying LLS
5390     int   m_TimeInfoFlag;       // L1B_time_info_flag - Time information is present,
5391                                 // see DTAPI_ATSC3_TIME_x
5392     bool  m_ReturnChannelFlag;  // L1B_return_channel_flag - DRC is supported
5393     int  m_Papr;                // L1B_papr; PAPR mode, see DTAPI_ATSC3_PAPR_x
5394     int  m_FrameLengthMode;     // L1B_frame_length_mode; Frame alignment, see
5395                                 // DTAPI_ATSC3_ALIGN_x
5396     int  m_FrameLength;         // L1B_frame_length, if framelength is time-aligned
5397                                 // time period = L1B_frame_length × 5 ms
5398     int  m_ExcessSamples;       // L1B_excess_samples_per_symbol; if framelength is
5399                                 // time-aligned, the number of excess samples included
5400                                 // in the guard interval of each non-Preamble OFDM symbol
5401     int  m_TimeOffset;          // L1B_time_offset - if m_FrameLengthMode=symbol-aligned,
5402                                 // the number of sample periods between the nearest
5403                                 // preceding or coincident millisecond boundary and the
5404                                 // leading edge of the frame
5405     int  m_AdditionalSamples;   // L1B_additional_samples - if m_FrameLengthMode=
5406                                 // symbol-aligned, the number of additional samples added
5407                                 // at the end of a frame.
5408     int  m_NumSubframes;        // L1B_num_subframes +1; number of subframes: 1..256
5409     // L1-Basic parameters for L1-Detail
5410     int  m_PreambleNumSymbols;  // L1B_preamble_num_symbols +1; number of Preamble
5411                                 // OFDM symbols
5412     int  m_PreambleReducedCarriers; // L1B_preamble_reduced_carriers - Carrier
5413                                 // reduction coefficient range 0..4
5414     int  m_L1DetailContentTag;  // L1B_L1_Detail_content_tag; incremented whenever
5415                                 // L1-Detail contents is modified, 0..3
5416     int  m_L1DetailSize;        // L1B_L1_Detail_size_bytes; size of L1-Detail (in bytes)
5417     int  m_L1DetailFecMode;     // L1B_L1_Detail_fec_type; FEC Type Mode: 1..7
5418     int  m_L1DetailAddParity;   // L1B_L1_Detail_additional_parity_mode;
5419                                 // additional parity mode K, 0, 1 or 2
5420     int  m_L1DetailNumCells;    // L1B_L1_Detail_total_cells; size (in OFDM cells) of
5421                                 // coded and modulated L1-Detail + additional parity bits
5422                                 // of the next frame
5423     // L1-Basic information for the first subframe
5424     bool  m_FirstSubMimo;       // L1B_first_sub_mimo; MIMO is used
5425     int  m_FirstSubMiso;        // L1B_first_sub_miso; MISO type, see DTAPI_ATSC3_MISO_x
5426     int  m_FirstSubFftSize;     // L1B_first_sub_fft_size; FFT-size, see DTAPI_ATSC3_FFT_x
5427     int  m_FirstSubReducedCarriers; // L1B_first_sub_reduced_carriers; carrier reduction
5428                                 // coefficient range: 0..4
5429     int  m_FirstSubGuardInterval; // L1B_first_sub_guard_interval; guard interval,
5430                                 // see DTAPI_ATSC3_GI_x
5431     int  m_FirstSubNumOfdmSymbols; // L1B_first_sub_num_ofdm_symbols +1; number of
5432                                 // data payload OFDM symbols
5433     int  m_FirstSubPilotPattern; // L1B_first_sub_scattered_pilot_pattern; pilot pattern,
5434                                 // see DTAPI_ATSC3_PP_x
5435     int  m_FirstSubPilotBoost;  // L1B_first_sub_scattered_pilot_boost; pilot power
5436                                 // boost, 0..4
5437     bool  m_FirstSubSbsFirst;   // L1B_first_sub_sbs_first; first symbol of the subframe
5438                                 // is a subframe boundary symbol
5439     bool  m_FirstSubSbsLast;    // L1B_first_sub_sbs_last; last symbol of the subframe is
5440                                 // a subframe boundary symbol
5441 };
5442 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3DemodL1DetailData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5443 //
5444 // ATSC3  L1-Detail
5445 //
5446 struct DtAtsc3DemodL1DetailData
5447 {
5448     int  m_Version;             // L1D_version; version: 0
5449     int  m_NumRf;               // L1D_num_rf; number of frequencies involved in channel
5450                                 // bonding
5451     int  m_BondedBsId[DTAPI_ATSC3_NUM_RF_MAX];   // L1D_bonded_bsid of the bonded channels
5452     int  m_BsId;                // Broadcast Stream ID or -1 if not valid
5453 
5454     // Time information seconds elapsed since the PTP epoch on 1st January 1970
5455     int  m_TimeSec;             // L1D_time_sec; seconds component
5456     int  m_TimeMillisec;        // L1D_time_msec; milliseconds component
5457     int  m_TimeMicrosec;        // L1D_time_usec; microseconds component
5458     int  m_TimeNanosec;         // L1D_time_nsec; nanoseconds component
5459     __int64  m_AgeOfTimeInfo;   // The age of the time information in nanoseconds
5460     // Note: L1 basic first_sub are copied in the first subframe
5461     std::vector<DtAtsc3DemodL1SubframeData> m_Subframes;    // Subframes
5462 };
5463 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3DemodBootstrapData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5464 //
5465 // ATSC3  Bootstrap data
5466 //
5467 struct DtAtsc3DemodBootstrapData
5468 {
5469     int  m_MinorVersion;        // Bootstrap minor version: 0..7
5470     int  m_NumSymbols;          // Number of bootstrap symbols
5471     int  m_EasWakeup;           // Emergency alert signal wake-up field: 0..3
5472     int  m_MinTimeToNext;       // Minimum time interval to next frame: 0..31
5473     int  m_SystemBandwidth;     // System bandwidth of the post bootstrap signal
5474     int  m_BsrCoefficient;      // bsr coefficient; sampe rate bootstrap = (N+16)*0.384MHz
5475                                 // 0-127
5476     int  m_PreambleStructure;   // Preample structure, see ATSC PHY standard Annex H
5477     // Parameters derived from the m_PreambleStructure
5478     int  m_L1BasicFecMode;      // L1-Basic FEC type mode: 1..7
5479     int  m_PreambleFftSize;     // Preamble FFT size, see DTAPI_ATSC3_FFT_x
5480     int  m_PreambleGuardInterval; // Preamble guard interval, see See DTAPI_ATSC3_GI_x
5481     int  m_PreamblePilotDx;     // Preamble pilot pattern Dx, see DTAPI_ATSC3_PP_DX_x
5482 };
5483 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3DemodL1Data -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5484 //
5485 // Struct for storing the ATSC 3.0 layer 1 data
5486 //
5487 struct DtAtsc3DemodL1Data
5488 {
5489     DtAtsc3DemodBootstrapData  m_Bootstrap; // Bootstrap data
5490     DtAtsc3DemodL1BasicData  m_L1Basic;     // L1-Basic data
5491     DtAtsc3DemodL1DetailData  m_L1Detail;   // L1-Detail data
5492 };
5493 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3StreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5494 //
5495 // This structure specifies the selection parameters for an ATSC 3.0 stream
5496 //
5497 struct DtAtsc3StreamSelPars
5498 {
5499     int  m_PlpId;                   // ID of the data PLP
5500 };
5501 
5502 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3TxId -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5503 struct DtAtsc3TxId
5504 {
5505     int  m_TxIdAddress;             // Transmitter identification address
5506     double  m_LeveldB;              // Level expressed in dB relative to the ATSC3
5507                                     // symbol power
5508 };
5509 
5510 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAtsc3TxIdInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5511 //
5512 // Information about a ATSC 3.0 transmitter identification
5513 //
5514 struct DtAtsc3TxIdInfo
5515 {
5516     __int64  m_ProgressCount;                   // Scan progress counter
5517     std::vector<DtAtsc3TxId>  m_TxIds;          // Transmitters sorted in decreasing
5518                                                 // relative power
5519 };
5520 
5521 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ DAB Parameters +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
5522 
5523 // DAB error protection modes
5524 #define DTAPI_DAB_UEP               0            // DAB unequal error protection
5525 #define DTAPI_DAB_EEP               1            // DAB equal error protection
5526 
5527 // DAB data extraction mode
5528 enum DtDabExtractionMode
5529 {
5530     DAB_RAW,                        // Raw DAB stream, no extraction
5531     DAB_EXTRACTION_AAC,             // AAC/DAB+ stream extraction
5532     DAB_EXTRACTION_DMB              // DMB stream extraction
5533 };
5534 
5535 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDabEtiStreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5536 //
5537 // Structure for DAB Ensemble Transport Interface (ETI) selection
5538 //
5539 struct DtDabEtiStreamSelPars
5540 {
5541     // No selection parameters yet
5542 };
5543 
5544 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDabStreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5545 //
5546 // Structure for DAB selection
5547 //
5548 struct DtDabStreamSelPars
5549 {
5550     int  m_BitrateKbps;             // Bitrate in kbps
5551     int  m_ErrProtLevel;            // Error protection level: 1..5 (UEP); 1..4 (EEP)
5552     int  m_ErrProtMode;             // Error protection mode: DTAPI_DAB_UEP/EEP
5553     int  m_ErrProtOption;           // Error protection option (EEP only): 0 or 1
5554     int  m_StartAddress;            // Start address in DAB capacity units (64bits)
5555 
5556     // DAB data extraction mode: DAB_RAW, DAB_EXTRACTION_AAC or DAB_EXTRACTION_DMB
5557     DtDabExtractionMode  m_ExtractionMode;
5558 };
5559 
5560 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDabFicStreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5561 //
5562 // Selection parameters for a DAB Fast Information Channel (FIC)
5563 //
5564 struct DtDabFicStreamSelPars
5565 {
5566     // Parameters below are passed in the WriteStreamFunc() callback function;
5567     // the parameters are not used for selection
5568     int  m_CifIndex;                // Index of the CIF in the DAB frame to which this
5569                                     // FIB is associated
5570     int  m_FibIndex;                // Index of this FIB in the group of FIBs that
5571                                     // are associated to the same CIF
5572 };
5573 
5574 // Forward declarations
5575 struct DtDabService;
5576 struct DtDabSubChannel;
5577 struct DtDabServiceComp;
5578 
5579 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDabEnsembleInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5580 //
5581 // Information about a DAB ensemble
5582 //
5583 struct DtDabEnsembleInfo
5584 {
5585     int  m_CountryId;               // Country identifier
5586     int  m_EnsembleReference;       // Indentifier of this ensemble in national area
5587     int  m_ExtCountryCode;          // Extended country code
5588     int  m_InterTableId;            // International table identifier
5589     std::wstring  m_Label;          // Label identifying this ensemble
5590     int  m_LocalTimeOffset;         // Local time offset in half hours from UTC
5591     int  m_LtoUnique;               // Covers one(=0) or several(=1) time zones
5592     int  m_TransmissionMode;        // Transmission mode: 1..4
5593 
5594     // Services contained in this ensemble
5595     std::vector<DtDabService>  m_Services;
5596 
5597     // Subchannels in this ensemble. Key: subchannel identifier
5598     std::map<int, DtDabSubChannel>  m_SubChannels;
5599 };
5600 
5601 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDabService -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5602 //
5603 // Information about a single service. Every service must have one primary service
5604 // component and can have one or more non-primay service components
5605 //
5606 struct DtDabService
5607 {
5608     int  m_CondAccessId;            // Conditional access identifier
5609     int  m_CountryId;               // Country identifier
5610     int  m_ExtCountryCode;          // Extended country code; -1 for program service
5611     bool  m_IsLocal;                // True if local (partial) ensemble service area
5612     std::wstring  m_Label;          // Label identifying this service
5613     int  m_ServiceReference;        // Identifier of the service
5614 
5615     // Components in this service
5616     std::vector<DtDabServiceComp>  m_Components;
5617 };
5618 
5619 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDabServiceComp -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5620 //
5621 // Information about a single DAB service component
5622 //
5623 struct DtDabServiceComp
5624 {
5625     int  m_AudioServiceCompType;    // Audio service component type; -1 if not applicable
5626     int  m_DataServiceCompType;     // Data service component type; -1 if not applicable
5627     int  m_FidChannelId;            // Fast information data channel identifier 0..63;
5628                                     // -1 if not applicable
5629     bool  m_HasCondAccess;          // True if access control applies
5630     bool  m_IsPrimary;              // True if this is the primary component
5631     std::wstring  m_Label;          // Label identifying this service component
5632     int  m_Language;                // Service compoment language or -1
5633     int  m_SubChannelId;            // Subchannel identifier: 0..63; -1 if not applicable
5634     int  m_ServiceCompId;           // Service component identifier; -1 if not applicable
5635     int  m_TransportMechanismId;    // Transport mechanism identifier
5636 };
5637 
5638 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDabSubChannel -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5639 //
5640 // A DAB subchannel contains the data for a single audio or data stream. Every service
5641 // component refers to a subchannel, but multiple service components can refer to the
5642 // same subchannel. In that case more than one service can use the same audio stream.
5643 //
5644 struct DtDabSubChannel
5645 {
5646     int  m_BitrateKbps;             // Bitrate in kbps
5647     int  m_ErrProtLevel;            // Protection level UEP: 1..5; EEP: 1..4
5648     int  m_ErrProtMode;             // Error protection mode: DTAPI_DAB_UEP/EEP
5649     int  m_ErrProtOption;           // Option for EEP; -1 for UEP
5650     int  m_FecScheme;               // FEC scheme; -1 if not applicable
5651     int  m_StartAddress;            // Start address in capacity units (64bits)
5652     int  m_SubChannelId;            // Subchannel identifier: 0..63
5653     int  m_SubChannelSize;          // Size of subchannel in capacity units (64bits)
5654     int  m_UepTableIndex;           // Index in UEP table; -1 if not applicable
5655     int  m_UepTableSwitch;          // UEP table switch; -1 if not applicable
5656 };
5657 
5658 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDabTransmitterId -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5659 struct DtDabTransmitterId
5660 {
5661     int  m_TxMainId;                // Transmitter main identifier;
5662                                     // 0...5 (for transmission mode 3) otherwise 0...69
5663     int  m_TxSubId;                 // Transmitter sub-identifier; 0...23
5664     double  m_RelativePowerdB;      // Transmitter power, relative to total power
5665 };
5666 
5667 
5668 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDabTransmitterIdInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5669 //
5670 // Information about a DAB transmitter identification
5671 //
5672 struct DtDabTransmitterIdInfo
5673 {
5674     std::vector<DtDabTransmitterId>  m_Transmitters;
5675 };
5676 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ DVB-C2 Parameters +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
5677 
5678 // Maxima
5679 #define DTAPI_DVBC2_NUM_DSLICE_MAX  255          // Maximum number of data slices
5680 #define DTAPI_DVBC2_NUM_PLP_MAX     255          // Maximum number of PLPs
5681 #define DTAPI_DVBC2_NUM_NOTCH_MAX   16           // Maximum number of Notches
5682 
5683 // PLP IDs
5684 #define DTAPI_DVBC2_PLP_ID_NONE     -1           // No PLP selected
5685 #define DTAPI_DVBC2_PLP_ID_AUTO     -2           // Automatic PLP selection
5686 
5687 // Data slice IDs
5688 #define DTAPI_DVBC2_DSLICE_ID_AUTO  -2           //  Automatic data slice selection
5689 
5690 // m_Bandwidth
5691 #define DTAPI_DVBC2_6MHZ            6            // 6 MHz
5692 #define DTAPI_DVBC2_8MHZ            8            // 8 MHz
5693 
5694 // m_Guard - Guard interval
5695 #define DTAPI_DVBC2_GI_1_128        0            // 1/128
5696 #define DTAPI_DVBC2_GI_1_64         1            // 1/64
5697 
5698 // m_L1TiMode - L1 time interleaving mode
5699 #define DTAPI_DVBC2_L1TIMODE_NONE   0            // No time interleaving
5700 #define DTAPI_DVBC2_L1TIMODE_BEST   1            // Best fit
5701 #define DTAPI_DVBC2_L1TIMODE_4      2            // 4 OFDM symbols
5702 #define DTAPI_DVBC2_L1TIMODE_8      3            // 8 OFDM symbols
5703 
5704 // m_Type - PLP type
5705 #define DTAPI_DVBC2_PLP_TYPE_COMMON 0            // Common PLP
5706 #define DTAPI_DVBC2_PLP_TYPE_GROUPED 1           // Grouped Data PLP
5707 #define DTAPI_DVBC2_PLP_TYPE_NORMAL 2            // Normal Data PLP
5708 
5709 // m_FecType - PLP FEC type
5710 #define DTAPI_DVBC2_LDPC_16K        0            // 16K LDPC
5711 #define DTAPI_DVBC2_LDPC_64K        1            // 64K LDPC
5712 
5713 // m_CodeRate - PLP code rate
5714 #define DTAPI_DVBC2_COD_2_3         1            // 2/3
5715 #define DTAPI_DVBC2_COD_3_4         2            // 3/4
5716 #define DTAPI_DVBC2_COD_4_5         3            // 4/5
5717 #define DTAPI_DVBC2_COD_5_6         4            // 5/6
5718 #define DTAPI_DVBC2_COD_8_9         5            // 8/9 (For 16K FEC)
5719 #define DTAPI_DVBC2_COD_9_10        5            // 9/10 (For 64K FEC)
5720 
5721 // m_Modulation - PLP constellation
5722 #define DTAPI_DVBC2_QAM16           1            // 16-QAM
5723 #define DTAPI_DVBC2_QAM64           2            // 64-QAM
5724 #define DTAPI_DVBC2_QAM256          3            // 256-QAM
5725 #define DTAPI_DVBC2_QAM1024         4            // 1024-QAM
5726 #define DTAPI_DVBC2_QAM4096         5            // 4096-QAM
5727 #define DTAPI_DVBC2_QAM16384        6            // 16K-QAM non standard, but supported
5728 #define DTAPI_DVBC2_QAM65536        7            // 64K-QAM non standard, but supported
5729 
5730 // m_C2Version - DVB-C2 specification version
5731 #define DTAPI_DVBC2_VERSION_1_2_1   0            // DVB-C2 version 1.2.1
5732 #define DTAPI_DVBC2_VERSION_1_3_1   1            // DVB-C2 version 1.3.1
5733 // m_GseLabelType - DVB-C2 GSE Label size
5734 #define DTAPI_DVBC2_GSE_LABEL_6BYTE 0           // 6 Byte GSE label
5735 #define DTAPI_DVBC2_GSE_LABEL_3BYTE 1           // 3 Byte GSE label
5736 #define DTAPI_DVBC2_GSE_LABEL_NONE  2           // No GSE label
5737 // m_Issy - PLP ISSY
5738 #define DTAPI_DVBC2_ISSY_NONE       0            // No ISSY field is used
5739 #define DTAPI_DVBC2_ISSY_SHORT      1            // 2 byte ISSY field is used
5740 #define DTAPI_DVBC2_ISSY_LONG       2            // 3 byte ISSY field is used
5741 
5742 // m_TiDepth - Data slice time interleaving depth
5743 #define DTAPI_DVBC2_TIDEPTH_NONE    0            // No time interleaving
5744 #define DTAPI_DVBC2_TIDEPTH_4       1            // 4 OFDM symbols
5745 #define DTAPI_DVBC2_TIDEPTH_8       2            // 8 OFDM symbols
5746 #define DTAPI_DVBC2_TIDEPTH_16      3            // 16 OFDM symbols
5747 
5748 // m_Type - Data slice type
5749 #define DTAPI_DVBC2_DSLICE_TYPE_1   0            // Type 1 (Single PLP and fixed mod/cod)
5750 #define DTAPI_DVBC2_DSLICE_TYPE_2   1            // Type 2
5751 
5752 // m_FecHdrType - Data slice FEC frame header type
5753 #define DTAPI_DVBC2_FECHDR_TYPE_ROBUST 0         // Robust mode
5754 #define DTAPI_DVBC2_FECHDR_TYPE_HEM 1            // High efficiency mode
5755 
5756 // DVB-C2 Test points
5757 enum {
5758     DTAPI_DVBC2_TP07,               // FEC frame
5759     DTAPI_DVBC2_TP08,
5760     DTAPI_DVBC2_TP10,
5761     DTAPI_DVBC2_TP13,
5762     DTAPI_DVBC2_TP15,               // Data slice
5763     DTAPI_DVBC2_TP18,               // OFDM output
5764     DTAPI_DVBC2_TP20,
5765     DTAPI_DVBC2_TP22,               // FEC header
5766     DTAPI_DVBC2_TP26,
5767     DTAPI_DVBC2_TP27,               // L1 header
5768     DTAPI_DVBC2_TP31,
5769     DTAPI_DVBC2_TP32,               // L1 part2 data
5770     DTAPI_DVBC2_TP33,               // L1 part2 + padding & CRC
5771     DTAPI_DVBC2_TP37,
5772     DTAPI_DVBC2_TP40,
5773     DTAPI_DVBC2_TP41,
5774     DTAPI_DVBC2_TP42,
5775     DTAPI_DVBC2_TP01,
5776     DTAPI_DVBC2_TP_COUNT,
5777 };
5778 
5779 // DVB-C2 test points
5780 extern const int DTAPI_DVBC2_TESTPOINTS[DTAPI_DVBC2_TP_COUNT];
5781 
5782 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2DSlicePars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5783 //
5784 // Class for specifying the data slice parameters
5785 //
5786 struct DtDvbC2DSlicePars
5787 {
5788     int  m_Id;                      // Data slice ID. 0..255
5789     int  m_TunePosition;            // Tune position relative to the start frequency in
5790                                     // multiples of pilot carrier spacing.
5791                                     // For guard interval 1/128: 0..8191
5792                                     // For guard interval 1/64: 0..16383
5793     int  m_OffsetLeft;              // Offset left in multiples of pilot carrier spacing.
5794                                     // For guard interval 1/128: -128..127
5795                                     // For guard interval 1/64: -256..255
5796     int  m_OffsetRight;             // Offset right in multiples of pilot carrier spacing.
5797                                     // For guard interval 1/128: -128..127
5798                                     // For guard interval 1/64: -256..255
5799                                     // If m_OffsetLeft = m_OffsetRight, the data slice is
5800                                     // empty and no input streams are created for the PLPs
5801                                     // of the data slice.
5802     int  m_TiDepth;                 // Time interleaving depth. See DTAPI_DVBC2_TIDEPTH_x
5803     int  m_Type;                    // Data slice type. See DTAPI_DVBC2_DSLICE_TYPE_x
5804     int  m_FecHdrType;              // FEC header type. See DTAPI_DVBC2_FECHDR_TYPE_x
5805     bool  m_ConstConfig;            // Constant data slice configuration
5806     bool  m_LeftNotch;              // Left notch present
5807 
5808     // Data per PLP
5809     std::vector<DtDvbC2PlpPars>  m_Plps;
5810 
5811 public:
5812     void  Init(int Id=0);
5813     bool  IsEqual(DtDvbC2DSlicePars& DSlicePars);
5814     bool  operator == (DtDvbC2DSlicePars& DSlicePars);
5815     bool  operator != (DtDvbC2DSlicePars& DSlicePars);
5816 };
5817 
5818 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2L1UpdatePlpPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5819 //
5820 // struct for L1 PLP parameter update support
5821 //
5822 struct DtDvbC2L1UpdatePlpPars
5823 {
5824     bool  m_Enable;                 // Enable or disable the PLP.
5825                                     // Only PLPs with m_NoData = true can be disabled.
5826 public:
5827     void  Init();
5828     bool  IsEqual(DtDvbC2L1UpdatePlpPars& PlpUpdatePars);
5829     bool  operator == (DtDvbC2L1UpdatePlpPars& PlpUpdatePars);
5830     bool  operator != (DtDvbC2L1UpdatePlpPars& PlpUpdatePars);
5831 };
5832 
5833 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2L1UpdateDSlicePars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5834 //
5835 // struct for L1 DSlice parameter update support
5836 //
5837 struct DtDvbC2L1UpdateDSlicePars
5838 {
5839     bool  m_Enable;                 // Enable or disable the DSlice.
5840                                     // Only dummy data slices can be disabled.
5841                                     // A data slice is considered as dummy if either:
5842                                     // - m_OffsetLeft == m_OffsetRight in its
5843                                     //   global configuration; or
5844                                     // - all its PLPs have m_NoData = true
5845                                     // A dummy data slice is modulated with dummy data.
5846 
5847     int  m_OffsetLeft;              // Data slice left offset - 0..2^(8+g)-1
5848     int  m_OffsetRight;             // Data slice right offset - 0..2^(8+g)-1
5849                                     // If the data slice is not dummy:
5850                                     // - For type 1 , no size change is accepted.
5851                                     // - For type 2 , size change is accepted
5852                                     //   provided it is not zero (i.e. m_OffsetRight >
5853                                     // m_OffsetLeft). It is up to the user to ensure that
5854                                     // there is no bitrate overflow.
5855     std::vector<DtDvbC2L1UpdatePlpPars>  m_Plps; // L1 PLP updates
5856 
5857 public:
5858     void  Init();
5859     bool  IsEqual(DtDvbC2L1UpdateDSlicePars& DSliceUpdatePars);
5860     bool  operator == (DtDvbC2L1UpdateDSlicePars& DSliceUpdatePars);
5861     bool  operator != (DtDvbC2L1UpdateDSlicePars& DSliceUpdatePars);
5862 };
5863 
5864 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2L1UpdatePars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5865 //
5866 // L1 update support
5867 //
5868 struct DtDvbC2L1UpdatePars
5869 {
5870     int  m_NumFrames;               // The following parameters are used during
5871                                     // 'm_NumFrames' C2 frames
5872     // L1 DSlice updates
5873     std::vector<DtDvbC2L1UpdateDSlicePars>  m_DSlices;
5874     bool m_EarlyWarningSystem;      // Early warning system
5875 
5876 public:
5877     void  Init();
5878     bool  IsEqual(DtDvbC2L1UpdatePars& L1UpdatePars);
5879     bool  operator == (DtDvbC2L1UpdatePars& L1UpdatePars);
5880     bool  operator != (DtDvbC2L1UpdatePars& L1UpdatePars);
5881 };
5882 
5883 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2ModStatus -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5884 //
5885 // Structure for retrieving the DVB-C2 MPLP modulator status
5886 //
5887 struct DtDvbC2ModStatus
5888 {
5889     int  m_MplpModFlags;            // Multi PLP modulator flags
5890     __int64  m_DjbOverflows;        // Count number of DJB overflows. If it happens,
5891                                     // issy output delay must be decreased or "issy bufs"
5892                                     // increased.
5893     __int64  m_DjbUnderflows;       // Count number of DJB underflows. If it happens,
5894                                     // issy output delay must be increased.
5895 };
5896 
5897 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2NotchPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5898 //
5899 // Class for specifying the notch parameters
5900 //
5901 struct DtDvbC2NotchPars
5902 {
5903     int  m_Start;                   // Notch start in multiples of pilot carrier spacing.
5904                                     // For guard interval 1/128: 0..8191
5905                                     // For guard interval 1/64: 0..16383
5906     int  m_Width;                   // Notch width in multiples of pilot carrier spacing.
5907                                     // For guard interval 1/128: 0..255
5908                                     // For guard interval 1/64: 0..511
5909 public:
5910     void  Init(void);
5911     bool  IsEqual(DtDvbC2NotchPars& NotchPars);
5912     bool  operator == (DtDvbC2NotchPars& NotchPars);
5913     bool  operator != (DtDvbC2NotchPars& NotchPars);
5914 };
5915 
5916 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2PaprPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5917 //
5918 // Class for specifying and enabling the PAPR reduction parameters
5919 //
5920 struct DtDvbC2PaprPars
5921 {
5922     bool  m_TrEnabled;              // TR enabled
5923     double  m_TrVclip;              // TR clipping threshold 1..4.32 (Volt)
5924     int  m_TrMaxIter;               // TR maximum number of iterations. Must be >= 1.
5925                                     // Note: PAPR TR processing time is proportional
5926                                     //       to this parameter
5927 public:
5928     void  Init(void);
5929     bool  IsEqual(DtDvbC2PaprPars& PaprPars);
5930     bool  operator == (DtDvbC2PaprPars& PaprPars);
5931     bool  operator != (DtDvbC2PaprPars& PaprPars);
5932 };
5933 
5934 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2ParamInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
5935 //
5936 // DVB-C2 parameter info
5937 //
5938 struct DtDvbC2ParamInfo
5939 {
5940     int  m_L1Part2Length;           // #bits of the L1 part2 data (including CRC)
5941     int  m_NumL1Symbols;            // Number of L1 symbols (LP)
5942     int  m_NumSymbols;              // Total number of symbols per frame (LP + Ldata)
5943     int  m_PilotSpacing;            // Distance between pilots (Dx)
5944     int  m_FftSize;                 // FFT size
5945     int  m_MinCarrierOffset;        // Lowest used carrier offset (Koffset)
5946     int  m_CenterFrequency;         // Center frequency in multiples of the carrier
5947                                     // spacing
5948 };
5949 
5950 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2PlpPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
5951 //
5952 // Class for specifying the parameters of a PLP.
5953 // In case of bundled PLPs, only the mode adaptation parameters from the
5954 // first PLP of the bundle are used.
5955 //
5956 struct DtDvbC2PlpPars
5957 {
5958     int  m_Ccm;                     // ACM/CMM bit in the BBframe header 0 or 1
5959     // Mode adaptation layer: TS input
5960     bool  m_Hem;                    // High Efficiency Mode
5961     bool  m_Npd;                    // Null Packet Deletion
5962     int  m_Issy;                    // Issy mode. See DTAPI_DVBC2_ISSY_x
5963     int  m_IssyBufs;                // Issy BUFS
5964     int  m_IssyOutputDelay;         // Delay (in T units) between the incoming data and
5965                                     // the output TS in the receiver model. This value
5966                                     // determines the minimum and maximum dejitter buffer
5967                                     // usage and is used to compute the ISSY BUFSTAT field
5968     int  m_TsRate;                  // If 0 the rate is computed from the PLP parameters,
5969                                     // only possible in case of single PLP and no ISSY
5970                                     // is used
5971     // Mode adaptation layer: GSE input
5972     int  m_GseLabelType;            // GSE-label type. See DTAPI_DVBC2_GSE_LABEL_XXX
5973     // Modulation parameters
5974     int  m_Id;                      // PLP ID. 0..255
5975     bool  m_Bundled;                // A bundled PLP can appear in several data slices.
5976                                     // All the PLP instances have the same PLP ID.
5977                                     // Only a single input stream results from the
5978                                     // first PLP of the bundle.
5979     int  m_Type;                    // PLP Type. See DTAPI_DVBC2_PLP_TYPE_x
5980     int  m_PayloadType;             // PLP payload type: DTAPI_DVBC2_PAYLOAD_XXX
5981     int  m_GroupId;                 // Group ID. 0..255
5982     int  m_FecType;                 // FEC Type. 0=16K, 1=64K
5983     int  m_CodeRate;                // PLP Code rate. See DTAPI_DVBC2_COD_x
5984     int  m_Modulation;              // PLP Modulation. See DTAPI_DVBC2_x
5985     int  m_HdrCntr;                 // Header counter #FECFrames following the
5986                                     // FECFrame header. 0=1FF 1=2FF.
5987                                     // Only used for DSlice type 2.
5988 
5989     // ACM test mode. Only available for type 2 data slices. If number ACM headers != 0,
5990     // then the successive XFEC frames of this PLP use the modulation and coding
5991     // parameters taken from the m_AcmHeaders array. After the last value is used, it
5992     // loops again to the start of the array.
5993     // So DtDvbC2PlpPars.m_FecType, m_Modulation, m_CodeRate and m_HdrCntr are ignored.
5994     std::vector<DtDvbC2XFecFrameHeader> m_AcmHeaders;
5995 
5996     bool  m_PsiSiReproc;            // Indicates whether PSI/SI reprocessing is performed
5997     int  m_TsId;                    // Transport Stream ID (if m_PsiSiReproc=false)
5998     int  m_OnwId;                   // Original Network ID (if m_PsiSiReproc=false)
5999     bool  m_NoData;                 // No input data is provided for this PLP.
6000                                     // It is implicitely true for all PLPs in a data slice
6001                                     // with m_OffsetLeft = m_OffsetRight
6002 public:
6003     void  Init(int PlpId = 0);
6004     bool  IsEqual(DtDvbC2PlpPars& PlpPars);
6005     bool  operator == (DtDvbC2PlpPars& PlpPars);
6006     bool  operator != (DtDvbC2PlpPars& PlpPars);
6007 };
6008 
6009 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2XFecFrameHeader -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6010 //
6011 // DVBC2 FEC frame header for ACM test
6012 //
6013 struct DtDvbC2XFecFrameHeader
6014 {
6015     int  m_FecType;                 // PLP FEC Type. 0=16K, 1=64K
6016     int  m_Modulation;              // PLP Modulation. See DTAPI_DVBC2_x
6017     int  m_CodeRate;                // PLP Code rate. See DTAPI_DVBC2_COD_x
6018     int  m_HdrCntr;                 // Header counter #FEC frames following the
6019                                     // FEC frame header. 0=1FF, 1=2FF
6020     int  m_XFecFrameCount;          // 1..256: Number of successive XFEC frames using
6021                                     // these parameters
6022 public:
6023     void  Init(void);
6024     bool  IsEqual(DtDvbC2XFecFrameHeader& FecHeader);
6025     bool  operator == (DtDvbC2XFecFrameHeader& FecHeader);
6026     bool  operator != (DtDvbC2XFecFrameHeader& FecHeader);
6027 };
6028 
6029 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2Pars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6030 //
6031 // Class for specifying the DVB-C2 modulation parameters
6032 //
6033  struct DtDvbC2Pars
6034 {
6035 public:
6036     // General C2 parameters
6037     int  m_Bandwidth;               // Bandwidth. Defines the OFDM carrier spacing
6038                                     // F=8e6*bandwidth/7/4096 Hz. See DVBC2_BW_x
6039     int  m_NetworkId;               // Network ID.  0..0xFFFF
6040     int  m_C2SystemId;              // C2 System ID.  0..0xFFFF
6041     int  m_StartFrequency;          // Start frequency in multiple of carrier spacing
6042                                     // 0..2^24 - 1 and multiples of dx.
6043                                     // For guard interval 1/128 dx=24, otherwise dx=12
6044     int  m_C2Bandwidth;             // Bandwidth of the generated signal in
6045                                     // multiples of pilot carrier spacing. 0..65535
6046     int  m_GuardInterval;           // Guard interval See DVBC2_GI_x
6047     bool  m_ReservedTone;           // Reserved tone. When there are reserved carriers
6048                                     // (e.g. PAPR TR is enabled) it shall be set to true;
6049                                     // otherwise false
6050     bool m_EarlyWarningSystem;      // Early warning system
6051     int  m_C2Version;               // DVB-C2 Version
6052     int  m_L1TiMode;                // L1 time interleaving mode. See DVBC2_L1TIMODE_x
6053 
6054     // Data slices parameters
6055     int  m_NumDSlices;              // Number of data slices
6056     DtDvbC2DSlicePars  m_DSlices[DTAPI_DVBC2_NUM_DSLICE_MAX];
6057 
6058     // Notches
6059     int  m_NumNotches;              // Number of notches
6060     DtDvbC2NotchPars  m_Notches[DTAPI_DVBC2_NUM_NOTCH_MAX];
6061 
6062     // PLP input
6063     int  m_NumPlpInputs;            // Number of PLPs
6064     DtPlpInpPars  m_PlpInputs[DTAPI_DVBC2_NUM_PLP_MAX];  // PLP inputs (Optional)
6065 
6066     DtDvbC2PaprPars  m_PaprPars;    // PAPR Params (Optional)
6067     DtVirtualOutPars  m_VirtOutput; // Virtual Output parameters(Optional)
6068     DtTestPointOutPars  m_TpOutput; // Test point data output parameters (Optional)
6069     int  m_OutpFreqOffset;          // Output frequency offset from 'm_StartFrequency'
6070                                     // in carriers of the generated spectrum.
6071                                     // Must be multiple of dx.
6072     int  m_OutpBandwidth;           // Output bandwidth in carriers and a multiple of dx.
6073                                     // 0 means default output bandwidth.
6074                                     // Note: for convenience, one more carrier is output
6075                                     // if an edge carrier needs to be output.
6076 
6077     std::vector<DtDvbC2L1UpdatePars>  m_L1Updates; // L1 updates
6078 
6079     // Undocumented
6080     int  m_L1P2ChangeCtr;           // Undocumented. For internal use only
6081     bool  m_NotchTestEnable;        // Undocumented. For internal use only
6082     int  m_TimeWindowLength;        // Undocumented. For internal use only
6083 
6084 public:
6085     DTAPI_RESULT  CheckValidity(void);
6086     DTAPI_RESULT  GetParamInfo(DtDvbC2ParamInfo& C2Info);
6087     void  Init(void);
6088     bool  IsEqual(DtDvbC2Pars& C2Pars);
6089     bool  operator == (DtDvbC2Pars& C2Pars);
6090     bool  operator != (DtDvbC2Pars& C2Pars);
6091 };
6092 
6093 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ DVB-C2 Demodulation  +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
6094 
6095 // DtDvbC2DemodL1Part2Plp::m_PayloadType - The PLP payload type
6096 #define DTAPI_DVBC2_PAYLOAD_GFPS    0            // Generic fixed-length packetized stream
6097 #define DTAPI_DVBC2_PAYLOAD_GCS     1            // Generic continuous stream
6098 #define DTAPI_DVBC2_PAYLOAD_GSE     2            // Generic stream encapsulation
6099 #define DTAPI_DVBC2_PAYLOAD_TS      3            // Transport Stream
6100 
6101 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2DemodL1PlpSigDataPlp -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6102  //
6103 // Struct for storing layer 1 PLP signalling information per PLP.
6104 // For type 1 data slices this struct contains the PLP-signalling information
6105 // from the layer 1 part 2 signalling.
6106 // For type 2 data slices this struct contains the PLP-signalling information
6107 // from the layer 1 part 1 (=FEC-frame header).
6108 //
6109 struct DtDvbC2DemodL1PlpSigDataPlp
6110 {
6111     int  m_Id;                      // PLP ID: 0..255
6112     int  m_FecType;                 // PLP FEC type: 0=LDPC 16K, 1=LDPC 64K
6113     int  m_Modulation;              // PLP modulation, see DTAPI_DVBC2_x
6114     int  m_CodeRate;                // PLP modulation, see DTAPI_DVBC2_x
6115     int  m_HdrCntr;                 // Header counter #FEC frames following the
6116                                     // FEC frame header. 0=1FF, 1=2FF. Only present for
6117                                     // type 2 data slices
6118 
6119     DtDvbC2DemodL1PlpSigDataPlp();
6120 
6121     // Serialisation
6122     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
6123     DTAPI_RESULT  ToXml(std::wstring& XmlString);
6124 };
6125 
6126 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2DemodL1PlpSigData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6127 //
6128 // Struct for storing the DVB-C2 layer 1 PLP signalling data
6129 //
6130 struct DtDvbC2DemodL1PlpSigData
6131 {
6132     int  m_NumPlps;                 // Number of PLPs
6133     std::vector<DtDvbC2DemodL1PlpSigDataPlp>  m_Plps;
6134 
6135     DtDvbC2DemodL1PlpSigData();
6136 
6137     // Serialisation
6138     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
6139     DTAPI_RESULT  ToXml(std::wstring& XmlString);
6140 
6141 };
6142 
6143 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2DemodL1Part2Plp -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6144 //
6145 // Struct for storing Layer 1 part 2 information per PLP
6146 //
6147 struct DtDvbC2DemodL1Part2Plp
6148 {
6149     int  m_Id;                      // PLP ID: 0..255
6150     int  m_Bundled;                 // Bundled PLP
6151     int  m_Type;                    // PLP type, see DTAPI_DVBC2_PLP_TYPE_x
6152     int  m_PayloadType;             // PLP payload type: 0..3
6153     int  m_GroupId;                 // Group ID: 0..255
6154     // Start, FecType, Modulation and CodeRate parameters are not present for type 2 data
6155     // slices
6156     int  m_Start;                   // PLP start: Start of the first complete XFECframe
6157     int  m_FecType;                 // PLP FEC type: 0=LDPC 16K, 1=LDPC 64K
6158     int  m_Modulation;              // PLP modulation, see DTAPI_DVBC2_x
6159     int  m_CodeRate;                // PLP modulation, see DTAPI_DVBC2_x
6160     int  m_PsiSiReproc;             // Indicates whether PSI/SI reprocessing is performed
6161     int  m_TsId;                    // Transport Stream ID (if m_PsiSiReproc=false)
6162     int  m_OnwId;                   // Original Network ID (if m_PsiSiReproc=false)
6163 
6164     DtDvbC2DemodL1Part2Plp();
6165 
6166     // Serialisation
6167     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
6168     DTAPI_RESULT  ToXml(std::wstring& XmlString);
6169 };
6170 
6171 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2DemodL1Part2DSlice -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6172 //
6173 // Struct for storing Layer 1 part 2 information per data slice
6174 //
6175 struct DtDvbC2DemodL1Part2DSlice
6176 {
6177     int  m_Id;                      // Data slice ID: 0..255
6178     int  m_TunePosition;            // Tune position relative to the start frequency in
6179                                     // multiples of pilot carrier spacing.
6180                                     // For guard interval 1/128: 0..8191
6181                                     // For guard interval 1/64: 0..16383
6182     int  m_OffsetLeft;              // Offset left in multiples of pilot carrier spacing.
6183                                     // For guard interval 1/128: -128..127
6184                                     // For guard interval 1/64: -256..255
6185     int  m_OffsetRight;             // Offset right in multiples of pilot carrier spacing.
6186                                     // For guard interval 1/128: -128..127
6187                                     // For guard interval 1/64: -256..255
6188                                     // If m_OffsetLeft = m_OffsetRight, the data slice is
6189                                     // empty and no input streams are created for the PLPs
6190                                     // of the data slice.
6191     int  m_TiDepth;                 // Time interleaving depth, see DTAPI_DVBC2_TIDEPTH_x
6192     int  m_Type;                    // Data slice type, see DTAPI_DVBC2_DSLICE_TYPE_x
6193     int  m_FecHdrType;              // FEC header type, see DTAPI_DVBC2_FECHDR_TYPE_x
6194     int  m_ConstConfig;             // Constant data slice configuration flag
6195     int  m_LeftNotch;               // Left notch present flag
6196     // PLPs
6197     int  m_NumPlps;                 // Number of PLPs
6198     std::vector<DtDvbC2DemodL1Part2Plp>  m_Plps;
6199 
6200     DtDvbC2DemodL1Part2DSlice();
6201 
6202     // Serialisation
6203     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
6204     DTAPI_RESULT  ToXml(std::wstring& XmlString);
6205 };
6206 
6207 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2DemodL1Part2Data -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6208 //
6209 // Struct for storing the DVB-C2 layer 1 part 2data
6210 //
6211 struct DtDvbC2DemodL1Part2Data
6212 {
6213     int  m_NetworkId;               // Network ID:  0..0xFFFF
6214     int  m_C2SystemId;              // C2 System ID: 0..0xFFFF
6215     int  m_StartFrequency;          // Start frequency in multiple of carrier spacing:
6216                                     // 0..2^24 - 1
6217     int  m_C2Bandwidth;             // Bandwidth of the generated signal in
6218                                     // multiples of pilot carrier spacing: 0..65535
6219     int  m_GuardInterval;           // Guard interval. See DVBC2_GI_x
6220     int  m_C2FrameLength;           // C2 frame length: #Data symbols per C2 frame
6221     int  m_L1P2ChangeCtr;           // Value of the L1_PART2_CHANGE_COUNTER field
6222     int  m_ReservedTone;            // Reserved tone
6223     bool m_EarlyWarningSystem;      // Early warning system
6224     int  m_C2Version;               // DVB-C2 Version
6225 
6226     // Data slices
6227     int  m_NumDSlices;              // Number of data slices
6228     std::vector<DtDvbC2DemodL1Part2DSlice>  m_DSlices;
6229 
6230     // Notches
6231     int  m_NumNotches;              // Number of notches
6232     std::vector<DtDvbC2NotchPars>  m_Notches;
6233 
6234     DtDvbC2DemodL1Part2Data();
6235 
6236     // Serialisation
6237     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
6238     DTAPI_RESULT  ToXml(std::wstring& XmlString);
6239 };
6240 
6241 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbC2StreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6242 //
6243 // Structure for DVB-C2 PLP-stream selection
6244 //
6245 struct DtDvbC2StreamSelPars
6246 {
6247     int  m_DSliceId;                // ID of the data slice or DTAPI_DVBC2_DSLICE_ID_AUTO
6248     int  m_PlpId;                   // ID of the data PLP or DTAPI_DVBC2_PLP_ID_xxx
6249     int  m_CommonPlpId;             // ID of the common PLP or DTAPI_DVBC2_PLP_ID_xxx
6250 
6251     // Serialisation
6252     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
6253     DTAPI_RESULT  ToXml(std::wstring& XmlString);
6254 };
6255 
6256 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ DVB-S2 Parameters +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
6257 
6258 #define DTAPI_DVBS2_NUM_PLP_MAX     255          // Maximum number of PLPs
6259 
6260 // m_Issy - PLP ISSY
6261 #define DTAPI_DVBS2_ISSY_NONE       0            // No ISSY field is used
6262 #define DTAPI_DVBS2_ISSY_SHORT      1            // 2 byte ISSY field is used
6263 #define DTAPI_DVBS2_ISSY_LONG       2            // 3 byte ISSY field is used
6264 
6265 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtDvbS2ModStatus -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6266 struct DtDvbS2ModStatus
6267 {
6268     int  m_MplpModFlags;            // Multi PLP modulator flags
6269     __int64  m_DjbOverflows;        // Count number of DJB overflows. If it happens,
6270                                     // issy output delay must be decreased or "issy bufs"
6271                                     // increased.
6272     __int64  m_DjbUnderflows;       // Count number of DJB underflows. If it happens,
6273                                     // issy output delay must be increased.
6274 };
6275 
6276 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtDvbS2FecFrameHeader -.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6277 struct DtDvbS2FecFrameHeader
6278 {
6279     int  m_Modulation;              // PLP Modulation. See DTAPI_MOD_DVBS2_*
6280     int  m_CodeRate;                // PLP Code rate. See DTAPI_MOD_x
6281     int  m_FecFrameSize;            // Fec frame size. See DTAPI_MOD_S2_*FRM
6282     bool  m_HasPilots;              // Enable pilots
6283     int  m_FecFrameCount;           // Number of successive FEC frames using these
6284                                     // parameters, 0 means infinite.
6285 };
6286 
6287 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtDvbS2ModCod -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6288 struct DtDvbS2ModCod
6289 {
6290     int  m_ModType;                 // Modulation type, e.g. DTAPI_MOD_DVBS_QPSK
6291     int  m_CodeRate;                // Code rate, e.g. DTAPI_MOD_1_2
6292     // Constructor
6293     DtDvbS2ModCod();
6294     DtDvbS2ModCod(int ModType, int CodeRate);
6295     bool operator < (const DtDvbS2ModCod& ModCod) const;
6296 };
6297 
6298 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtDvbS2PlpPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6299 struct DtDvbS2PlpPars
6300 {
6301     bool  m_Hem;                    // High Efficiency Mode
6302     bool  m_Npd;                    // Null Packet Deletion
6303     int  m_Issy;                    // Issy mode. See DTAPI_DVBS2_ISSY_x
6304     int  m_IssyBufs;                // Issy BUFS
6305     int  m_IssyOutputDelay;         // Delay (in T units) between the incoming data and
6306                                     // the output TS in the receiver model. This value
6307                                     // determines the minimum and maximum dejitter buffer
6308                                     // usage and is used to compute the ISSY BUFSTAT field
6309     int  m_TsRate;                  // Ts rate
6310     int  m_Ccm;                     // ACM/CMM bit in the BBframe header 0 or 1
6311     int  m_Id;                      // PLP ID. 0..255
6312 
6313     // One or more fec frame headers. If there is only 1 the m_FecFrameCount member
6314     // is ignored. Otherwise that specifies the number of frames to generate with those
6315     // parameters. When that number of frames are generated, the next set of parameters
6316     // is taken. After the last DtDvbS2FecFrameHeader the first one is used again.
6317     std::vector<DtDvbS2FecFrameHeader> m_AcmHeaders;
6318 };
6319 
6320 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtDvbS2Pars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6321 struct DtDvbS2Pars
6322 {
6323     DtVirtualOutPars  m_VirtOutput; // Virtual-output parameters (Optional)
6324     bool  m_L3Output;               // Set to true to enable L3 output
6325     int  m_SymRate;                 // Symbol rate
6326     int  m_RollOff;                 // Roll-off DTAPI_MOD_ROLLOFF_xxx
6327 
6328     // Data per PLP
6329     std::vector<DtDvbS2PlpPars>  m_Plps;
6330     // PLP input
6331     int  m_NumPlpInputs;            // Number of PLPs
6332     DtPlpInpPars  m_PlpInputs[DTAPI_DVBS2_NUM_PLP_MAX];  // PLP inputs (Optional)
6333 
6334     DtDvbS2Pars();
6335     DTAPI_RESULT  CheckValidity();
6336 };
6337 
6338 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ DVB-T2 Parameters +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
6339 
6340 // Maxima
6341 #define DTAPI_DVBT2_NUM_PLP_MAX     255          // Maximum number of PLPs
6342 #define DTAPI_DVBT2_NUM_RF_MAX      7            // Maximum number of RF output signals
6343 
6344 // PLP IDs
6345 #define DTAPI_DVBT2_PLP_ID_NONE     -1           // No PLP selected
6346 #define DTAPI_DVBT2_PLP_ID_AUTO     -2           // Automatic PLP selection
6347 
6348 // m_Issy
6349 #define DTAPI_DVBT2_ISSY_NONE       0            // No ISSY field is used
6350 #define DTAPI_DVBT2_ISSY_SHORT      1            // 2-byte ISSY field is used
6351 #define DTAPI_DVBT2_ISSY_LONG       2            // 3-byte ISSY field is used
6352 
6353 // m_Bandwidth
6354 #define DTAPI_DVBT2_1_7MHZ          0            // 1.7 MHz
6355 #define DTAPI_DVBT2_5MHZ            1            // 5 MHz
6356 #define DTAPI_DVBT2_6MHZ            2            // 6 MHz
6357 #define DTAPI_DVBT2_7MHZ            3            // 7 MHz
6358 #define DTAPI_DVBT2_8MHZ            4            // 8 MHz
6359 #define DTAPI_DVBT2_10MHZ           5            // 10 MHz
6360 #define DTAPI_DVBT2_BW_UNK          -1           // Unknown bandwith
6361 #define DTAPI_DVBT2MI_BW_MSK        0xF          // Mask for T2MI ParXtra2
6362 #define DTAPI_DVBT2MI_BW_UNK        0xF          //Val in ParXtra2 if not set, map to 8MHz
6363 
6364 // m_FftMode
6365 // Warning: the codes are different from the corresponding L1 field
6366 #define DTAPI_DVBT2_FFT_1K          0            // 1K FFT
6367 #define DTAPI_DVBT2_FFT_2K          1            // 2K FFT
6368 #define DTAPI_DVBT2_FFT_4K          2            // 4K FFT
6369 #define DTAPI_DVBT2_FFT_8K          3            // 8K FFT
6370 #define DTAPI_DVBT2_FFT_16K         4            // 16K FFT
6371 #define DTAPI_DVBT2_FFT_32K         5            // 32K FFT
6372 #define DTAPI_DVBT2_FFT_UNK         -1           // Unknown FFT mode
6373 
6374 // m_Miso
6375 #define DTAPI_DVBT2_MISO_OFF        0            // No MISO
6376 #define DTAPI_DVBT2_MISO_TX1        1            // TX1 only
6377 #define DTAPI_DVBT2_MISO_TX2        2            // TX2 only
6378 #define DTAPI_DVBT2_MISO_TX1TX2     3            // TX1+TX2 Legacy
6379 #define DTAPI_DVBT2_MISO_SUM        3            // TX1+TX2
6380 #define DTAPI_DVBT2_MISO_BOTH       4            // TX1 and TX2
6381 
6382 // m_Guard - Guard interval
6383 // Warning: the codes are different from the corresponding L1 field
6384 #define DTAPI_DVBT2_GI_1_128        0            // 1/128
6385 #define DTAPI_DVBT2_GI_1_32         1            // 1/32
6386 #define DTAPI_DVBT2_GI_1_16         2            // 1/16
6387 #define DTAPI_DVBT2_GI_19_256       3            // 19/256
6388 #define DTAPI_DVBT2_GI_1_8          4            // 1/8
6389 #define DTAPI_DVBT2_GI_19_128       5            // 19/128
6390 #define DTAPI_DVBT2_GI_1_4          6            // 1/4
6391 #define DTAPI_DVBT2_GI_UNK          -1           // Unknown guard interval
6392 
6393 // m_Papr - PAPR - Peak to Average Power Reduction
6394 #define DTAPI_DVBT2_PAPR_NONE       0
6395 #define DTAPI_DVBT2_PAPR_ACE        1            // ACE - Active Constellation Extension
6396 #define DTAPI_DVBT2_PAPR_TR         2            // TR - PAPR using reserved carriers
6397 #define DTAPI_DVBT2_PAPR_ACE_TR     3            // ACE and TR
6398 
6399 // m_BwtExt - Bandwidth extension
6400 #define DTAPI_DVBT2_BWTEXT_OFF      false        // No bandwidth extension
6401 #define DTAPI_DVBT2_BWTEXT_ON       true         // Bandwidth extension on
6402 
6403 // m_PilotPattern
6404 // Warning: the codes are different from the corresponding L1 field
6405 #define DTAPI_DVBT2_PP_1            1            // PP1
6406 #define DTAPI_DVBT2_PP_2            2            // PP2
6407 #define DTAPI_DVBT2_PP_3            3            // PP3
6408 #define DTAPI_DVBT2_PP_4            4            // PP4
6409 #define DTAPI_DVBT2_PP_5            5            // PP5
6410 #define DTAPI_DVBT2_PP_6            6            // PP6
6411 #define DTAPI_DVBT2_PP_7            7            // PP7
6412 #define DTAPI_DVBT2_PP_8            8            // PP8
6413 
6414 // m_CodeRate - Code rate
6415 #define DTAPI_DVBT2_COD_1_2         0            // 1/2
6416 #define DTAPI_DVBT2_COD_3_5         1            // 3/5
6417 #define DTAPI_DVBT2_COD_2_3         2            // 2/3
6418 #define DTAPI_DVBT2_COD_3_4         3            // 3/4
6419 #define DTAPI_DVBT2_COD_4_5         4            // 4/5 not for T2 lite
6420 #define DTAPI_DVBT2_COD_5_6         5            // 5/6 not for T2 lite
6421 #define DTAPI_DVBT2_COD_1_3         6            // 1/3 only for T2 lite
6422 #define DTAPI_DVBT2_COD_2_5         7            // 2/5 only for T2 lite
6423 
6424 // m_FefSignal - Type of signal generated during the FEF period
6425 #define DTAPI_DVBT2_FEF_ZERO        0            // Use zero I/Q samples during FEF
6426 #define DTAPI_DVBT2_FEF_1K_OFDM     1            // 1K OFDM symbols with 852 active
6427                                                  // carriers containing BPSK symbols
6428                                                  // (same PRBS as the T2 dummy cells,
6429                                                  // not reset between symbols)
6430 #define DTAPI_DVBT2_FEF_1K_OFDM_384 2            // 1K OFDM symbols with 384 active
6431                                                  //  carriers containing BPSK symbols
6432 
6433 // m_PlpConstel and m_L1Constel - Modulation constellation
6434 #define DTAPI_DVBT2_BPSK            0            // BPSK
6435 #define DTAPI_DVBT2_QPSK            1            // QPSK
6436 #define DTAPI_DVBT2_QAM16           2            // 16-QAM
6437 #define DTAPI_DVBT2_QAM64           3            // 64-QAM
6438 #define DTAPI_DVBT2_QAM256          4            // 256-QAM
6439 
6440 // m_Type - PLP type
6441 #define DTAPI_DVBT2_PLP_TYPE_COMM   0            // Common PLP
6442 #define DTAPI_DVBT2_PLP_TYPE_1      1            // PLP type 1
6443 #define DTAPI_DVBT2_PLP_TYPE_2      2            // PLP type 2
6444 
6445 // m_FecType - PLP FEC type
6446 #define DTAPI_DVBT2_LDPC_16K        0            // 16K LDPC
6447 #define DTAPI_DVBT2_LDPC_64K        1            // 64K LDPC
6448 
6449 // m_TimeIlType - Time interleaving type
6450 #define DTAPI_DVBT2_IL_ONETOONE     0            // Interleaving frame in one T2 frame
6451 #define DTAPI_DVBT2_IL_MULTI        1            // Interleaving frame in multiple frames
6452 
6453 // m_TimeStamping - Type of timestamps in T2MI
6454 #define DTAPI_DVBT2MI_TIMESTAMP_NULL 0           // No timestamping
6455 #define DTAPI_DVBT2MI_TIMESTAMP_REL 1            // Relative timestamps. Use m_Subseconds
6456 #define DTAPI_DVBT2MI_TIMESTAMP_ABS 2            // Absolute timestamps. Use m_T2miUtco,
6457                                                  // m_SecSince2000, m_Subseconds,
6458 
6459 // m_T2Version - DVB-T2 specification version
6460 #define DTAPI_DVBT2_VERSION_1_1_1   0            // DVB-T2 version 1.1.1
6461 #define DTAPI_DVBT2_VERSION_1_2_1   1            // DVB-T2 version 1.2.1
6462 #define DTAPI_DVBT2_VERSION_1_3_1   2            // DVB-T2 version 1.3.1
6463 
6464 // m_T2Profile - DVB-T2 profile
6465 #define DTAPI_DVBT2_PROFILE_BASE    0
6466 #define DTAPI_DVBT2_PROFILE_LITE    1            // Requires DVB-T2 version 1.3.1
6467 
6468 // m_BiasBalancing
6469 #define DTAPI_DVBT2_BIAS_BAL_OFF    0            // No L1 bias compensation
6470 #define DTAPI_DVBT2_BIAS_BAL_ON     1            // Modify L1 reserved fields and L1 ext.
6471                                                  // field padding to compensate L1 bias
6472 // m_GseLabelType - DVB-T2 GSE Label size
6473 #define DTAPI_DVBT2_GSE_LABEL_6BYTE 0           // 6 Byte GSE label
6474 #define DTAPI_DVBT2_GSE_LABEL_3BYTE 1           // 3 Byte GSE label
6475 #define DTAPI_DVBT2_GSE_LABEL_NONE  2           // No GSE label
6476 
6477 #define DTAPI_TXSIG_FEF_LEN_MIN  162212          // Min. FEF length for FEF TX sgnalling
6478 
6479 // DVB-T2 test point enum
6480 enum {
6481     DTAPI_DVBT2_TP00,
6482     DTAPI_DVBT2_TP01,
6483     DTAPI_DVBT2_TP03,
6484     DTAPI_DVBT2_TP04,
6485     DTAPI_DVBT2_TP06,
6486     DTAPI_DVBT2_TP08,
6487     DTAPI_DVBT2_TP09,
6488     DTAPI_DVBT2_TP11,
6489     DTAPI_DVBT2_TP12,
6490     DTAPI_DVBT2_TP15,
6491     DTAPI_DVBT2_TP16,
6492     DTAPI_DVBT2_TP19,               // Only usable if CFLOAT32 output format is selected
6493     DTAPI_DVBT2_TP20,
6494     DTAPI_DVBT2_TP21,
6495     DTAPI_DVBT2_TP22,
6496     DTAPI_DVBT2_TP23,
6497     DTAPI_DVBT2_TP24,
6498     DTAPI_DVBT2_TP25,
6499     DTAPI_DVBT2_TP26,
6500     DTAPI_DVBT2_TP27,
6501     DTAPI_DVBT2_TP28,
6502     DTAPI_DVBT2_TP29,
6503     DTAPI_DVBT2_TP30,
6504     DTAPI_DVBT2_TP32,
6505     DTAPI_DVBT2_TP33,               // T2MI output
6506     DTAPI_DVBT2_TP34,               // T2MI output
6507 
6508     // Receiver Buffer Model
6509     DTAPI_DVBT2_TP50,               // TDI size
6510     DTAPI_DVBT2_TP51,               // TDI write index, TDI read available
6511     DTAPI_DVBT2_TP53,               // DJB size
6512     DTAPI_DVBT2_TP_COUNT,           // Number of test points
6513 };
6514 
6515 extern const int  DTAPI_DVBT2_TESTPOINTS[DTAPI_DVBT2_TP_COUNT];
6516 
6517 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2AuxPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6518 //
6519 // Class for specifying the parameters of AUX streams
6520 //
6521 struct DtDvbT2AuxPars
6522 {
6523     int  m_NumDummyStreams;         // Number of dummy AUX streams
6524 
6525 public:
6526     void  Init(void);
6527     bool  IsEqual(DtDvbT2AuxPars& AuxPars);
6528     bool  operator == (DtDvbT2AuxPars& AuxPars);
6529     bool  operator != (DtDvbT2AuxPars& AuxPars);
6530 };
6531 
6532 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2MiPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6533 //
6534 // Structure for specifying the parametes for T2MI output streams
6535 //
6536 struct DtDvbT2MiPars
6537 {
6538     bool  m_Enabled;                // Enable T2MI output. If enabled, a T2MI
6539                                     // Transport Stream is generated and output
6540     int  m_Pid;                     // T2MI data PID
6541     int  m_StreamId;                // stream ID for the first T2MI stream
6542     int  m_Pid2;                    // Second T2MI data PID
6543     int  m_StreamId2;               // stream ID for the second T2MI stream
6544     int  m_PcrPid;                  // PCR PID. If -1, no PCR is included otherwise
6545                                     // PCRs are inserted on the specified PID
6546     int  m_PmtPid;                  // PMT PID. If -1, no PMT-table and no PAT-table
6547                                     // are included otherwise a PMT-table is inserted
6548                                     // on the specified PID
6549     int  m_TsRate;                  // Rate in bps for the T2MI output
6550     int  m_TimeStamping;            // T2MI timestamps: None, Absolute or Releative
6551                                     // See DVBT2MI_TIMESTAMP_x
6552     __int64  m_SecSince2000;        // First T2MI output timestamp value. Next values
6553                                     // are computed
6554     int  m_Subseconds;              // The number of subseconds. See T2MI spec table 4
6555     int  m_T2miUtco;                // Offset in seconds between UTC and m_SecSince2000.
6556                                     // As of February 2009 the value shall be 2 and
6557                                     // shall change as a result of each new leap second.
6558     bool  m_EncodeFef;              // If true, outputs a FEF part composite packet
6559                                     // with the required subpart. Otherwise, only
6560                                     // outputs a FEF part NULL packet when FEF is
6561                                     // enabled.
6562     bool  m_SyncWithExtClock;       // Undocumented. For internal use only.
6563 public:
6564     void  Init(void);
6565     bool  IsEqual(DtDvbT2MiPars& T2MiPars);
6566     bool  operator == (DtDvbT2MiPars& T2MiPars);
6567     bool  operator != (DtDvbT2MiPars& T2MiPars);
6568 };
6569 
6570 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2ModStatus -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6571 //
6572 // Structure for retrieving the MPLP modulator status
6573 //
6574 struct DtDvbT2ModStatus
6575 {
6576     int  m_MplpModFlags;            // Multi PLP modulator flags
6577     // General MPLP status info
6578     __int64  m_PlpNumBlocksOverflows;
6579                                     // Counts the FEC frames for which the requested
6580                                     // number of PLP blocks is bigger than NumBlocks
6581                                     // (the receiver will get an invalid stream)
6582     __int64  m_BitrateOverflows;    // Counts the frames in which too many bits were
6583                                     // allocated (the receiver will get an invalid stream)
6584     __int64  m_TtoErrorCount;       // Number of times the generated TTO value was
6585                                     // invalid (typically from a too small T_design)
6586 
6587     // T2MI Specific status info
6588     __int64  m_T2MiOutputRateOverFlows;
6589                                     // Number of bit rate overflows(i.e. the T2MI output
6590                                     // rate must be increased for reliable operation)
6591     int  m_T2MiOutputRate;          // Current T2MI rate excluding null packets(in bps)
6592 };
6593 
6594 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2PaprPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6595 //
6596 // Class for specifying and enabling the PAPR reduction parameters
6597 //
6598 struct DtDvbT2PaprPars
6599 {
6600     bool  m_AceEnabled;             // ACE enabled
6601     double  m_AceVclip;             // ACE clipping threshold 1..4.32 (Volt)
6602     double  m_AceGain;              // ACE gain 0..31 (steps of 1)
6603     double  m_AceLimit;             // ACE limit 0.7..1.4 (steps of 0.1)
6604     int  m_AceInterpFactor;         // ACE interpolation factor 1..4
6605                                     // Note: PAPR ACE processing time is proportional
6606                                     // to this parameter (1 recommended for realtime)
6607     int  m_AcePlpIndex;             // PLP used for the PAPR ACE
6608     bool  m_TrEnabled;              // TR enabled
6609     bool  m_TrP2Only;               // PAPR TR is only applied on the P2 symbol
6610     double  m_TrVclip;              // TR clipping threshold 1..4.32 (Volt)
6611     int  m_TrMaxIter;               // TR maximum number of iterations. Must be >= 1
6612                                     // Note: PAPR TR processing time is proportional
6613                                     // to this parameter
6614     int  m_L1ExtLength;             // L1 extension field length 0..65535
6615     bool  m_L1AceEnabled;           // L1 ACE enabled
6616     double  m_L1AceCMax;            // L1 ACE maximum constellation extension value
6617     bool  m_L1Scrambling;           // L1 post scrabling (requires T2-version 1.3.1)
6618 
6619     // Parameters below only apply if DVB-T2 V1.2.1 is selected
6620     int  m_NumBiasBalCells;         // Dummy cells added to reduce the P2 PAPR
6621                                     // 0..BiasBalancingCellsMax
6622     int  m_BiasBalancing;           // Modify the L1 reserved fields and
6623                                     // L1 ext padding to compensate the L1 bias.
6624                                     // See DTAPI_DVBT2_BIAS_x
6625     int  m_TrAlgorithm;             // Undocumented. Must be 1 (default)
6626 
6627 public:
6628     void  Init(void);
6629     bool  IsEqual(DtDvbT2PaprPars& PaprPars);
6630     bool  operator == (DtDvbT2PaprPars& PaprPars);
6631     bool  operator != (DtDvbT2PaprPars& PaprPars);
6632 };
6633 
6634 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2ParamInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6635 //
6636 // DVB-T2 parameter info
6637 //
6638 struct DtDvbT2ParamInfo
6639 {
6640     int  m_TotalCellsPerFrame;      // Total number of cells per frame
6641     int  m_L1CellsPerFrame;         // Total #cells per frame used for L1 signaling
6642                                     // Overhead: m_L1CellsPerFrame/m_TotalCellsPerFrame
6643     int  m_AuxCellsPerFrame;        // Total number of auxiliary stream cells per frame
6644                                     // (currently only used for TX signalling if enabled)
6645     int  m_BiasBalCellsPerFrame;    // Total number of L1 bias balancing cells per frame
6646     int  m_BiasBalCellsMax;         // Maximum number of L1 bias balancing cells per P2
6647     int  m_DummyCellsPerFrame;      // Total number of cells lost per frame. Dummy cells
6648                                     // overhead: m_DummyCellsPerFrame/m_TotalCellsPerFrame
6649                                     // It is computed in case no NDP is used for frame 0.
6650     int  m_SamplesPerFrame;         // Total number of samples per frame
6651 };
6652 
6653 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2PlpPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6654 //
6655 // Class for specifying the parameters of a PLP
6656 //
6657 struct DtDvbT2PlpPars
6658 {
6659     // Mode adaptation layer: TS input
6660     bool  m_Hem;                    // High Efficiency Mode: yes/no
6661     bool  m_Npd;                    // Null Packet Deletion: yes/no
6662     int  m_Issy;                    // ISSY mode. See DTAPI_DVBT2_ISSY_XXX
6663     int  m_IssyBufs;                // ISSY BUFS
6664     int  m_IssyTDesign;             // T-design value for TTO generation.
6665                                     // Use 0 to have the modulator choose the value.
6666                                     // T-design is defined as the delay (in samples)
6667                                     // between the start of the first T2 frame in
6668                                     // which the PLP is mapped (m_FirstFrameIdx) and
6669                                     // the first output bit of the transport stream.
6670     int  m_CompensatingDelay;       // Additional delay (in samples) before the TS
6671                                     // data is sent. Use -1 to have the modulator
6672                                     // choose the value
6673     int  m_TsRate;                  // If 0 the rate is computed from the PLP
6674                                     // parameters. Only possible if no NPD is used.
6675     // Mode adaptation layer: GSE input
6676     int  m_GseLabelType;            // GSE-label type. See DTAPI_DVBT2_GSE_LABEL_XXX
6677 
6678     // DVB-T2 L1 parameters
6679     int  m_Id;                      // PLP ID: 0..255
6680     int  m_GroupId;                 // PLP group ID: 0..255
6681     int  m_Type;                    // PLP type: DTAPI_DVBT2_PLP_TYPE_XXX
6682     int  m_PayloadType;             // PLP payload type: DTAPI_DVBT2_PAYLOAD_XXX
6683     int  m_CodeRate;                // PLP code rate: DTAPI_DVBT2_COD_XXX
6684     int  m_Modulation;              // PLP modulation: DTAPI_DVBT2_BPSK/...
6685     bool  m_Rotation;               // Constellation rotation: yes/no
6686     int  m_FecType;                 // FEC Type. 0=16K, 1=64K; Must be 16K for T2 lite
6687     int  m_FrameInterval;           // T2-frame interval for this PLP: 1..255
6688     int  m_FirstFrameIdx;           // First frame index: 0..m_FrameInterval-1
6689     int  m_TimeIlLength;            // Time interleaving length: 0..255
6690     int  m_TimeIlType;              // Time interleaving type: DTAPI_DVBT2_IL_XXX
6691     bool  m_InBandAFlag;            // In band A signaling information: yes/no
6692     bool  m_InBandBFlag;            // In band B Signaling information: yes/no
6693                                     // Only useful if DVB-T2 V1.2.1 is selected
6694     int  m_NumBlocks;               // Maximum number of FEC blocks contained in
6695                                     // one interleaving frame
6696     bool  m_PlpMute;                // If true the PLP data cells are muted
6697 
6698     // IDs of the other PLPs in the in-band signaling
6699     int  m_NumOtherPlpInBand;       // Number of other PLPs in m_OtherPlpInBand
6700     int  m_OtherPlpInBand[DTAPI_DVBT2_NUM_PLP_MAX-1];
6701 
6702     // The parameters below are only meaningful for type 1 PLPs in TFS case
6703     bool  m_FfFlag;                 // FF flag
6704     int  m_FirstRfIdx;              // First TFS RF channel: 0..NumRf-1
6705 
6706 public:
6707     void  Init(int PlpId = 0);
6708     bool  IsEqual(DtDvbT2PlpPars& PlpPars);
6709     bool  operator == (DtDvbT2PlpPars& PlpPars);
6710     bool  operator != (DtDvbT2PlpPars& PlpPars);
6711 };
6712 
6713 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- RBM events -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6714 //
6715 // RBM events all are errors except plot
6716 //
6717 enum DtDvbT2RbmEventType
6718 {
6719     // Plot event (only generated if m_PlotEnabled is true)
6720     DTAPI_DVBT2_RBM_EVENT_PLOT,
6721     // Dejitter buffer underflow
6722     DTAPI_DVBT2_RBM_EVENT_DJB_UNDERFLOW,
6723     // BUFS=[m_Bufs] gives too small dejitter buffer
6724     DTAPI_DVBT2_RBM_EVENT_BUFS_TOO_SMALL,
6725     // TTO=[m_Tto] gives time in the past
6726     DTAPI_DVBT2_RBM_EVENT_TTO_IN_THE_PAST,
6727     // DJB overflow (should never happen except if the model is buggy)
6728     DTAPI_DVBT2_RBM_EVENT_DJB_OVERFLOW,
6729     // BBFrame parser: CRC8 error in header (val=[m_Val])
6730     DTAPI_DVBT2_RBM_EVENT_CRC8_ERROR_HEADER,
6731     // BBFrame parser: DFL too large
6732     DTAPI_DVBT2_RBM_EVENT_DFL_TOO_LARGE,
6733     // BBFrame parser: SYNCD too large (SYNCD=[m_SyncD] DFL=[m_Dfl])
6734     DTAPI_DVBT2_RBM_EVENT_SYNCD_TOO_LARGE,
6735     // BBFrame parser: invalid UPL
6736     DTAPI_DVBT2_RBM_EVENT_INVALID_UPL,
6737     // BBFrame parser: invalid syncd (syncd=[m_SyncD] left=[m_Left])
6738     DTAPI_DVBT2_RBM_EVENT_INVALID_SYNCD,
6739     // TDI overflow: write pointer ([m_TdiWriteIndex]) ahead of
6740     // read pointer ([m_TdiReadIndex])
6741     DTAPI_DVBT2_RBM_EVENT_TDI_OVERFLOW,
6742     // TDI overflow: too many TI blocks queued
6743     DTAPI_DVBT2_RBM_EVENT_TOO_MANY_TI_BLOCKS,
6744     // plp_start value gives overlap between PLP id=[m_PlpId1] and id=[m_PlpId2]
6745     DTAPI_DVBT2_RBM_EVENT_INVALID_PLP_START,
6746     // Frequency/L1 deinterleaver overflow
6747     DTAPI_DVBT2_RBM_EVENT_FDI_OVERFLOW,
6748     // Not enough ISCR data to estimate the TS rate
6749     DTAPI_DVBT2_RBM_EVENT_NO_TS_RATE,
6750     // ISCR error (delta=[m_Delta])
6751     DTAPI_DVBT2_RBM_EVENT_ISCR_ERROR,
6752     // BUFS not constant (current=[m_CurBufs] new=[m_NewBufs])
6753     DTAPI_DVBT2_RBM_EVENT_BUFS_NOT_CONSTANT,
6754     // ISSYI field cannot change its value
6755     DTAPI_DVBT2_RBM_EVENT_ISSYI_NOT_CONSTANT,
6756     // HEM field cannot change its value
6757     DTAPI_DVBT2_RBM_EVENT_HEM_NOT_CONSTANT,
6758     // plp_num_blocks for this interleaving frame is too small (plp_num_blocks=%d)
6759     // At least 3 FEC block required in interleaving frame with HEM=1,
6760     // at least 1 if HEM=0.
6761     DTAPI_DVBT2_RBM_EVENT_PLP_NUM_BLOCKS_TOO_SMALL,
6762 };
6763 
6764 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2RbmEvent -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6765 //
6766 // RBM event parameters
6767 //
6768 struct DtDvbT2RbmEvent
6769 {
6770     int  m_DataPlpId;               // Data plp ID identifiying the stream
6771     int  m_DataPlpIndex;            // Data plp index
6772     double  m_Time;                 // Time in T units
6773     int  m_IsCommonPlp;             // 1 = common PLP, 0 = data PLP,
6774                                     // -1 = the event does not refer to a particular PLP
6775     DtDvbT2RbmEventType m_EventType;
6776     // Additional parameters
6777     union {
6778         // DTAPI_DVBT2_RBM_EVENT_PLOT parameters
6779         struct {
6780             int  m_TdiWriteIndex;   // TDI write index
6781             int  m_TdiReadIndex;    // TDI read index
6782             int  m_TdiReadAvailable;// Available cells in the TDI read buffer
6783             int  m_DjbSize;         // Dejitter buffer size in bits
6784         } Plot;
6785 
6786         // DTAPI_DVBT2_RBM_EVENT_BUFS_TOO_SMALL parameters
6787         struct {
6788             int  m_Bufs;            // BUFS value
6789         } BufsTooSmall;
6790 
6791         // DTAPI_DVBT2_RBM_EVENT_TTO_IN_THE_PAST parameters
6792         struct {
6793             int  m_Tto;             // TTO value
6794         } TtoInThePast;
6795 
6796         // DTAPI_DVBT2_RBM_EVENT_DJB_OVERFLOW paraneters
6797         struct {
6798             int  m_DjbSize;         // Dejitter buffer size in bits
6799             int  m_DjbMaxSize;
6800         } DjbOverflow;
6801 
6802         // DTAPI_DVBT2_RBM_EVENT_CRC8_ERROR_HEADER parameters
6803         struct {
6804             int  m_Val;             // CRC8 value
6805         } Crc8ErrorHeader;
6806 
6807         // DTAPI_DVBT2_RBM_EVENT_DFL_TOO_LARGE parameters
6808         struct {
6809             int  m_SyncD;           // SYNCD
6810             int  m_Dfl;             // DFL
6811         } SyncDTooLarge;
6812 
6813         // DTAPI_DVBT2_RBM_EVENT_INVALID_SYNCD parameters
6814         struct {
6815             int  m_Syncd;           // SYNCD
6816             int  m_Left;            // Left
6817         } InvalidSyncD;
6818 
6819         // DTAPI_DVBT2_RBM_EVENT_TDI_OVERFLOW parameters
6820         struct {
6821             int  m_TdiWriteIndex;   // TDI write index
6822             int  m_TdiReadIndex;    // TDI read index
6823         } TdiOverflow;
6824 
6825         // DTAPI_DVBT2_RBM_EVENT_INVALID_PLP_START parameters
6826         struct {
6827             int  m_PlpId1;          // IDs of overlapping PLPs
6828             int  m_PlpId2;
6829         } InvalidPlpStart;
6830 
6831         // DTAPI_DVBT2_RBM_EVENT_ISCR_ERROR parameters
6832         struct {
6833             int  m_Delta;           // Delta time in T units
6834         } IscrError;
6835 
6836         // DTAPI_DVBT2_RBM_EVENT_BUFS_NOT_CONSTANT parameters
6837         struct {
6838             int  m_CurBufs;         // Different BUFS values
6839             int  m_newBufs;
6840         } BufsNotConstant;
6841 
6842         // DTAPI_DVBT2_RBM_EVENT_PLP_NUM_BLOCKS_TOO_SMALL parameters
6843         struct {
6844             int  m_PlpNumBlocks;    // Number of blocks
6845         } PlpNumBlocksTooSmall;
6846     } u;
6847 };
6848 
6849 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2RbmValidation -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6850 //
6851 // Class for enabling the RBM validation and specifying a callback function
6852 //
6853 struct DtDvbT2RbmValidation
6854 {
6855 public:
6856     bool  m_Enabled;                // Enable RBM validation
6857     bool  m_PlotEnabled;            // Enable RBM plotting events
6858     int  m_PlotPeriod;              // Plot period
6859     void*  m_pCallbackOpaque;       // RBM event callback function and environment
6860     void  (*m_pCallbackFunc)(void *pOpaque, const DtDvbT2RbmEvent* pRbmEvent);
6861 
6862 public:
6863     void  Init(void);
6864     bool  IsEqual(DtDvbT2RbmValidation& RbmPars);
6865     bool  operator == (DtDvbT2RbmValidation& RbmPars);
6866     bool  operator != (DtDvbT2RbmValidation& RbmPars);
6867 };
6868 
6869 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2TxSigPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6870 //
6871 // Class for specifying and enabling the Transmitter Signature
6872 //
6873 struct DtDvbT2TxSigPars
6874 {
6875     // TX Signature through Auxiliary Streams
6876     // The total number of possible TX IDs are M=3*(P+1)
6877     // The number of cells used per transmitter is N=2^Q
6878     // The number of of T2 frames per TX SIG frame is L=R+1
6879     bool  m_TxSigAuxEnabled;        // Enabled
6880     int  m_TxSigAuxId;              // Transmitter ID. 0..3071
6881     int  m_TxSigAuxP;               // P 0..1023. The total number of possible
6882                                     // TX IDs is M=3*(P+1). Hence M <= 3072
6883     int  m_TxSigAuxQ;               // Q 0..15. The number of cells used per
6884                                     // transmitter is N=2^Q
6885     int  m_TxSigAuxR;               // R 0..255. The number of T2 frames
6886                                     // per TX SIG frame is L=R+1
6887 
6888     // TX Signature through FEF.
6889     // To use this FEF generation must be enabled and  the FEF length
6890     // must be >= DTAPI_TXSIG_FEF_LEN_MIN
6891     bool  m_TxSigFefEnabled;        // Enabled
6892     int  m_TxSigFefId1;             // TX ID for 1st signature period. 0..7
6893     int  m_TxSigFefId2;             // TX ID for 2nd signature period. 0..7
6894 
6895 public:
6896     void  Init(void);
6897     bool  IsEqual(DtDvbT2TxSigPars& TxSigPars);
6898     bool  operator == (DtDvbT2TxSigPars& TxSigPars);
6899     bool  operator != (DtDvbT2TxSigPars& TxSigPars);
6900 };
6901 
6902 // Compare modes
6903 #define DTAPI_DVBT2_COMPA_ALL       0
6904 #define DTAPI_DVBT2_COMPA_ESSENTIAL 1
6905 
6906 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2ComponentPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
6907 //
6908 // Class for specifying the DVB-T2 component modulation parameters
6909 //
6910 class DtDvbT2ComponentPars
6911 {
6912 public:
6913     // General T2 parameters
6914     int  m_T2Version;               // DVB-T2 spec. version. See DVBT2_VERSION_x
6915     int  m_T2Profile;               // DVB-T2 profile. See DVBT2_PROFILE_x
6916     bool  m_T2BaseLite;             // Indicates whether T2 lite is used in a base
6917                                     // profile stream
6918     int  m_Bandwidth;               // Bandwidth: DVBT2_BW_XXX
6919     int  m_FftMode;                 // FFT-mode: DVBT2_FFT_XXX
6920     int  m_Miso;                    // MISO. See DVBT2_MISO_x
6921     int  m_GuardInterval;           // Guard interval. See DVBT2_GI_x
6922     int  m_Papr;                    // PAPR. See DVBT2_PAPR_x
6923     bool  m_BwtExt;                 // Bandwidth extention
6924     int  m_PilotPattern;            // Pilot pattern. Pattern 1 .. 8.
6925     int  m_L1Modulation;            // L1 modulation. See DVBT2_BPSK/...
6926     int  m_CellId;                  // Cell ID.  0..0xFFFF.
6927     int  m_NetworkId;               // Network ID.  0..0xFFFF.
6928     int  m_T2SystemId;              // T2 System ID.  0..0xFFFF.
6929     bool  m_L1Repetition;           // L1 repetition
6930 
6931     // T2-Frame related parameters
6932     int  m_NumT2Frames;             // #T2-frames per superframe. 1..255.
6933     int  m_NumDataSyms;             // #Data symbols
6934     int  m_NumSubslices;            // #Subslices per T2-frame (for type2 PLPs)
6935 
6936     // Component start time
6937     int  m_ComponentStartTime;      // Offset in T unit at which the T2 component
6938                                     // begins to be modulated. (0 in the first component)
6939     // FEF parameters
6940     bool  m_FefEnable;              // FEF enable
6941     int  m_FefType;                 // FEF type. 0..15
6942     int  m_FefS1;                   // FEF S1. 2..7
6943     int  m_FefS2;                   // FEF S2. 1, 3, 5, 7, 9 ,11, 13 or 15
6944     int  m_FefSignal;               // Selects the type of signal generated during
6945                                     // the FEF period (see DTAPI_DVBT2_FEF_x)
6946     int  m_FefLength;               // FEF Length in number of samples.
6947     int  m_FefInterval;             // FEF Interval.
6948                                     //  Requires: (m_NumT2Frames % m_FefInterval) == 0
6949     // RF channels for TFS
6950     int  m_NumRfChans;              // Number of RF channels 1..7
6951     int  m_RfChanFreqs[DTAPI_DVBT2_NUM_RF_MAX];
6952                                     // Channel frequencis
6953     int  m_StartRfIdx;              // First used RF channel
6954 
6955     // PLPs
6956     int  m_NumPlps;                 // Number of PLPs
6957     DtDvbT2PlpPars  m_Plps[DTAPI_DVBT2_NUM_PLP_MAX];
6958                                     // PLP parameters
6959     DtPlpInpPars  m_PlpInputs[DTAPI_DVBT2_NUM_PLP_MAX];
6960                                     // PLP inputs (Optional)
6961     // Optional
6962     DtDvbT2AuxPars  m_Aux;          // AUX Streams (Optional)
6963     DtDvbT2PaprPars  m_PaprPars;    // PAPR Params (Optional)
6964     DtDvbT2TxSigPars  m_TxSignature;// TX-Signature (Optional)
6965     DtDvbT2RbmValidation  m_RbmValidation;
6966                                     // RBM validation (Optional)
6967     DtTestPointOutPars  m_TpOutput; // Test point data output parameters (optional)
6968 
6969     int  m_L1ChangeCounter;         // Undocumented. For internal use only.
6970 
6971 public:
6972     virtual void  Init(void);
6973     virtual bool  IsEqual(DtDvbT2ComponentPars&, int CompareMode=DTAPI_DVBT2_COMPA_ALL);
6974     virtual bool  operator == (DtDvbT2ComponentPars& T2Pars);
6975     virtual bool  operator != (DtDvbT2ComponentPars& T2Pars);
6976 };
6977 
6978 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2Pars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
6979 //
6980 // Class for specifying the DVB-T2 modulation parameters.
6981 //
6982 class DtDvbT2Pars : public DtDvbT2ComponentPars
6983 {
6984 public:
6985     // Optional
6986     DtVirtualOutPars  m_VirtOutput; // Virtual-output parameters (Optional)
6987     DtDvbT2MiPars  m_T2Mi;          // T2MI output (Optional)
6988     int  m_NumFefComponents;        // Number of other T2 stream transmitted in the
6989                                     // FEF part of the first component. The parameters
6990                                     // come from 'm_FefComponent'.
6991 
6992     // FEF components. Currently maximum 1 other component
6993     DtDvbT2ComponentPars  m_FefComponent[1];
6994 
6995 public:
6996       // Constructor
DtDvbT2Pars()6997     DtDvbT2Pars() { Init(); }
6998 
6999     // Methods
7000     virtual void  Init(void);
7001     virtual DTAPI_RESULT  CheckValidity(void);
7002     virtual DTAPI_RESULT  ComputeTDesign();
7003     virtual DTAPI_RESULT  GetParamInfo(DtDvbT2ParamInfo& T2Info);
7004     virtual DTAPI_RESULT  GetParamInfo(DtDvbT2ParamInfo& T2Info1,
7005                                                                DtDvbT2ParamInfo& T2Info2);
7006 
7007     // Only usefull for single PLP
7008     DTAPI_RESULT  OptimisePlpNumBlocks(DtDvbT2ParamInfo&, int&);
7009     DTAPI_RESULT  OptimisePlpNumBlocks(DtDvbT2ParamInfo&, int&, int&);
7010 
7011     // Helper function to determine T2MI ts rate.
7012     static DTAPI_RESULT  RetrieveT2miTsRateFromTs(char* pBuffer, int NumBytes,
7013                                                             int  Bandwidth, int&  TsRate);
7014 
7015     // Operators
7016     virtual bool  operator == (DtDvbT2Pars& T2Pars);
7017     virtual bool  operator != (DtDvbT2Pars& T2Pars);
7018     virtual bool  IsEqual(DtDvbT2Pars& T2Pars, int CompareMode=DTAPI_DVBT2_COMPA_ALL);
7019 };
7020 
7021 //=+=+=+=+=+=+=+=+=+=+=+=+=+ DVB-T2 Demodulation layer 1 data  +=+=+=+=+=+=+=+=+=+=+=+=+=+
7022 
7023 // DtDvbT2DemodL1PostPlp::m_PayloadType - The PLP payload type
7024 #define DTAPI_DVBT2_PAYLOAD_GFPS    0            // Generic Fixed-length Packetized Stream
7025 #define DTAPI_DVBT2_PAYLOAD_GCS     1            // Generic Continuous Stream
7026 #define DTAPI_DVBT2_PAYLOAD_GSE     2            // Generic Stream Encapsulation
7027 #define DTAPI_DVBT2_PAYLOAD_TS      3            // Transport Stream
7028 
7029 // DtDvbT2DemodL1Pre::m_Type - The current T2 super-frame stream type
7030 #define DTAPI_DVBT2_TYPE_TS         0            // Transport Stream (TS) only
7031 #define DTAPI_DVBT2_TYPE_GS         1            // Generic Stream (GS) only
7032 #define DTAPI_DVBT2_TYPE_TS_GS      2            // Mixed TS and GS
7033 
7034 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2DemodAuxPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7035 //
7036 // Struct for storing the Auxiliary stream information from Layer 1 Post
7037 //
7038 struct DtDvbT2DemodAuxPars
7039 {
7040     int  m_AuxStreamType;           // Auxiliary stream type
7041     int  m_AuxPrivateConf;          // Auxiliary stream info
7042 };
7043 
7044 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2DemodL1PostPlp -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7045 //
7046 // Struct for storing Layer 1 Post per PLP
7047 //
7048 struct DtDvbT2DemodL1PostPlp
7049 {
7050     int  m_Id;                      // PLP ID: 0..255
7051     int  m_Type;                    // PLP type, see DTAPI_DVBT2_PLP_TYPE_x
7052     int  m_PayloadType;             // PLP payload type: 0..3
7053     int  m_FfFlag;                  // FF flag
7054     int  m_FirstRfIdx;              // 0..NumRf-1
7055     int  m_FirstFrameIdx;           // First frame in which PLP appears
7056     int  m_GroupId;                 // Group ID: 0..255
7057     int  m_CodeRate;                // PLP code rate, see DTAPI_DVBT2_COD_x
7058     int  m_Modulation;              // PLP modulation, see DTAPI_DVBT2_BPSK/...
7059     int  m_Rotation;                // PLP rotation yes/no
7060     int  m_FecType;                 // PLP FEC type: 0=LDPC 16K, 1=LDPC 64K
7061     int  m_NumBlocks;               // PLP_NUM_BLOCKS_MAX: Maximum number of FEC blocks
7062                                     // contained in one interleaving frame
7063     int  m_FrameInterval;           // The PLP appears every m_FrameInterval frames
7064     int  m_TimeIlLength;            // Time interleaver length: 0..255
7065     int  m_TimeIlType;              // Time interleaver type: 0 or 1
7066     int  m_InBandAFlag;             // IN_BAND_A_FLAG is used yes/no
7067     // V1.2.1 spec revision
7068     int  m_InBandBFlag;             // IN_BAND_B_FLAG is used yes/no
7069     int  m_Reserved1;               // Reserved field, may be used for bias balancing
7070     int  m_PlpMode;                 // PLP mode: 0..3
7071     int  m_Static;                  // Static flag: 0 or 1=Configuration changes only at
7072                                     // super frame boundaries
7073     int  m_StaticPadding;           // Static padding flag: 0 or 1=BBFRAME padding is not
7074                                     // used
7075     DtDvbT2DemodL1PostPlp();
7076 
7077     // Serialisation
7078     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
7079     DTAPI_RESULT  ToXml(std::wstring& XmlString);
7080 };
7081 
7082 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2DemodRfPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7083 //
7084 // Struct for storing the TFS RF channels information from Layer 1 Post
7085 //
7086 struct DtDvbT2DemodRfPars
7087 {
7088     int  m_RfIdx;                   // Index of the RF-frequency
7089     int  m_Frequency;               // Centre frequency in Hz
7090 };
7091 
7092 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2DemodL1Data -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7093 //
7094 // Struct for storing the DVB-T2 layer 1 data
7095 //
7096 struct DtDvbT2DemodL1Data
7097 {
7098     // P1 Info
7099     struct DtDvbT2DemodL1P1
7100     {
7101         bool  m_Valid;              // True if P1 was found
7102         int  m_FftMode;             // FFT mode, see DVBT2_FFT_x
7103         int  m_Miso;                // MISO used
7104         int  m_Fef;                 // FEF used
7105         int  m_T2Profile;           // DVB-T2 profile. See DVBT2_PROFILE_x
7106     } m_P1;
7107 
7108     // L1-pre info
7109     struct DtDvbT2DemodL1Pre
7110     {
7111         bool  m_Valid;              // True if L1 pre was correctly demodulated
7112 
7113         int  m_Type;                // Stream type within the current T2 super-frame
7114         int  m_BwtExt;              // Bandwidth extension
7115         int  m_S1;                  // S1 signalling. P1 S1.
7116         int  m_S2;                  // S2 signalling. P1 S2.
7117         int  m_L1Repetition;        // L1 repetition
7118         int  m_GuardInterval;       // Guard interval, see DVBT2_GI_x
7119         int  m_Papr;                // PAPR. see DVBT2_PAPR_x
7120         int  m_L1Modulation;        // L1 modulation, see DVBT2_BPSK/...
7121         int  m_L1CodeRate;          // L1 coderate, see DTAPI_DVBT2_COD_x
7122         int  m_L1FecType;           // L1 FEC type: 0=LDPC 16K, 1=LDPC 64K
7123         int  m_L1PostSize;          // Size of the L1-post in OFDM cells
7124         int  m_l1PostInfoSize;      // L1-post info size =
7125                                     //              L1-post configurable+dynamic+extension
7126         int  m_PilotPattern;        // Pilot pattern: 1..8
7127         int  m_TxIdAvailability;    // The Tx ID
7128         int  m_CellId;              // Cell ID: 0..0xFFFF
7129         int  m_NetworkId;           // Network ID: 0..0xFFFF
7130         int  m_T2SystemId;          // T2 System ID: 0..0xFFFF
7131         int  m_NumT2Frames;         // Number of T2-frames per superframe: 1..255
7132         int  m_NumDataSyms;         // Number of data symbols
7133         int  m_RegenFlag;           // Regeneration count indicator
7134         int  m_L1PostExt;           // L1-post extensions enabled
7135         int  m_NumRfChans;          // Number of RF channels: 1..7
7136         int  m_CurrentRfIdx;        // Current RF index: 0..m_NumRfChans-1
7137         int  m_T2Version;           // DVB-T2 spec version, see DVBT2_VERSION_x
7138         int  m_L1PostScrambling;    // L1 Post scrambling
7139         int  m_T2BaseLite;          // Indicates whether T2 lite is used in a base
7140                                     // profile stream
7141     } m_L1Pre;
7142 
7143     // L1-post info
7144     struct DtDvbT2DemodL1Post
7145     {
7146         bool  m_Valid;              // True if L1 post was correctly demodulated
7147         int  m_NumSubslices;        // Number of subslices per T2-frame (for type2 PLPs)
7148         int  m_NumPlps;             // Number of PLPs
7149         int  m_NumAux;              // Number of auxiliary streams
7150 
7151         // TFS RF-channels
7152         std::vector<DtDvbT2DemodRfPars>  m_RfChanFreqs;
7153 
7154         // FEF info is meaningful if m_P1.m_Fef = true
7155         int  m_FefType;             // FEF type: 0..15
7156         int  m_FefLength;           // FEF length in number of samples
7157         int  m_FefInterval;         // FEF Interval
7158 
7159         // PLPs
7160         std::vector<DtDvbT2DemodL1PostPlp>  m_Plps;
7161 
7162         // Auxiliary stream signalling information
7163         std::vector<DtDvbT2DemodAuxPars>  m_AuxPars;
7164 
7165     } m_L1Post;
7166 
7167     DtDvbT2DemodL1Data();
7168 
7169     // Serialisation
7170     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
7171     DTAPI_RESULT  ToXml(std::wstring& XmlString);
7172 };
7173 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2TransmitterId -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7174 struct DtDvbT2TransmitterId
7175 {
7176     int  m_TxId;                    // Transmitter identifier;
7177     double  m_RelativePowerdB;      // Transmitter power, relative to total power
7178 };
7179 
7180 
7181 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2TransmitterIdInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7182 //
7183 // Information about identified DVB-T2 transmitters
7184 //
7185 struct DtDvbT2TransmitterIdInfo
7186 {
7187     std::vector<DtDvbT2TransmitterId>  m_Transmitters;
7188 };
7189 
7190 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ ISDBT-TMM +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
7191 
7192 #define DTAPI_ISDBT_NUM_TS_MAX  14
7193 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIsdbTmmPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7194 //
7195 // ISDB-Tmm parameters including per-layer parameters
7196 //
7197 struct DtIsdbTmmPars
7198 {
7199     int  m_Bandwidth;
7200     int  m_SubChannel;
7201     int  m_NumTss;
7202     DtVirtualOutPars  m_VirtOutput;  // Virtual Output parameters(Optional)
7203     DtIsdbtPars  m_Tss[DTAPI_ISDBT_NUM_TS_MAX];
7204     DtPlpInpPars  m_TsInputs[DTAPI_ISDBT_NUM_TS_MAX];
7205 
7206     // Member function
DtIsdbTmmParsDtIsdbTmmPars7207     DtIsdbTmmPars() { Init(); }
7208     DTAPI_RESULT  CheckValidity();
7209     int  NumSegm();
7210     void Init();
7211     DTAPI_RESULT SetSegmentFormat(int TsIdx, int SegmFormat);
7212 
7213     bool  operator == (DtIsdbTmmPars& Rhs);
7214     bool  operator != (DtIsdbTmmPars& Rhs);
7215 };
7216 
7217 
7218 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ Advanced Demodulator +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
7219 
7220 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtStreamType -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7221 //
7222 // Classifies the type of the stream
7223 //
7224 enum DtStreamType
7225 {
7226     STREAM_ATSC,                    // ATSC stream
7227     STREAM_ATSC3,                   // ATSC 3.0 stream (ALP packets)
7228     STREAM_CONSTEL,                 // Constellation points
7229     STREAM_DAB,                     // DAB stream
7230     STREAM_DABETI,                  // DAB Ensemble Transport Interface (NI, G.703)
7231     STREAM_DABFIC,                  // DAB Fast Information Channel
7232     STREAM_DVBC2,                   // DVB-C2 stream (Transport Stream packets)
7233     STREAM_DVBC2_BBFRAME,           // DVB-C2 stream base-band frames
7234     STREAM_DVBC2_GSE,               // DVB-C2 stream GSE-packets
7235     STREAM_DVBT,                    // DVB-T stream
7236     STREAM_DVBT2,                   // DVB-T2 stream (Transport Stream packets)
7237     STREAM_DVBT2_BBFRAME,           // DVB-T2 stream base band frames
7238     STREAM_DVBT2_GSE,               // DVB-T2 stream GSE-packets
7239     STREAM_IMPRESP,                 // Impulse response
7240     STREAM_ISDBT,                   // ISDB-T stream
7241     STREAM_MER,                     // MER
7242     STREAM_QAM,                     // QAM stream
7243     STREAM_SPECTRUM,                // Spectrum
7244     STREAM_T2MI,                    // DVB-T2 stream
7245     STREAM_TF_ABS,                  // Transfer function absolute
7246     STREAM_TF_PHASE,                // Transfer function phase
7247     STREAM_TF_GROUPDELAY,           // Transfer function group delay
7248     STREAM_TXID_IMPRESP             // Impulse reponse of Tx-ID
7249 };
7250 
7251 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtConstelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7252 //
7253 // This structure specifies the parameters for a stream of constellation points
7254 //
7255 struct DtConstelPars
7256 {
7257     int  m_Period;                  // Minimum period between callbacks in ms
7258     int  m_ConstellationType;       // 0: Constellation per PLP
7259                                     // 1: Constellation per carrier (after equalization)
7260     int  m_Index;                   // Index of the carrier or PLP-ID
7261     int  m_MaxNumPoints;            // Maximum number of constellation points
7262 };
7263 
7264 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbTStreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7265 //
7266 // This structure specifies the selection parameters for a DVB-T transport stream
7267 //
7268 struct DtDvbTStreamSelPars
7269 {
7270     // No selection parameters yet
7271 };
7272 
7273 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbTTpsInfo -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7274 //
7275 // DVB-T Transmission Parameter Signalling (TPS) information structure
7276 //
7277 struct DtDvbTTpsInfo
7278 {
7279     int  m_LengthIndicator;         // TPS length indicator
7280     int  m_Constellation;           // Constellation (DTAPI_MOD_DVBT_xxx)
7281     int  m_HpCodeRate;              // High Priority code rate (DTAPI_MOD_xxx)
7282     int  m_LpCodeRate;              // Low Priority code rate(DTAPI_MOD_xxx)
7283     int  m_Guard;                   // Guard interval (DTAPI_MOD_DVBT_G_xx)
7284     int  m_Interleaving;            // Interleaving (DTAPI_MOD_DVBT_xxx)
7285     int  m_Mode;                    // Transmission mode (DTAPI_MOD_DVBT_xK)
7286     int  m_Hierarchy;               // Hierarchy   (DTAPI_MOD_DVBT_HARCHY_xxx)
7287     int  m_CellId;                  // CellId or -1 when not present
7288     int  m_HpS48S49;                // S48S49 of the odd frames  (DTAPI_MOD_DVBT_Sxx)
7289     int  m_LpS48S49;                // S48S49 of the even frames (DTAPI_MOD_DVBT_Sxx)
7290     int  m_OddS50_S53;              // S50..S53 of the odd frames
7291     int  m_EvenS50_S53;             // S50..S53 of the even frames
7292 
7293     // Serialisation
7294     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
7295     DTAPI_RESULT  ToXml(std::wstring& XmlString);
7296 };
7297 
7298 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtDvbT2StreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7299 //
7300 // This structure specifies the selection parameters for a DVB-T2 DVB-T2 GSE and
7301 // DVB-T2 BBFRAME stream
7302 //
7303 struct DtDvbT2StreamSelPars
7304 {
7305     int  m_PlpId;                   // ID of the data PLP or DTAPI_DVBT2_PLP_ID_xxx
7306     int  m_CommonPlpId;             // ID of the common PLP or DTAPI_DVBT2_PLP_ID_xxx
7307 
7308     // Serialisation
7309     DTAPI_RESULT  FromXml(const std::wstring& XmlString);
7310     DTAPI_RESULT  ToXml(std::wstring& XmlString);
7311 };
7312 
7313 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtImpRespPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7314 //
7315 // This structure specifies the parameters for an impulse-response stream
7316 //
7317 struct DtImpRespPars
7318 {
7319     int  m_Period;                  // Minimum period bewteen callbacks in ms
7320     int  m_Channel;                 // Channel used for MISO
7321 };
7322 
7323 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtIsdbtStreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7324 //
7325 // This structure specifies the selection parameters for an ISDB-T stream
7326 //
7327 struct DtIsdbtStreamSelPars
7328 {
7329     // No additional selection parameters
7330 };
7331 
7332 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtMeasurement -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7333 //
7334 // Structure describing a set of measurement values. It used to pass measurements from
7335 // the advanced demodulator to the user application through user-supplied
7336 // DtWriteMeasFunc callback.
7337 //
7338 struct DtMeasurement
7339 {
7340     DtStreamType  m_MeasurementType;// Type of measurement values
7341     __int64  m_TimeStamp;           // Timestamp in number of samples
7342     int  m_NumValues;               // Number of measurement values
7343     DtComplexFloat*  m_pMeasurement;// Measurement values
7344 };
7345 
7346 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtMerPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7347 //
7348 // This structure specifies the parameters for a MER stream.
7349 //
7350 struct DtMerPars
7351 {
7352     int  m_Period;                  // Minimum period between callbacks in ms
7353 };
7354 
7355 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtSpectrumPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7356 //
7357 // This structure specifies the parameters for a spectrum stream.
7358 //
7359 struct DtSpectrumPars
7360 {
7361     int  m_Period;                  // Minimum time between callbacks in ms
7362     int  m_FftLength;               // FFT length, must be a power of two
7363     int  m_AverageLength;           // Number of FFT blocks on wich the average is done
7364 };
7365 
7366 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtT2MiStreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7367 //
7368 // This structure specifies the selection parameters for a T2-MI transport stream
7369 // containing a com-plete DVB-T2 stream.
7370 //
7371 struct DtT2MiStreamSelPars
7372 {
7373     int  m_T2MiOutPid;              // T2-MI output PID
7374     int  m_T2MiTsRate;              // Rate in bps for the T2MI output.
7375                                     // If -1, output a variable bitrate T2MI stream
7376                                     // (set_output_rate is not called in this case).
7377                                     // Otherwise, use m_T2MiTsRate to set the rate.
7378                                     // Padding null packets are used to reach the target
7379                                     // bitrate. The maximum T2-MI bitrate is 72Mbps.
7380 };
7381 
7382 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtTransFuncPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7383 //
7384 // This structure specifies the parameters for a transfer-function stream.
7385 //
7386 struct DtTransFuncPars
7387 {
7388     int  m_Period;                  // Minimum time between callbacks in ms
7389     int  m_Channel;                 // Channel used for MISO
7390 };
7391 
7392 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtTxIdImpRespPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7393 //
7394 // This structure specifies the parameters for an transmitter identification
7395 // impulse-response stream
7396 //
7397 struct DtTxIdImpRespPars
7398 {
7399     int  m_Period;                  // Minimum period between callbacks in ms
7400     int  m_TxIdAddress;             // Selected Tx-ID address: 0..8191
7401     int  m_AveragePeriod;           // In 8192 samples Tx-ID sequences.
7402                                     // Increase it to lower noise.
7403 };
7404 
7405 
7406 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtStreamSelPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7407 //
7408 // Structure for streaming data selection
7409 //
7410 struct DtStreamSelPars
7411 {
7412     intptr_t  m_Id;                 // Unique stream identifier
7413     DtStreamType  m_StreamType;     // Stream selection type
7414 
7415     union {
7416         // Selection parameters for demodulated streams
7417         DtAtscStreamSelPars  m_Atsc;
7418         DtAtsc3StreamSelPars  m_Atsc3;
7419         DtQamStreamSelPars  m_Qam;
7420         DtDvbC2StreamSelPars  m_DvbC2;
7421         DtDvbTStreamSelPars  m_DvbT;
7422         DtDvbT2StreamSelPars  m_DvbT2;
7423         DtIsdbtStreamSelPars  m_Isdbt;
7424         DtT2MiStreamSelPars  m_T2Mi;
7425         DtDabStreamSelPars  m_Dab;
7426         DtDabEtiStreamSelPars  m_DabEti;
7427         DtDabFicStreamSelPars  m_DabFic;
7428 
7429         // Parameters for streams of measurement values
7430         DtConstelPars  m_Constel;
7431         DtImpRespPars  m_ImpResp;
7432         DtMerPars  m_Mer;
7433         DtSpectrumPars  m_Spectrum;
7434         DtTransFuncPars  m_TransFunc;
7435         DtTxIdImpRespPars   m_TxIdImpResp;
7436     } u;
7437 
7438     bool  operator == (DtStreamSelPars& Rhs);
7439     bool  operator != (DtStreamSelPars& Rhs);
7440 };
7441 
7442 // Software demodulator callback functions
7443 typedef void  DtOutputRateChangedFunc(void *pOpaque, DtStreamSelPars&, int Bitrate);
7444 typedef void  DtReadIqFunc(void* pOpaque,
7445                                      unsigned char* pIqBuf, int IqBufSize, int& IqLength);
7446 typedef void  DtWriteMeasFunc(void *pOpaque, DtStreamSelPars&, DtMeasurement*);
7447 typedef void  DtWriteStreamFunc(void* pOpaque, DtStreamSelPars& StreamSel,
7448                                                   const unsigned char* pData, int Length);
7449 
7450 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtAdvDemod -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7451 //
7452 // Class representing an advanced demodulator.
7453 // DtAdvDemod can be considered a specialized in-put channel.
7454 //
7455 class DtAdvDemod
7456 {
7457 public:
7458     DtAdvDemod();
7459     virtual ~DtAdvDemod();
7460 private:
7461     // No implementation is provided for the copy constructor
7462     DtAdvDemod(const DtAdvDemod&);
7463 
7464 public:
7465     DtHwFuncDesc  m_HwFuncDesc;     // Hardware function descriptor
7466 
7467     // Convenience functions
7468 public:
Category(void)7469     int  Category(void)         { return m_HwFuncDesc.m_DvcDesc.m_Category; }
FirmwareVersion(void)7470     int  FirmwareVersion(void)  { return m_HwFuncDesc.m_DvcDesc.m_FirmwareVersion; }
IsAttached(void)7471     bool  IsAttached(void)      { return m_pAdvDemod != NULL; }
TypeNumber(void)7472     int  TypeNumber(void)       { return m_HwFuncDesc.m_DvcDesc.m_TypeNumber; }
7473 
7474 public:
7475     DTAPI_RESULT  AttachToPort(DtDevice* pDtDvc, int Port,
7476                                                bool Exclusive=true, bool ProbeOnly=false);
7477     DTAPI_RESULT  AttachVirtual(DtDevice* pDtDvc,
7478                                                 DtReadIqFunc* pReadIqFunc, void* pOpaque);
7479     DTAPI_RESULT  ClearFlags(int Latched);
7480     DTAPI_RESULT  CloseStream(intptr_t Id);
7481     DTAPI_RESULT  Detach(int DetachMode);
7482     DTAPI_RESULT  GetDemodControl(DtDemodPars* pDemodPars);
7483     DTAPI_RESULT  GetDescriptor(DtHwFuncDesc& HwFunDesc);
7484     DTAPI_RESULT  GetFlags(int& Flags, int& Latched);
7485     DTAPI_RESULT  GetIoConfig(int Group, int& Value);
7486     DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue);
7487     DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue, __int64& ParXtra0);
7488     DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue,
7489                                                     __int64& ParXtra0, __int64& ParXtra1);
7490     DTAPI_RESULT  GetPars(int Count, DtPar* pPars);
7491     DTAPI_RESULT  GetRxControl(int& RxControl);
7492     DTAPI_RESULT  GetStatistics(int Count, DtStatistic* pStatistics);
7493     DTAPI_RESULT  GetStatistic(int Type, int& Statistic);
7494     DTAPI_RESULT  GetStatistic(int Type, double& Statistic);
7495     DTAPI_RESULT  GetStatistic(int Type, bool& Statistic);
7496     DTAPI_RESULT  GetStreamSelection(std::vector<DtStreamSelPars>& StreamSelList);
7497     DTAPI_RESULT  GetSupportedPars(int& NumPars, DtPar* pPars);
7498     DTAPI_RESULT  GetSupportedStatistics(int& Count, DtStatistic* pStatistics);
7499     DTAPI_RESULT  GetTsRateBps(intptr_t Id, int& TsRate);
7500     DTAPI_RESULT  GetTunerFrequency(__int64& FreqHz);
7501     DTAPI_RESULT  LedControl(int LedControl);
7502     DTAPI_RESULT  OpenStream(DtStreamSelPars StreamSel);
7503     DTAPI_RESULT  RegisterCallback(DtOutputRateChangedFunc* pCallback, void* pOpaque);
7504     DTAPI_RESULT  RegisterCallback(DtWriteStreamFunc* pCallback, void* pOpaque);
7505     DTAPI_RESULT  RegisterCallback(DtWriteMeasFunc* pCallback, void* pOpaque);
7506     DTAPI_RESULT  Reset(int ResetMode);
7507     DTAPI_RESULT  SetAntPower(int AntPower);
7508     DTAPI_RESULT  SetDemodControl(DtDemodPars *pDemodPars);
7509     DTAPI_RESULT  SetIoConfig(int Group, int Value, int SubValue,
7510                                             __int64 ParXtra0 = -1, __int64 ParXtra1 = -1);
7511     DTAPI_RESULT  SetPars(int Count, DtPar* pPars);
7512     DTAPI_RESULT  SetRxControl(int RxControl);
7513     DTAPI_RESULT  SetTunerFrequency(__int64 FreqHz);
7514     DTAPI_RESULT  Tune(__int64 FreqHz, int ModType,
7515                                                 int ParXtra0, int ParXtra1, int ParXtra2);
7516     DTAPI_RESULT  Tune(__int64 FreqHz, DtDemodPars *pDemodPars);
7517 
7518 protected:
7519     AdvDemod*  m_pAdvDemod;         // Advanced demodulation channel implementation
7520     bool  m_IsAttachedToVirtual;    // Attached to virtual input port?
7521 
7522     // Encapsulated data
7523 private:
7524     IXpMutex*  m_pMTLock;           // Multi-threading lock for get/read functions
7525     void*  m_pDetachLockCount;
7526     int  m_Port;
7527     bool  m_WantToDetach;
7528 
7529 // Private helper functions
7530 private:
7531     DTAPI_RESULT  DetachLock(void);
7532     DTAPI_RESULT  DetachUnlock(void);
7533     DTAPI_RESULT  ReadAccessLock(void);
7534     DTAPI_RESULT  ReadAccessUnlock(void);
7535 };
7536 
7537 // Forward declaration for use in DtRs422Channel
7538 class Rs422Channel;
7539 
7540 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtRs422Channel -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7541 //
7542 class DtRs422Channel
7543 {
7544 public:
7545     DtRs422Channel();
7546     virtual ~DtRs422Channel();
7547 private:
7548     // No implementation is provided for the copy constructor
7549     DtRs422Channel(const DtRs422Channel&);
7550 
7551 public:
7552     DTAPI_RESULT  AttachToPort(DtDevice* pDtDvc, int Port,
7553                                                bool Exclusive=true, bool ProbeOnly=false);
7554     DTAPI_RESULT  Detach();
7555     DTAPI_RESULT  Flush();
7556     DTAPI_RESULT  Read(char* pBuffer, int NumBytesToRead, int Timeout, int& NumBytesRead);
7557     DTAPI_RESULT  Write(char* pBuffer, int NumBytesToWrite, bool Blocking=true);
7558 
7559 protected:
7560     Rs422Channel*  m_pRs422Channel;
7561     void*  m_pDetachLockCount;
7562     bool  m_WantToDetach;
7563 
7564 // Private helper functions
7565 private:
7566     DTAPI_RESULT  DetachLock(void);
7567     DTAPI_RESULT  DetachUnlock(void);
7568 };
7569 
7570 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
7571 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ MATRIX CONFIGURATION +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
7572 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
7573 
7574 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum DtMxPixelFormat -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7575 //
7576 enum DtMxPixelFormat
7577 {
7578     DT_PXFMT_UYVY422_8B,        // Packed CbYCrY, 8 bits per symbol
7579     DT_PXFMT_UYVY422_10B,       // Packed CbYCrY, 10 bits per symbol
7580     DT_PXFMT_UYVY422_16B,       // Packed CbYCrY, 16 bits per symbol (10 significant bits)
7581     DT_PXFMT_UYVY422_10B_NBO,   // Packed CbYCrY, 10 bits per symbol, network byte order
7582     DT_PXFMT_YUYV422_8B,        // Packed YCbYCr, symbol swap of DT_PXFMT_UYVY422_8B
7583     DT_PXFMT_YUYV422_10B,       // Packed YCbYCr, symbol swap of DT_PXFMT_UYVY422_10B
7584     DT_PXFMT_YUYV422_16B,       // Packed YCbYCr, symbol swap of DT_PXFMT_UYVY422_16B
7585     DT_PXFMT_Y_8B,              // Luminance plane only, 8 bits per symbol
7586     DT_PXFMT_Y_16B,             // Luminance plane only, 16 bits per symbol (10 sign bits)
7587     DT_PXFMT_YUV422P_8B,        // Planar YUV, 3 planes, 1 Cb & 1 Cr sample per 2 Y. 8BPS
7588     DT_PXFMT_YUV422P_16B,       // Planar YUV, 3 planes, 1 Cb & 1 Cr sample per 2 Y. 16BPS
7589     DT_PXFMT_YUV422P2_8B,       // Planar YUV, 2 planes, Y plane + Cb+Cr plane. 8BPS
7590     DT_PXFMT_YUV422P2_16B,      // Planar YUV, 2 planes, Y plane + Cb+Cr plane. 16BPS
7591     DT_PXFMT_YUV420P2_8B,       // Planar YUV, 2 planes, Y plane + Cb+Cr plane with
7592                                 // 2x2 sub-sampling. 8BPS. Also called NV12
7593     DT_PXFMT_BGR_8B,            // Packed RGB data. First B, then G, then R. 8 bits per ch
7594     DT_PXFMT_BGRX_8B,           // Packed RGB data with a 4th dummy byte per pixel. Not
7595                                 // yet supported.
7596     DT_PXFMT_V210,              // Packed CbYCrY, 3 10-bit symbols per 32-bit
7597     // Likely future extensions:
7598     //DT_PXFMT_YUV420P,           // Planar YUV, 3 planes, 1 Cb & 1 Cr sample per 2x2 Y.This
7599                                 // is often used as decoder input/output.
7600     //DT_PXFMT_RGB_P,             // Planar RGB data
7601 
7602     DT_PXFMT_INVALID = -1,
7603 };
7604 
7605 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxVideoConfig -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7606 //
7607 class DtMxVideoConfig
7608 {
7609 public:
7610     // m_StartLine1 / m_NumLines1 are for field 1, m_StartLine2 / m_NumLines2 are for
7611     // field 2. For progressive input m_StartLine2 / m_NumLines2 are ignored.
7612     // If no video input is required set m_NumLines1 and m_NumLines2 to 0.
7613     int  m_StartLine1;          // 1st line to transfer (1-based relative to 1st field)
7614     int  m_NumLines1;           // #lines to transfer (-1 for all lines)
7615 
7616     int  m_StartLine2;          // 1st line to transfer (1-based relative to 2nd field)
7617     int  m_NumLines2;           // #lines to transfer (-1 for all lines)
7618 
7619     int  m_Scaling;             // Scaling mode (OFF, 1/4, 1/16). DTAPI_SCALING_*
7620     int  m_LineAlignment;       // -1 if all symbols should directly follow eachother,
7621                                 // otherwise the minimum alignment each line should
7622                                 // have. DTAPI will chose the stride internally, usually
7623                                 // n*m_LineAlignment for smallest n where the stride is
7624                                 // equal or longer than the required number of bytes per
7625                                 // line. DTAPI is allowed to pick larger stride for
7626                                 // performance reasons.
7627                                 // Common values will be -1 (no alignment), 1 (align
7628                                 // each line at byte-boundary) and 16 (sse2 alignment).
7629     int  m_BufAlignment;        // Minimal byte alignment for the video buffers. Defaults
7630                                 // to -1 in which case DTAPI will pick an alignment.
7631                                 // Must be a multiple of 2.
7632     DtMxPixelFormat  m_PixelFormat; // Pixel format
7633     bool  m_UserBuffer;         // When set to true the callback function is responsible
7634                                 // for allocating the video sample buffers. When set to
7635                                 // false the framework will allocate the buffers. Defaults
7636                                 // to false.
7637 
7638     DtMxVideoConfig();
7639 };
7640 
7641 
7642 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxRawConfigSdi -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7643 //
7644 class DtMxRawConfigSdi
7645 {
7646 public:
7647     DtMxPixelFormat  m_PixelFormat; // Pixel format. Allowed are: UYVY422 or YUYV422
7648     int  m_StartLine;           // 1st line to transfer (1-based)
7649     int  m_NumLines;            // #lines to transfer (-1 for all lines)
7650     int  m_LineAlignment;       // See DtMxVideoConfig::m_LineAlignment
7651 };
7652 
7653 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum DtMxRawDataType -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7654 //
7655 enum DtMxRawDataType
7656 {
7657     DT_RAWDATA_SDI,
7658 };
7659 
7660 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxRawConfig -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7661 //
7662 class DtMxRawConfig
7663 {
7664 public:
7665     DtMxRawDataType  m_Type;    // Indicates which of the fields below is valid.
7666 
7667     union {
7668         DtMxRawConfigSdi  m_Sdi;
7669     };
7670 
7671     DtMxRawConfig();
7672 };
7673 
7674 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum DtMuxAudioSampleType -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7675 //
7676 enum DtMxAudioSampleType
7677 {
7678     DT_AUDIO_SAMPLE_PCM,        // 32-bit PCM samples
7679     DT_AUDIO_SAMPLE_AES3,       // AES samples
7680     DT_AUDIO_SAMPLE_S337,       // 32-bit SMPTE-337 data-burst samples
7681 };
7682 
7683 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum DtMxOutputMode -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7684 //
7685 enum DtMxOutputMode
7686 {
7687     DT_OUTPUT_MODE_ADD,
7688     DT_OUTPUT_MODE_COPY,
7689     DT_OUTPUT_MODE_DROP,
7690 };
7691 
7692 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxAudioConfig -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7693 //
7694 class DtMxAudioConfig
7695 {
7696 public:
7697     int  m_Index;               // Identifies the corresponding audio channel.
7698     bool  m_DeEmbed;            // If true, decode the input to data buffers per stream.
7699                                 // m_DeEmbed is ignored for output rows.
7700     DtMxOutputMode  m_OutputMode;
7701                                 // DROP: Audio group is not generated at output, whether
7702                                 //       or not it was available at input. Data buffers
7703                                 //       are available read-only if m_DeEmbed is true.
7704                                 // COPY: Output for this group is directly copied from
7705                                 //       input, timing stays the same. Data buffers are
7706                                 //       available read-only if m_DeEmbed is true. For
7707                                 //       output rows this has the same effect as DROP: no
7708                                 //       generated output.
7709                                 // ADD:  Output is generated by framework from data
7710                                 //       buffers filled by callback. Data buffers are
7711                                 //       initialized with input data if m_DeEmbed is
7712                                 //       true, otherwise they're initially empty.
7713                                 // m_OutputMode is ignored for input rows.
7714     DtMxAudioSampleType  m_Format; // Inidicate whether to (de-)embed PCM samples or
7715                                 // AES subframes. Dolby E can be (de-)embedded as
7716                                 // AES samples.
7717 
7718     DtMxAudioConfig();
7719 };
7720 
7721 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum DtMxAuxDataType -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7722 //
7723 enum DtMxAuxDataType
7724 {
7725     DT_AUXDATA_SDI,
7726 };
7727 
7728 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxAuxObjConfig -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7729 //
7730 class DtMxAuxObjConfig
7731 {
7732 public:
7733     bool  m_DeEmbed;            // If true, decode this AuxData object. m_DeEmbed is
7734                                 // ignored for output rows.
7735     DtMxOutputMode  m_OutputMode;
7736                                 // DROP: AuxData object is not generated at output no
7737                                 //       matter whether or not it was available at the
7738                                 //       input. AuxData object is available read-only if
7739                                 //       m_DeEmbed is true.
7740                                 // COPY: The embedded AuxData of this type in the input
7741                                 //       frame, if present, is copied one-to-one to the
7742                                 //       output, without re-embedding. If m_DeEmbed is
7743                                 //       true the data will be available in the callback.
7744                                 // ADD:  Output is generated by framework from data
7745                                 //       buffers filled by callback. Data buffers are
7746                                 //       initialized with input data if m_DeEmbed is
7747                                 //       true, otherwise they're initially empty.
7748 };
7749 
7750 //-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxAuxObjConfigVideoIndex -.-.-.-.-.-.-.-.-.-.-.-.-.-
7751 //
7752 class DtMxAuxObjConfigVideoIndex : public DtMxAuxObjConfig
7753 {
7754 public:
7755     static const int  LINE1_DEFAULT_525 = 11;
7756     static const int  LINE2_DEFAULT_525 = 274;
7757     static const int  LINE1_DEFAULT_625 = 19;
7758     static const int  LINE2_DEFAULT_625 = 332;
7759 
7760 public:
7761     int  m_Line1;               // Line in field 1 to extract or insert the video-index
7762                                 // from/to. Valid lines are:
7763                                 // - 525: 1..16 (default=11)
7764                                 // - 625: 1..22 (default=19)
7765                                 // NOTE: -1, means use default
7766     int  m_Line2;               // Line in field 2 to extract or insert the video-index
7767                                 // from/to. Valid lines are:
7768                                 // - 525: 263..279 (default=274)
7769                                 // - 625: 313..35 (default=332)
7770                                 // NOTE: -1, means use default
7771 };
7772 
7773 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxAuxConfigSdi -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7774 //
7775 class DtMxAuxConfigSdi
7776 {
7777 public:
7778     typedef std::vector<std::pair<unsigned int, unsigned int> >  VpidList;
7779 
7780     DtMxAuxObjConfig  m_AncPackets;  // Settings for ancillary data packets
7781     DtMxAuxObjConfigVideoIndex  m_VideoIndex;
7782                                      // Settings for (deprecated SD only) video index data
7783     DtMxAuxObjConfig  m_Wss;         // Settings for (SD only) Wide Screen Signaling
7784     DtMxAuxObjConfig  m_Line21;      // Settings for (SD only) analog CEA-608 line 21 data
7785     DtMxAuxObjConfig  m_Teletext;    // Settings for (PAL only) teletext
7786     VpidList  m_Vpid;                // VPID(s) to insert in output signal
7787     bool  m_DisableVpidProcessing;   // If true, user must add VPID ancillary data
7788     //DtMxAuxObjConfig  m_Rp188;
7789     //DtMxAuxObjConfig  m_Vitc;
7790     //DtMxAuxObjConfig  m_Eia608;
7791     //DtMxAuxObjConfig  m_Eia708;
7792     DtMxAuxConfigSdi();
7793 };
7794 
7795 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxAuxDataConfig -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7796 //
7797 class DtMxAuxDataConfig
7798 {
7799 public:
7800     bool  m_DeEmbedAll;         // De-embed all auxdata. Defaults to false.
7801     DtMxAuxDataType  m_DataType; // Indicates which of the following objects is valid.
7802 
7803     DtMxAuxConfigSdi  m_Sdi;    // SDI-specific settings. Valid only if
7804                                 // m_DataType==DT_AUXDATA_SDI
7805 
7806     DtMxAuxDataConfig();
7807 };
7808 
7809 
7810 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxRowConfig -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7811 //
7812 class DtMxRowConfig
7813 {
7814     // Constants
7815 public:
7816     static const int  MAX_NUM_AUDIO_CHANNELS = 16; // Max. # audio channels supported
7817 
7818 public:
7819     DtMxRowConfig();
7820     virtual ~DtMxRowConfig();
7821 
7822 public:
7823     bool  m_Enable;             // Global flag to enable/disable to the complete row.
7824                                 // When disabled input rows will not provide data and all
7825                                 // output ports will generate black frames.
7826                                 // Wnen set to false all further configuration below
7827                                 // is not taken into account.
7828 
7829     int  m_RowSize;             // Number of frame buffers available in the callback
7830                                 // function.
7831 
7832     void*  m_pOpaq;             // Opaque user pointer. Framework itself will not change
7833                                 // this value. This can be used if the row configuration
7834                                 // is changed dynamically to detect the change. It can
7835                                 // also be used to change the function  of the callback
7836                                 // frame-synchronous without implementing any locks
7837                                 // on the user-side.
7838 
7839     // Each matrix row operates either in RAW mode or in "parsed data" mode. This means
7840     // that m_RawDataEnable is mutually exclusive with m_VideoEnable, m_AudioEnable
7841     // and m_AuxDataEnable.
7842 
7843     // Raw data
7844     bool  m_RawDataEnable;      // Enable raw data processing. m_RawData is ignored when
7845                                 // set to false. Defaults to false.
7846     DtMxRawConfig  m_RawData;   // Configuration of raw input/output data.
7847 
7848     // Video
7849     bool  m_VideoEnable;        // Enables video processing. m_Video is ignored when set
7850                                 // to false. Defaults to true.
7851     DtMxVideoConfig  m_Video;   // Configuration of video input/output.
7852 
7853     // Audio
7854     bool  m_AudioEnable;        // Enables audio processing. m_AudioGen and m_Audio are
7855                                 // ignored when set to false. Defaults to true.
7856     DtMxAudioConfig  m_AudioDef; // Default audio settings, can be used to de-embed all
7857                                 // channels. These settings are used as defaults for
7858                                 // all channels and can be overriden on a per-channel
7859                                 // basis by the m_Audio vector.
7860     std::vector<DtMxAudioConfig>  m_Audio; // Configuration for each audio channel
7861 
7862     // AUX data
7863     bool  m_AuxDataEnable;      // Enables auxiliary data processing. m_AuxData is ignored
7864                                 // when set to false. Defaults to false.
7865     DtMxAuxDataConfig  m_AuxData; // Configuration of aux data input/output.
7866 };
7867 
7868 
7869 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
7870 //+=+=+=+=+=+=+=+=+=+=+=+=+=+ MATRIX CALLBACK DATA STRUCTURES +=+=+=+=+=+=+=+=+=+=+=+=+=+=
7871 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
7872 
7873 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxRawDataSdi -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7874 //
7875 class DtMxRawDataSdi
7876 {
7877 public:
7878     unsigned char*  m_pBuf;
7879     int  m_BufSize;
7880     int  m_Stride;              // Size of each line in bytes
7881     int  m_StartLine;           // 1st line in buffer (1-based)
7882     int  m_NumLines;            // #lines to transfer (-1 for all lines)
7883     // Informational
7884     DtMxPixelFormat  m_PixelFormat;  // Pixel format. Can be UYVY422 or YUVY422
7885     int  m_Width;               // Width in pixels
7886     int  m_Height;              // Height in pixels
7887 };
7888 
7889 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxRawData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
7890 //
7891 class DtMxRawData
7892 {
7893 public:
7894     DtMxRawDataType  m_Type;    // Indicates which of the fields below is valid.
7895 
7896     union {
7897         DtMxRawDataSdi  m_Sdi;
7898     };
7899 };
7900 
7901 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxVideoPlaneBuf -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7902 //
7903 class DtMxVideoPlaneBuf
7904 {
7905 public:
7906     unsigned char*  m_pBuf;     // Pointer to buffer
7907     int  m_BufSize;             // Total size in bytes of buffer
7908     int  m_Stride;              // Size of each line in bytes
7909     int  m_StartLine;           // 1st line in buffer (1-based)
7910     int  m_NumLines;            // Number of lines. Usually equal to
7911                                 // DtMxVideoBuf::m_Height but might vary for some
7912                                 // pixel formats, for 4:2:0 planar for example both
7913                                 // chrominancy planes have m_NumLines twice as small
7914                                 // as DtMatrixVideoBuf::m_Height.
7915 
7916     DtMxVideoPlaneBuf();
7917 };
7918 
7919 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum DtMxVidPattern -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7920 //
7921 enum DtMxVidPattern
7922 {
7923     DT_VIDPAT_BLACK_FRAME,
7924     DT_VIDPAT_RED_FRAME,
7925     DT_VIDPAT_GREEN_FRAME,
7926     DT_VIDPAT_BLUE_FRAME,
7927     DT_VIDPAT_WHITE_FRAME,
7928 };
7929 
7930 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxVideoBuf -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7931 //
7932 class DtMxVideoBuf
7933 {
7934 public:
7935     DtMxVideoPlaneBuf  m_Planes[3];
7936     int  m_NumPlanes;           // The number of planes directly depends on the pixel
7937                                 // format chosen.
7938     DtMxPixelFormat  m_PixelFormat; // See DtMxVideoConfig::m_PixelFormat
7939     int  m_Scaling;             // Scaling mode (OFF, 1/4, 1/16). DTAPI_SCALING_*
7940     int  m_Width;               // Width in pixels
7941     int  m_Height;              // Height in pixels
7942 
7943     // Initialize the video buffers with a specific pattern in an efficient way. Can
7944     // be used by the callback function for output rows if no useful data is available.
7945     // Framework does not do this automatically because in normal operation it'd be
7946     // a waste of resources to initialize buffers that will be overwritten later anyway.
7947     DTAPI_RESULT  InitBuf(DtMxVidPattern  Pattern);
7948 
7949     DtMxVideoBuf();
7950 };
7951 
7952 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxSdVideoIndex -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7953 //
7954 class DtMxSdVideoIndex
7955 {
7956 public:
7957     //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum ScanningSystem -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7958     //
7959     enum ScanningSystem
7960     {
7961         SCS_NO_INFORMATION = 0,
7962         SCS_525_5994_4X3   = 1,
7963         SCS_625_50_4X3     = 2,
7964         SCS_525_5994_16X9  = 5,
7965         SCS_625_50_16X9    = 6,
7966     };
7967 
7968     // -.-.-.-.-.-.-.-.-.-.-.-.-.- enum ActiveFormatDescriptor -.-.-.-.-.-.-.-.-.-.-.-.-.-
7969     //
7970     enum ActiveFormatDescriptor
7971     {
7972         AFD_NO_INFOMATION = 0,
7973         AFD_BOX_16_9_TOP=2,
7974         AFD_BOX_14_9_TOP=3,
7975         AFD_BOX_LARGER_THAN_16_9_CENTER=4,
7976         AFD_SAME_AS_CODED=8,
7977         AFD_4_3_CENTER=9,
7978         AFD_16_9_CENTER=10,
7979         AFD_14_9_CENTER=11,
7980         AFD_4_3_SHOT_AND_PROTECT_14_9= 13,
7981         AFD_16_9_SHOT_AND_PROTECT_14_9 = 14,
7982         AFD_14_9_SHOT_AND_PROTECT_4_3 = 15,
7983     };
7984 
7985     //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum SignalForm -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
7986     //
7987     enum SignalForm
7988     {
7989         SF_NO_INFORMATION = 0,
7990         SF_RGB            = 1,
7991         SF_YCbCr          = 2,
7992         SF_YUV            = 3,
7993         SF_MONOCHROME     = 4,
7994         SF_NTSC           = 5,
7995         SF_PAL            = 6,
7996         SF_PAL_M          = 7,
7997         SF_SECAM          = 8,
7998     };
7999     //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum SamplingStructure -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8000     //
8001     enum SamplingStructure
8002     {
8003         SAS_NO_INFORMATION   = 0,
8004         SAS_420              = 1,
8005         SAS_422              = 2,
8006         SAS_4224_MAIN        = 3,
8007         SAS_4224_SUB         = 4,
8008         SAS_444_MAIN         = 5,
8009         SAS_444_SUB          = 6,
8010         SAS_4444_MAIN        = 7,
8011         SAS_4444_SUB         = 8,
8012         SAS_422P_MAIN        = 9,
8013         SAS_422P_SUB         = 10,
8014         SAS_420P             = 11,
8015         SAS_844_MAIN         = 12,
8016         SAS_844_SUB          = 13,
8017         SAS_4224_SINGLE_LINK = 14,
8018     };
8019 
8020     //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum ColorField -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8021     //
8022     enum ColorField
8023     {
8024         CF_NO_INFORMATION  = 0,
8025         CF_COLOR_FIELD_1   = 1,
8026         CF_COLOR_FIELD_2   = 2,
8027         CF_COLOR_FIELD_3   = 3,
8028         CF_COLOR_FIELD_4   = 4,
8029         CF_COLOR_FIELD_5   = 5,
8030         CF_COLOR_FIELD_6   = 6,
8031         CF_COLOR_FIELD_7   = 7,
8032         CF_COLOR_FIELD_8   = 8,
8033     };
8034 
8035     //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum VideoFieldsRates -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8036     //
8037     enum VideoFieldsRates
8038     {
8039         VFR_NO_INFORMATION     = 0,
8040         VFR_FIELD1_SCAN1_2SCAN = 1,
8041         VFR_FIELD2_SCAN2_2SCAN = 2,
8042         VFR_FIELD1_SCAN1_3SCAN = 3,
8043         VFR_FIELD2_SCAN2_3SCAN = 4,
8044         VFR_FIELD1_SCAN3_3SCAN = 5,
8045         VFR_FIELD2_SCAN1_2SCAN = 6,
8046         VFR_FIELD1_SCAN2_2SCAN = 7,
8047         VFR_FIELD2_SCAN1_3SCAN = 8,
8048         VFR_FIELD1_SCAN2_3SCAN = 9,
8049         VFR_FIELD2_SCAN3_3SCAN = 10,
8050     };
8051 
8052     // Get or set the scanning system
8053     DTAPI_RESULT  GetScanningSystem(ScanningSystem&  ScanSystem);
8054     DTAPI_RESULT  SetScanningSystem(ScanningSystem  ScanSystem);
8055     // Get or set the active-fomat-descriptor
8056     DTAPI_RESULT  GetAfd(ActiveFormatDescriptor&  Afd);
8057     DTAPI_RESULT  SetAfd(ActiveFormatDescriptor  Afd);
8058     // Get or set the signal form
8059     DTAPI_RESULT  GetSignalForm(SignalForm&  Form);
8060     DTAPI_RESULT  SetSignalForm(SignalForm  Form);
8061     // Get or set the sampling structure
8062     DTAPI_RESULT  GetSamplingStructure(SamplingStructure&  Structure);
8063     DTAPI_RESULT  SetSamplingStructure(SamplingStructure  Structure);
8064     // Get or set the pand and scan data
8065     DTAPI_RESULT  GetPanAndScan(int& Pan, int& Tilt, int& Zoom, bool& X, bool& Y, bool& Z);
8066     DTAPI_RESULT  SetPanAndScan(int Pan, int Tilt, int Zoom, bool X, bool Y, bool Z);
8067     // Get or set the color field
8068     DTAPI_RESULT  GetColorField(ColorField&  Cf);
8069     DTAPI_RESULT  SetColorField(ColorField  Cf);
8070     // Get or set the video fields and film frames
8071     DTAPI_RESULT  GetVideoFieldsFilmRates(VideoFieldsRates&  Vfr);
8072     DTAPI_RESULT  SetVideoFieldsFilmRates(VideoFieldsRates  Vfr);
8073     // Get or set the film frame rate as percentage of nominal rate (1%-254%)
8074     // 0=no information, 255=still frame
8075     DTAPI_RESULT  GetFilmFrameRate(int&  Ffr);
8076     DTAPI_RESULT  SetFilmFrameRate(int  Ffr);
8077 
8078     void  UpdateCrcs();
8079 
8080     unsigned char m_Data[90];   // Raw video index data
8081     bool  m_Valid;              // True if m_Data contains valid data
8082     int  m_Line;                // Line number in which the video index was found
8083 
8084     DtMxSdVideoIndex();
8085 };
8086 
8087 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxSdWss -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8088 //
8089 class DtMxSdWss
8090 {
8091 public:
8092     enum WssType
8093     {
8094         WSS_INVALID,
8095         WSS_PAL,
8096         WSS_NTSC,
8097     };
8098 
8099     enum  AspectRatioFormat
8100     {
8101         ARF_4_3_FULL,
8102         ARF_4_3_BOX,
8103         ARF_16_9_FULL,
8104         ARF_16_9_BOX,
8105         ARF_16_9_BOX_TOP,
8106         ARF_16_9_ANAMORPHIC,
8107         ARF_14_9_BOX,
8108         ARF_14_9_BOX_TOP,
8109         ARF_14_9_FULL,
8110         ARF_GREATER_16_9_BOX,
8111     };
8112 
8113     // Get or set the aspect ratio
8114     DTAPI_RESULT  GetAspectRatio(DtAspectRatio&  Ratio);
8115     DTAPI_RESULT  GetAspectRatioFormat(AspectRatioFormat&  Ratio);
8116     //DTAPI_RESULT  SetAspectRatioFormat(AspectRatioFormat  Ratio);
8117 
8118     // Get or set the 'subtitles within Teletext' bit
8119     DTAPI_RESULT  GetTeletextSubtitles(bool&  Subtitles);
8120     //DTAPI_RESULT  SetTeletextSubtitles(bool  Subtitles);
8121 
8122     WssType  m_Type;            // Encoding of data in m_Data
8123     int  m_Data;                // Raw data
8124     int  m_NumBitsValid;        // The number of bits in m_Data that contain valid data
8125 
8126     DtMxSdWss();
8127 };
8128 
8129 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxLine21 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8130 //
8131 class DtMxLine21
8132 {
8133 public:
8134     unsigned char  m_Data[2];   // Raw data including parity bit
8135     bool  m_Valid;              // True if m_Data contains valid data
8136 
8137     DtMxLine21();
8138 };
8139 
8140 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxTeletextPacket -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8141 //
8142 class DtMxTeletextPacket
8143 {
8144 public:
8145     int  m_Line;                // Line the teletext packet was found
8146     unsigned char  m_Data[42];  // Raw packet data (excl. clock run-in and framing code)
8147 };
8148 
8149 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxAuxData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8150 //
8151 class DtMxAuxData
8152 {
8153 public:
8154     // Teletext
8155     // Closed captioning
8156 
8157     DtMxSdVideoIndex  m_VidIndex[2];
8158     DtMxSdWss  m_Wss[2];
8159     DtMxLine21  m_Line21[2];
8160     std::vector<DtMxTeletextPacket>  m_Teletext;
8161 
8162     // Other anc data
8163     bool  m_AncTimeCodeValid;
8164     __int64  m_AncTimeCode;
8165 };
8166 
8167 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtMxAncPacket -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8168 //
8169 class DtMxAncPacket
8170 {
8171 public:
8172     int  m_Did;                     // Data identifier
8173     int  m_SdidOrDbn;               // Secondary data identifier / Data block number
8174     int  m_Dc;                      // Data count
8175     int  m_Cs;                      // Check sum
8176     unsigned short*  m_pUdw;        // User data words
8177     int  m_Line;                    // Line number in which packet was found
8178 
8179     // Operations
8180 public:
Type()8181     int  Type() const  { return (m_Did & 0x80)==0 ? 2 : 1; }
8182 
8183 public:
8184     DtMxAncPacket();
8185     virtual ~DtMxAncPacket();
8186 private:
8187     DtMxAncPacket(const DtMxAncPacket&);
8188 };
8189 
8190 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxAudioChannelStatus -.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8191 //
8192 class DtMxAudioChannelStatus
8193 {
8194 public:
8195     // Get or set the sampling rate in Hz.
8196     DTAPI_RESULT  GetSampleRate(int& SampleRate);
8197     DTAPI_RESULT  SetSampleRate(int SampleRate);
8198     // Get or set whether the channel contains linear audio PCM data or something else.
8199     DTAPI_RESULT  GetPcmAudio(bool&  IsPcm);
8200     DTAPI_RESULT  SetPcmAudio(bool  IsPcm);
8201     // Get or set the the significant and maximum number of bits
8202     DTAPI_RESULT  GetPcmNumBits(int&  NumBits, int&  NumAuxBits);
8203     DTAPI_RESULT  SetPcmNumBits(int  NumBits, int  NumAuxBits=0);
8204 
8205     unsigned char m_Data[24];   // Raw AES3 channel-status word data.
8206     bool  m_Valid;              // True, if channel status word has been initialised
8207 
8208     DtMxAudioChannelStatus();
8209     virtual ~DtMxAudioChannelStatus();
8210 };
8211 
8212 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxAudioChannel -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8213 //
8214 class DtMxAudioChannel
8215 {
8216 public:
8217     int  m_Index;                   // Index of this channel in underlaying AV format.
8218     bool  m_Present;                // True if this channel was actually present in the
8219                                     // input frame.
8220     int  m_Service;                 // Index in m_Services vector for the service this
8221                                     // channel is a part of.
8222 
8223     unsigned int*  m_pBuf;          // Buffer with audio samples
8224     int  m_BufSizeSamples;          // Total size of buffer (in #samples)
8225     int  m_NumValidSamples;         // Number of valid samples inside buffer
8226 
8227     DtMxAudioChannelStatus  m_Status;  // AES3 status word;
8228 
8229     const int  m_NumSamplesHint;    // Suggested number of audio samples for this frame.
8230                                     // This is based on the audio frame number.
8231     const DtMxAudioSampleType  m_Format;  // Format of audio samples: PCM32 or AES
8232 
8233     // Constructor, destructor
8234 public:
8235     DtMxAudioChannel();
8236     virtual ~DtMxAudioChannel();
8237     DtMxAudioChannel&  operator = (const DtMxAudioChannel& Other);
8238 };
8239 
8240 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum DtMxAudioServiceType -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8241 //
8242 enum DtMxAudioServiceType
8243 {
8244     DT_AUDIOSERVICE_UNKNOWN,
8245     DT_AUDIOSERVICE_MONO,
8246     DT_AUDIOSERVICE_DUAL_MONO,
8247     DT_AUDIOSERVICE_STEREO,
8248     DT_AUDIOSERVICE_5_1,
8249 };
8250 
8251 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtFixedVector -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8252 //
8253 // Represents a vector which has a fixed size (i.e. cannot add or remove elements)
8254 //
8255 template<typename T>
8256 class DtFixedVector
8257 {
8258     // Operations
8259 public:
empty()8260     bool  empty() const { return m_Data.empty(); }
size()8261     size_t  size() const { return m_Data.size(); }
8262     T& operator[](size_t  n) { return m_Data[n]; }
8263 protected:
8264     // Cast to a "normal" std::vector. NOTE: Intended for internal DTAPI use only
8265     inline operator typename std::vector<T>& () { return m_Data; }
8266     inline DtFixedVector&  operator = (const DtFixedVector&  Oth)
8267     {
8268         this->m_Data = Oth.m_Data;
8269         return *this;
8270     }
8271 
8272     // Data / Attributes
8273 private:
8274     std::vector<T>  m_Data;     // Actual std::vector with the data
8275 
8276     // Constructor / Desstructor
8277 public:
DtFixedVector()8278     DtFixedVector() {}
~DtFixedVector()8279     virtual ~DtFixedVector() {}
8280 protected:
DtFixedVector(size_t Size)8281     DtFixedVector(size_t  Size) { m_Data.resize(Size); }
DtFixedVector(const DtFixedVector & Oth)8282     DtFixedVector(const DtFixedVector&  Oth) { *this= Oth; }
8283 
8284     // Friends
8285 private:
8286     friend class  MxFrameImpl;
8287     friend class  MxCommonData;
8288     friend class  MxDecData;
8289     friend class  MxActionAncEnc;
8290     friend class  MxActionAncDec;
8291     friend class  MxProcessImpl;
8292 };
8293 
8294 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxAudioService -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8295 //
8296 class DtMxAudioService
8297 {
8298 public:
8299     bool  m_Valid;                    // Indicates whether or not this is a valid entry
8300     DtMxAudioServiceType  m_ServiceType; // Type of service: mono, stereo, 5.1 etc.
8301     std::vector<int>  m_Channels;     // Indices of channels that are part of this service
8302     int  m_PcmNumBits;                // For PCM samples only: number of significant bits
8303     bool  m_ContainsData;             // For AES only: true if data, false if PCM samples
8304     int  m_SampleRate;                // Sample rate of audio channels
8305     const int  m_SamplesInFrame;      // Number of samples in the current frame
8306     //double  m_SamplePhase;            // Phase of the first audio sample
8307     int  m_AudioFrameNumber;          // Indicates where we are in the audio frame
8308                                       // sequence frame
8309 
8310     // Constructor, destructor
8311 public:
8312     DtMxAudioService();
8313     DtMxAudioService&  operator = (const DtMxAudioService& Other);
8314 };
8315 
8316 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxAudioData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8317 //
8318 class DtMxAudioData
8319 {
8320 public:
8321     DtFixedVector<DtMxAudioChannel>  m_Channels;
8322     DtFixedVector<DtMxAudioService>  m_Services;
8323 
8324     // Utility function to make the AES3 status word consistent with the members in this
8325     // struct. It's recommended to call this after modifying any members to make sure
8326     // the final output is consistent.
8327     DTAPI_RESULT  InitChannelStatus();
8328     DTAPI_RESULT  InitChannelStatus(const DtMxAudioService&  Service);
8329 
8330     DTAPI_RESULT  AddAudio(const DtMxAudioService&, unsigned char* pSamples,
8331                                                          int& NumSamples, int SampleSize);
8332     DTAPI_RESULT  GetAudio(const DtMxAudioService&, unsigned char* pSamples,
8333                                                          int& NumSamples, int SampleSize);
8334 };
8335 
8336 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum DtMxFrameStatus -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8337 //
8338 enum DtMxFrameStatus
8339 {
8340     DT_FRMSTATUS_OK,               // Frame has been received and decoded without problems
8341     DT_FRMSTATUS_SKIPPED,          // Row has been received and decoded but the callback
8342                                    // function was never called. This will only be set
8343                                    // for historic buffers, never for the current
8344                                    // frame buffer.
8345     DT_FRMSTATUS_DISABLED,         // Row has been disabled, buffers not available.
8346     DT_FRMSTATUS_DUPLICATE,        // Frame data is duplicated from previous frame
8347                                    // because the input was too slow.
8348     DT_FRMSTATUS_LATE,             // Frame data was dropped because the input data
8349                                    // arrived too late. Data is not available. Later
8350                                    // frames will report NO_SIGNAL is the input signal
8351                                    // is lost or will return to OK if the frame was
8352                                    // dropped due to too high CPU load.
8353     DT_FRMSTATUS_NO_SIGNAL,        // No signal at input port. Frame data not available.
8354     DT_FRMSTATUS_WRONG_VIDSTD,     // Unconfigured video signal at input. Frame data
8355                                    // not available.
8356     DT_FRMSTATUS_DEV_DISCONNECTED, // Input (usb) device has been disconnected. Frame data
8357                                    // not available.
8358     DT_FRMSTATUS_ERROR_INTERNAL,   // Internal error. Frame data is not available.
8359 };
8360 static const DtMxFrameStatus  DTAPI_DEPRECATED(DT_FRMSTATUS_DROPPED,
8361       "Deprecated (will be removed!): Use DT_FRMSTATUS_LATE instead") = DT_FRMSTATUS_LATE;
8362 
8363 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxFrame -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8364 //
8365 // Data buffers for a single frame. Can be used for input, for output or be shared
8366 // between input and output.
8367 //
8368 class DtMxFrame
8369 {
8370 public:
8371     const DtMxRowConfig*  const m_Config;
8372                                     // Row configuration at the time the frame processing
8373                                     // was started by the HLM.
8374 
8375     // Status of this frame. DT_FRMSTATUS_DISABLED overrules all other status fields.
8376     // For output-only rows this will always be DT_FRMSTATUS_OK or DT_FRMSTATUS_DISABLED.
8377     // For input/output and output-only rows the data buffers requested will always be
8378     // available if m_Status is not DT_FRMSTATUS_DISABLED.
8379     DtMxFrameStatus  m_Status;
8380 
8381     // Configured video standard, or for fixed-rate rows the actual received rate.
8382     // For fixed rate output rows this has to be set by callback.
8383     int  m_VidStd;
8384 
8385     // For input and input/output rows this can contain a pointer to the data of an input
8386     // frame that was received before this frame but not processed to maintain clock sync.
8387     // Normally this is a NULL pointer, but if the input is faster than the HLM clock
8388     // occasionally a frame needs to be dropped to keep the system in sync. By providing
8389     // a pointer to the data of the dropped frame the callback might be able to prevent
8390     // audio hickups.
8391     // For each frame processed by the callback function there will be at most one
8392     // dropped frame due to different clocks, so this->m_DroppedFrame->m_DroppedFrame is
8393     // always NULL.
8394     DtMxFrame*  m_DroppedFrame;
8395 
8396     bool  m_InpPhaseValid;      // True if m_InpPhase contains a valid value.
8397     double  m_InpPhase;         // Phase of this input relative to the HLM clock source.
8398                                 // In a genlocked system this should be approximately
8399                                 // zero. In a non-genlocked system the HLM will try
8400                                 // to keep it between -1.25 and 0.05. A frame drop will
8401                                 // increase this value by 1.
8402 
8403     bool  m_InLock;             // Output only: true if output is in sync with genlock
8404 
8405     bool  m_RawTimestampValid;  // True if m_RawTimestamp is valid
8406     __int64  m_RawTimestamp;    // 64-bit timestamp of the arrival of the SDI frame.
8407                                 // Timestamps created by different hardware devices have
8408                                 // no relation to eachother.
8409 
8410     // Raw data buffer
8411     bool  m_RawDataValid;       // True, if the raw data is valid; False if invalid
8412     DtMxRawData  m_RawData;
8413     // Video buffers for field 1 and 2
8414     bool  m_VideoValid;         // True, if the video data is valid; False if invalid
8415     DtMxVideoBuf  m_Video[2];
8416     // Audio data
8417     bool  m_AudioValid;         // True, if the audio data is valid; False if invalid
8418     DtMxAudioData  m_Audio;
8419     // Auxiliary data
8420     bool  m_AuxDataValid;       // True, if the aux data is valid; False if invalid
8421     DtMxAuxData  m_AuxData;
8422 
8423     // Access functions for raw ANC packets
8424     virtual DTAPI_RESULT  AncAddPacket(DtMxAncPacket&  AncPacket, int HancVanc,
8425                                                              int Stream, int Link=-1) = 0;
8426     virtual DTAPI_RESULT  AncDelPacket(int Did, int Sdid, int StartLine,
8427                        int NumLines, int HancVanc, int Stream, int Mode, int Link=-1) = 0;
8428     virtual DTAPI_RESULT  AncGetPacket(int Did, int Sdid, DtMxAncPacket*, int& NumPackets,
8429                                                    int HancVanc, int Stream, int Link=-1,
8430                                                    int StartLine=-1, int NumLines=-1) = 0;
8431 
8432     // Constructor, destructor
8433 protected:
8434     DtMxFrame();
8435     virtual ~DtMxFrame();
8436 private:
8437     // No implementation is provided for the copy constructor or for operator=
8438     DtMxFrame(const DtMxFrame&);
8439     DtMxFrame&  operator = (const DtMxFrame&);
8440 };
8441 
8442 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxRowData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8443 //
8444 class DtMxRowData
8445 {
8446 public:
8447     // Pointer to current frame. This is the only read/write buffer, all other buffers
8448     // are read-only.
8449     DtMxFrame*  m_CurFrame;
8450 
8451     // m_Hist.size() == RowSize-1
8452     // m_Hist[0] is the previous frame, m_Hist[1] the one before that etc.
8453     std::vector<const DtMxFrame*>  m_Hist;
8454 };
8455 
8456 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxData -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8457 //
8458 // Top-level data class for the user callback function.
8459 //
8460 class DtMxData
8461 {
8462 public:
8463     __int64  m_Frame;           // Frame counter. Increases by 1 for every frame the
8464                                 // matrix clock source processes.
8465     int  m_Phase;               // Current phase (0..NumPhases-1). Each callback function
8466                                 // can run up to NumPhases time in parallel, each of them
8467                                 // will be called with a different value in m_Phase.
8468     int  m_NumSkippedFrames;    // Error counter, will normally be 0. If due to a timeout
8469                                 // the matrix API has to skip the callback processing of
8470                                 // a number of frames, it'll indicate it here in the data
8471                                 // of the next processed frame.
8472     DtFixedVector<DtMxRowData>  m_Rows; // Data per row
8473 
8474     // Constructor, destructor
8475 public:
8476     DtMxData();
8477     virtual ~DtMxData();
8478 };
8479 
8480 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
8481 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ MATRIX CONTROL +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
8482 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
8483 
8484 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxPort -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8485 //
8486 // The DtMxPort is used as abstraction for one logical input or output. Often this
8487 // maps 1-to-1 to one physical output port, but other mappings are possible as well.
8488 // 4K-video over SDI can be transported over 4x3G links for example, creating
8489 // a 1 logical to 4 physical ports mapping.
8490 //
8491 // Example for single-port:
8492 // Matrix.AttachToInput(0, DtMxPort(&Dvc, 1));
8493 //
8494 // Example for 4K (Assuming DtDevice Dvc; which is attached to DTA-2174):
8495 // DtMxPort  Port4k(DTAPI_VIDSTD_2160P60, DTAPI_LINK_4K_SMPTE425);
8496 // Port4k.AddPhysicalPort(&Dvc, 1);
8497 // Port4k.AddPhysicalPort(&Dvc, 2);
8498 // Port4k.AddPhysicalPort(&Dvc, 3);
8499 // Port4k.AddPhysicalPort(&Dvc, 4);
8500 // Matrix.AttachToOutput(0, Port4k, 3);
8501 //
8502 // 3G over 1x3G-SDI link:
8503 // DtMxPort  Port3G1(DTAPI_VIDSTD_1080P60);
8504 // Port3G1.AddPhysicalPort(&Dvc, 1);
8505 // Alternatively "DtMxPort  Port3G;" is enough, VidStd can be determined
8506 // from the IoConfig.
8507 //
8508 // 3G over 2xHD-SDI links (NOT SUPPORTED):
8509 // DtMxPort  Port3G2(DTAPI_VIDSTD_1080P60, DTAPI_LINK_3G_SMPTE372);
8510 // Port3G2.AddPhysicalPort(&Dvc, 1);
8511 // Port3G2.AddPhysicalPort(&Dvc, 2);
8512 //
8513 // After Matrix.AttachToInput() / Matrix.AttachToOutput() it's completely transparent
8514 // whether Port3G1 or Port3G2 is used. Both support exactly the same data and filtering,
8515 // the matrix API will take care of splitting over 1 or multiple physical links.
8516 //
8517 class DtMxPort
8518 {
8519 public:
8520     // 1. Constructor that doesn't link to a physical port yet.
8521     DtMxPort();
8522     // 2. Constructor that links to a single physical port. Video standard and
8523     // link standard are not explicitly set and will be determined from IOConfig.
8524     DtMxPort(DtDevice*, int  Port, int  ClockPriority=0, int  PixelOffset=0);
8525     // 3. Constructor that initializes the object for a multi-link structure.
8526     DtMxPort(int  VidStd, int  LinkStd);
8527     // 4. Copy constructor
8528     DtMxPort(const DtMxPort&);
8529     // Destructor
8530     virtual ~DtMxPort();
8531     // Assignment operator
8532     DtMxPort& operator = (const DtMxPort&);
8533 
8534     DTAPI_RESULT  AddPhysicalPort(DtDevice*, int  Port, int  ClockPriority=0,
8535                                                                       int  PixelOffset=0);
8536 
8537 private:
8538     class MxPortImpl*  m_pImpl;
8539     friend class DtMxProcess;
8540 };
8541 
8542 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtMxProcFrameFunc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8543 //
8544 // Signature of a user-defined matrix callback function.
8545 //
8546 typedef void  DtMxProcFrameFunc(DtMxData* pData, void* pOpaque);
8547 
8548 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtMxVidBufFreeCallback -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8549 //
8550 // Signature of callback function that will be called by the HLM to free user-provided
8551 // video buffers.
8552 //
8553 typedef void  DtMxVidBufFreeCallback(void* pMem, void* pOpaque);
8554 
8555 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- enum DtMxClockMode -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8556 //
8557 enum DtMxClockMode
8558 {
8559     DT_MXCLOCK_AUTO,            // Default, HLM internally picks a device as clock source
8560     DT_MXCLOCK_PCR_TIME_ACC,    // HLM changes internal clock source based on PCR samples
8561                                 // provided by user. Each PCR sample is accurately
8562                                 // timestamped (by using transparent input mode on
8563                                 // a DekTec device).
8564     DT_MXCLOCK_PCR_TIME_IP,     // HLM changes internal clock source based on PCR samples
8565                                 // provided by user. The PCR samples do not have an
8566                                 // accurate timestamp, so HLM will adjust the internal
8567                                 // clock very slowly.
8568     DT_MXCLOCK_SW_FIFO,         // User provides timestamped Fifo-loads. HLM controls the
8569                                 // clock so that the average fifo load remains the same.
8570 };
8571 
8572 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxSchedulingArgs -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8573 //
8574 class DtMxSchedulingArgs
8575 {
8576 public:
8577     // List of cores that are allowed to run threads in this group. Leave empty
8578     // to allow the threads to run on all cores.
8579     std::vector<int>  m_Affinity;
8580     // Linux-only: Scheduling policy for threads part of this group. Currently
8581     // only SCHED_OTHER, SCHED_FIFO and SCHED_RR are supported
8582     int  m_SchedPolicy;
8583     // OS-specific thread priority.
8584     // Windows: THREAD_PRIORITY_*
8585     // Linux with SCHED_FIFO or SCHED_RR: 1..99 (higher is higher priority)
8586     // Linux with SCHED_OTHER: -20..19 (lower value is higher priority)
8587     int  m_SchedPrio;
8588 };
8589 
8590 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxThreadScheduling -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8591 //
8592 class DtMxThreadScheduling
8593 {
8594 public:
8595     // Scheduling settings for threads in the events group. Those threads have low CPU
8596     // usage but need to react very quickly to various events. They shall have the
8597     // highest priority of all threads in the system.
8598     // Default priority windows: THREAD_PRIORITY_TIME_CRITICAL
8599     // Default priority linux: SCHED_FIFO 80
8600     DtMxSchedulingArgs  m_EventThreads;
8601     // The worker threads are CPU intensive but can tolerate a bit more scheduling latency
8602     // than the event threads. In general those threads should be run at a fairly high
8603     // priority to make sure no frames are dropped.
8604     // Default priority windows: THREAD_PRIORITY_HIGHEST
8605     // Default priority linux: SCHED_FIFO 20
8606     DtMxSchedulingArgs  m_WorkerThreads;
8607     // The callback threads are the ones that run the callback functions. The priority
8608     // of these threads depends on the kind of work the callback does. It should not
8609     // be higher than the priority of the worker threads.
8610     // Default priority windows: THREAD_PRIORITY_ABOVE_NORMAL
8611     // Default priority linux: SCHED_OTHER -10
8612     DtMxSchedulingArgs  m_CallbackThreads;
8613 
8614 public:
8615     DtMxThreadScheduling();
8616 };
8617 
8618 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtMxProcess -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8619 //
8620 class DtMxProcess
8621 {
8622 public:
8623     // The matrix process has 2 states: IDLE and RUNNING. You can switch between those
8624     // states by calling Start() and Stop(). Most functions can only be called in IDLE and
8625     // will return immediately with an error if called in RUN mode.
8626 
8627     // Register a new callback function that will be called by the framework whenever
8628     // a new frame is ready for processing.
8629     DTAPI_RESULT  AddMatrixCbFunc(DtMxProcFrameFunc* pFunc, void* pOpaque);
8630 
8631     // Reset complete matrix process. The following things will be done:
8632     // 1. Detach all attached ports.
8633     // 2. Set NumPhases to default value.
8634     // 3. Clear any configuration done via SetRowConfig()
8635     // 4. Set end-to-end delay to default.
8636     // 5. Remove all callbacks.
8637     DTAPI_RESULT  Reset();
8638 
8639     // The matrix can have any number of rows (limited by system resources). Row numbers
8640     // start with 0 and go up to N-1 (where N=number of rows). Rows can be attached to
8641     // ports in any order, it's not required to start with row 0.
8642     // Each row can be attached to:
8643     // - 1 input port
8644     // - 1 or more output ports
8645     // - 1 input port and 1 or more output ports
8646     DTAPI_RESULT  AttachRowToInput(int Row, const DtMxPort& Port);
8647     DTAPI_RESULT  AttachRowToOutput(int Row, const DtMxPort& Port, int ExtraOutDelay=0);
8648 
8649     // Change the way the HLM clock source is controlled.
8650     DTAPI_RESULT  SetClockControl(DtMxClockMode, DtDevice* pDvc=NULL, int AvgFifoLoad=-1);
8651 
8652     // Can be called by the user while the matrix process is running. HLM will keep
8653     // track of a number of these samples and will adjust it's clock source so the
8654     // output rate is matched to the provided samples.
8655     DTAPI_RESULT  NewClockSample(__int64 PcrOrFifoLoad, int RefClkCnt);
8656 
8657     // Changes the number of phases. Global setting per matrix.
8658     DTAPI_RESULT  SetNumPhases(int NumPhases);
8659 
8660     // SetRowConfig sets the configuration and validates if it is possible valid. Not all
8661     // errors can be caught at this time since some depend on the video standard (for
8662     // example DtMxVideoConfig::m_NumLines1 if not equal to -1).
8663     // SetRowConfig(Row) is only valid after AttachToInput(Row)/AttachToOutput(Row) has
8664     // been called and will return an error otherwise.
8665     DTAPI_RESULT  SetRowConfig(int Row, const DtMxRowConfig& Config);
8666 
8667     // Function to change the video standard for all ports attached to the given row.
8668     DTAPI_RESULT  SetVidStd(int Row, int VidStd);
8669 
8670     // Set a callback function the framework can use to free user-provided video buffers.
8671     DTAPI_RESULT  SetVidBufFreeCb(DtMxVidBufFreeCallback* pFunc);
8672 
8673     // Get the minimum/default end-to-end delay. CbFrames will be an approximation
8674     // of the time the user callback function has relative to the time of a complete
8675     // frame. GetDefEndToEndDelay() will return a value: CbFrames >= NumPhases.
8676     // GetMinEndToEndDelay() will return a value: NumPhases-1 < CbFrames <= NumPhases.
8677     DTAPI_RESULT  GetMinEndToEndDelay(int& Delay, double& CbFrames);
8678     DTAPI_RESULT  GetDefEndToEndDelay(int& Delay, double& CbFrames);
8679     DTAPI_RESULT  SetEndToEndDelay(int Delay);
8680 
8681     // Makes sure the configuration of all rows and global matrix settings is consistent.
8682     // If it is, start the matrix process.
8683     DTAPI_RESULT  Start();
8684     // Stop a runnig matrix process and return to IDLE.
8685     DTAPI_RESULT  Stop();
8686 
8687     DTAPI_RESULT  SetThreadScheduling(const DtMxThreadScheduling& Scheduling);
8688 
8689     //TODO: add function to initialize "error-frame" for input/output and output rows.
8690     // This error-frame can be played out during the first few frames when there is
8691     // no data available yet and when the input is stalled and configuration requests it.
8692 
8693     // Print profiling information collected while the matrix was running
8694     DTAPI_RESULT  PrintProfilingInfo();
8695 
8696     // Implementation data
8697 private:
8698     class MxProcessImpl*  m_pImpl;
8699 
8700     // Constructor, destructor
8701 public:
8702     DtMxProcess();
8703     ~DtMxProcess();
8704 private:
8705     // No implementation is provided for the copy constructor or for operator=
8706     DtMxProcess(const DtMxProcess&);
8707     DtMxProcess& operator = (const DtMxProcess&);
8708 };
8709 
8710 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
8711 //+=+=+=+=+=+=+=+=+=+=+=+=+ ENCODING & DECODING CONTROL CLASSES +=+=+=+=+=+=+=+=+=+=+=+=+=
8712 //+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
8713 
8714 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- RESULT CODES -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8715 
8716 // Result codes for methods used in encoder and decoder control
8717 enum DtEncResult
8718 {
8719     DT_ENC_OK,                      // All is fine
8720     DT_ENC_E_AUDBITRATETOOLOW,      // Bitrate too low for selected audio service type
8721     DT_ENC_E_AUDBITRATETOOHIGH,     // Bitrate too high for selected audio service type
8722     DT_ENC_E_EXC_NUMAAC,            // #AAC services too high
8723     DT_ENC_E_EXC_NUMDOLBYE,         // #DolbyE services too high
8724     DT_ENC_E_EXC_NUMNONSURROUND,    // #Non-surround services too high
8725     DT_ENC_E_EXC_NUMSURROUND,       // #Surround services too high
8726     DT_ENC_E_INV_AACPAR,            // Invalid AAC parameter
8727     DT_ENC_E_INV_AFDBARMODE,        // Invalid AFD/BAR mode
8728     DT_ENC_E_INV_ASPECTRATIO,       // Invalid aspect ratio
8729     DT_ENC_E_INV_AUDBITRATE,        // Invalid audio service bitrate
8730     DT_ENC_E_INV_AUDCHANCONFIG,     // Invalid audio channel configuration
8731     DT_ENC_E_INV_AUDCHANIDX,        // Invalid channel index
8732     DT_ENC_E_INV_AUDDELAY,          // Invalid audio delay
8733     DT_ENC_E_INV_AUDENCSTD,         // Invalid audio-encoding standard
8734     DT_ENC_E_INV_AUDPID,            // Invalid audio PID
8735     DT_ENC_E_INV_AUDSAMPLERATE,     // Invalid audio sample rate
8736     DT_ENC_E_INV_AUDSVCCONFIG,      // Invalid audio service configuration
8737     DT_ENC_E_INV_AUDSVCTYPE,        // Invalid audio service type
8738     DT_ENC_E_INV_BITPERSAMPLE,      // Invalid #bits per audio sample
8739     DT_ENC_E_INV_BITRATE_PCM,       // Embedded PCM samples bitrate out of range
8740     DT_ENC_E_INV_BITRATE_TS,        // TS bitrate out of valid range
8741     DT_ENC_E_INV_BITRATE_VID,       // Video bitrate out of valid range
8742     DT_ENC_E_INV_CCMODE,            // Invalid closed captions mode
8743     DT_ENC_E_INV_CCSOURCE,          // Invalid closed captions source
8744     DT_ENC_E_INV_CODINGMODE,        // Invalid coding mode
8745     DT_ENC_E_INV_DOLBYMETADATA,     // Invalid Dolby metadata
8746     DT_ENC_E_INV_DUPLICATEPIDS,     // One or more duplicate PIDs used
8747     DT_ENC_E_INV_END2ENDDELAY,      // The end-to-end delay is invalid
8748     DT_ENC_E_INV_ENTROPYENC,        // The entropy encoding (e.g. CABAC/CAVLC) is invalid
8749     DT_ENC_E_INV_FRAMERATE,         // The frame rate is invalid
8750     DT_ENC_E_INV_FRAMESIZE,         // The frame size is invalid
8751     DT_ENC_E_INV_HEAACE2EDELAY,     // The end-to-end delay is invalid for HE-AAC
8752     DT_ENC_E_INV_GOPSIZE,           // Invalid GOP size
8753     DT_ENC_E_INV_IDRFREQ,           // Invalid IDR frequency
8754     DT_ENC_E_INV_ILIMAGE,           // Invalid input loss image
8755     DT_ENC_E_INV_INTRADCPREC,       // Invalid DC precision
8756     DT_ENC_E_INV_INTRAVLCFMT,       // Invalid intra VLC format
8757     DT_ENC_E_INV_LEVEL,             // Invalid level
8758     DT_ENC_E_INV_NUMBPICTURES,      // Invalid #B pictures between I/P pictures
8759     DT_ENC_E_INV_NUMCHANNELS,       // Invalid number of (audio) channels
8760     DT_ENC_E_INV_PATITV,            // Invalid PAT interval
8761     DT_ENC_E_INV_PIXDEPTH,          // Invalid pixel depth
8762     DT_ENC_E_INV_PMTITV,            // Invalid PMT interval
8763     DT_ENC_E_INV_PMTPID,            // Invalid PMT PID
8764     DT_ENC_E_INV_PCRITV,            // Invalid PCR interval
8765     DT_ENC_E_INV_PCRPID,            // Invalid PCR PID
8766     DT_ENC_E_INV_PROFILE,           // Invalid profile
8767     DT_ENC_E_INV_QSCALETYPE,        // Invalid type of quantization scale
8768     DT_ENC_E_INV_QUANTTABLE,        // Invalid quantization table
8769     DT_ENC_E_INV_RESCALEHOR,        // Invalid rescaled horizontal resolution
8770     DT_ENC_E_INV_SOURCEPORT,        // Invalid source port selection
8771     DT_ENC_E_INV_STREAMID,          // Invalid stream ID
8772     DT_ENC_E_INV_TELECINE,          // Invalid inverse telecine operation
8773     DT_ENC_E_INV_TRANSBLOCKSIZE,    // Invalid transform block size (8x8 tranform)
8774     DT_ENC_E_INV_TSID,              // Invalid TS ID
8775     DT_ENC_E_INV_TYPE,              // Type number is not valid encoding hardware
8776     DT_ENC_E_INV_UVSAMPLING,        // Invalid chroma sampling
8777     DT_ENC_E_INV_VBVDELAY,          // Invalid VBV delay
8778     DT_ENC_E_INV_VIDENCSTD,         // Invalid video-encoding standard
8779     DT_ENC_E_INV_VIDPID,            // Invalid video PID
8780     DT_ENC_E_INV_VIDSTD,            // Invalid video standard
8781     DT_ENC_E_INV_VOLUMEADJUST,      // Invalid volume adjustment
8782     DT_ENC_E_PASSTHROUGHONLY,       // Standard is only supported in passthrough mode
8783     DT_ENC_E_TYPE_NOT_SET,          // No type number has been set
8784     DT_ENC_E_UNSUP_PRF_LVL          // Unsupported profile level combination
8785 };
8786 
8787 // Convert DT_ENC result code to string for debugging purposes
8788 const char*  DtEncResult2Str(DtEncResult);
8789 
8790 // Video encoder status (see also DTAPI_STAT_VID_STATUS)
8791 #define DTAPI_VIDSTATUS_IDLE         0           // Not encoding
8792 #define DTAPI_VIDSTATUS_OK           1           // Encoding
8793 #define DTAPI_VIDSTATUS_SYNCLOSS     2           // Lost input synchronisation
8794 #define DTAPI_VIDSTATUS_ERROR        -1          // Unknown encoding error
8795 
8796 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+ ENCODING PARAMETERS BASE CLASS +=+=+=+=+=+=+=+=+=+=+=+=+=+=
8797 
8798 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncParsBase -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8799 //
8800 // Base class for encoder parameter classes that are dependent on the encoder type.
8801 //
8802 class DtEncParsBase
8803 {
8804 public:
8805     // Public methods
8806     bool  IsEncTypeValid() const;
GetEncType()8807     int  GetEncType() const { return m_EncType; }
8808 
8809 protected:
8810     DTAPI_RESULT  SetEncType(int EncType);
8811 
8812     // Constructor, destructor
8813     DtEncParsBase(int EncType=-1);
~DtEncParsBase()8814     ~DtEncParsBase() {}
8815 
8816 protected:
8817     int  m_EncType;                 // DekTec type number of encoder card (e.g. 2180)
8818 };
8819 
8820 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+ ANCILLARY ENCODING PARAMETERS +=+=+=+=+=+=+=+=+=+=+=+=+=+=+
8821 
8822 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncAncPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
8823 //
8824 // Encoding/embedding parameters for data that is not audio or video.
8825 //
8826 class DtEncAncPars : public DtEncParsBase
8827 {
8828 public:
8829     // AFD/BAR insertion mode
8830     enum AfdBarMode
8831     {
8832         AFDBAR_NONE,                // Do not extract/insert AFD/BAR
8833         AFDBAR_WHENNEEDED,          // Insert/extract AFD/BAR as needed
8834         AFDBAR_ALWAYS               // Always extract/insert AFD/BAR
8835     };
8836 
8837     // Closed caption extraction and processing mode
8838     enum CcMode
8839     {
8840         CC_DISABLE,                 // Do not extract/insert captions
8841         CC_ALL,                     // Extract/insert all captions
8842         CC_608B,                    // Extract/insert EIA608B field 1 and EIA608B field 2
8843         CC_608B_FLD1,               // Extract/insert EIA608B field 1
8844         CC_608B_FLD2,               // Extract/insert EIA608B field 2
8845         CC_708B                     // Extract/insert EIA708B
8846     };
8847 
8848     // Closed caption capture source
8849     enum CcSource
8850     {
8851         CS_NONE,                    // Closed captions not used
8852         CS_VANC,                    // Closed caption data taken from VANC
8853         CS_WAVEFORM,                // For SD only: Decode waveform in line 21
8854         CS_ALL                      // Either VANC or line 21
8855     };
8856 
8857     // VBI format
8858     enum VbiFormat
8859     {
8860         VBI_MSB,                    // VBI input in MSB
8861         VBI_LSB                     // VBI input in LSB
8862     };
8863 
8864     // Parameters
8865     AfdBarMode  m_AfdBarMode;       // AFD/BAR insertion mode
8866     CcMode  m_CcMode;               // Closed caption extraction and processing mode
8867     CcSource  m_CcSource;           // Closed caption source
8868     VbiFormat  m_VbiFormat;         // VBI input in MSB or LSB
8869     bool  m_VideoIndex;             // Enable/disable video index processing
8870     bool  m_Vitc;                   // Enable/disable VITC
8871 
8872     // Public methods
8873     DtEncResult  CheckValidity() const;
8874     DTAPI_RESULT  SetDefaultPars();
8875     DTAPI_RESULT  SetEncType(int EncType);
8876 
8877     // Constructor, destructor, operators
8878     DtEncAncPars(int EncType=-1);
8879     bool  operator == (const DtEncAncPars&) const;
8880     bool  operator != (const DtEncAncPars&) const;
8881 };
8882 
8883 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ AUDIO ENCODING PARAMETERS +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
8884 
8885 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncAudParsStdBase -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8886 //
8887 // Base class for encoding parameters specific to an audio encoding standard.
8888 //
8889 class DtEncAudParsStdBase : public DtEncParsBase
8890 {
8891 public:
8892     // Public methods
8893     virtual DtEncResult  CheckValidity() const = 0;
8894     virtual DTAPI_RESULT  SetDefaultPars() = 0;
SetEncType(int EncType)8895     virtual  DTAPI_RESULT  SetEncType(int EncType)
8896                                             { return DtEncParsBase::SetEncType(EncType); }
8897     // Undocumented public methods for DTAPI-internal usage
SetAudSvcParsPtr(class DtEncAudPars * pSvcPars)8898     void  SetAudSvcParsPtr(class DtEncAudPars* pSvcPars) { m_pSvcPars = pSvcPars; }
8899 
8900     // Constructor / Destructor
DtEncParsBase(EncType)8901     DtEncAudParsStdBase(int EncType=-1) : DtEncParsBase(EncType), m_pSvcPars(NULL) {}
~DtEncAudParsStdBase()8902     virtual ~DtEncAudParsStdBase() {}
8903 
8904 protected:
8905     // Pointer back to DtEncAudPars, so that e.g m_Bitrate can be accessed
8906     class DtEncAudPars*  m_pSvcPars;
8907 };
8908 
8909 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncAudParsAac -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8910 //
8911 // AAC audio encoding parameters
8912 //
8913 class DtEncAudParsAac : public DtEncAudParsStdBase
8914 {
8915 public:
8916     // AAC container format
8917     enum AacFmt
8918     {
8919         CF_ADTS,                    // Audio Data Transport Stream (ADTS) format
8920         CF_LATM                     // Low Overhead Audio Transport Multiplex (LATM)
8921     };
8922 
8923     // AAC container format
8924     enum AacProfile
8925     {
8926         AAC_LC,                     // Low Complexity profile (AAC-LC)
8927         AAC_HE,                     // High Efficiency profile (HE-AAC)
8928         AAC_HEv2                    // High Efficiency version 2 profile (HE-AAC)
8929     };
8930 
8931     // AAC version
8932     enum AacVersion
8933     {
8934         AAC_MP4,                    // MPEG-4 AAC
8935         AAC_MP2                     // MPEG-2 AAC
8936     };
8937 
8938     // AAC parameters
8939     AacFmt  m_ContainerFormat;      // Container format: CF_ADTS or CF_LATM
8940     AacProfile  m_Profile;          // Encoder profile
8941     bool  m_Crc;                    // Add CRC to data packets
8942     AacVersion  m_Version;          // MPEG-2 or MPEG-4 AAC
8943     bool  m_LowLoad;                // Use low-load encoding algorithm
8944 
8945     // Public methods
8946     DtEncResult  CheckValidity() const;
8947 
8948     // Undocumented public methods for DTAPI-internal usage
8949     DTAPI_RESULT  SetDefaultPars();
8950 
8951     // Constructor, destructor
8952     DtEncAudParsAac(int EncType=-1);
8953     bool  operator == (const DtEncAudParsAac&) const;
8954     bool  operator != (const DtEncAudParsAac&) const;
8955 };
8956 
8957 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncAudParsAc3 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
8958 //
8959 // AC-3 audio encoding parameters
8960 //
8961 class DtEncAudParsAc3 : public DtEncAudParsStdBase
8962 {
8963 public:
8964     bool  m_LfeOn;                  // Enable Low Frequency Effect (LFE) channel
8965     bool  m_LfeLpfOn;               // Enable LFE lowpass filter
8966     bool  m_DynRangeCtrl1;          // Enable normal compression
8967     bool  m_DynRangeCtrl2;          // Enable secondary compression
8968     bool  m_SurDelay;               // Enable surround channel delay
8969     int  m_DialNorm;                // Dialog normalization
8970     bool  m_HpFOn;                  // Enable DC filter
8971     int  m_CompChar;                // Global compression profile
8972     int  m_DComp;                   // Line mode profile
8973     int  m_D2Comp;                  // Line mode profile for second channel
8974     int  m_CComp;                   // RF mode profile
8975     int  m_C2Comp;                  // RF mode profile for second channel
8976     bool  m_RfPremphOn;             // Enable digital deemphasis
8977     bool  m_BwLpfOn;                // Enable bandwidth filter
8978     bool  m_Sur90On;                // Enable 90-degree phase shift for surround
8979     bool  m_XbsiE;                  // Enabled extended bitstream information
8980     int  m_DHeadPhonMod;            // Dolby headphone mode
8981     int  m_AdConvTyp;               // A/D converter type
8982     int  m_MixLevel;                // Mixing level
8983     bool  m_CopyrightB;             // Copyright flag
8984     bool  m_OrigBs;                 // Original bitstream flag
8985     int  m_BsMod;                   // Bitstream mode
8986     int  m_RoomTyp;                 // Room type
8987     int  m_DSurMod;                 // Dolby surround mode
8988     bool  m_AdvDrc;                 // Enable advanced DRC
8989     int  m_CMixLev;                 // Center mix level
8990     int  m_SurMixLev;               // Surround mix level
8991     int  m_DMixMod;                 // Preferred stereo downmix mode
8992     int  m_LtrtCMixLev;             // Lt/Rt center mix level
8993     int  m_LtrtSurMixLev;           // Lt/Rt surround mix level
8994     int  m_LoroCMixLev;             // Lo/Ro center mix level
8995     int  m_LoroSurMixLev;           // Lo/Ro surround mix level
8996     int  m_DSurExMod;               // Dolby surround EX mode
8997     bool  m_SurAtton;               // 3dB surround attenuation flag
8998     bool  m_AudProdIE;              // Audio production info exists
8999 
9000     // Public methods
9001     DtEncResult  CheckValidity() const;
9002 
9003     // Undocumented public methods for DTAPI-internal usage
9004     DTAPI_RESULT  SetDefaultPars();
9005 
9006     // Constructor, destructor
9007     DtEncAudParsAc3(int EncType=-1);
9008     bool  operator == (const DtEncAudParsAc3&) const;
9009     bool  operator != (const DtEncAudParsAc3&) const;
9010 };
9011 
9012 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncAudParsMp1LII -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
9013 //
9014 // MPEG-1 layer II audio encoding parameters
9015 //
9016 class DtEncAudParsMp1LII : public DtEncAudParsStdBase
9017 {
9018 public:
9019     // MPEG 1 layer II parameters
9020     bool  m_Crc;                    // Add CRC to data packets
9021 
9022     // Public methods
9023     DtEncResult  CheckValidity() const;
9024 
9025     // Undocumented public methods for DTAPI-internal usage
9026     DTAPI_RESULT  SetDefaultPars();
9027 
9028     // Constructor, destructor
9029     DtEncAudParsMp1LII(int EncType=-1);
9030     bool  operator == (const DtEncAudParsMp1LII&) const;
9031     bool  operator != (const DtEncAudParsMp1LII&) const;
9032 };
9033 
9034 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncAudParsPcm -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
9035 //
9036 // PCM direct mapping into MPEG-2 transport stream according to SMPTE 302M
9037 //
9038 class DtEncAudParsPcm : public DtEncAudParsStdBase
9039 {
9040 public:
9041     // PCM mapping parameters
9042     int  m_BitPerSample;            // #bits per sample: 16, 20 or 24
9043 
9044     // Public methods
9045     DtEncResult  CheckValidity() const;
9046 
9047     // Undocumented public methods for DTAPI-internal usage
9048     DTAPI_RESULT  SetDefaultPars();
9049 
9050     // Constructor, destructor
9051     DtEncAudParsPcm(int EncType=-1);
9052     bool  operator == (const DtEncAudParsPcm&) const;
9053     bool  operator != (const DtEncAudParsPcm&) const;
9054 };
9055 
9056 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncAudPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
9057 //
9058 // Class for specifying the encoding parameters for a single audio service.
9059 // It consists of:
9060 //  - Parameters specifying the audio channels (forming the audio service) to encode
9061 //  - Audio encoding parameters for this audio service
9062 //
9063 class DtEncAudPars : public DtEncParsBase
9064 {
9065 public:
9066     // Audio service type
9067     enum AudServiceType
9068     {
9069         SVC_DUAL_MONO,              // Dual mono
9070         SVC_MONO,                   // Mono
9071         SVC_PASSTHROUGH,            // Pass-through mode
9072         SVC_STEREO,                 // Stereo
9073         SVC_SURROUND_5_1            // 5.1 surround
9074     };
9075 
9076     bool  m_Enable;                 // Enable/disable this instance of DtEncAudPars.
9077                                     // If disabled, all remaining parameters are ignored.
9078 
9079     // Audio input configuration
9080     std::vector<int>  m_AudChans;   // Audio channels (left+right stream of audio samples)
9081                                     // included in the audio service
9082 
9083     // Generic (standard-independent) audio-encoding parameters
9084     int  m_Bitrate;                 // Bitrate of encoded audio service
9085     int  m_Delay;                   // Audio delay in milliseconds
9086     int  m_SampleRate;              // Sample rate: 32000, 44100, 48000
9087 
9088     // Advanced generic audio-encoding parameters
9089     bool  m_AlignedPes;             // Enable aligned PES
9090     bool  m_VolumeAdjust;           // Enable volume adjustment
9091     double  m_VolumeAdjustdB;       // Volume adjustment in dB
9092 
9093 public:
9094      // Public methods
9095     DtEncResult  CheckValidity(int SourcePort=-1) const;
GetAudEncStd()9096     DtAudEncStd  GetAudEncStd() const { return m_AudEncStd; }
GetSvcType()9097     AudServiceType  GetSvcType() const { return m_SvcType; }
9098     DTAPI_RESULT  SetAudEncStd(DtAudEncStd, AudServiceType);
9099     DTAPI_RESULT  SetEncType(int EncType);
9100     int  TpRate(int FrameRate) const;
9101 
9102     // Methods to get a pointer to the encoding parameters for a specific audio
9103     // encoding standard
9104     DtEncAudParsAac*  Aac() const;
9105     DtEncAudParsAc3*  Ac3() const;
9106     DtEncAudParsMp1LII*  Mp1LII() const;
9107     DtEncAudParsPcm*  Pcm() const;
9108 
9109     // pParsAudEncStd() can be used for calling generic methods that are independent
9110     // of the current Audio encoding standard.
ParsForAudEncStd()9111     DtEncAudParsStdBase*  ParsForAudEncStd() const { return m_pPars; }
9112 
9113     // Undocumented public methods for DTAPI-internal usage
9114     int  ReqNumLicPoints() const;
9115     DTAPI_RESULT  SetDefaultPars(DtAudEncStd, AudServiceType);
9116     DTAPI_RESULT  SetDefaultCommonPars(DtAudEncStd);
9117 
9118     // Constructor, destructor, operators
9119     DtEncAudPars(int EncType=-1);
9120     DtEncAudPars(const DtEncAudPars&);
9121     virtual ~DtEncAudPars();
9122     DtEncAudPars&  operator = (const DtEncAudPars&);
9123     bool  operator == (const DtEncAudPars&) const;
9124     bool  operator != (const DtEncAudPars&) const;
9125     // Serialisation
9126     DTAPI_RESULT  FromXml(const std::wstring&);
9127     DTAPI_RESULT  ToXml(std::wstring&);
9128 
9129 private:
9130     DtAudEncStd  m_AudEncStd;       // Audio encoding standard
9131     AudServiceType  m_SvcType;      // Service type: SVC_STEREO, ...
9132     DtEncAudParsStdBase*  m_pPars;  // Audio encoding parameters, specific to AAC, AC-3,
9133                                     // AES, MPEG-2 audio
9134 };
9135 
9136 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ MULTIPLEXER PARAMETERS +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
9137 
9138 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncMuxPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
9139 //
9140 // Multiplexing parameters for encoders
9141 //
9142 class DtEncMuxPars : public DtEncParsBase
9143 {
9144 public:
9145     // Elementary stream parameters
9146     struct EsPars
9147     {
9148         int  m_Pid;                 // PID of the elementary stream; if disabled: -1
9149         int  m_StreamId;            // Stream ID of the elementary stream
9150 
9151         // Operators
9152         EsPars&  operator = (const EsPars&);
9153         bool  operator == (const EsPars&) const;
9154         bool  operator != (const EsPars&) const;
9155 
9156         // Constructor
m_PidEsPars9157         EsPars(int Pid=-1, int StreamId=-1) : m_Pid(Pid), m_StreamId(StreamId) {}
9158     };
9159 
9160     // Overall (elementary-stream independent) parameters
9161     int  m_Bitrate;                 // Transport stream output bitrate
9162     int  m_TsId;                    // Transport stream ID
9163 
9164     // Elementary stream parameters: PIDs and stream IDs
9165     int  m_PcrPid;                  // PCR PID
9166     int  m_PmtPid;                  // PMT PID
9167     EsPars  m_VidEsPars;            // Elementary stream parameters for encoded video
9168 
9169     // Elementary stream parameters (PID, stream ID) for encoded audio.
9170     // This vector gets sized in SetEncType.
9171     std::vector<EsPars>  m_AudEsPars;
9172 
9173     // Scheduling intervals
9174     int  m_PatInterval;             // PAT interval in ms
9175     int  m_PmtInterval;             // PMT interval in ms
9176     int  m_PcrInterval;             // PCR interval in ms
9177 
9178     // Methods
9179     DtEncResult  CheckValidity(bool SkipRateChecks=false) const;
9180     int  NumAudEsPars() const;
9181     DTAPI_RESULT  SetEncType(int EncType);
9182 
9183     // Constructor, destructor, operators
9184     DtEncMuxPars(int EncType=-1);
9185     DtEncMuxPars&  operator = (const DtEncMuxPars&);
9186     bool  operator == (const DtEncMuxPars&) const;
9187     bool  operator != (const DtEncMuxPars&) const;
9188 };
9189 
9190 //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ VIDEO ENCODING PARAMETERS +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
9191 
9192 //.-.-.-.-.-.-.-.-.-.- Video encoding parameters - Enumeration types -.-.-.-.-.-.-.-.-.-.-
9193 
9194 // Video encoding standard
9195 enum DtVidEncStd
9196 {
9197     DT_VIDENCSTD_UNKNOWN,           // Unknown or not defined yet
9198     DT_VIDENCSTD_MP2V,              // MPEG-2 video
9199     DT_VIDENCSTD_H264,              // H.264 (AVC)
9200     DT_VIDENCSTD_H265               // H.265 (HEVC)
9201 };
9202 
9203 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncVidParsStdBase -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
9204 //
9205 // Base class for encoding parameters specific to a video encoding standard.
9206 // This class is specialized for MPEG-2 video, H.264 and (later on) for H.265.
9207 //
9208 class DtEncVidParsStdBase : public DtEncParsBase
9209 {
9210 public:
DtEncParsBase(EncType)9211     DtEncVidParsStdBase(int EncType=-1) : DtEncParsBase(EncType) {}
~DtEncVidParsStdBase()9212     virtual ~DtEncVidParsStdBase() {};
9213     virtual DtEncResult  CheckValidity(bool SkipRateChecks=false) const = 0;
GetVideoBitrate()9214     virtual int  GetVideoBitrate() const { return -1; }
GetVideoGopNumBPictures()9215     virtual int  GetVideoGopNumBPictures() const { return -1; }
SetEncType(int EncType)9216     virtual DTAPI_RESULT  SetEncType(int EncType)
9217                                             { return DtEncParsBase::SetEncType(EncType); }
9218 };
9219 
9220 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncVidParsMp2V -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
9221 //
9222 // MPEG-2 video encoding parameters
9223 //
9224 class DtEncVidParsMp2V : public DtEncVidParsStdBase
9225 {
9226 public:
9227     // MPEG-2 video - Profile
9228     enum Mp2VProfile
9229     {
9230         PROFILE_SIMPLE,             // Simple profile
9231         PROFILE_MAIN,               // Main profile
9232         PROFILE_HIGH,               // High profile
9233         PROFILE_422P                // 422P profile
9234     };
9235 
9236     // MPEG-2 video - Level
9237     enum Mp2VLevel
9238     {
9239         LEVEL_AUTO,                 // Automatic
9240         LEVEL_HIGH,                 // High level
9241         LEVEL_HIGH1440,             // High 1440 level
9242         LEVEL_MAIN                  // Main level
9243     };
9244 
9245     // Intra-VLC format
9246     enum IntraVlcFormat
9247     {
9248         IV_ALTERNATE,               // Alternate intra-VLC format
9249         IV_MPEG1                    // MPEG-1 intra-VLC format
9250     };
9251 
9252     // Quantization scale
9253     enum QScaleType
9254     {
9255         QS_LINEAR,                  // Linear quantization scale
9256         QS_NONLINEAR                // Non-linear quantization scale
9257     };
9258 
9259     // Top-level parameters
9260     Mp2VProfile  m_Profile;         // MPEG-2 video profile: PROFILE_MAIN, ...
9261     Mp2VLevel  m_Level;             // MPEG-2 video level: LEVEL_MAIN, ...
9262     int  m_Bitrate;                 // Bitrate of the encoded video stream
9263     int  m_VbvDelayMax;             // Maximum VBV delay in milliseconds
9264 
9265     // GOP related parameters
9266     bool  m_ClosedGop;              // If true, use closed GOPs
9267     int  m_GopSize;                 // The size of each GOP in frames
9268     int  m_GopNumBPictures;         // Number of B pictures (-1=auto)
9269 
9270     // Specialized MPEG-2 video encoding parameters
9271     bool  m_AlternateScan;          // Use alternate scan pattern for VLC coefficients
9272     int  m_IntraDcPrecision;        // Number of bits used for intra-DC values: 8..11
9273     IntraVlcFormat  m_IntraVlcFmt;  // Format to use for intra-vlc: MPEG-1, alternate
9274     QScaleType  m_QScaleType;       // Type of quantization scale: linear, non-linear
9275     bool  m_LowDelayFlag;           // Set the low delay flag (no B pictures)
9276 
9277     // MPEG-2 video encoding parameters specific to the Magnum D7Pro
9278     bool  m_AdaptiveQuantization;   // Enable adaptive quantization
9279     int  m_IdrFrequency;            // Frequency of IDRs relative to I frames
9280                                     // 0=every I-frame, 1=every 2nd I-frame, etc
9281     int  m_QuantizationTable;       // Quantization table to use (0=use Magnum default)
9282 
9283     // Public methods
9284     DtEncResult  CheckValidity(bool SkipRateChecks=false) const;
9285 
9286     // Undocumented public methods for DTAPI-internal usage
SetVidParsPtr(class DtEncVidPars * pVidPars)9287     void  SetVidParsPtr(class DtEncVidPars* pVidPars) { m_pVidPars = pVidPars; }
9288 
9289     // Constructor, destructor
9290     DtEncVidParsMp2V(int EncType=-1);
9291     bool  operator == (const DtEncVidParsMp2V&) const;
9292     bool  operator != (const DtEncVidParsMp2V&) const;
9293 
9294 private:
9295     // Pointer back to top-level video encoding parameters
9296     class DtEncVidPars*  m_pVidPars;
9297 };
9298 
9299 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncVidParsH264 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
9300 //
9301 // H.264 video encoding parameters
9302 //
9303 class DtEncVidParsH264 : public DtEncVidParsStdBase
9304 {
9305 public:
9306     // H.264 - Profile
9307     enum H264Profile
9308     {
9309         PROFILE_CONSTRAINED_BASE,   // Constrained Baseline profile
9310         PROFILE_MAIN,               // Main profile
9311         PROFILE_HIGH,               // High profile
9312         PROFILE_AVCI50,             // AVC-I 50 profile
9313         PROFILE_AVCI100             // AVC-I 100 profile
9314     };
9315 
9316     // H.264 - Level
9317     enum H264Level
9318     {
9319         LEVEL_AUTO,                 // Automatic
9320         LEVEL_1,                    // Level 1
9321         LEVEL_1_1,                  // Level 1.1
9322         LEVEL_1_2,                  // Level 1.2
9323         LEVEL_1_3,                  // Level 1.3
9324         LEVEL_2,                    // Level 2
9325         LEVEL_2_1,                  // Level 2.1
9326         LEVEL_2_2,                  // Level 2.2
9327         LEVEL_3,                    // Level 3
9328         LEVEL_3_1,                  // Level 3.1
9329         LEVEL_3_2,                  // Level 3.2
9330         LEVEL_4,                    // Level 4
9331         LEVEL_4_1,                  // Level 4.1
9332         LEVEL_4_2,                  // Level 4.2
9333         LEVEL_5,                    // Level 5
9334         LEVEL_5_1                   // Level 5.1
9335     };
9336 
9337     // Generic
9338     H264Profile  m_Profile;         // H.264 profile: PROFILE_MAIN, ...
9339     H264Level  m_Level;             // H.264 level: LEVEL_1_0, ...
9340     int  m_Bitrate;                 // Bitrate of the encoded video stream
9341     int  m_VbvDelayMax;             // Maximum VBV delay in milliseconds
9342 
9343     // GOP parameters
9344     bool  m_ClosedGop;              // Use closed GOPs
9345     int  m_GopSize;                 // GOP size in #frames (-1=auto)
9346     int  m_GopNumBPictures;         // Number of B pictures (-1=auto)
9347 
9348     // Specialized H.264 encoding parameters
9349     bool  m_8x8Transform;           // Enable 8x8 transforms
9350     bool  m_Cabac;                  // Enable CABAC, use CAVLC otherwise
9351 
9352     // H.264 video encoding parameters, specific to the Magnum D7Pro
9353 
9354     // Coding mode
9355     enum CodingMode
9356     {
9357         CM_AUTO,                    // Automatic
9358         CM_FRAME,                   // Frame, for progressive content
9359         CM_FIELD,                   // Field, for interlaced content
9360         CM_MBAFF                    // MBAFF, for interlaced content
9361     };
9362 
9363     bool  m_AdaptiveQuantization;   // Enable adaptive quantization
9364     bool  m_ChromaScalingList;      // Enable chroma scaling list
9365     CodingMode  m_CodingMode;       // Coding mode: CM_FRAME, ...
9366     int  m_IdrFrequency;            // Frequency of IDRs relative to I frames
9367                                     // 0=every I-frame, 1=every 2nd I-frame, etc
9368     bool  m_IntraScoreAvg;          // Use averaged intra score to compute QP increase
9369     int  m_QuantizationTable;       // Quantization table to use (0=use Magnum default)
9370     bool  m_WeightedPrediction;     // Enable weighted prediction
9371 
9372     // Public methods
9373     DtEncResult  CheckValidity(bool SkipRateChecks=false) const;
9374 
9375     // Undocumented public methods for DTAPI-internal usage
SetVidParsPtr(class DtEncVidPars * pVidPars)9376     void  SetVidParsPtr(class DtEncVidPars* pVidPars) { m_pVidPars = pVidPars; }
9377 
9378     // Constructor, destructor
9379     DtEncVidParsH264(int EncType=-1);
9380     bool  operator == (const DtEncVidParsH264&) const;
9381     bool  operator != (const DtEncVidParsH264&) const;
9382 
9383 private:
9384     // Pointer back to top-level video encoding parameters
9385     class DtEncVidPars*  m_pVidPars;
9386 };
9387 
9388 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncVidPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
9389 //
9390 // Top-level video encoding parameters class, consisting of:
9391 //  - Parameters related to preprocessing of the video, before encoding
9392 //  - Video encoding parameters
9393 //
9394 class DtEncVidPars : public DtEncParsBase
9395 {
9396 public:
9397     // Image inserted at the encoder input when the input signal is lost
9398     enum InpLossImage
9399     {
9400         IL_BLACKFRAME,              // Black frames
9401         IL_COLORBARS                // Color bars
9402     };
9403 
9404     // Image inserted at the encoder input when the input signal is lost
9405     enum UvSampling
9406     {
9407         UV_420,                     // 4:2:0
9408         UV_422                      // 4:2:2
9409     };
9410 
9411     // Video input settings (not related to encoding)
9412     DtAspectRatio  m_AspectRatio;   // Aspect ratio: 4x3, 16x9 or 14x9
9413     bool  m_Dithering;              // Use dithering to reduce 10-bit input data to 8 bits
9414     int  m_HorResolutionRescaled;   // Horizontal resolution after rescaling
9415     InpLossImage  m_InpLossImage;   // Image to encode when input sync is lossed:
9416                                     // black frames or color bars
9417     bool  m_InvTelecineDetect;      // Enable inverse telecine operation
9418     int  m_PixelDepth;              // Number of bits per pixel
9419     UvSampling  m_UvSampling;       // Chroma subsampling: 4:2:0 or 4:2:2
9420     int  m_VidStd;                  // Video standard: DTAPI_VIDSTD_XXX
9421 
9422     // System parameter, but strongly connected to video encoding parameters
9423     int  m_EndToEndDelay;           // End-to-end delay in ms
9424 
9425     // Public methods
9426     DtEncResult  CheckValidity(bool SkipRateChecks=false) const;
GetVidEncStd()9427     DtVidEncStd  GetVidEncStd() const { return m_VidEncStd; }
9428     DtEncResult  SetDefaultsForProfileLevel(DtEncVidParsH264::H264Profile,
9429                                                              DtEncVidParsH264::H264Level);
9430     DtEncResult  SetDefaultsForProfileLevel(DtEncVidParsMp2V::Mp2VProfile,
9431                                                              DtEncVidParsMp2V::Mp2VLevel);
9432     DTAPI_RESULT  SetEncType(int EncType);
9433     DTAPI_RESULT  SetVidEncStd(DtVidEncStd);
9434     int  TpRate(int PcrInterval) const;
9435 
9436     static DTAPI_RESULT  Es2TpRate(int PcrInterval, int VidStd, int EsRate, int& TpRate);
9437     static DTAPI_RESULT  Tp2EsRate(int PcrInterval, int VidStd, int TpRate, int& EsRate);
9438 
9439     // Methods to get a pointer to the encoding parameters for the selected video
9440     // encoding standard.
9441     DtEncVidParsH264*  H264() const;// H.264 video encoding parameters
9442     DtEncVidParsMp2V*  Mp2V() const;// MPEG-2 video encoding parameters
9443 
9444     // Undocumented public methods for DTAPI-internal usage
9445     DTAPI_RESULT  SetDefaultCommonPars(int VidStd);
9446     DTAPI_RESULT  SetDefaultPars(DtVidEncStd, int VidStd, bool ApplyVidEncStd);
9447     // pParsVidEncStd() can be used for calling generic methods that are independent
9448     // of the current video encoding standard.
9449     DtEncVidParsStdBase*  ParsForVidEncStd();
9450 
9451     // Constructor, destructor, operators
9452     DtEncVidPars(int EncType=-1);
9453     DtEncVidPars(const DtEncVidPars&);
9454     virtual ~DtEncVidPars();
9455     DtEncVidPars&  operator = (const DtEncVidPars&);
9456     bool  operator == (const DtEncVidPars&) const;
9457     bool  operator != (const DtEncVidPars&) const;
9458 
9459 private:
9460     DtVidEncStd  m_VidEncStd;       // Video encoding standard
9461     DtEncVidParsStdBase*  m_pPars;  // Video encoding parameters, specific to MPEG-2
9462                                     // video, H.264, H.265
9463     DTAPI_RESULT  SetDefaultPars(); // Set default encoding parameters for 1080i50, H.264
9464 };
9465 
9466 
9467 
9468 //=+=+=+=+=+=+=+=+=+=+=+=+=+ TOP-LEVEL ENCODER CONTROL CLASSES +=+=+=+=+=+=+=+=+=+=+=+=+=+
9469 
9470 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncPars -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
9471 //
9472 // Top-level class for representing encoding parameters.
9473 //
9474 class DtEncPars : public DtEncParsBase
9475 {
9476 public:
9477     int  m_SourcePort;              // Physical port number of encoder source
9478                                     // DTA-2180: 1=SDI 2=HDMI
9479     DtEncAncPars  m_AncPars;        // Ancillary encoding/embedding parameters
9480     DtEncMuxPars  m_MuxPars;        // Multiplexing/"system" parameters
9481     DtEncVidPars  m_VidPars;        // Video encoding parameters
9482 
9483     // Audio encoding parameters per audio service. This vector gets sized in SetEncType.
9484     std::vector<DtEncAudPars>  m_AudPars;
9485 
9486     // Methods
9487     DtEncResult  CheckValidity(bool SkipRateChecks=false) const;
9488     int  MinTsRate() const;
9489     int  NumAudPars() const;
9490     DTAPI_RESULT  ReqNumLicPoints(DtAudEncStd, int& NumPoints) const;
9491     DTAPI_RESULT  SetEncType(int EncType);
9492     DTAPI_RESULT  SetVidEncDefaultPars(DtVidEncStd, int VidStd);
9493 
9494     static DTAPI_RESULT  IsSeamless(const DtEncPars&, const DtEncPars&, bool& Seamless);
9495 
9496     // Constructor, destructor, operators
9497     DtEncPars(int EncType=-1);
9498     DtEncPars(const DtEncPars&);
9499     virtual ~DtEncPars();
9500     DtEncPars&  operator = (const DtEncPars&);
9501     bool  operator == (const DtEncPars&) const;
9502     bool  operator != (const DtEncPars&) const;
9503 
9504     // Serialisation
9505     DTAPI_RESULT  FromXml(const std::wstring&);
9506     DTAPI_RESULT  ToXml(std::wstring&);
9507 };
9508 
9509 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtEncControl -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
9510 //
9511 // Top-level class for controlling encoder hardware.
9512 // This version of the DTAPI supports the DTA-2180 and DTA-2182.
9513 //
9514 class DtEncControl
9515 {
9516 public:
9517     // The 'control state' of the underlying encoder hardware and/or firmware
9518     enum OpState
9519     {
9520         OS_BOOTING,                 // Encoder is booting
9521         OS_INIT,                    // Encoder is initializing
9522         OS_IDLE,                    // Encoder is initialized, but not encoding
9523         OS_RUN,                     // Encoder is running
9524         OS_ERROR,                   // Encoder is in an error state
9525         OS_FAN_FAIL,                // Fan is failing
9526         OS_NO_POWER                 // Power is not connected to the encoder
9527     };
9528 
9529     // Public members
9530     DtHwFuncDesc  m_HwFuncDesc;     // Hardware function descriptor
9531 
9532     // Public methods
9533     DTAPI_RESULT  GetEncPars(DtEncPars&);
9534     DTAPI_RESULT  GetOperationalState(OpState&);
9535     DTAPI_RESULT  GetSourcePort(int& Port);
9536     DTAPI_RESULT  IsSeamless(const DtEncPars&, bool& Seamless);
9537     DTAPI_RESULT  Reboot();
9538     DTAPI_RESULT  SetEncPars(const DtEncPars&);
9539     DTAPI_RESULT  SetOperationalState(const OpState&);
9540     DTAPI_RESULT  WaitForInitialized(int TimeOut);
9541 
9542     // General member functions for top-level hardware abstraction classes
9543     DTAPI_RESULT  AttachToPort(DtDevice*, int Port, bool ProbeOnly=false);
9544     DTAPI_RESULT  Detach();
9545     DTAPI_RESULT  GetCodecVersion(DtAudEncStd, std::wstring&);
9546     DTAPI_RESULT  GetCodecVersion(DtVidEncStd, std::wstring&);
9547     DTAPI_RESULT  GetDescriptor(DtHwFuncDesc&);
9548     DTAPI_RESULT  GetIoConfig(int Group, int& Value);
9549     DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue);
9550     DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue, __int64& ParXtra0);
9551     DTAPI_RESULT  GetIoConfig(int Group, int& Value, int& SubValue,
9552                                                     __int64& ParXtra0, __int64& ParXtra1);
9553     DTAPI_RESULT  GetStatistics(int Count, DtStatistic*);
9554     DTAPI_RESULT  GetStatistic(int Type, int& Statistic);
9555     DTAPI_RESULT  GetStatistic(int Type, double& Statistic);
9556     DTAPI_RESULT  GetStatistic(int Type, bool& Statistic);
9557     DTAPI_RESULT  GetSupportedStatistics(int& Count, DtStatistic*);
9558     DTAPI_RESULT  SetIoConfig(int Group, int Value, int SubValue,
9559                                                       __int64 ParXtra0, __int64 ParXtra1);
9560 
9561     // Convenience functions
Category()9562     int  Category() { return m_HwFuncDesc.m_DvcDesc.m_Category; }
FirmwareVersion()9563     int  FirmwareVersion() { return m_HwFuncDesc.m_DvcDesc.m_FirmwareVersion; }
IsAttached()9564     bool  IsAttached() { return m_pEnc != NULL; }
TypeNumber()9565     int  TypeNumber() { return m_HwFuncDesc.m_DvcDesc.m_TypeNumber; }
HasCaps(const DtCaps Caps)9566     bool  HasCaps(const DtCaps Caps) const { return ((m_HwFuncDesc.m_Flags&Caps)==Caps); }
9567 
9568     // Undocumented public methods for DTAPI-internal usage
9569     DTAPI_RESULT  EnableSettingsVerification(bool Enable);
9570     DTAPI_RESULT  GetEncVersion(int& Major, int& Minor, int& BugFix, int& Build);
9571 
9572     // Constructor, destructor, operators
9573     DtEncControl();
9574     virtual ~DtEncControl();
9575     // Disable copy assignment by not providing an implementation for the copy constructor
9576 private:
9577     DtEncControl(const DtEncControl&);
9578     DtEncControl&  operator = (const DtEncControl&);
9579 
9580     // Encapsulated data
9581 protected:
9582     class EncControl*  m_pEnc;      // Encoder-control implementation object
9583     IXpMutex*  m_pMTLock;           // Multi-threading lock for get/control functions
9584     void*  m_pDetachLockCount;
9585     int  m_Port;
9586     bool  m_WantToDetach;
9587 
9588 // Protected internal helper functions
9589 protected:
9590     DTAPI_RESULT  DetachLock();
9591     DTAPI_RESULT  DetachUnlock();
9592     DTAPI_RESULT  ControlAccessLock();
9593     DTAPI_RESULT  ControlAccessUnlock();
9594 };
9595 
9596 //+=+=+=+=+=+=+=+=+=+=+=+=+=+ HDMI output port control/status +=+=+=+=+=+=+=+=+=+=+=+=+=+=
9597 
9598 //-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- struct DtHdmiVidStd -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
9599 //
9600 // Structure specifying the video standard on the HDMI port
9601 //
9602 struct DtHdmiVidStd
9603 {
9604     int  m_VidStd;                  // Video standard
9605     DtAspectRatio  m_AspectRatio;   // Picture Aspect Ratio
9606 };
9607 
9608 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- DtHdmiTxStatus -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
9609 //
9610 //
9611 struct DtHdmiTxStatus
9612 {
9613     bool  m_MonDetected;                    // True if a monitor is detected
9614     bool  m_EdidError;                      // True if an error in the EDID was detected
9615     bool  m_SupportHdmi;                    // True if HDMI VSDB (IEEE 0xc03) is available
9616     bool  m_SupportYCbCr444;                // True if YCbCr 4:4:4 is supported
9617     bool  m_SupportYCbCr422;                // True if YCbCr 4:2:2 is supported
9618     bool  m_SupportBasicAudio;              // True if basic audio is supported
9619     bool  m_SupportScDc;                    // True if Status and Control Data Channel
9620                                             // (SCDC) is supported
9621     bool  m_SupportHdr;                     // True if HDR is supported
9622     bool  m_ColorimetryForced;              // True if user set the Colorimetry values
9623     bool  m_ForceTestPicture;               // True if user forced the test picture
9624     bool  m_UsingTestPicture;               // True if test picture is used
9625     bool  m_ForceMonitorDetected;           // True if user forced monitor detected
9626     bool  m_DisableEdidCheck;               // True if user forced the selected format
9627                                             // (ignore EDID check)
9628     bool  m_DisableHdmiOutput;              // True if user disabled HDMI output
9629     bool  m_ForcedEdid;                     // True if EDID is set by application
9630     DtHdmiVidStd  m_UsedVidStd;             // Video standard used
9631     DtHdmiVidStd  m_SelectedVidStd;         // Video standard selected
9632     int  m_UsedVidMod;                      // DTAPI_HDMI_VIDMOD_xx video mode used
9633     int  m_SelectedVidMod;                  // DTAPI_HDMI_VIDMOD_xx video mode selected
9634     // HDR support
9635     int  m_SupportedEotf;                   // Supported Electro-Optical Transfer Function
9636     int  m_SupportedStaticMetadataDescr;    // Supported Static Metadata Descriptor
9637     // Monitor range limits
9638     bool  m_SupportMonitorRangeLimits;      // True if monitor range limits are set
9639     int  m_MaxPixelClk;                     // Maximum pixel rate clock in MHz
9640     int  m_MinVRate;                        // Minimum vertical rate; For interlaced = Field rate
9641     int  m_MaxVRate;                        // Maximum vertical rate; interlaced = Field rate
9642     int  m_MinHRate;                        // Minimum horizontal rate
9643     int  m_MaxHRate;                        // Maximum horizontal rate
9644     std::vector<DtHdmiVidStd>  m_MonSupportedVidStd;
9645                                             // Vector of supported video standards
9646     //__int64  m_MonSupportedAudio;         // Currently not used
9647     unsigned int  m_StateMask;              // State of the HDMI Tx output port
9648 };
9649 
9650 #define DTAPI_HDMI_VIDMOD_YCBCR_422     0
9651 #define DTAPI_HDMI_VIDMOD_YCBCR_444     1
9652 #define DTAPI_HDMI_VIDMOD_RGB_444       2
9653 #define DTAPI_HDMI_VIDMOD_UNKNOWN       -1
9654 
9655 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- class DtAvOutput -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
9656 //
9657 //
9658 
9659 class AvOutput;
9660 class DtAvOutput
9661 {
9662 public:
9663     DtAvOutput();
9664     virtual ~DtAvOutput();
9665 private:
9666     // No implementation is provided for the copy constructor
9667     DtAvOutput(const DtAvOutput&);
9668     DtAvOutput&  operator = (const DtAvOutput&);
9669 
9670 public:
9671     DtHwFuncDesc  m_HwFuncDesc;     // Hardware function descriptor
9672 
9673                                     // Convenience functions
9674 public:
Category()9675     int  Category()             { return m_HwFuncDesc.m_DvcDesc.m_Category; }
FirmwareVersion()9676     int  FirmwareVersion()      { return m_HwFuncDesc.m_DvcDesc.m_FirmwareVersion; }
IsAttached()9677     bool  IsAttached()          { return m_pOutp != NULL; }
TypeNumber()9678     int  TypeNumber()           { return m_HwFuncDesc.m_DvcDesc.m_TypeNumber; }
HasCaps(const DtCaps Caps)9679     bool  HasCaps(const DtCaps  Caps) const
9680     {
9681         return ((m_HwFuncDesc.m_Flags & Caps) == Caps);
9682     }
9683 
9684 public:
9685     DTAPI_RESULT  AttachToPort(DtDevice* pDtDvc, int Port, bool Exclusive=true);
9686     DTAPI_RESULT  Detach();
9687     DTAPI_RESULT  DisableHdmiEdidCheck(bool Disable);
9688     DTAPI_RESULT  DisableHdmiOutput(bool Disable);
9689     DTAPI_RESULT  ForceHdmiTestPicture(bool Enable);
9690     DTAPI_RESULT  GetHdmiStatus(DtHdmiTxStatus& Status);
9691     DTAPI_RESULT  SetHdmiVideoMode(int VidMod);
9692     DTAPI_RESULT  SetHdmiColorimetry(int Colorimetry, int ExtendedColorimetry);
9693     DTAPI_RESULT  GetHdmiColorimetry(int& Colorimetry, int& ExtendedColorimetry);
9694     DTAPI_RESULT  SetHdmiAudioChannel(int AudioCh1, int AudioCh2);
9695     DTAPI_RESULT  GetHdmiAudioChannel(int& AudioCh1, int& AudioCh2);
9696 
9697     // Encapsulated data
9698 private:
9699     void*  m_pDetachLockCount;
9700 protected:
9701     AvOutput*  m_pOutp;
9702 
9703     // Private helper functions
9704 private:
9705     DTAPI_RESULT  DetachLock();
9706     DTAPI_RESULT  DetachUnlock();
9707 };
9708 
9709 //.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- Global DTAPI Functions -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
9710 
9711 DTAPI_RESULT  DtapiCheckDeviceDriverVersion(void);
9712 DTAPI_RESULT  DtapiCheckDeviceDriverVersion(int DeviceCategory);
9713 DTAPI_RESULT  DtapiDeviceScan(int NumEntries, int& NumEntriesResult,
9714                                          DtDeviceDesc* DvcDescArr, bool InclDteDvcs=false,
9715                                          int  ScanOrder=DTAPI_SCANORDER_ORIG);
9716 DTAPI_RESULT  DtapiDtaPlusDeviceScan(int NumEntries, int& NumEntriesResult,
9717                                                          DtDtaPlusDeviceDesc* DvcDescArr);
9718 DTAPI_RESULT  DtapiDtDeviceDesc2String(const DtDeviceDesc* pDvcDesc, int StringType,
9719                                                            char* pString, int StringSize);
9720 DTAPI_RESULT  DtapiDtDeviceDesc2String(const DtDeviceDesc* pDvcDesc, int StringType,
9721                                                         wchar_t* pString, int StringSize);
9722 DTAPI_RESULT  DtapiDtHwFuncDesc2String(DtHwFuncDesc* pHwFunc, int StringType,
9723                                                            char* pString, int StringSize);
9724 DTAPI_RESULT  DtapiDtHwFuncDesc2String(DtHwFuncDesc* pHwFunc, int StringType,
9725                                                         wchar_t* pString, int StringSize);
9726 DTAPI_RESULT  DtapiGetDeviceDriverVersion(int, int&, int&, int&, int&);
9727 DTAPI_RESULT  DtapiGetDtapiServiceVersion(int&, int&, int&, int&);
9728 DTAPI_RESULT  DtapiGetVersion(int& Maj, int& Min, int& BugFix, int& Build);
9729 DTAPI_RESULT  DtapiHwFuncScan(int NumEntries, int& NumEntriesResult,
9730                                            DtHwFuncDesc* pHwFuncs, bool InclDteDvcs=false,
9731                                            int  ScanOrder=DTAPI_SCANORDER_ORIG);
9732 DTAPI_RESULT  DtapiPower2Voltage(int dBm, int& dBmV, bool Is50Ohm=false);
9733 const char*  DtapiResult2Str(DTAPI_RESULT DtapiResult);
9734 DTAPI_RESULT  DtapiVoltage2Power(int dBmV, int& dBm, bool Is50Ohm=false);
9735 
9736 // Callbacks
9737 DTAPI_RESULT  DtapiRegisterCallback(pDtEventCallback Callback, void* pContext,
9738                                                        int EventTypes, void** pId = NULL);
9739 DTAPI_RESULT  DtapiUnregisterCallback(void* pId);
9740 
9741 // IP address conversion
9742 DTAPI_RESULT  DtapiInitDtIpParsFromIpString(DtIpPars& IpPars,
9743                                                   const char* pDstIp, const char* pSrcIp);
9744 DTAPI_RESULT  DtapiInitDtIpParsFromIpString(DtIpPars2& IpPars,
9745                                                   const char* pDstIp, const char* pSrcIp);
9746 DTAPI_RESULT  DtapiInitDtIpParsFromIpString(DtIpPars& IpPars,
9747                                             const wchar_t* pDstIp, const wchar_t* pSrcIp);
9748 DTAPI_RESULT  DtapiInitDtIpParsFromIpString(DtIpPars2& IpPars,
9749                                             const wchar_t* pDstIp, const wchar_t* pSrcIp);
9750 DTAPI_RESULT  DtapiIpAddr2ByteArray(const char* pIpStr, unsigned char* pIpByte,
9751                                                                               int& Flags);
9752 DTAPI_RESULT  DtapiIpAddr2ByteArray(const wchar_t* pIpStr,
9753                                                       unsigned char* pIpByte, int& Flags);
9754 DTAPI_RESULT  DtapiIpAddr2Str(char* pStr, int Len, unsigned char* pIpAddr);
9755 DTAPI_RESULT  DtapiIpAddr2Str(wchar_t* pStr, int Len, unsigned char* pIpAddr);
9756 DTAPI_RESULT  DtapiStr2IpAddr(unsigned char* pIpAddr, const char* pStr);
9757 DTAPI_RESULT  DtapiStr2IpAddr(unsigned char* pIpAddr, const wchar_t* pStr);
9758 
9759 // Legacy
9760 #define DtapiInitDtTsIpParsFromIpString DtapiInitDtIpParsFromIpString
9761 
9762 // Modulator functions
9763 DTAPI_RESULT  DtapiModPars2Bandwidth(int& ModBandwidth, int& TotalBandwidth,
9764                                     int ModType, int ParXtra0, int ParXtra1, int ParXtra2,
9765                                     void* pXtraPars, int SymRate);
9766 DTAPI_RESULT  DtapiModPars2SymRate(int& SymRate, int ModType, int ParXtra0,
9767                                                   int ParXtra1, int ParXtra2, int TsRate);
9768 DTAPI_RESULT  DtapiModPars2SymRate(int& SymRate, int ModType, int ParXtra0,
9769                                         int ParXtra1, int ParXtra2, DtFractionInt TsRate);
9770 DTAPI_RESULT  DtapiModPars2SymRate(int& SymRate, int ModType, int ParXtra0,
9771                                  int ParXtra1, int ParXtra2, void* pXtraPars, int TsRate);
9772 DTAPI_RESULT  DtapiModPars2SymRate(int& SymRate, int ModType, int ParXtra0,
9773                        int ParXtra1, int ParXtra2, void* pXtraPars, DtFractionInt TsRate);
9774 DTAPI_RESULT  DtapiModPars2TsRate(int& TsRate, int ModType, int ParXtra0,
9775                                             int ParXtra1, int ParXtra2, int SymRate = -1);
9776 DTAPI_RESULT  DtapiModPars2TsRate(DtFractionInt& TsRate, int ModType, int ParXtra0,
9777                                             int ParXtra1, int ParXtra2, int SymRate = -1);
9778 DTAPI_RESULT  DtapiModPars2TsRate(int& TsRate, DtDvbC2Pars&, int PlpIdx = 0);
9779 DTAPI_RESULT  DtapiModPars2TsRate(DtFractionInt& TsRate, DtDvbC2Pars&, int PlpIdx = 0);
9780 DTAPI_RESULT  DtapiModPars2TsRate(int& TsRate, DtDvbS2Pars&, int PlpIdx = 0);
9781 DTAPI_RESULT  DtapiModPars2TsRate(DtFractionInt& TsRate, DtDvbS2Pars&, int PlpIdx = 0);
9782 DTAPI_RESULT  DtapiModPars2TsRate(int& TsRate, DtDvbT2Pars&, int PlpIdx = 0);
9783 DTAPI_RESULT  DtapiModPars2TsRate(DtFractionInt& TsRate, DtDvbT2Pars&, int PlpIdx = 0);
9784 DTAPI_RESULT  DtapiModPars2TsRate(int& TsRate, DtIsdbTmmPars&, int TsIdx = 0);
9785 DTAPI_RESULT  DtapiModPars2TsRate(DtFractionInt& TsRate, DtIsdbTmmPars&, int TsIdx = 0);
9786 DTAPI_RESULT  DtapiModPars2TsRate(int& TsRate, int ModType, int ParXtra0,
9787                                 int ParXtra1, int ParXtra2, void* pXtraPars, int SymRate);
9788 DTAPI_RESULT  DtapiModPars2TsRate(DtFractionInt& TsRate, int ModType, int ParXtra0,
9789                                 int ParXtra1, int ParXtra2, void* pXtraPars, int SymRate);
9790 
9791 // HD-SDI functions
9792 DTAPI_RESULT  DtapiGetRequiredUsbBandwidth(int VidStd, int RxMode, long long&  Bandwidth);
9793 DTAPI_RESULT  DtapiGetVidStdInfo(int VidStd, DtVidStdInfo& Info);
9794 DTAPI_RESULT  DtapiGetVidStdInfo(int VidStd, int  LinkStd, DtVidStdInfo& Info);
9795 DTAPI_RESULT  DtapiIoStd2VidStd(int Value, int SubValue, int& VidStd);
9796 DTAPI_RESULT  DtapiIoStd2VidStd(int Value, int SubValue, int& VidStd, int& LinkStd);
9797 DTAPI_RESULT  DtapiVidStd2IoStd(int VidStd, int& Value, int& SubValue);
9798 DTAPI_RESULT  DtapiVidStd2IoStd(int VidStd, int  LinkStd, int& Value, int& SubValue);
9799 const char*  DtapiVidStd2Str(int VidStd);
9800 const char*  DtapiLinkStd2Str(int LinkStd);
9801 const char*  DtapiMxFrameStatus2Str(DtMxFrameStatus  Status);
9802 
9803 } // namespace Dtapi
9804 
9805 #ifndef _NO_USING_NAMESPACE_DTAPI
9806 using namespace Dtapi;
9807 #endif
9808 
9809 #endif //#ifndef __DTAPI_H
9810