11 #include <QReadWriteLock> 20 #define LOC QString("ChanUtil: ") 37 "WHERE sourceid = :SOURCEID " 38 " AND sistandard = :SISTANDARD ";
40 if (sistandard.toLower() !=
"dvb")
41 qstr +=
"AND frequency = :FREQUENCY ";
44 qstr +=
"AND transportid = :TRANSPORTID ";
45 qstr +=
"AND networkid = :NETWORKID ";
46 qstr +=
"AND polarity = :POLARITY ";
53 query.
bindValue(
":SOURCEID", db_source_id);
54 query.
bindValue(
":SISTANDARD", sistandard);
56 if (sistandard.toLower() !=
"dvb")
57 query.
bindValue(
":FREQUENCY", QString::number(frequency));
60 query.
bindValue(
":TRANSPORTID", transport_id);
61 query.
bindValue(
":NETWORKID", network_id);
62 query.
bindValue(
":POLARITY", QString(polarity));
72 return query.
value(0).toUInt();
78 int db_source_id, QString sistandard,
79 uint64_t frequency, QString modulation,
81 int transport_id,
int network_id,
82 int symbol_rate,
signed char bandwidth,
83 signed char polarity,
signed char inversion,
84 signed char trans_mode,
85 QString inner_FEC, QString constellation,
86 signed char hierarchy, QString hp_code_rate,
87 QString lp_code_rate, QString guard_interval,
88 QString mod_sys, QString rolloff)
94 db_source_id, sistandard, frequency,
96 transport_id, network_id, polarity);
98 LOG(VB_CHANSCAN, LOG_INFO, QString(
99 "insert_dtv_multiplex(db_source_id: %1, sistandard: '%2', " 100 "frequency: %3, modulation: %4, transport_id: %5, " 101 "network_id: %6, polarity: %7...) mplexid:%8")
102 .arg(db_source_id).arg(sistandard)
103 .arg(frequency).arg(modulation)
104 .arg(transport_id).arg(network_id)
105 .arg(polarity).arg(mplex));
107 bool isDVB = (sistandard.toLower() ==
"dvb");
110 "UPDATE dtv_multiplex " 111 "SET frequency = :FREQUENCY1, ";
113 updateStr += (!modulation.isNull()) ?
114 "modulation = :MODULATION, " :
"";
115 updateStr += (symbol_rate >= 0) ?
116 "symbolrate = :SYMBOLRATE, " :
"";
117 updateStr += (bandwidth >= 0) ?
118 "bandwidth = :BANDWIDTH, " :
"";
119 updateStr += (polarity >= 0) ?
120 "polarity = :POLARITY, " :
"";
121 updateStr += (inversion >= 0) ?
122 "inversion = :INVERSION, " :
"";
123 updateStr += (trans_mode >= 0) ?
124 "transmission_mode= :TRANS_MODE, " :
"";
125 updateStr += (!inner_FEC.isNull()) ?
126 "fec = :INNER_FEC, " :
"";
127 updateStr += (!constellation.isNull()) ?
128 "constellation = :CONSTELLATION, " :
"";
129 updateStr += (hierarchy >= 0) ?
130 "hierarchy = :HIERARCHY, " :
"";
131 updateStr += (!hp_code_rate.isNull()) ?
132 "hp_code_rate = :HP_CODE_RATE, " :
"";
133 updateStr += (!lp_code_rate.isNull()) ?
134 "lp_code_rate = :LP_CODE_RATE, " :
"";
135 updateStr += (!guard_interval.isNull()) ?
136 "guard_interval = :GUARD_INTERVAL, " :
"";
137 updateStr += (!mod_sys.isNull()) ?
138 "mod_sys = :MOD_SYS, " :
"";
139 updateStr += (symbol_rate >= 0) ?
140 "rolloff = :ROLLOFF, " :
"";
141 updateStr += (transport_id && !isDVB) ?
142 "transportid = :TRANSPORTID, " :
"";
144 updateStr = updateStr.left(updateStr.length()-2) +
" ";
147 "WHERE sourceid = :SOURCEID AND " 148 " sistandard = :SISTANDARD AND ";
150 updateStr += (isDVB) ?
151 " polarity = :WHEREPOLARITY AND " 152 " transportid = :TRANSPORTID AND networkid = :NETWORKID " :
153 " frequency = :FREQUENCY2 ";
156 "INSERT INTO dtv_multiplex " 157 " (sourceid, sistandard, frequency, ";
159 insertStr += (!modulation.isNull()) ?
"modulation, " :
"";
160 insertStr += (transport_id || isDVB) ?
"transportid, " :
"";
161 insertStr += (isDVB) ?
"networkid, " :
"";
162 insertStr += (symbol_rate >= 0) ?
"symbolrate, " :
"";
163 insertStr += (bandwidth >= 0) ?
"bandwidth, " :
"";
164 insertStr += (polarity >= 0) ?
"polarity, " :
"";
165 insertStr += (inversion >= 0) ?
"inversion, " :
"";
166 insertStr += (trans_mode >= 0) ?
"transmission_mode, " :
"";
167 insertStr += (!inner_FEC.isNull()) ?
"fec, " :
"";
168 insertStr += (!constellation.isNull()) ?
"constellation, " :
"";
169 insertStr += (hierarchy >= 0) ?
"hierarchy, " :
"";
170 insertStr += (!hp_code_rate.isNull()) ?
"hp_code_rate, " :
"";
171 insertStr += (!lp_code_rate.isNull()) ?
"lp_code_rate, " :
"";
172 insertStr += (!guard_interval.isNull()) ?
"guard_interval, " :
"";
173 insertStr += (!mod_sys.isNull()) ?
"mod_sys, " :
"";
174 insertStr += (!rolloff.isNull()) ?
"rolloff, " :
"";
175 insertStr = insertStr.left(insertStr.length()-2) +
") ";
179 " (:SOURCEID, :SISTANDARD, :FREQUENCY1, ";
180 insertStr += (!modulation.isNull()) ?
":MODULATION, " :
"";
181 insertStr += (transport_id || isDVB) ?
":TRANSPORTID, " :
"";
182 insertStr += (isDVB) ?
":NETWORKID, " :
"";
183 insertStr += (symbol_rate >= 0) ?
":SYMBOLRATE, " :
"";
184 insertStr += (bandwidth >= 0) ?
":BANDWIDTH, " :
"";
185 insertStr += (polarity >= 0) ?
":POLARITY, " :
"";
186 insertStr += (inversion >= 0) ?
":INVERSION, " :
"";
187 insertStr += (trans_mode >= 0) ?
":TRANS_MODE, " :
"";
188 insertStr += (!inner_FEC.isNull()) ?
":INNER_FEC, " :
"";
189 insertStr += (!constellation.isNull()) ?
":CONSTELLATION, " :
"";
190 insertStr += (hierarchy >= 0) ?
":HIERARCHY, " :
"";
191 insertStr += (!hp_code_rate.isNull()) ?
":HP_CODE_RATE, " :
"";
192 insertStr += (!lp_code_rate.isNull()) ?
":LP_CODE_RATE, " :
"";
193 insertStr += (!guard_interval.isNull()) ?
":GUARD_INTERVAL, " :
"";
194 insertStr += (!mod_sys.isNull()) ?
":MOD_SYS, " :
"";
195 insertStr += (!rolloff.isNull()) ?
":ROLLOFF, " :
"";
196 insertStr = insertStr.left(insertStr.length()-2) +
");";
198 query.
prepare((mplex) ? updateStr : insertStr);
200 query.
bindValue(
":SOURCEID", db_source_id);
201 query.
bindValue(
":SISTANDARD", sistandard);
202 query.
bindValue(
":FREQUENCY1", QString::number(frequency));
208 query.
bindValue(
":TRANSPORTID", transport_id);
209 query.
bindValue(
":NETWORKID", network_id);
210 query.
bindValue(
":WHEREPOLARITY", QString(polarity));
214 query.
bindValue(
":FREQUENCY2", QString::number(frequency));
216 query.
bindValue(
":TRANSPORTID", transport_id);
221 if (transport_id || isDVB)
222 query.
bindValue(
":TRANSPORTID", transport_id);
224 query.
bindValue(
":NETWORKID", network_id);
227 if (!modulation.isNull())
228 query.
bindValue(
":MODULATION", modulation);
230 if (symbol_rate >= 0)
231 query.
bindValue(
":SYMBOLRATE", symbol_rate);
233 query.
bindValue(
":BANDWIDTH", QString(
"%1").arg((
char)bandwidth));
235 query.
bindValue(
":POLARITY", QString(
"%1").arg((
char)polarity));
237 query.
bindValue(
":INVERSION", QString(
"%1").arg((
char)inversion));
239 query.
bindValue(
":TRANS_MODE", QString(
"%1").arg((
char)trans_mode));
241 if (!inner_FEC.isNull())
242 query.
bindValue(
":INNER_FEC", inner_FEC);
243 if (!constellation.isNull())
244 query.
bindValue(
":CONSTELLATION", constellation);
246 query.
bindValue(
":HIERARCHY", QString(
"%1").arg((
char)hierarchy));
247 if (!hp_code_rate.isNull())
248 query.
bindValue(
":HP_CODE_RATE", hp_code_rate);
249 if (!lp_code_rate.isNull())
250 query.
bindValue(
":LP_CODE_RATE", lp_code_rate);
251 if (!guard_interval.isNull())
252 query.
bindValue(
":GUARD_INTERVAL",guard_interval);
253 if (!mod_sys.isNull())
255 if (!rolloff.isNull())
268 db_source_id, sistandard, frequency,
270 transport_id, network_id, polarity);
272 LOG(VB_CHANSCAN, LOG_INFO, QString(
"insert_dtv_multiplex -- ") +
273 QString(
"inserted %1").arg(mplex));
296 uint dummy_tsid, dummy_netid;
298 dummy_tsid, dummy_netid, dummy_sistd);
302 (
int)sourceid,
"dvb",
305 (
int)tsid, (
int)netid,
312 QString(), QString());
315 muxes.push_back(mux);
339 QString(), QString(),
343 muxes.push_back(mux);
363 QString(), QString(),
364 QString(), QString());
367 muxes.push_back(mux);
372 uint64_t frequency, QString modulation,
373 int transport_id,
int network_id)
375 return CreateMultiplex(
376 sourceid, sistandard,
377 frequency, modulation,
378 transport_id, network_id,
382 QString(), QString(),
384 QString(), QString(),
385 QString(), QString());
389 int sourceid, QString sistandard,
390 uint64_t
freq, QString modulation,
392 int transport_id,
int network_id,
393 int symbol_rate,
signed char bandwidth,
394 signed char polarity,
signed char inversion,
395 signed char trans_mode,
396 QString inner_FEC, QString constellation,
397 signed char hierarchy, QString hp_code_rate,
398 QString lp_code_rate, QString guard_interval,
399 QString mod_sys, QString rolloff)
402 sourceid, sistandard,
405 transport_id, network_id,
406 symbol_rate, bandwidth,
409 inner_FEC, constellation,
410 hierarchy, hp_code_rate,
411 lp_code_rate, guard_interval,
416 int transport_id,
int network_id)
422 transport_id, network_id,
452 for (
uint j = 0; j < list.size(); ++j)
468 "WHERE sourceid = :SOURCEID AND " 469 " channum = :CHANNUM");
476 else if (query.
next())
477 return query.
value(0).toInt();
488 "FROM dtv_multiplex " 489 "WHERE sourceid = :SOURCEID AND " 490 " frequency = :FREQUENCY");
493 query.
bindValue(
":FREQUENCY", QString::number(frequency));
502 return query.
value(0).toInt();
514 "FROM dtv_multiplex " 515 "WHERE networkid = :NETWORKID AND " 516 " transportid = :TRANSPORTID AND " 517 " frequency = :FREQUENCY AND " 518 " sourceid = :SOURCEID");
521 query.
bindValue(
":NETWORKID", network_id);
522 query.
bindValue(
":TRANSPORTID", transport_id);
523 query.
bindValue(
":FREQUENCY", QString::number(frequency));
532 return query.
value(0).toInt();
544 "FROM dtv_multiplex " 545 "WHERE networkid = :NETWORKID AND " 546 " transportid = :TRANSPORTID AND " 547 " sourceid = :SOURCEID");
550 query.
bindValue(
":NETWORKID", network_id);
551 query.
bindValue(
":TRANSPORTID", transport_id);
560 return query.
value(0).toInt();
572 "WHERE chanid = :CHANID");
578 else if (query.
next())
579 return query.
value(0).toInt();
612 LOG(VB_CHANSCAN, LOG_INFO,
613 QString(
"GetBetterMplexID(mplexId %1, tId %2, netId %3)")
614 .arg(current_mplexid).arg(transport_id).arg(network_id));
616 int q_networkid = 0, q_transportid = 0;
619 query.
prepare(
"SELECT networkid, transportid " 620 "FROM dtv_multiplex " 621 "WHERE mplexid = :MPLEX_ID");
623 query.
bindValue(
":MPLEX_ID", current_mplexid);
627 else if (query.
next())
629 q_networkid = query.
value(0).toInt();
630 q_transportid = query.
value(1).toInt();
634 if ((q_networkid == network_id) && (q_transportid == transport_id))
636 LOG(VB_CHANSCAN, LOG_INFO,
637 QString(
"GetBetterMplexID(): Returning perfect match %1")
638 .arg(current_mplexid));
639 return current_mplexid;
643 if (!q_networkid && !q_transportid)
645 int qsize = query.
size();
646 query.
prepare(
"UPDATE dtv_multiplex " 647 "SET networkid = :NETWORK_ID, " 648 " transportid = :TRANSPORT_ID " 649 "WHERE mplexid = :MPLEX_ID");
651 query.
bindValue(
":NETWORK_ID", network_id);
652 query.
bindValue(
":TRANSPORT_ID", transport_id);
653 query.
bindValue(
":MPLEX_ID", current_mplexid);
658 LOG(VB_CHANSCAN, LOG_INFO,
659 QString(
"GetBetterMplexID(): net id and transport id " 660 "are null, qsize(%1), Returning %2")
661 .arg(qsize).arg(current_mplexid));
662 return current_mplexid;
666 QString theQueries[2] =
668 QString(
"SELECT a.mplexid " 669 "FROM dtv_multiplex a, dtv_multiplex b " 670 "WHERE a.networkid = :NETWORK_ID AND " 671 " a.transportid = :TRANSPORT_ID AND " 672 " a.sourceid = b.sourceid AND " 673 " b.mplexid = :MPLEX_ID"),
675 QString(
"SELECT mplexid " 676 "FROM dtv_multiplex " 677 "WHERE networkid = :NETWORK_ID AND " 678 " transportid = :TRANSPORT_ID"),
681 for (
uint i=0; i<2; i++)
685 query.
bindValue(
":NETWORK_ID", network_id);
686 query.
bindValue(
":TRANSPORT_ID", transport_id);
688 query.
bindValue(
":MPLEX_ID", current_mplexid);
693 if (query.
size() == 1 && query.
next())
695 LOG(VB_CHANSCAN, LOG_INFO,
696 QString(
"GetBetterMplexID(): query#%1 qsize(%2) " 698 .arg(i).arg(query.
size()).arg(current_mplexid));
699 return query.
value(0).toInt();
704 int ret = (i==0) ? current_mplexid : query.
value(0).toInt();
705 LOG(VB_CHANSCAN, LOG_INFO,
706 QString(
"GetBetterMplexID(): query#%1 qsize(%2) " 708 .arg(i).arg(query.
size()).arg(ret));
714 LOG(VB_CHANSCAN, LOG_INFO,
"GetBetterMplexID(): Returning -1");
721 uint &dvb_transportid,
725 if (!mplexid || (mplexid == 32767))
730 "SELECT transportid, networkid, frequency, modulation, sistandard " 731 "FROM dtv_multiplex " 732 "WHERE mplexid = :MPLEXID");
744 dvb_transportid = query.
value(0).toUInt();
745 dvb_networkid = query.
value(1).toUInt();
746 frequency = query.
value(2).toULongLong();
747 modulation = query.
value(3).toString();
748 si_std = query.
value(4).toString();
759 query.
prepare(QString(
"SELECT %1 FROM channel " 760 "WHERE chanid = :CHANID").arg(field));
771 return query.
value(0).toString();
776 return GetChannelStringField(chan_id, QString(
"channum"));
781 return GetChannelStringField(chan_id, QString(
"tmoffset")).toInt();
788 query.
prepare(
"SELECT sourceid " 789 "FROM dtv_multiplex " 790 "WHERE mplexid = :MPLEXID");
799 return query.
value(0).toInt();
811 "WHERE chanid = :CHANID");
816 else if (query.
next())
817 return query.
value(0).toUInt();
825 query.
prepare(
"SELECT cardtype " 826 "FROM capturecard, channel " 827 "WHERE channel.chanid = :CHANID AND " 828 " channel.sourceid = capturecard.sourceid " 829 "GROUP BY cardtype");
839 list.push_back(query.
value(0).toString());
846 return a.
GetPID() <
b.GetPID();
859 query.
prepare(
"SELECT pid, tableid FROM pidcache " 860 "WHERE chanid = :CHANID");
872 int pid = query.
value(0).toInt(), tid = query.
value(1).toInt();
873 if ((pid >= 0) && (tid >= 0))
876 stable_sort(pid_cache.begin(), pid_cache.end(),
lt_pidcache);
895 query.
prepare(
"DELETE FROM pidcache WHERE chanid = :CHANID");
898 "DELETE FROM pidcache " 899 "WHERE chanid = :CHANID AND tableid < 65536");
910 GetCachedPids(chanid, old_cache);
912 stable_sort(pid_cache.begin(), pid_cache.end(),
lt_pidcache);
916 "INSERT INTO pidcache " 917 "SET chanid = :CHANID, pid = :PID, tableid = :TABLEID");
921 pid_cache_t::const_iterator ito = old_cache.begin();
922 pid_cache_t::const_iterator itn = pid_cache.begin();
923 for (; itn != pid_cache.end(); ++itn)
926 for (; ito != old_cache.end() && ito->GetPID() < itn->GetPID(); ++ito);
929 if (ito != old_cache.end() && ito->GetPID() == itn->GetPID())
933 query.
bindValue(
":TABLEID", itn->GetComposite());
947 const QString &channum)
957 "WHERE channum = :CHANNUM AND " 958 " sourceid = :SOURCEID")
959 .arg(channel_field));
966 else if (query.
next())
967 retval = query.
value(0).toString();
974 const QString &channum)
976 QString val = GetChannelValueStr(channel_field, sourceid, channum);
980 retval = val.toInt();
982 return (retval) ? retval : -1;
986 const QString &new_channum,
987 const QString &old_channum)
989 if (new_channum.isEmpty() || old_channum.isEmpty())
992 if (new_channum == old_channum)
995 uint old_mplexid = GetMplexID(srcid, old_channum);
999 uint new_mplexid = GetMplexID(srcid, new_channum);
1003 LOG(VB_CHANNEL, LOG_INFO, QString(
"IsOnSameMultiplex? %1==%2 -> %3")
1004 .arg(old_mplexid).arg(new_mplexid)
1005 .arg(old_mplexid == new_mplexid));
1007 return old_mplexid == new_mplexid;
1017 QStringList reclist;
1024 "SELECT capturecard.cardid " 1026 "LEFT JOIN capturecard ON channel.sourceid = capturecard.sourceid " 1027 "WHERE channel.chanid = :CHANID AND " 1028 " capturecard.livetvorder > 0 " 1029 "ORDER BY capturecard.livetvorder, capturecard.cardid");
1038 while (query.
next())
1039 reclist << query.
value(0).toString();
1051 QStringList reclist;
1058 "SELECT capturecard.cardid " 1060 "LEFT JOIN capturecard ON channel.sourceid = capturecard.sourceid " 1061 "WHERE channel.channum = :CHANNUM AND " 1062 " capturecard.livetvorder > 0 " 1063 "ORDER BY capturecard.livetvorder, capturecard.cardid");
1072 while (query.
next())
1073 reclist << query.
value(0).toString();
1086 uint chanid,
const QString &channum)
1090 else if (!channum.isEmpty())
1092 return QStringList();
1099 vector<uint> conflicting;
1104 "SELECT chanid from channel " 1105 "WHERE sourceid = :SOURCEID AND " 1106 " channum = :CHANNUM");
1112 "SELECT chanid from channel " 1113 "WHERE channum = :CHANNUM");
1120 conflicting.push_back(0);
1124 while (query.
next())
1125 conflicting.push_back(query.
value(0).toUInt());
1133 const QString &channum)
1138 QString(
"UPDATE channel SET channel.%1=:VALUE " 1139 "WHERE channel.channum = :CHANNUM AND " 1140 " channel.sourceid = :SOURCEID").arg(field_name));
1146 return query.
exec();
1156 QString(
"UPDATE channel SET channel.%1=:VALUE " 1157 "WHERE channel.chanid = :CHANID").arg(field_name));
1162 return query.
exec();
1168 static QReadWriteLock channel_default_authority_map_lock;
1169 static QMap<uint,QString> channel_default_authority_map;
1170 static bool run_init =
true;
1172 channel_default_authority_map_lock.lockForRead();
1176 channel_default_authority_map_lock.unlock();
1177 channel_default_authority_map_lock.lockForWrite();
1182 "SELECT chanid, m.default_authority " 1184 "LEFT JOIN dtv_multiplex m " 1185 "ON (c.mplexid = m.mplexid)");
1188 while (query.
next())
1190 if (!query.
value(1).toString().isEmpty())
1192 channel_default_authority_map[query.
value(0).toUInt()] =
1193 query.
value(1).toString();
1204 "SELECT chanid, default_authority " 1208 while (query.
next())
1210 if (!query.
value(1).toString().isEmpty())
1212 channel_default_authority_map[query.
value(0).toUInt()] =
1213 query.
value(1).toString();
1226 QMap<uint,QString>::iterator it = channel_default_authority_map.find(chanid);
1228 if (it != channel_default_authority_map.end())
1230 channel_default_authority_map_lock.unlock();
1237 static QReadWriteLock channel_icon_map_lock;
1238 static QHash<uint,QString> channel_icon_map;
1239 static bool run_init =
true;
1241 channel_icon_map_lock.lockForRead();
1243 QString ret(channel_icon_map.value(chanid,
"_cold_"));
1245 channel_icon_map_lock.unlock();
1247 if (ret !=
"_cold_")
1250 channel_icon_map_lock.lockForWrite();
1253 QString iconquery =
"SELECT chanid, icon FROM channel";
1256 iconquery +=
" WHERE visible = 1";
1258 iconquery +=
" WHERE chanid = :CHANID";
1269 channel_icon_map.reserve(query.
size());
1270 while (query.
next())
1272 channel_icon_map[query.
value(0).toUInt()] =
1273 query.
value(1).toString();
1279 channel_icon_map[chanid] = (query.
next()) ?
1280 query.
value(1).toString() :
"";
1288 ret = channel_icon_map.value(chanid,
"");
1290 channel_icon_map_lock.unlock();
1297 return tr(
"UNKNOWN",
"Synthesized callsign");
1301 int major_channel,
int minor_channel,
1307 query.
prepare(
"SELECT sourceid " 1308 "FROM dtv_multiplex " 1309 "WHERE mplexid = :MPLEXID");
1319 int source_id = query.
value(0).toInt();
1322 query.
prepare(
"SELECT chanid FROM channel,dtv_multiplex " 1323 "WHERE channel.sourceid = :SOURCEID AND " 1324 " atsc_major_chan = :MAJORCHAN AND " 1325 " atsc_minor_chan = :MINORCHAN AND " 1326 " dtv_multiplex.transportid = :TRANSPORTID AND " 1327 " dtv_multiplex.mplexid = :MPLEXID AND " 1328 " dtv_multiplex.sourceid = channel.sourceid AND " 1329 " dtv_multiplex.mplexid = channel.mplexid");
1331 query.
bindValue(
":SOURCEID", source_id);
1332 query.
bindValue(
":MAJORCHAN", major_channel);
1333 query.
bindValue(
":MINORCHAN", minor_channel);
1334 query.
bindValue(
":TRANSPORTID", service_transport_id);
1338 return query.
value(0).toInt();
1342 query.
prepare(
"SELECT chanid FROM channel " 1343 "WHERE sourceid = :SOURCEID AND " 1344 "atsc_major_chan = :MAJORCHAN AND " 1345 "atsc_minor_chan = :MINORCHAN");
1347 query.
bindValue(
":SOURCEID", source_id);
1348 query.
bindValue(
":MAJORCHAN", major_channel);
1349 query.
bindValue(
":MINORCHAN", minor_channel);
1352 return query.
value(0).toInt();
1355 query.
prepare(
"SELECT chanid FROM channel " 1356 "WHERE sourceid = :SOURCEID AND " 1357 "serviceID = :SERVICEID AND " 1358 "mplexid = :MPLEXID");
1360 query.
bindValue(
":SOURCEID", source_id);
1361 query.
bindValue(
":SERVICEID", program_number);
1365 return query.
value(0).toInt();
1373 query.
prepare(
"SELECT chanid " 1375 "WHERE sourceid = :SOURCEID AND " 1376 " freqid = :FREQID");
1383 else if (query.
next())
1384 return query.
value(0).toUInt();
1392 QString qstr =
"SELECT MAX(chanid) FROM channel ";
1393 qstr += (sourceid) ?
"WHERE sourceid = :SOURCEID" :
"";
1403 else if (!query.
next())
1404 LOG(VB_GENERAL, LOG_ERR,
"Error getting chanid for new channel.");
1406 return query.
value(0).toUInt();
1417 "WHERE chanid = :CHANID");
1422 else if (query.
size() == 0)
1436 int chansep = chan_num.indexOf(QRegExp(
"\\D"));
1441 chan_num.left(chansep).toInt() * 100 +
1442 chan_num.right(chan_num.length() - chansep - 1).toInt();
1446 chanid = sourceid * 10000 + chan_num.toInt();
1470 uint new_channel_id,
1471 const QString &callsign,
1472 const QString &service_name,
1473 const QString &chan_num,
1475 uint atsc_major_channel,
1476 uint atsc_minor_channel,
1477 bool use_on_air_guide,
1479 bool hidden_in_guide,
1480 const QString &freqid,
1484 QString default_authority)
1488 QString chanNum = (chan_num ==
"-1") ?
1489 QString::number(service_id) : chan_num;
1492 "INSERT INTO channel " 1493 " (chanid, channum, sourceid, " 1494 " callsign, name, serviceid, ";
1495 qstr += (db_mplexid > 0) ?
"mplexid, " :
"";
1496 qstr += (!freqid.isEmpty()) ?
"freqid, " :
"";
1498 " atsc_major_chan, atsc_minor_chan, " 1499 " useonairguide, visible, tvformat, " 1500 " icon, xmltvid, default_authority) " 1502 " (:CHANID, :CHANNUM, :SOURCEID, " 1503 " :CALLSIGN, :NAME, :SERVICEID, ";
1504 qstr += (db_mplexid > 0) ?
":MPLEXID, " :
"";
1505 qstr += (!freqid.isEmpty()) ?
":FREQID, " :
"";
1507 " :MAJORCHAN, :MINORCHAN, " 1508 " :USEOAG, :VISIBLE, :TVFORMAT, " 1509 " :ICON, :XMLTVID, :AUTHORITY) ";
1513 query.
bindValue(
":CHANID", new_channel_id);
1515 query.
bindValue(
":SOURCEID", db_sourceid);
1520 query.
bindValue(
":MPLEXID", db_mplexid);
1522 query.
bindValue(
":SERVICEID", service_id);
1523 query.
bindValue(
":MAJORCHAN", atsc_major_channel);
1524 query.
bindValue(
":MINORCHAN", atsc_minor_channel);
1525 query.
bindValue(
":USEOAG", use_on_air_guide);
1527 (void) hidden_in_guide;
1529 if (!freqid.isEmpty())
1532 QString tvformat = (atsc_minor_channel > 0) ?
"ATSC" : format;
1533 tvformat = tvformat.isNull() ?
"" : tvformat;
1536 icon = (icon.isNull()) ?
"" : icon;
1539 xmltvid = (xmltvid.isNull()) ?
"" : xmltvid;
1542 default_authority = (default_authority.isNull()) ?
"" : default_authority;
1543 query.
bindValue(
":AUTHORITY", default_authority);
1556 const QString &callsign,
1557 const QString &service_name,
1558 const QString &chan_num,
1560 uint atsc_major_channel,
1561 uint atsc_minor_channel,
1562 bool use_on_air_guide,
1564 bool hidden_in_guide,
1569 QString default_authority)
1574 QString tvformat = (atsc_minor_channel > 0) ?
"ATSC" : format;
1575 bool set_channum = !chan_num.isEmpty() && chan_num !=
"-1";
1576 QString qstr = QString(
1578 "SET %1 %2 %3 %4 %5 %6" 1579 " mplexid = :MPLEXID, serviceid = :SERVICEID, " 1580 " atsc_major_chan = :MAJORCHAN, atsc_minor_chan = :MINORCHAN, " 1581 " callsign = :CALLSIGN, name = :NAME, " 1582 " sourceid = :SOURCEID, useonairguide = :USEOAG, " 1583 " visible = :VISIBLE " 1584 "WHERE chanid=:CHANID")
1585 .arg((!set_channum) ?
"" :
"channum = :CHANNUM, ")
1586 .arg((freqid.isEmpty()) ?
"" :
"freqid = :FREQID, ")
1587 .arg((icon.isEmpty()) ?
"" :
"icon = :ICON, ")
1588 .arg((tvformat.isEmpty()) ?
"" :
"tvformat = :TVFORMAT, ")
1589 .arg((xmltvid.isEmpty()) ?
"" :
"xmltvid = :XMLTVID, ")
1590 .arg((default_authority.isEmpty()) ?
1591 "" :
"default_authority = :AUTHORITY,");
1601 query.
bindValue(
":SOURCEID", source_id);
1605 query.
bindValue(
":MPLEXID", db_mplexid);
1607 query.
bindValue(
":SERVICEID", service_id);
1608 query.
bindValue(
":MAJORCHAN", atsc_major_channel);
1609 query.
bindValue(
":MINORCHAN", atsc_minor_channel);
1610 query.
bindValue(
":USEOAG", use_on_air_guide);
1612 (void) hidden_in_guide;
1614 if (!freqid.isEmpty())
1617 if (!tvformat.isEmpty())
1620 if (!icon.isEmpty())
1622 if (!xmltvid.isEmpty())
1624 if (!default_authority.isEmpty())
1625 query.
bindValue(
":AUTHORITY", default_authority);
1639 "SELECT xmltvid, useonairguide, visible " 1641 "WHERE chanid = :ID");
1652 QString xmltvid = query.
value(0).toString();
1653 bool useeit = query.
value(1).toInt();
1654 bool visible = query.
value(2).toInt();
1656 if (!xmltvid.isEmpty())
1659 LOG(VB_GENERAL, LOG_ERR,
1660 "Using EIT and xmltv for the same channel " 1661 "is a unsupported configuration.");
1676 "DELETE FROM iptv_channel " 1677 "WHERE chanid=:CHANID");
1687 "INSERT INTO iptv_channel (chanid, url, type, bitrate) " 1688 "VALUES (:CHANID, :URL, :TYPE, :BITRATE)");
1732 "DELETE FROM channel " 1733 "WHERE chanid = :ID");
1743 "DELETE FROM iptv_channel " 1744 "WHERE chanid = :ID");
1761 "SET visible = :VISIBLE " 1762 "WHERE chanid = :ID");
1779 query.
prepare(
"UPDATE dtv_multiplex " 1780 "SET serviceversion = :VERSION " 1781 "WHERE mplexid = :MPLEXID");
1798 query.
prepare(
"SELECT serviceversion " 1799 "FROM dtv_multiplex " 1800 "WHERE mplexid = :MPLEXID");
1811 return query.
value(0).toInt();
1823 "SELECT atsc_major_chan, atsc_minor_chan " 1825 "WHERE channum = :CHANNUM AND " 1826 " sourceid = :SOURCEID");
1833 else if (query.
next())
1835 major = query.
value(0).toUInt();
1845 uint &chanid,
const QString &channum,
1846 QString &tvformat, QString &modulation,
1847 QString &freqtable, QString &freqid,
1848 int &finetune, uint64_t &frequency,
1849 QString &dtv_si_std,
int &mpeg_prog_num,
1850 uint &atsc_major,
uint &atsc_minor,
1851 uint &dvb_transportid,
uint &dvb_networkid,
1864 atsc_major = atsc_minor = mplexid = 0;
1865 dvb_networkid = dvb_transportid = 0;
1871 "SELECT finetune, freqid, tvformat, freqtable, " 1872 " commmethod, mplexid, " 1873 " atsc_major_chan, atsc_minor_chan, serviceid, " 1875 "FROM channel, videosource " 1876 "WHERE videosource.sourceid = channel.sourceid AND " 1877 " channum = :CHANNUM AND " 1878 " channel.sourceid = :SOURCEID " 1879 "ORDER BY channel.visible DESC, channel.chanid ");
1891 finetune = query.
value(0).toInt();
1892 freqid = query.
value(1).toString();
1893 tvformat = query.
value(2).toString();
1894 freqtable = query.
value(3).toString();
1895 commfree = (query.
value(4).toInt() == -2);
1896 mplexid = query.
value(5).toUInt();
1897 atsc_major = query.
value(6).toUInt();
1898 atsc_minor = query.
value(7).toUInt();
1899 mpeg_prog_num = (query.
value(8).isNull()) ? -1
1900 : query.
value(8).toInt();
1901 chanid = query.
value(9).toUInt();
1903 found += query.
value(10).toInt();
1906 while (query.
next())
1907 found += query.
value(10).toInt();
1909 if (found == 0 && chanid)
1911 LOG(VB_GENERAL, LOG_WARNING,
1912 QString(
"No visible channels for %1, using invisble chanid %2")
1913 .arg(channum).arg(chanid));
1918 LOG(VB_GENERAL, LOG_WARNING,
1919 QString(
"Found multiple visible channels for %1, using chanid %2")
1920 .arg(channum).arg(chanid));
1925 LOG(VB_GENERAL, LOG_ERR,
1926 QString(
"GetChannelData() failed because it could not\n" 1927 "\t\t\tfind channel number '%1' in DB for source '%2'.")
1928 .arg(channum).arg(sourceid));
1932 if (!mplexid || (mplexid == 32767))
1935 return GetTuningParams(mplexid, modulation, frequency,
1936 dvb_transportid, dvb_networkid, dtv_si_std);
1943 "SELECT type+0, url, bitrate " 1944 "FROM iptv_channel " 1945 "WHERE chanid = :CHANID " 1955 QString data_url, fec_url0, fec_url1;
1957 uint bitrate[3] = { 0, 0, 0, };
1958 while (query.
next())
1961 query.
value(0).toUInt();
1965 data_url = query.
value(1).toString();
1966 bitrate[0] = query.
value(2).toUInt();
1971 fec_url0 = query.
value(1).toString();
1972 bitrate[1] = query.
value(2).toUInt();
1977 fec_url1 = query.
value(1).toString();
1978 bitrate[2] = query.
value(2).toUInt();
2002 fec_url0, bitrate[1], fec_url1, bitrate[2]);
2003 LOG(VB_GENERAL, LOG_INFO, QString(
"Loaded %1 for %2")
2014 uint sourceid,
bool vis_only,
bool include_disconnected,
2015 const QString &grp,
uint changrpid)
2021 QString qstr = QString(
2022 "SELECT channum, callsign, channel.chanid, " 2023 " atsc_major_chan, atsc_minor_chan, " 2024 " name, icon, mplexid, visible, " 2025 " channel.sourceid, GROUP_CONCAT(DISTINCT capturecard.cardid), " 2026 " GROUP_CONCAT(DISTINCT channelgroup.grpid), " 2029 "LEFT JOIN channelgroup ON channel.chanid = channelgroup.chanid " 2030 " %1 JOIN capturecard ON capturecard.sourceid = channel.sourceid ")
2031 .arg((include_disconnected) ?
"LEFT" :
"");
2033 QString cond =
" WHERE ";
2037 qstr += QString(
"WHERE channel.sourceid='%1' ").arg(sourceid);
2044 qstr += QString(
"%1 channelgroup.grpid = '%2' ")
2045 .arg(cond).arg(changrpid);
2051 qstr += QString(
"%1 visible=1 ").arg(cond);
2055 qstr +=
" GROUP BY chanid";
2058 qstr += QString(
", %1").arg(grp);
2067 while (query.
next())
2069 if (query.
value(0).toString().isEmpty() || !query.
value(2).toUInt())
2073 query.
value(0).toString(),
2074 query.
value(1).toString(),
2075 query.
value(2).toUInt(),
2076 query.
value(3).toUInt(),
2077 query.
value(4).toUInt(),
2078 query.
value(7).toUInt(),
2079 query.
value(8).toBool(),
2080 query.
value(5).toString(),
2081 query.
value(6).toString(),
2082 query.
value(9).toUInt());
2086 QStringList inputIDs = query.
value(11).toString().split(
",");
2088 while (!inputIDs.isEmpty())
2089 chan.AddInputId(inputIDs.takeFirst().toUInt());
2091 QStringList groupIDs = query.
value(10).toString().split(
",");
2093 while (!groupIDs.isEmpty())
2094 chan.AddGroupId(groupIDs.takeFirst().toUInt());
2096 list.push_back(chan);
2107 QString select =
"SELECT chanid FROM channel ";
2109 if (onlyVisible || sourceid > 0)
2113 select +=
"visible = 1 ";
2118 select +=
"sourceid=" + QString::number(sourceid);
2123 if (!query.
exec(select))
2129 while (query.
next())
2130 list.push_back(query.
value(0).toUInt());
2142 static QMutex sepExprLock;
2147 bool isIntA, isIntB;
2148 int a_int = a.
channum.toUInt(&isIntA);
2149 int b_int =
b.channum.toUInt(&isIntB);
2151 int b_major =
b.atsc_major_chan;
2153 int b_minor =
b.atsc_minor_chan;
2159 QMutexLocker locker(&sepExprLock);
2160 idxA = a.
channum.indexOf(sepExpr);
2161 idxB =
b.channum.indexOf(sepExpr);
2165 int major = a.
channum.left(idxA).toUInt(&tmp1);
2168 (a_major = major), (a_minor =
minor), (isIntA =
false);
2173 int major =
b.channum.left(idxB).toUInt(&tmp1);
2174 int minor =
b.channum.mid(idxB+1).toUInt(&tmp2);
2176 (b_major = major), (b_minor =
minor), (isIntB =
false);
2180 if ((a_minor > 0) && isIntA)
2182 int atsc_int = (QString(
"%1%2").arg(a_major).arg(a_minor)).toInt();
2183 a_minor = (atsc_int == a_int) ? a_minor : 0;
2186 if ((b_minor > 0) && isIntB)
2188 int atsc_int = (QString(
"%1%2").arg(b_major).arg(b_minor)).toInt();
2189 b_minor = (atsc_int == b_int) ? b_minor : 0;
2194 if ((a_minor || b_minor) &&
2195 (a_minor || isIntA) && (b_minor || isIntB))
2197 int a_maj = (!a_minor && isIntA) ? a_int : a_major;
2198 int b_maj = (!b_minor && isIntB) ? b_int : b_major;
2199 if ((cmp = a_maj - b_maj))
2202 if ((cmp = a_minor - b_minor))
2206 if (isIntA && isIntB)
2209 cmp = a_int - b_int;
2213 else if (isIntA ^ isIntB)
2235 select =
"SELECT chanid FROM channel";
2237 select +=
" WHERE sourceid=" + QString::number(sourceid);
2245 return query.
size();
2249 bool eliminate_duplicates)
2251 bool cs = order.toLower() ==
"callsign";
2253 stable_sort(list.begin(), list.end(),
lt_callsign);
2255 stable_sort(list.begin(), list.end(),
lt_smart);
2257 if (eliminate_duplicates && !list.empty())
2260 tmp.push_back(list[0]);
2261 for (
uint i = 1; i < list.size(); i++)
2266 tmp.push_back(list[i]);
2282 const QString &channum)
2287 for (
int i = 0; i < (int)list.size(); ++i)
2308 uint mplexid_restriction,
2309 uint chanid_restriction,
2311 bool skip_non_visible,
2312 bool skip_same_channum_and_callsign)
2314 ChannelInfoList::const_iterator it =
2315 find(sorted.begin(), sorted.end(), old_chanid);
2317 if (it == sorted.end())
2318 it = sorted.begin();
2320 if (it == sorted.end())
2323 ChannelInfoList::const_iterator start = it;
2329 if (it == sorted.begin())
2331 it =
find(sorted.begin(), sorted.end(),
2332 sorted.rbegin()->chanid);
2333 if (it == sorted.end())
2341 while ((it != start) &&
2342 ((skip_non_visible && !it->visible) ||
2343 (skip_same_channum_and_callsign &&
2344 it->channum == start->channum &&
2345 it->callsign == start->callsign) ||
2346 (mplexid_restriction &&
2347 (mplexid_restriction != it->mplexid)) ||
2348 (chanid_restriction &&
2349 (chanid_restriction != it->chanid))));
2357 if (it == sorted.end())
2358 it = sorted.begin();
2360 while ((it != start) &&
2361 ((skip_non_visible && !it->visible) ||
2362 (skip_same_channum_and_callsign &&
2363 it->channum == start->channum &&
2364 it->callsign == start->callsign) ||
2365 (mplexid_restriction &&
2366 (mplexid_restriction != it->mplexid)) ||
2367 (chanid_restriction &&
2368 (chanid_restriction != it->chanid))));
2375 uint &totalAvailable,
2380 uint channelGroupID,
2388 QString sql =
"SELECT %1 channum, freqid, channel.sourceid, " 2389 "callsign, name, icon, finetune, videofilters, xmltvid, " 2390 "channel.recpriority, channel.contrast, channel.brightness, " 2391 "channel.colour, channel.hue, tvformat, " 2392 "visible, outputfilters, useonairguide, mplexid, " 2393 "serviceid, atsc_major_chan, atsc_minor_chan, last_record, " 2394 "default_authority, commmethod, tmoffset, iptvid, " 2396 "GROUP_CONCAT(DISTINCT channelgroup.grpid " 2397 " ORDER BY channelgroup.grpid), " 2398 "GROUP_CONCAT(DISTINCT capturecard.cardid " 2399 " ORDER BY livetvorder), " 2400 "MIN(livetvorder) livetvorder " 2402 "LEFT JOIN channelgroup ON channel.chanid = channelgroup.chanid " 2403 "LEFT JOIN capturecard ON capturecard.sourceid = channel.sourceid ";
2407 cond <<
"channel.visible = :VISIBLE ";
2409 if (channelGroupID > 0)
2410 cond <<
"channelgroup.grpid = :CHANGROUPID ";
2413 cond <<
"channel.sourceid = :SOURCEID ";
2416 cond <<
"capturecard.livetvorder > 0 ";
2418 if (!cond.isEmpty())
2419 sql += QString(
"WHERE %1").arg(cond.join(
"AND "));
2421 if (groupBy == kChanGroupByCallsign)
2422 sql +=
"GROUP BY channel.callsign ";
2424 sql +=
"GROUP BY channel.chanid ";
2426 if (orderBy == kChanOrderByName)
2427 sql +=
"ORDER BY channel.name ";
2428 else if (orderBy == kChanOrderByChanNum)
2431 sql +=
"ORDER BY LPAD(CAST(channel.channum AS UNSIGNED), 10, 0), " 2432 " LPAD(channel.channum, 10, 0) ";
2436 sql +=
"ORDER BY callsign = :CALLSIGN1 AND channum = :CHANNUM DESC, " 2437 " callsign = :CALLSIGN2 DESC, " 2439 " channel.recpriority DESC, " 2444 sql +=
"LIMIT :LIMIT ";
2447 sql +=
"OFFSET :STARTINDEX ";
2450 if (startIndex > 0 || count > 0)
2451 sql = sql.arg(
"SQL_CALC_FOUND_ROWS");
2460 if (channelGroupID > 0)
2461 query.
bindValue(
":CHANGROUPID", channelGroupID);
2470 query.
bindValue(
":STARTINDEX", startIndex);
2472 if (orderBy == kChanOrderByLiveTV)
2474 query.
bindValue(
":CALLSIGN1", callsign);
2476 query.
bindValue(
":CALLSIGN2", callsign);
2485 while (query.
next())
2492 channelInfo.
name = query.
value(4).toString();
2493 channelInfo.
icon = query.
value(5).toString();
2501 channelInfo.
hue = query.
value(13).toUInt();
2517 QStringList groupIDs = query.
value(28).toString().split(
",");
2519 while (!groupIDs.isEmpty())
2520 channelInfo.
AddGroupId(groupIDs.takeFirst().toUInt());
2522 QStringList inputIDs = query.
value(29).toString().split(
",");
2524 while (!inputIDs.isEmpty())
2525 channelInfo.
AddInputId(inputIDs.takeFirst().toUInt());
2527 channelList.push_back(channelInfo);
2530 if ((startIndex > 0 || count > 0) &&
2531 query.
exec(
"SELECT FOUND_ROWS()") && query.
next())
2532 totalAvailable = query.
value(0).toUInt();
2534 totalAvailable = query.
size();
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
unsigned long long FrequencyHz(void) const
uint SymbolRateHz(void) const
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(), QString format="Default", QString xmltvid=QString(), QString default_authority=QString())
void bindValue(const QString &placeholder, const QVariant &val)
static bool GetTuningParams(uint mplexid, QString &modulation, uint64_t &frequency, uint &dvb_transportid, uint &dvb_networkid, QString &si_std)
ChannelChangeDirection
ChannelChangeDirection is an enumeration of possible channel changing directions.
QString HierarchyString(void) const
static uint get_dtv_multiplex(uint db_source_id, QString sistandard, uint64_t frequency, uint transport_id, uint network_id, signed char polarity)
QString GuardIntervalString(void) const
static bool UpdateIPTVTuningData(uint channel_id, const IPTVTuningData &tuning)
static vector< uint > GetConflicting(const QString &channum, uint sourceid=0)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
static bool GetCachedPids(uint chanid, pid_cache_t &pid_cache)
Returns cached MPEG PIDs when given a Channel ID.
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
QString RollOffString(void) const
static QStringList GetInputTypes(uint chandid)
vector< pid_cache_item_t > pid_cache_t
QString FECInnerString(void) const
uint DescriptorTag(void) const
static int GetBetterMplexID(int current_mplexid, int transport_id, int network_id)
Returns best match multiplex ID, creating one if needed.
DTVCodeRate hp_code_rate
High Priority FEC rate.
void AddInputId(uint linputid)
static int GetTimeOffset(int chanid)
Returns the listings time offset in minutes for given channel.
vector< const unsigned char * > desc_list_t
static void SortChannels(ChannelInfoList &list, const QString &order, bool eliminate_duplicates=false)
static int GetSourceID(int mplexid)
static uint GetMplexID(uint sourceid, const QString &channum)
static bool SetVisible(uint channel_id, bool hidden)
static IPTVTuningData GetIPTVTuningData(uint chanid)
static bool lt_pidcache(const pid_cache_item_t &a, const pid_cache_item_t &b)
static bool GetATSCChannel(uint sourceid, const QString &channum, uint &major, uint &minor)
DTVGuardInterval guard_interval
QVariant value(int i) const
QUrl GetFECURL0(void) const
QString GetFECTypeString(uint i) const
static uint get_max_chanid(uint sourceid)
void AddGroupId(uint lgroupid)
static bool chanid_available(uint chanid)
static QString GetUnknownCallsign(void)
DTVCodeRate lp_code_rate
Low Priority FEC rate.
static int GetChanID(int db_mplexid, int service_transport_id, int major_channel, int minor_channel, int program_number)
QString BandwidthString(void) const
uint GetBitrate(uint i) const
static uint FindChannel(uint sourceid, const QString &freqid)
static ChannelInfoList GetChannelsInternal(uint sourceid, bool visible_only, bool include_disconnected, const QString &group_by, uint channel_groupid)
static uint insert_dtv_multiplex(int db_source_id, QString sistandard, uint64_t frequency, QString modulation, 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)
bool isActive(void) const
static MSqlQueryInfo DDCon()
Returns dedicated connection. (Required for using temporary SQL tables.)
bool lt_smart(const ChannelInfo &a, const ChannelInfo &b)
QUrl GetFECURL1(void) const
static QString GetIcon(uint chanid)
QString ModulationString(void) const
QString ConstellationString(void) const
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(), QString icon=QString(), QString format=QString(), QString xmltvid=QString(), QString default_authority=QString())
static ChannelInfoList LoadChannels(uint startIndex, uint count, uint &totalAvailable, bool ignoreHidden=true, OrderBy orderBy=kChanOrderByChanNum, GroupBy groupBy=kChanGroupByChanid, uint sourceID=0, uint channelGroupID=0, bool liveTVOnly=false, QString callsign="", QString channum="")
Load channels from database into a list of ChannelInfo objects.
static int GetChannelValueInt(const QString &channel_field, uint sourceid, const QString &channum)
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static bool IsOnSameMultiplex(uint sourceid, const QString &new_channum, const QString &old_channum)
static int CreateChanID(uint sourceid, const QString &chan_num)
Creates a unique channel ID for database use.
static int GetServiceVersion(int mplexid)
QString GetDeviceName(void) const
DTVCodeRate fec
Inner Forward Error Correction rate.
QString CodeRateLPString(void) const
vector< ChannelInfo > ChannelInfoList
static void UpdateInsertInfoFromDB(ChannelInsertInfo &chan)
static QStringList get_valid_recorder_list(uint chanid)
Returns list of the recorders that have chanid in their sources.
bool lt_callsign(const ChannelInfo &a, const ChannelInfo &b)
static QString GetChannelValueStr(const QString &channel_field, uint sourceid, const QString &channum)
static QString GetChannelStringField(int chanid, const QString &field)
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
#define LOG(_MASK_, _LEVEL_, _STRING_)
static QStringList GetValidRecorderList(uint chanid, const QString &channum)
Returns list of the recorders that have chanid or channum in their sources.
static uint GetSourceIDForChannel(uint chanid)
static bool GetChannelData(uint sourceid, uint &chanid, 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)
QString PolarizationString() const
static bool SaveCachedPids(uint chanid, const pid_cache_t &_pid_cache, bool delete_all=false)
Saves PIDs for PSIP tables to database.
QString TransmissionModeString(void) const
static int GetNearestChannel(const ChannelInfoList &list, const QString &channum)
static vector< uint > GetChanIDs(int sourceid=-1, bool onlyVisible=false)
static QString GetDefaultAuthority(uint chanid)
Returns the DVB default authority for the chanid given.
QString FECInnerString(void) const
unsigned long long FrequencyHz(void) const
uint SymbolRateHz(void) const
uint64_t FrequencyHz(void) const
QString ModulationSystemString(void) const
static uint CreateMultiplex(int sourceid, QString sistandard, uint64_t frequency, QString modulation, int transport_id=-1, int network_id=-1)
static bool SetServiceVersion(int mplexid, int version)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
static void handle_transport_desc(vector< uint > &muxes, const MPEGDescriptor &desc, uint sourceid, uint tsid, uint netid)
static void DBError(const QString &where, const MSqlQuery &query)
static QString GetChanNum(int chanid)
Returns the channel-number string of the given channel.
QString CodeRateHPString(void) const
DTVTransmitMode trans_mode
static bool SetChannelValue(const QString &field_name, QString value, uint sourceid, const QString &channum)
QString ModulationString(void) const
int naturalCompare(const QString &_a, const QString &_b, Qt::CaseSensitivity caseSensitivity)
static const QString kATSCSeparators
static uint GetChannelCount(int sourceid=-1)
static desc_list_t Parse(const unsigned char *data, uint len)
static vector< uint > CreateMultiplexes(int sourceid, const NetworkInformationTable *nit)
QUrl GetDataURL(void) const
DTVModulationSystem mod_sys
modulation system (only DVB-S or DVB-S2 atm)
static bool DeleteChannel(uint channel_id)
QString default_authority
static uint GetNextChannel(const ChannelInfoList &sorted, uint old_chanid, uint mplexid_restriction, uint chanid_restriction, ChannelChangeDirection direction, bool skip_non_visible=true, bool skip_same_channum_and_callsign=false)