/
cardutil.h
458 lines (404 loc) · 18.3 KB
/
cardutil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
// -*- Mode: c++ -*-
#ifndef CARDUTIL_H
#define CARDUTIL_H
// C++ headers
#include <cstdint>
#include <vector>
// Qt headers
#include <QList>
#include <QStringList>
#include <QMap>
// MythTV headers
#include "mythtvexp.h"
#include "dtvconfparserhelpers.h"
class InputInfo;
class CardInput;
using InputNames = QMap<int,QString>;
MTV_PUBLIC QString get_on_input(const QString &to_get, uint inputid);
MTV_PUBLIC bool set_on_input(const QString &to_set, uint inputid, const QString &value);
enum dvb_dev_type_t
{
DVB_DEV_FRONTEND = 1,
DVB_DEV_DVR,
DVB_DEV_DEMUX,
DVB_DEV_CA,
DVB_DEV_AUDIO,
DVB_DEV_VIDEO,
};
/** \class CardUtil
* \brief Collection of helper utilities for input DB use
*/
class MTV_PUBLIC CardUtil
{
public:
using InputTypes = QMap<QString, QString>;
/// \brief all the different inputs
enum INPUT_TYPES
{
ERROR_OPEN = 0,
ERROR_UNKNOWN = 1,
ERROR_PROBE = 2,
QPSK = 3, DVBS = 3,
QAM = 4, DVBC = 4,
OFDM = 5, DVBT = 5,
ATSC = 6,
V4L = 7,
MPEG = 8,
FIREWIRE = 9,
HDHOMERUN = 10,
FREEBOX = 11,
HDPVR = 12,
DVBS2 = 13,
IMPORT = 14,
DEMO = 15,
ASI = 16,
CETON = 17,
EXTERNAL = 18,
VBOX = 19,
DVBT2 = 20,
V4L2ENC = 21,
SATIP = 22
};
static enum INPUT_TYPES toInputType(const QString &name)
{
if ("ERROR_OPEN" == name)
return ERROR_OPEN;
if ("ERROR_UNKNOWN" == name)
return ERROR_UNKNOWN;
if ("ERROR_PROBE" == name)
return ERROR_PROBE;
if ("QPSK" == name)
return QPSK;
if ("DVBS" == name)
return DVBS;
if ("QAM" == name)
return QAM;
if ("DVBC" == name)
return DVBC;
if ("OFDM" == name)
return OFDM;
if ("DVBT" == name)
return DVBT;
if ("ATSC" == name)
return ATSC;
if ("V4L" == name)
return V4L;
if ("MPEG" == name)
return MPEG;
if ("FIREWIRE" == name)
return FIREWIRE;
if ("HDHOMERUN" == name)
return HDHOMERUN;
if ("FREEBOX" == name)
return FREEBOX;
if ("HDPVR" == name)
return HDPVR;
if ("DVB_S2" == name)
return DVBS2;
if ("IMPORT" == name)
return IMPORT;
if ("DEMO" == name)
return DEMO;
if ("ASI" == name)
return ASI;
if ("CETON" == name)
return CETON;
if ("EXTERNAL" == name)
return EXTERNAL;
if ("VBOX" == name)
return VBOX;
if ("DVB_T2" == name)
return DVBT2;
if ("V4L2ENC" == name)
return V4L2ENC;
if ("SATIP" == name)
return SATIP;
return ERROR_UNKNOWN;
}
static bool IsEncoder(const QString &rawtype)
{
return
(rawtype != "DVB") && (rawtype != "FIREWIRE") &&
(rawtype != "HDHOMERUN") && (rawtype != "FREEBOX") &&
(rawtype != "IMPORT") && (rawtype != "DEMO") &&
(rawtype != "ASI") && (rawtype != "CETON") &&
(rawtype != "VBOX") && (rawtype != "SATIP");
}
static bool IsV4L(const QString &rawtype)
{
return (rawtype == "V4L" || rawtype == "MPEG" ||
rawtype == "HDPVR" || rawtype == "GO7007" ||
rawtype == "MJPEG" || rawtype == "V4L2ENC");
}
static bool IsChannelChangeDiscontinuous(const QString &rawtype)
{
return (!IsEncoder(rawtype) || rawtype == "HDPVR" ||
rawtype == "EXTERNAL");
}
static bool IsUnscanable(const QString &rawtype)
{
return
(rawtype == "FIREWIRE") || (rawtype == "HDPVR") ||
(rawtype == "IMPORT") || (rawtype == "DEMO") ||
(rawtype == "GO7007") || (rawtype == "MJPEG");
}
static QString GetScanableInputTypes(void);
static bool IsCableCardPresent(uint inputid,
const QString &inputType);
static bool IsEITCapable(const QString &rawtype)
{
return
(rawtype == "DVB") || (rawtype == "HDHOMERUN") ||
(rawtype == "SATIP");
}
static bool IsTunerSharingCapable(const QString &rawtype)
{
return
(rawtype == "DVB") || (rawtype == "HDHOMERUN") ||
(rawtype == "ASI") || (rawtype == "FREEBOX") ||
(rawtype == "CETON") || (rawtype == "EXTERNAL") ||
(rawtype == "VBOX") || (rawtype == "V4L2ENC") ||
(rawtype == "SATIP");
}
static bool HasTuner(const QString &rawtype, const QString & device);
static bool IsTunerShared(uint inputidA, uint inputidB);
static bool IsTuningDigital(const QString &rawtype)
{
return
(rawtype == "DVB") || (rawtype == "HDHOMERUN") ||
(rawtype == "ASI") || (rawtype == "CETON") ||
(rawtype == "EXTERNAL") || (rawtype == "SATIP");
}
static bool IsTuningAnalog(const QString &rawtype)
{
return
(rawtype == "V4L") || (rawtype == "V4L2ENC" ||
rawtype == "MPEG");
}
static bool IsTuningVirtual(const QString &rawtype)
{
return
(rawtype == "FIREWIRE") || (rawtype == "HDPVR") ||
(rawtype == "EXTERNAL") || (rawtype == "V4L2ENC");
}
static bool IsSingleInputType(const QString &rawtype)
{
return
(rawtype == "FIREWIRE") || (rawtype == "HDHOMERUN") ||
(rawtype == "FREEBOX") || (rawtype == "ASI") ||
(rawtype == "IMPORT") || (rawtype == "DEMO") ||
(rawtype == "CETON") || (rawtype == "EXTERNAL") ||
(rawtype == "VBOX") || (rawtype == "SATIP");
}
static bool IsChannelReusable(const QString &rawtype)
{
return !(rawtype == "FREEBOX" || rawtype == "VBOX");
}
static bool IsVBoxPresent(uint inputid);
// Card creation and deletion
static int CreateCaptureCard(const QString &videodevice,
const QString &audiodevice,
const QString &vbidevice,
const QString &inputtype,
uint audioratelimit,
const QString &hostname,
uint dvb_swfilter,
uint dvb_sat_type,
bool dvb_wait_for_seqstart,
bool skipbtaudio,
bool dvb_on_demand,
uint dvb_diseqc_type,
uint firewire_speed,
const QString &firewire_model,
uint firewire_connection,
uint signal_timeout,
uint channel_timeout,
uint dvb_tuning_delay,
uint contrast,
uint brightness,
uint colour,
uint hue,
uint diseqcid,
bool dvb_eitscan);
static bool DeleteInput(uint inputid);
static bool DeleteAllInputs(void);
static std::vector<uint> GetInputList(void);
static std::vector<uint> GetSchedInputList(void);
static std::vector<uint> GetLiveTVInputList(void);
/// Convenience function for GetInputIDs()
static uint GetFirstInputID(const QString &videodevice)
{
std::vector<uint> list = GetInputIDs(videodevice);
if (list.empty())
return 0;
return list[0];
}
static std::vector<uint> GetInputIDs(const QString& videodevice = QString(),
const QString& rawtype = QString(),
const QString& inputname = QString(),
QString hostname = QString());
static uint GetChildInputCount(uint inputid);
static std::vector<uint> GetChildInputIDs(uint inputid);
static bool IsInputTypePresent(const QString &rawtype,
QString hostname = QString());
static InputTypes GetInputTypes(void); // input types on ALL hosts
static QStringList GetInputTypeNames(uint sourceid); // input types for a given source id
static QStringList GetVideoDevices(const QString &rawtype,
QString hostname = QString());
static QString GetRawInputType(uint inputid)
{ return get_on_input("cardtype", inputid).toUpper(); }
static QString GetVideoDevice(uint inputid)
{ return get_on_input("videodevice", inputid); }
static QString GetAudioDevice(uint inputid)
{ return get_on_input("audiodevice", inputid); }
static QString GetVBIDevice(uint inputid)
{ return get_on_input("vbidevice", inputid); }
static QString GetDeliverySystemFromDB(uint inputid)
{ return get_on_input("inputname", inputid); } // use capturecard/inputname for now
static QString GetHostname(uint inputid)
{ return get_on_input("hostname", inputid); }
static int GetValueInt(const QString &col, uint inputid)
{ return get_on_input(col, inputid).toInt(); }
static bool SetValue(const QString &col, uint inputid,
int val)
{ return set_on_input(col, inputid, QString::number(val)); }
static bool SetValue(const QString &col, uint inputid,
const QString &val)
{ return set_on_input(col, inputid, val); }
static bool SetStartChannel(uint inputid,
const QString &channum);
// Input creation and deletion
static int CreateCardInput(uint inputid,
uint sourceid,
const QString &inputname,
const QString &externalcommand,
const QString &changer_device,
const QString &changer_model,
const QString &hostname,
const QString &tunechan,
const QString &startchan,
const QString &displayname,
bool dishnet_eit,
uint recpriority,
uint quicktune,
uint schedorder,
uint livetvorder);
// Other input functions
static std::vector<uint> GetInputIDs(uint sourceid);
static bool GetInputInfo(InputInfo &input,
std::vector<uint> *groupids = nullptr);
static QList<InputInfo> GetAllInputInfo();
static QString GetInputName(uint inputid);
static QString GetStartingChannel(uint inputid);
static QString GetDisplayName(uint inputid);
static bool IsUniqueDisplayName(const QString &name,
uint exclude_inputid);
static uint GetSourceID(uint inputid);
// Input Groups
static uint CreateInputGroup(const QString &name);
static uint CreateDeviceInputGroup(uint inputid,
const QString &type,
const QString &host,
const QString &device);
static uint GetDeviceInputGroup(uint inputid);
static bool LinkInputGroup(uint inputid, uint inputgroupid);
static bool UnlinkInputGroup(uint inputid, uint inputgroupid);
static std::vector<uint> GetInputGroups(uint inputid);
static std::vector<uint> GetGroupInputIDs(uint inputgroupid);
static std::vector<uint> GetConflictingInputs(uint inputid);
static QString GetDeviceLabel(const QString &inputtype,
const QString &videodevice);
static QString GetDeviceLabel(uint inputid);
static QString ProbeSubTypeName(uint inputid);
static QStringList ProbeVideoInputs(const QString& device,
const QString& inputtype = QString());
static QStringList ProbeAudioInputs(const QString& device,
const QString& inputtype = QString());
static void GetDeviceInputNames(const QString &device,
const QString &inputtype,
QStringList &inputs);
// General info from OS
static QStringList ProbeVideoDevices(const QString &rawtype);
static void ClearVideoDeviceCache();
// Other
static uint CloneCard(uint src_inputid, uint dst_inputid);
static uint AddChildInput(uint parentid);
static QString GetFirewireChangerNode(uint inputid);
static QString GetFirewireChangerModel(uint inputid);
// DTV info
static bool GetTimeouts(uint inputid,
uint &signal_timeout,
uint &channel_timeout);
static bool IgnoreEncrypted(uint inputid,
const QString &inputname);
static bool TVOnly(uint inputid, const QString &inputname);
static bool IsInNeedOfExternalInputConf(uint inputid);
static uint GetQuickTuning(uint inputid, const QString &input_name);
// DVB info
/// \brief Returns true if the input is a DVB input
static bool IsDVB(uint inputid)
{ return "DVB" == GetRawInputType(inputid); }
static bool IsDVBInputType(const QString &inputType);
static QStringList ProbeDeliverySystems(const QString &device);
static QStringList ProbeDeliverySystems(int fd_frontend);
static QString ProbeDefaultDeliverySystem(const QString &device);
static QString ProbeDVBType(const QString &device);
static QString ProbeDVBFrontendName(const QString &device);
static bool HasDVBCRCBug(const QString &device);
static uint GetMinSignalMonitoringDelay(const QString &device);
static DTVTunerType ConvertToTunerType(DTVModulationSystem delsys);
static DTVTunerType GetTunerType(uint inputid);
static DTVTunerType ProbeTunerType(int fd_frontend);
static DTVTunerType ProbeTunerType(const QString &device);
static DTVTunerType GetTunerTypeFromMultiplex(uint mplexid);
static DTVModulationSystem GetDeliverySystem(uint inputid);
static DTVModulationSystem ProbeCurrentDeliverySystem(const QString &device);
static DTVModulationSystem ProbeCurrentDeliverySystem(int fd_frontend);
static DTVModulationSystem ProbeBestDeliverySystem(int fd);
static DTVModulationSystem GetOrProbeDeliverySystem(uint inputid, int fd);
static int SetDefaultDeliverySystem(uint inputid, int fd);
static int SetDeliverySystem(uint inputid);
static int SetDeliverySystem(uint inputid, DTVModulationSystem delsys);
static int SetDeliverySystem(uint inputid, int fd);
static int SetDeliverySystem(uint inputid, DTVModulationSystem delsys, int fd);
static int OpenVideoDevice(int inputid);
static int OpenVideoDevice(const QString &device);
static QString GetDeviceName(dvb_dev_type_t type, const QString &device);
static InputNames GetConfiguredDVBInputs(const QString &device);
// V4L info
static bool hasV4L2(int videofd);
static bool GetV4LInfo(int videofd, QString &input, QString &driver,
uint32_t &version, uint32_t &capabilities);
static bool GetV4LInfo(int videofd, QString &input, QString &driver)
{
uint32_t d1 = 0;
uint32_t d2 = 0;
return GetV4LInfo(videofd, input, driver, d1, d2);
}
static InputNames ProbeV4LVideoInputs(int videofd, bool &ok);
static InputNames ProbeV4LAudioInputs(int videofd, bool &ok);
// HDHomeRun info
static bool HDHRdoesDVB(const QString &device);
static bool HDHRdoesDVBC(const QString &device);
static QString GetHDHRdesc(const QString &device);
// VBox info
static QString GetVBoxdesc(const QString &id, const QString &ip,
const QString &tunerNo, const QString &tunerType);
// ASI info
static int GetASIDeviceNumber(const QString &device,
QString *error = nullptr);
static uint GetASIBufferSize(uint device_num,
QString *error = nullptr);
static uint GetASINumBuffers(uint device_num,
QString *error = nullptr);
static int GetASIMode(uint device_num,
QString *error = nullptr);
static bool SetASIMode(uint device_num, uint mode,
QString *error = nullptr);
private:
static QStringList ProbeV4LVideoInputs(const QString& device);
static QStringList ProbeV4LAudioInputs(const QString& device);
static QStringList ProbeDVBInputs(const QString& device);
static QMap <QString,QStringList> s_videoDeviceCache;
};
#endif //CARDUTIL_H