forked from MythTV/mythtv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
channelutil.h
289 lines (246 loc) · 12 KB
/
channelutil.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
// -*- Mode: c++ -*-
#ifndef CHANUTIL_H
#define CHANUTIL_H
// POSIX headers
#include <stdint.h>
// C++ headers
#include <vector>
#include <deque>
using namespace std;
// Qt headers
#include <QString>
// MythTV headers
#include "mythtvexp.h"
#include "dtvmultiplex.h"
#include "dbchannelinfo.h"
class NetworkInformationTable;
class pid_cache_item_t
{
public:
pid_cache_item_t() : pid(0), sid_tid(0) {}
pid_cache_item_t(uint _pid, uint _sid_tid) :
pid(_pid), sid_tid(_sid_tid) {}
uint GetPID(void) const { return pid; }
uint GetStreamID(void) const
{ return (sid_tid&0x100) ? GetID() : 0; }
uint GetTableID(void) const
{ return (sid_tid&0x100) ? 0 : GetID(); }
uint GetID(void) const { return sid_tid & 0xff; }
bool IsPCRPID(void) const { return sid_tid&0x200; }
bool IsPermanent(void) const { return sid_tid&0x10000; }
uint GetComposite(void) const { return sid_tid; }
private:
uint pid;
uint sid_tid;
};
typedef vector<pid_cache_item_t> pid_cache_t;
/** \class ChannelUtil
* \brief Collection of helper utilities for channel DB use
*/
class MTV_PUBLIC ChannelUtil
{
public:
// Multiplex Stuff
static uint CreateMultiplex(
int sourceid, QString sistandard,
uint64_t frequency, QString modulation,
int transport_id = -1, int network_id = -1);
static uint CreateMultiplex(
int sourceid, QString sistandard,
uint64_t frequency, QString modulation,
// DVB specific
int transport_id, int network_id,
int symbol_rate, signed char bandwidth,
signed char polarity, signed char inversion,
signed char trans_mode,
QString inner_FEC, QString constellation,
signed char hierarchy, QString hp_code_rate,
QString lp_code_rate, QString guard_interval,
QString mod_sys, QString rolloff);
static uint CreateMultiplex(uint sourceid, const DTVMultiplex&,
int transport_id, int network_id);
static vector<uint> CreateMultiplexes(
int sourceid, const NetworkInformationTable *nit);
static uint GetMplexID(uint sourceid, const QString &channum);
static int GetMplexID(uint sourceid, uint64_t frequency);
static int GetMplexID(uint sourceid, uint64_t frequency,
uint transport_id, uint network_id);
static int GetMplexID(uint sourceid,
uint transport_id, uint network_id);
static uint GetMplexID(uint chanid);
static int GetBetterMplexID(int current_mplexid,
int transport_id, int network_id);
static bool GetTuningParams(uint mplexid,
QString &modulation,
uint64_t &frequency,
uint &dvb_transportid,
uint &dvb_networkid,
QString &si_std);
static bool GetATSCChannel(uint sourceid, const QString &channum,
uint &major, uint &minor);
static bool IsATSCChannel(uint sourceid, const QString &channum)
{ uint m1, m2; GetATSCChannel(sourceid, channum, m1,m2); return m2; }
// Channel/Service Stuff
static int CreateChanID(uint sourceid, const QString &chan_num);
static bool CreateChannel(uint db_mplexid,
uint db_sourceid,
uint new_channel_id,
const QString &callsign,
const QString &service_name,
const QString &chan_num,
uint service_id,
uint atsc_major_channel,
uint atsc_minor_channel,
bool use_on_air_guide,
bool hidden,
bool hidden_in_guide,
const QString &freqid,
QString icon = QString::null,
QString format = "Default",
QString xmltvid = QString::null,
QString default_authority = QString::null);
static bool UpdateChannel(uint db_mplexid,
uint source_id,
uint channel_id,
const QString &callsign,
const QString &service_name,
const QString &chan_num,
uint service_id,
uint atsc_major_channel,
uint atsc_minor_channel,
bool use_on_air_guide,
bool hidden,
bool hidden_in_guide,
QString freqid = QString::null,
QString icon = QString::null,
QString format = QString::null,
QString xmltvid = QString::null,
QString default_authority = QString::null);
static void UpdateInsertInfoFromDB(ChannelInsertInfo &chan);
static bool DeleteChannel(uint channel_id);
static bool SetVisible(uint channel_id, bool hidden);
static bool SetServiceVersion(int mplexid, int version);
static int GetChanID(int db_mplexid, int service_transport_id,
int major_channel, int minor_channel,
int program_number);
static int GetServiceVersion(int mplexid);
// Misc gets
static QString GetDefaultAuthority(uint chanid);
static QString GetIcon(uint chanid);
static vector<uint> GetCardIDs(uint chanid);
static QString GetUnknownCallsign(void);
static uint FindChannel(uint sourceid, const QString &freqid);
static int GetChanID(uint sourceid, const QString &channum)
{ return GetChannelValueInt("chanid", sourceid, channum); }
static bool GetChannelData(
uint sourceid, const QString &channum,
QString &tvformat, QString &modulation,
QString &freqtable, QString &freqid,
int &finetune, uint64_t &frequency,
QString &dtv_si_std, int &mpeg_prog_num,
uint &atsc_major, uint &atsc_minor,
uint &dvb_transportid, uint &dvb_networkid,
uint &mplexid, bool &commfree,
bool &use_on_air_guide,bool &visible,
QString &xmltvid, QString &default_authority,
QString &icon);
static int GetProgramNumber(uint sourceid, const QString &channum)
{ return GetChannelValueInt("serviceid", sourceid, channum); }
static QString GetVideoFilters(uint sourceid, const QString &channum)
{ return GetChannelValueStr("videofilters", sourceid, channum); }
static DBChanInfoList GetChannels(
uint sourceid, bool visible_only,
const QString &group_by = QString(), uint channel_groupid = 0)
{
return GetChannelsInternal(sourceid, visible_only, false,
group_by, channel_groupid);
}
/// Returns channels that are not connected to a capture card
/// and channels that are not marked as visible.
static DBChanInfoList GetAllChannels(uint sourceid)
{
return GetChannelsInternal(sourceid, false, true, QString(), 0);
}
static bool GetChannelSourceID(uint sourceid, const QString channum, const uint cardinputid, QString maptypes = "main");
static vector<uint> GetChanIDs(int sourceid = -1);
static uint GetChannelCount(int sourceid = -1);
static void SortChannels(DBChanInfoList &list, const QString &order,
bool eliminate_duplicates = false);
static uint GetNextChannel(const DBChanInfoList &sorted,
uint old_chanid,
uint mplexid_restriction,
int direction,
bool skip_non_visible = true,
bool skip_same_channum_and_callsign = false);
static QString GetChannelValueStr(const QString &channel_field,
uint sourceid,
const QString &channum);
static int GetChannelValueInt(const QString &channel_field,
uint sourceid,
const QString &channum);
static bool IsOnSameMultiplex(uint sourceid,
const QString &new_channum,
const QString &old_channum);
static QStringList GetValidRecorderList(uint chanid,
const QString &channum);
static bool IsConflicting(const QString &channum,
uint sourceid = 0, uint excluded_chanid = 0)
{
vector<uint> chanids = GetConflicting(channum, sourceid);
return (chanids.size() > 1) ||
((1 == chanids.size()) && (chanids[0] != excluded_chanid));
}
static vector<uint> GetConflicting(const QString &channum,
uint sourceid = 0);
/**
* \brief Returns the channel-number string of the given channel.
* \param chanid primary key for channel record
*/
static QString GetChanNum(int chanid);
/**
* \brief Returns the callsign of the given channel.
* \param chanid primary key for channel record
*/
static QString GetCallsign(int chanid);
/**
* \brief Returns the service name of the given channel.
* \param chanid primary key for channel record
*/
static QString GetServiceName(int chanid);
/**
* \brief Returns the listings time offset in minutes for given channel.
* \param chanid primary key for channel record
*/
static int GetTimeOffset(int chanid);
static int GetSourceID(int mplexid);
static uint GetSourceIDForChannel(uint chanid);
static int GetInputID(int sourceid, int cardid);
static QStringList GetCardTypes(uint chandid);
static bool GetCachedPids(uint chanid, pid_cache_t &pid_cache);
// Misc sets
static bool SetChannelValue(const QString &field_name,
QString value,
uint sourceid,
const QString &channum);
static bool SetChannelValue(const QString &field_name,
QString value,
int chanid);
static bool SaveCachedPids(uint chanid,
const pid_cache_t &pid_cache,
bool delete_all = false);
static const QString kATSCSeparators;
private:
static DBChanInfoList GetChannelsInternal(
uint sourceid, bool visible_only, bool include_disconnected,
const QString &group_by, uint channel_groupid);
static QString GetChannelStringField(int chanid, const QString &field);
static QString GetChannelValueStr(const QString &channel_field,
uint cardid,
const QString &input,
const QString &channum);
static int GetChannelValueInt(const QString &channel_field,
uint cardid,
const QString &input,
const QString &channum);
};
#endif // CHANUTIL_H