32 #include "libmythbase/mythconfig.h"
40 #include "libmythbase/mythversion.h"
55 qRegisterMetaType<V2CaptureCardList*>(
"V2CaptureCardList");
56 qRegisterMetaType<V2CaptureCard*>(
"V2CaptureCard");
57 qRegisterMetaType<V2CardTypeList*>(
"V2CardTypeList");
58 qRegisterMetaType<V2CardType*>(
"V2CardType");
59 qRegisterMetaType<V2CaptureDeviceList*>(
"V2CaptureDeviceList");
60 qRegisterMetaType<V2CaptureDevice*>(
"V2CaptureDevice");
61 qRegisterMetaType<V2DiseqcTree*>(
"V2DiseqcTree");
62 qRegisterMetaType<V2DiseqcTreeList*>(
"V2DiseqcTreeList");
63 qRegisterMetaType<V2InputGroupList*>(
"V2InputGroupList");
64 qRegisterMetaType<V2InputGroup*>(
"V2InputGroup");
65 qRegisterMetaType<V2DiseqcConfig*>(
"V2DiseqcConfig");
66 qRegisterMetaType<V2DiseqcConfigList*>(
"V2DiseqcConfigList");
67 qRegisterMetaType<V2RecProfParam*>(
"V2RecProfParam");
68 qRegisterMetaType<V2RecProfile*>(
"V2RecProfile");
69 qRegisterMetaType<V2RecProfileGroup*>(
"V2RecProfileGroup");
70 qRegisterMetaType<V2RecProfileGroupList*>(
"V2RecProfileGroupList");
71 qRegisterMetaType<V2CardSubType*>(
"V2CardSubType");
89 throw( QString(
"Database not open while trying to list "
92 QString str =
"SELECT cardid, parentid, videodevice, audiodevice, vbidevice, "
93 "cardtype, defaultinput, audioratelimit, hostname, "
94 "dvb_swfilter, dvb_sat_type, dvb_wait_for_seqstart, "
95 "skipbtaudio, dvb_on_demand, dvb_diseqc_type, "
96 "firewire_speed, firewire_model, firewire_connection, "
97 "signal_timeout, channel_timeout, dvb_tuning_delay, "
98 "contrast, brightness, colour, hue, diseqcid, dvb_eitscan, "
99 "inputname, sourceid, externalcommand, changer_device, "
100 "changer_model, tunechan, startchan, displayname, "
101 "dishnet_eit, recpriority, quicktune, schedorder, "
102 "livetvorder, reclimit, schedgroup "
105 if (!sHostName.isEmpty())
106 str +=
" WHERE hostname = :HOSTNAME";
108 str +=
" WHERE cardtype = :CARDTYPE";
110 if (!sHostName.isEmpty() && !
CardType.isEmpty())
111 str +=
" AND cardtype = :CARDTYPE";
115 if (!sHostName.isEmpty())
123 throw( QString(
"Database Error executing query." ));
137 pCaptureCard->setCardId ( query.
value(0).toInt() );
138 pCaptureCard->setParentId ( query.
value(1).toInt() );
139 pCaptureCard->setVideoDevice ( query.
value(2).toString() );
140 pCaptureCard->setAudioDevice ( query.
value(3).toString() );
141 pCaptureCard->setVBIDevice ( query.
value(4).toString() );
142 pCaptureCard->setCardType ( query.
value(5).toString() );
143 pCaptureCard->setDefaultInput ( query.
value(6).toString() );
144 pCaptureCard->setAudioRateLimit ( query.
value(7).toUInt() );
145 pCaptureCard->setHostName ( query.
value(8).toString() );
146 pCaptureCard->setDVBSWFilter ( query.
value(9).toUInt() );
147 pCaptureCard->setDVBSatType ( query.
value(10).toUInt() );
148 pCaptureCard->setDVBWaitForSeqStart( query.
value(11).toBool() );
149 pCaptureCard->setSkipBTAudio ( query.
value(12).toBool() );
150 pCaptureCard->setDVBOnDemand ( query.
value(13).toBool() );
151 pCaptureCard->setDVBDiSEqCType ( query.
value(14).toUInt() );
152 pCaptureCard->setFirewireSpeed ( query.
value(15).toUInt() );
153 pCaptureCard->setFirewireModel ( query.
value(16).toString() );
154 pCaptureCard->setFirewireConnection( query.
value(17).toUInt() );
155 pCaptureCard->setSignalTimeout ( query.
value(18).toUInt() );
156 pCaptureCard->setChannelTimeout ( query.
value(19).toUInt() );
157 pCaptureCard->setDVBTuningDelay ( query.
value(20).toUInt() );
158 pCaptureCard->setContrast ( query.
value(21).toUInt() );
159 pCaptureCard->setBrightness ( query.
value(22).toUInt() );
160 pCaptureCard->setColour ( query.
value(23).toUInt() );
161 pCaptureCard->setHue ( query.
value(24).toUInt() );
162 pCaptureCard->setDiSEqCId ( query.
value(25).toUInt() );
163 pCaptureCard->setDVBEITScan ( query.
value(26).toBool() );
164 pCaptureCard->setInputName ( query.
value(27).toString() );
165 pCaptureCard->setSourceId ( query.
value(28).toInt() );
166 pCaptureCard->setExternalCommand ( query.
value(29).toString() );
167 pCaptureCard->setChangerDevice ( query.
value(30).toString() );
168 pCaptureCard->setChangerModel ( query.
value(31).toString() );
169 pCaptureCard->setTuneChannel ( query.
value(32).toString() );
170 pCaptureCard->setStartChannel ( query.
value(33).toString() );
171 pCaptureCard->setDisplayName ( query.
value(34).toString() );
172 pCaptureCard->setDishnetEit ( query.
value(35).toBool() );
173 pCaptureCard->setRecPriority ( query.
value(36).toInt() );
174 pCaptureCard->setQuickTune ( query.
value(37).toBool() );
175 pCaptureCard->setSchedOrder ( query.
value(38).toUInt() );
176 pCaptureCard->setLiveTVOrder ( query.
value(39).toUInt() );
177 pCaptureCard->setRecLimit ( query.
value(40).toUInt() );
178 pCaptureCard->setSchedGroup ( query.
value(41).toBool() );
191 throw( QString(
"The Card ID is invalid."));
196 throw( QString(
"Database not open while trying to list "
197 "V2Capture Cards."));
199 QString str =
"SELECT cardid, parentid, videodevice, audiodevice, vbidevice, "
200 "cardtype, defaultinput, audioratelimit, hostname, "
201 "dvb_swfilter, dvb_sat_type, dvb_wait_for_seqstart, "
202 "skipbtaudio, dvb_on_demand, dvb_diseqc_type, "
203 "firewire_speed, firewire_model, firewire_connection, "
204 "signal_timeout, channel_timeout, dvb_tuning_delay, "
205 "contrast, brightness, colour, hue, diseqcid, dvb_eitscan, "
206 "inputname, sourceid, externalcommand, changer_device, "
207 "changer_model, tunechan, startchan, displayname, "
208 "dishnet_eit, recpriority, quicktune, schedorder, "
209 "livetvorder, reclimit, schedgroup "
210 "from capturecard WHERE cardid = :CARDID";
218 throw( QString(
"Database Error executing query." ));
225 pCaptureCard->setCardId ( query.
value(0).toInt() );
226 pCaptureCard->setParentId ( query.
value(1).toInt() );
227 pCaptureCard->setVideoDevice ( query.
value(2).toString() );
228 pCaptureCard->setAudioDevice ( query.
value(3).toString() );
229 pCaptureCard->setVBIDevice ( query.
value(4).toString() );
230 pCaptureCard->setCardType ( query.
value(5).toString() );
231 pCaptureCard->setDefaultInput ( query.
value(6).toString() );
232 pCaptureCard->setAudioRateLimit ( query.
value(7).toUInt() );
233 pCaptureCard->setHostName ( query.
value(8).toString() );
234 pCaptureCard->setDVBSWFilter ( query.
value(9).toUInt() );
235 pCaptureCard->setDVBSatType ( query.
value(10).toUInt() );
236 pCaptureCard->setDVBWaitForSeqStart( query.
value(11).toBool() );
237 pCaptureCard->setSkipBTAudio ( query.
value(12).toBool() );
238 pCaptureCard->setDVBOnDemand ( query.
value(13).toBool() );
239 pCaptureCard->setDVBDiSEqCType ( query.
value(14).toUInt() );
240 pCaptureCard->setFirewireSpeed ( query.
value(15).toUInt() );
241 pCaptureCard->setFirewireModel ( query.
value(16).toString() );
242 pCaptureCard->setFirewireConnection( query.
value(17).toUInt() );
243 pCaptureCard->setSignalTimeout ( query.
value(18).toUInt() );
244 pCaptureCard->setChannelTimeout ( query.
value(19).toUInt() );
245 pCaptureCard->setDVBTuningDelay ( query.
value(20).toUInt() );
246 pCaptureCard->setContrast ( query.
value(21).toUInt() );
247 pCaptureCard->setBrightness ( query.
value(22).toUInt() );
248 pCaptureCard->setColour ( query.
value(23).toUInt() );
249 pCaptureCard->setHue ( query.
value(24).toUInt() );
250 pCaptureCard->setDiSEqCId ( query.
value(25).toUInt() );
251 pCaptureCard->setDVBEITScan ( query.
value(26).toBool() );
252 pCaptureCard->setInputName ( query.
value(27).toString() );
253 pCaptureCard->setSourceId ( query.
value(28).toInt() );
254 pCaptureCard->setExternalCommand ( query.
value(29).toString() );
255 pCaptureCard->setChangerDevice ( query.
value(30).toString() );
256 pCaptureCard->setChangerModel ( query.
value(31).toString() );
257 pCaptureCard->setTuneChannel ( query.
value(32).toString() );
258 pCaptureCard->setStartChannel ( query.
value(33).toString() );
259 pCaptureCard->setDisplayName ( query.
value(34).toString() );
260 pCaptureCard->setDishnetEit ( query.
value(35).toBool() );
261 pCaptureCard->setRecPriority ( query.
value(36).toInt() );
262 pCaptureCard->setQuickTune ( query.
value(37).toBool() );
263 pCaptureCard->setSchedOrder ( query.
value(38).toUInt() );
264 pCaptureCard->setLiveTVOrder ( query.
value(39).toUInt() );
265 pCaptureCard->setRecLimit ( query.
value(40).toUInt() );
266 pCaptureCard->setSchedGroup ( query.
value(41).toBool() );
285 #endif // CONFIG_SATIP
287 bool HDHRdoesDVBC =
false;
288 bool HDHRdoesDVB =
false;
297 #endif // CONFIG_HDHOMERUN
299 pCardType->setCardId(CardId);
300 pCardType->setSubType (subtype);
304 QMetaEnum meta = QMetaEnum::fromType<CardUtil::INPUT_TYPES>();
305 QString key = meta.valueToKeys(
static_cast<uint>(cardType));
306 QStringList keyList = key.split(
"|");
308 if (keyList.length() > 1 && keyList[1].startsWith(
"DV"))
311 pCardType->setInputType (key);
312 pCardType->setHDHRdoesDVBC (HDHRdoesDVBC);
313 pCardType->setHDHRdoesDVB (HDHRdoesDVB);
330 throw( QString(
"The Card ID is invalid."));
342 const QString &sAudioDevice,
343 const QString &sVBIDevice,
345 const uint nAudioRateLimit,
346 const QString &sHostName,
347 const uint nDVBSWFilter,
348 const uint nDVBSatType,
349 bool bDVBWaitForSeqStart,
352 const uint nDVBDiSEqCType,
353 const uint nFirewireSpeed,
354 const QString &sFirewireModel,
355 const uint nFirewireConnection,
356 const uint nSignalTimeout,
357 const uint nChannelTimeout,
358 const uint nDVBTuningDelay,
359 const uint nContrast,
360 const uint nBrightness,
363 const uint nDiSEqCId,
366 if ( sVideoDevice.isEmpty() ||
CardType.isEmpty() || sHostName.isEmpty() )
367 throw( QString(
"This API requires at least a video device node, a card type, "
368 "and a hostname." ));
371 sVBIDevice,
CardType, nAudioRateLimit,
372 sHostName, nDVBSWFilter, nDVBSatType, bDVBWaitForSeqStart,
373 bSkipBTAudio, bDVBOnDemand, nDVBDiSEqCType, nFirewireSpeed,
374 sFirewireModel, nFirewireConnection, std::chrono::milliseconds(nSignalTimeout),
375 std::chrono::milliseconds(nChannelTimeout), nDVBTuningDelay, nContrast, nBrightness,
376 nColour, nHue, nDiSEqCId, bDVBEITScan);
379 throw( QString(
"Unable to create capture device." ));
385 const QString &sSetting,
386 const QString &sValue )
388 if ( nCardId < 1 || sSetting.isEmpty() || sValue.isEmpty() )
389 throw( QString(
"Card ID, Setting Name, and Value are required." ));
398 if ( nCardInputId < 1 )
399 throw( QString(
"The Input ID is invalid."));
407 const uint nSourceId,
408 const QString &sInputName,
409 const QString &sExternalCommand,
410 const QString &sChangerDevice,
411 const QString &sChangerModel,
412 const QString &sHostName,
413 const QString &sTuneChan,
414 const QString &sStartChan,
415 const QString &sDisplayName,
417 const uint nRecPriority,
418 const uint nQuicktune,
419 const uint nSchedOrder,
420 const uint nLiveTVOrder)
422 if ( nCardId < 1 || nSourceId < 1 ||
423 sInputName.isEmpty() || sInputName ==
"None" )
424 throw( QString(
"This API requires at least a card ID, a source ID, "
425 "and an input name." ));
428 throw QString(
" DisplayName is not set or is not unique.");
431 sExternalCommand, sChangerDevice, sChangerModel,
432 sHostName, sTuneChan, sStartChan, sDisplayName,
433 bDishnetEIT, nRecPriority, nQuicktune, nSchedOrder,
440 const QString &sSetting,
441 const QString &sValue )
443 if ( nCardInputId < 1 || sSetting.isEmpty() || sValue.isEmpty() )
444 throw( QString(
"Input ID, Setting Name, and Value are required." ));
454 pCardTypeList->AddCardType(
455 QObject::tr(
"DVB-T/S/C, ATSC or ISDB-T tuner card"),
"DVB");
459 pCardTypeList->AddCardType(
460 QObject::tr(
"V4L2 encoder"),
"V4L2ENC");
461 pCardTypeList->AddCardType(
462 QObject::tr(
"HD-PVR H.264 encoder"),
"HDPVR");
463 #endif // CONFIG_V4L2
466 pCardTypeList->AddCardType(
467 QObject::tr(
"HDHomeRun networked tuner"),
"HDHOMERUN");
468 #endif // CONFIG_HDHOMERUN
471 pCardTypeList->AddCardType(
472 QObject::tr(
"Sat>IP networked tuner"),
"SATIP");
473 #endif // CONFIG_SATIP
476 pCardTypeList->AddCardType(
477 QObject::tr(
"V@Box TV Gateway networked tuner"),
"VBOX");
478 #endif // CONFIG_VBOX
481 pCardTypeList->AddCardType(
482 QObject::tr(
"FireWire cable box"),
"FIREWIRE");
483 #endif // CONFIG_FIREWIRE
486 pCardTypeList->AddCardType(
487 QObject::tr(
"Ceton Cablecard tuner"),
"CETON");
488 #endif // CONFIG_CETON
491 pCardTypeList->AddCardType(QObject::tr(
"IPTV recorder"),
"FREEBOX");
492 #endif // CONFIG_IPTV
495 pCardTypeList->AddCardType(
496 QObject::tr(
"Analog to MPEG-2 encoder card (PVR-150/250/350, etc)"),
"MPEG");
497 pCardTypeList->AddCardType(
498 QObject::tr(
"Analog to MJPEG encoder card (Matrox G200, DC10, etc)"),
"MJPEG");
499 pCardTypeList->AddCardType(
500 QObject::tr(
"Analog to MPEG-4 encoder (Plextor ConvertX USB, etc)"),
502 pCardTypeList->AddCardType(
503 QObject::tr(
"Analog capture card"),
"V4L");
504 #endif // CONFIG_V4L2
507 pCardTypeList->AddCardType(QObject::tr(
"DVEO ASI recorder"),
"ASI");
510 pCardTypeList->AddCardType(QObject::tr(
"Import test recorder"),
"IMPORT");
511 pCardTypeList->AddCardType(QObject::tr(
"Demo test recorder"),
"DEMO");
512 #if !defined( _WIN32 )
513 pCardTypeList->AddCardType(QObject::tr(
"External (black box) recorder"),
516 return pCardTypeList;
526 throw( QString(
"Database not open while trying to list "
529 QString q =
"SELECT cardinputid,inputgroupid,inputgroupname "
530 "FROM inputgroup WHERE inputgroupname LIKE 'user:%' "
531 "ORDER BY inputgroupid, cardinputid";
537 return pInputGroupList;
542 pInputGroupList->AddInputGroup(query.
value(0).toUInt(),
543 query.
value(1).toUInt(),
544 query.
value(2).toString());
547 return pInputGroupList;
553 throw( QString(
"Input group name cannot be empty." ) );
555 QString new_name = QString(
"user:") +
Name;
559 if (inputgroupid == 0)
561 throw( QString(
"Failed to add or retrieve %1" ).arg(new_name) );
568 const uint InputGroupId)
571 throw( QString (
"Failed to link input %1 to group %2" )
572 .arg(InputId).arg(InputGroupId));
578 const uint InputGroupId)
581 throw( QString (
"Failed to unlink input %1 from group %2" )
582 .arg(InputId).arg(InputGroupId));
594 static QString remove_chaff(
const QString &name)
597 QString short_name = name;
598 if (short_name.startsWith(
"LG Electronics"))
599 short_name = short_name.right(short_name.length() - 15);
600 if (short_name.startsWith(
"Oren"))
601 short_name = short_name.right(short_name.length() - 5);
602 if (short_name.startsWith(
"Nextwave"))
603 short_name = short_name.right(short_name.length() - 9);
604 if (short_name.startsWith(
"frontend", Qt::CaseInsensitive))
605 short_name = short_name.left(short_name.length() - 9);
606 if (short_name.endsWith(
"VSB/QAM"))
607 short_name = short_name.left(short_name.length() - 8);
608 if (short_name.endsWith(
"VSB"))
609 short_name = short_name.left(short_name.length() - 4);
610 if (short_name.endsWith(
"DVB-T"))
611 short_name = short_name.left(short_name.length() - 6);
617 short_name = short_name.simplified();
618 if (short_name.startsWith(
"or51211", Qt::CaseInsensitive))
619 short_name =
"pcHDTV HD-2000";
620 else if (short_name.startsWith(
"or51132", Qt::CaseInsensitive))
621 short_name =
"pcHDTV HD-3000";
622 else if (short_name.startsWith(
"bcm3510", Qt::CaseInsensitive))
623 short_name =
"Air2PC v1";
624 else if (short_name.startsWith(
"nxt2002", Qt::CaseInsensitive) ||
625 short_name.startsWith(
"nxt200x", Qt::CaseInsensitive))
626 short_name =
"Air2PC v2";
627 else if (short_name.startsWith(
"lgdt3302", Qt::CaseInsensitive))
628 short_name =
"DViCO HDTV3";
629 else if (short_name.startsWith(
"lgdt3303", Qt::CaseInsensitive))
630 short_name =
"DViCO v2 or Air2PC v3 or pcHDTV HD-5500";
642 QRegularExpression drv {
"^(?!ivtv|hdpvr|(saa7164(.*))).*$" };
646 QRegularExpression drv {
"^hdpvr$" };
657 for (
const auto & it : std::as_const(sdevs))
659 auto* pDev = pList->AddCaptureDevice();
661 pDev->setVideoDevice (it);
670 int signalTimeout = 0;
671 int channelTimeout = 0;
673 QString err_open = tr(
"Could not open card %1").arg(it);
674 QString err_other = tr(
"Could not get card info for card %1").arg(it);
679 frontendName = err_open;
680 subType = strerror(errno);
683 frontendName = err_other;
684 subType =
"Unknown error";
687 frontendName = err_other;
688 subType = strerror(errno);
692 signalTimeout = 7000;
693 channelTimeout = 10000;
697 signalTimeout = 7000;
698 channelTimeout = 10000;
702 signalTimeout = 3000;
703 channelTimeout = 6000;
707 signalTimeout = 3000;
708 channelTimeout = 6000;
713 signalTimeout = 3000;
714 channelTimeout = 6000;
715 if (frontendName.toLower().indexOf(
"usb") >= 0)
717 signalTimeout = 40000;
718 channelTimeout = 42500;
722 if ((frontendName ==
"DiBcom 3000P/M-C DVB-T") ||
724 "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver"))
732 QString short_name = remove_chaff(frontendName);
734 frontendName = short_name;
735 signalTimeout = 2000;
736 channelTimeout = 4000;
740 if (frontendName ==
"Nextwave NXT200X VSB/QAM frontend")
742 signalTimeout = 3000;
743 channelTimeout = 5500;
751 pDev->setFrontendName ( frontendName );
752 pDev->setSubType ( subType );
753 pDev->setSignalTimeout ( signalTimeout );
754 pDev->setChannelTimeout ( channelTimeout );
755 pDev->setTuningDelay ( tuningDelay );
760 pDev->setSignalTimeout ( 3000 );
761 pDev->setChannelTimeout ( 6000 );
766 pDev->setSignalTimeout ( 7000 );
767 pDev->setChannelTimeout ( 10000 );
770 auto word = it.split(
' ');
772 if (word.size() == 5) {
773 pDev->setVideoDevice(QString(
"%1:%2:%3").arg(word[0], word[4], word[3]));
774 pDev->setVideoDevicePrompt(QString(
"%1, %2, Tuner #%3").arg(word[0], word[4], word[3]));
775 pDev->setDescription(word[1]);
776 pDev->setIPAddress(word[2]);
777 pDev->setTunerType(word[4]);
778 pDev->setTunerNumber(word[3].toUInt());
781 #endif // CONFIG_SATIP
785 pDev->setSignalTimeout ( 7000 );
786 pDev->setChannelTimeout ( 10000 );
789 auto word = it.split(
" ");
790 if (word.size() == 4) {
791 QString device = QString(
"%1-%2-%3").arg(word[0], word[2], word[3]);
792 pDev->setVideoDevice(device);
793 pDev->setVideoDevicePrompt(device);
795 pDev->setDescription(desc);
796 pDev->setIPAddress(word[1]);
797 pDev->setTunerType(word[3]);
798 pDev->setTunerNumber(word[2].toUInt());
801 #endif // CONFIG_VBOX
813 throw( QString(
"Database not open while trying to list "
816 QString str =
"SELECT diseqcid, "
835 "FROM diseqc_tree ORDER BY diseqcid";
842 throw( QString(
"Database Error executing query." ));
853 auto *pRec = pList->AddDiseqcTree();
854 pRec->setDiSEqCId ( query.
value( 0 ).toUInt() );
855 pRec->setParentId ( query.
value( 1 ).toUInt() );
856 pRec->setOrdinal ( query.
value( 2 ).toUInt() );
857 pRec->setType ( query.
value( 3 ).toString() );
858 pRec->setSubType ( query.
value( 4 ).toString() );
859 pRec->setDescription ( query.
value( 5 ).toString() );
860 pRec->setSwitchPorts ( query.
value( 6 ).toUInt() );
861 pRec->setRotorHiSpeed ( query.
value( 7 ).toFloat() );
862 pRec->setRotorLoSpeed ( query.
value( 8 ).toFloat() );
863 pRec->setRotorPositions ( query.
value( 9 ).toString() );
864 pRec->setLnbLofSwitch ( query.
value( 10 ).toInt() );
865 pRec->setLnbLofHi ( query.
value( 11 ).toInt() );
866 pRec->setLnbLofLo ( query.
value( 12 ).toInt() );
867 pRec->setCmdRepeat ( query.
value( 13 ).toInt() );
868 pRec->setLnbPolInv ( query.
value( 14 ).toBool() );
869 pRec->setAddress ( query.
value( 15 ).toInt() );
870 pRec->setScrUserband ( query.
value( 16 ).toUInt() );
871 pRec->setScrFrequency ( query.
value( 17 ).toUInt() );
872 pRec->setScrPin ( query.
value( 18 ).toInt() );
881 const QString& SubType,
882 const QString& Description,
886 const QString& RotorPositions,
900 "INSERT INTO diseqc_tree "
941 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
942 query.
bindValue(
":PARENTID", QVariant(QVariant::UInt));
944 query.
bindValue(
":PARENTID", QVariant(QMetaType(QMetaType::UInt)));
954 query.
bindValue(
":DESCRIPTION", Description);
955 query.
bindValue(
":SWITCH_PORTS", SwitchPorts);
956 query.
bindValue(
":ROTOR_HI_SPEED", RotorHiSpeed);
957 query.
bindValue(
":ROTOR_LO_SPEED", RotorLoSpeed);
958 query.
bindValue(
":ROTOR_POSITIONS", RotorPositions);
959 query.
bindValue(
":LNB_LOF_SWITCH", LnbLofSwitch);
960 query.
bindValue(
":LNB_LOF_HI", LnbLofHi);
961 query.
bindValue(
":LNB_LOF_LO", LnbLofLo);
962 query.
bindValue(
":CMD_REPEAT", CmdRepeat);
963 query.
bindValue(
":LNB_POL_INV", LnbPolInv);
965 query.
bindValue(
":SCR_USERBAND", ScrUserband);
966 query.
bindValue(
":SCR_FREQUENCY", ScrFrequency);
972 throw( QString(
"Database Error executing query." ));
982 const QString& SubType,
983 const QString& Description,
987 const QString& RotorPositions,
1001 "UPDATE diseqc_tree SET "
1002 "parentid = :PARENTID, "
1003 "ordinal = :ORDINAL, "
1005 "subtype = :SUBTYPE, "
1006 "description = :DESCRIPTION, "
1007 "switch_ports = :SWITCH_PORTS, "
1008 "rotor_hi_speed = :ROTOR_HI_SPEED, "
1009 "rotor_lo_speed = :ROTOR_LO_SPEED, "
1010 "rotor_positions = :ROTOR_POSITIONS, "
1011 "lnb_lof_switch = :LNB_LOF_SWITCH, "
1012 "lnb_lof_hi = :LNB_LOF_HI, "
1013 "lnb_lof_lo = :LNB_LOF_LO, "
1014 "cmd_repeat = :CMD_REPEAT, "
1015 "lnb_pol_inv = :LNB_POL_INV, "
1016 "address = :ADDRESS, "
1017 "scr_userband = :SCR_USERBAND, "
1018 "scr_frequency = :SCR_FREQUENCY, "
1019 "scr_pin = :SCR_PIN "
1020 "WHERE diseqcid = :DISEQCID " );
1025 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
1026 query.
bindValue(
":PARENTID", QVariant(QVariant::UInt));
1028 query.
bindValue(
":PARENTID", QVariant(QMetaType(QMetaType::UInt)));
1038 query.
bindValue(
":DESCRIPTION", Description);
1039 query.
bindValue(
":SWITCH_PORTS", SwitchPorts);
1040 query.
bindValue(
":ROTOR_HI_SPEED", RotorHiSpeed);
1041 query.
bindValue(
":ROTOR_LO_SPEED", RotorLoSpeed);
1042 query.
bindValue(
":ROTOR_POSITIONS", RotorPositions);
1043 query.
bindValue(
":LNB_LOF_SWITCH", LnbLofSwitch);
1044 query.
bindValue(
":LNB_LOF_HI", LnbLofHi);
1045 query.
bindValue(
":LNB_LOF_LO", LnbLofLo);
1046 query.
bindValue(
":CMD_REPEAT", CmdRepeat);
1047 query.
bindValue(
":LNB_POL_INV", LnbPolInv);
1049 query.
bindValue(
":SCR_USERBAND", ScrUserband);
1050 query.
bindValue(
":SCR_FREQUENCY", ScrFrequency);
1056 throw( QString(
"Database Error executing query." ));
1065 query.
prepare(
"SELECT diseqcid FROM diseqc_tree WHERE parentid = :PARENTID ");
1071 throw( QString(
"Database Error executing query." ));
1074 bool childOK =
true;
1075 while (query.
next())
1082 query2.
prepare(
"DELETE FROM diseqc_tree WHERE diseqcid = :DISEQCID ");
1083 query2.
bindValue(
":DISEQCID", DiSEqCId);
1087 throw( QString(
"Database Error executing query." ));
1090 return numrows > 0 && childOK;
1100 throw( QString(
"Database not open while trying to list "
1103 QString str =
"SELECT cardinputid, "
1106 "FROM diseqc_config ORDER BY cardinputid, diseqcid";
1113 throw( QString(
"Database Error executing query." ));
1122 while (query.
next())
1124 auto *pRec = pList->AddDiseqcConfig();
1125 pRec->setCardId ( query.
value( 0 ).toUInt() );
1126 pRec->setDiSEqCId ( query.
value( 1 ).toUInt() );
1127 pRec->setValue ( query.
value( 2 ).toString() );
1134 const QString& Value)
1139 "INSERT INTO diseqc_config "
1155 throw( QString(
"Database Error executing query." ));
1164 query.
prepare(
"DELETE FROM diseqc_config WHERE cardinputid = :CARDID ");
1169 throw( QString(
"Database Error executing query." ));
1181 "SELECT profilegroups.id, profilegroups.name, cardtype, recordingprofiles.id, recordingprofiles.name, "
1182 "videocodec, audiocodec, "
1183 "codecparams.name, codecparams.value "
1184 "FROM profilegroups "
1185 "INNER JOIN recordingprofiles on profilegroups.id = recordingprofiles.profilegroup "
1186 "LEFT OUTER JOIN codecparams on codecparams.profile = recordingprofiles.id ";
1187 QString where =
"WHERE ";
1190 str.append(where).append(
"CARDTYPE = 'TRANSCODE' OR (cardtype in (SELECT cardtype FROM capturecard)) ");
1195 str.append(where).append(
"profilegroups.id = :GROUPID ");
1200 str.append(where).append(
"recordingprofiles.id = :PROFILEID ");
1205 "ORDER BY IF(cardtype = 'TRANSCODE', 9999, profilegroups.id), recordingprofiles.id, codecparams.name ");
1212 query.
bindValue(
":PROFILEID", ProfileId);
1217 throw( QString(
"Database Error executing query." ));
1226 int prevGroupId = -1;
1227 int prevProfileId = -1;
1232 while (query.
next())
1234 int groupId = query.
value(0).toInt();
1235 if (groupId != prevGroupId)
1237 pGroup = pList->AddProfileGroup();
1238 pGroup->setId ( groupId );
1239 pGroup->setName ( query.
value(1).toString() );
1240 pGroup->setCardType ( query.
value(2).toString() );
1241 prevGroupId = groupId;
1243 int profileId = query.
value(3).toInt();
1247 if (profileId != prevProfileId && pGroup !=
nullptr)
1250 pProfile->setId ( profileId );
1251 pProfile->setName ( query.
value(4).toString() );
1252 pProfile->setVideoCodec ( query.
value(5).toString() );
1253 pProfile->setAudioCodec ( query.
value(6).toString() );
1254 prevProfileId = profileId;
1259 if (!query.
isNull(7) && pProfile !=
nullptr)
1261 auto *pParam = pProfile->
AddParam();
1262 pParam->setName ( query.
value(7).toString() );
1263 pParam->setValue ( query.
value(8).toString() );
1271 const QString& VideoCodec,
const QString& AudioCodec )
1273 if (GroupId == 0 || ProfileName.isEmpty())
1275 LOG(VB_GENERAL, LOG_ERR,
1276 QString(
"AddRecProfile: GroupId and ProfileName are required." ));
1285 "FROM recordingprofiles "
1286 "WHERE name = :NAME AND profilegroup = :PROFILEGROUP;");
1288 query.
bindValue(
":PROFILEGROUP", GroupId);
1292 throw( QString(
"Database Error executing SELECT." ));
1296 int id = query.
value(0).toInt();
1297 LOG(VB_GENERAL, LOG_ERR,
1298 QString(
"Profile %1 already exists in group id %2 with id %3").arg(ProfileName).arg(GroupId).arg(
id));
1303 "INSERT INTO recordingprofiles "
1304 "(name, videocodec, audiocodec, profilegroup) "
1306 "(:NAME, :VIDEOCODEC, :AUDIOCODEC, :PROFILEGROUP);");
1308 query.
bindValue(
":VIDEOCODEC", VideoCodec);
1309 query.
bindValue(
":AUDIOCODEC", AudioCodec);
1310 query.
bindValue(
":PROFILEGROUP", GroupId);
1314 throw( QString(
"Database Error executing INSERT." ));
1325 const QString& VideoCodec,
1326 const QString& AudioCodec )
1330 "SELECT id from recordingprofiles "
1331 "WHERE id = :ID; ");
1336 throw( QString(
"Database Error executing SELECT." ));
1341 id = query.
value(0).toUInt();
1343 if (
id != ProfileId)
1345 LOG(VB_GENERAL, LOG_ERR,
1346 QString(
"UpdateRecProfile: Profile id %1 does not exist").arg(ProfileId));
1350 "UPDATE recordingprofiles "
1351 "SET videocodec = :VIDEOCODEC, "
1352 "audiocodec = :AUDIOCODEC "
1353 "WHERE id = :ID; ");
1354 query.
bindValue(
":VIDEOCODEC", VideoCodec);
1355 query.
bindValue(
":AUDIOCODEC", AudioCodec);
1360 throw( QString(
"Database Error executing UPDATE." ));
1374 "DELETE from codecparams "
1375 "WHERE profile = :ID; ");
1380 throw( QString(
"Database Error executing DELETE." ));
1384 "DELETE from recordingprofiles "
1385 "WHERE id = :ID; ");
1390 throw( QString(
"Database Error executing DELETE." ));
1401 "REPLACE INTO codecparams "
1402 "(profile, name, value) "
1404 "(:PROFILE, :NAME, :VALUE);");
1411 throw( QString(
"Database Error executing REPLACE." ));