37 #include "libmythbase/mythversion.h"
52 qRegisterMetaType<V2CaptureCardList*>(
"V2CaptureCardList");
53 qRegisterMetaType<V2CaptureCard*>(
"V2CaptureCard");
54 qRegisterMetaType<V2CardTypeList*>(
"V2CardTypeList");
55 qRegisterMetaType<V2CardType*>(
"V2CardType");
56 qRegisterMetaType<V2CaptureDeviceList*>(
"V2CaptureDeviceList");
57 qRegisterMetaType<V2CaptureDevice*>(
"V2CaptureDevice");
58 qRegisterMetaType<V2DiseqcTree*>(
"V2DiseqcTree");
59 qRegisterMetaType<V2DiseqcTreeList*>(
"V2DiseqcTreeList");
60 qRegisterMetaType<V2InputGroupList*>(
"V2InputGroupList");
61 qRegisterMetaType<V2InputGroup*>(
"V2InputGroup");
62 qRegisterMetaType<V2DiseqcConfig*>(
"V2DiseqcConfig");
63 qRegisterMetaType<V2DiseqcConfigList*>(
"V2DiseqcConfigList");
64 qRegisterMetaType<V2RecProfParam*>(
"V2RecProfParam");
65 qRegisterMetaType<V2RecProfile*>(
"V2RecProfile");
66 qRegisterMetaType<V2RecProfileGroup*>(
"V2RecProfileGroup");
67 qRegisterMetaType<V2RecProfileGroupList*>(
"V2RecProfileGroupList");
68 qRegisterMetaType<V2CardSubType*>(
"V2CardSubType");
86 throw( QString(
"Database not open while trying to list "
89 QString str =
"SELECT cardid, parentid, videodevice, audiodevice, vbidevice, "
90 "cardtype, defaultinput, audioratelimit, hostname, "
91 "dvb_swfilter, dvb_sat_type, dvb_wait_for_seqstart, "
92 "skipbtaudio, dvb_on_demand, dvb_diseqc_type, "
93 "firewire_speed, firewire_model, firewire_connection, "
94 "signal_timeout, channel_timeout, dvb_tuning_delay, "
95 "contrast, brightness, colour, hue, diseqcid, dvb_eitscan, "
96 "inputname, sourceid, externalcommand, changer_device, "
97 "changer_model, tunechan, startchan, displayname, "
98 "dishnet_eit, recpriority, quicktune, schedorder, "
99 "livetvorder, reclimit, schedgroup "
102 if (!sHostName.isEmpty())
103 str +=
" WHERE hostname = :HOSTNAME";
105 str +=
" WHERE cardtype = :CARDTYPE";
107 if (!sHostName.isEmpty() && !
CardType.isEmpty())
108 str +=
" AND cardtype = :CARDTYPE";
112 if (!sHostName.isEmpty())
120 throw( QString(
"Database Error executing query." ));
134 pCaptureCard->setCardId ( query.
value(0).toInt() );
135 pCaptureCard->setParentId ( query.
value(1).toInt() );
136 pCaptureCard->setVideoDevice ( query.
value(2).toString() );
137 pCaptureCard->setAudioDevice ( query.
value(3).toString() );
138 pCaptureCard->setVBIDevice ( query.
value(4).toString() );
139 pCaptureCard->setCardType ( query.
value(5).toString() );
140 pCaptureCard->setDefaultInput ( query.
value(6).toString() );
141 pCaptureCard->setAudioRateLimit ( query.
value(7).toUInt() );
142 pCaptureCard->setHostName ( query.
value(8).toString() );
143 pCaptureCard->setDVBSWFilter ( query.
value(9).toUInt() );
144 pCaptureCard->setDVBSatType ( query.
value(10).toUInt() );
145 pCaptureCard->setDVBWaitForSeqStart( query.
value(11).toBool() );
146 pCaptureCard->setSkipBTAudio ( query.
value(12).toBool() );
147 pCaptureCard->setDVBOnDemand ( query.
value(13).toBool() );
148 pCaptureCard->setDVBDiSEqCType ( query.
value(14).toUInt() );
149 pCaptureCard->setFirewireSpeed ( query.
value(15).toUInt() );
150 pCaptureCard->setFirewireModel ( query.
value(16).toString() );
151 pCaptureCard->setFirewireConnection( query.
value(17).toUInt() );
152 pCaptureCard->setSignalTimeout ( query.
value(18).toUInt() );
153 pCaptureCard->setChannelTimeout ( query.
value(19).toUInt() );
154 pCaptureCard->setDVBTuningDelay ( query.
value(20).toUInt() );
155 pCaptureCard->setContrast ( query.
value(21).toUInt() );
156 pCaptureCard->setBrightness ( query.
value(22).toUInt() );
157 pCaptureCard->setColour ( query.
value(23).toUInt() );
158 pCaptureCard->setHue ( query.
value(24).toUInt() );
159 pCaptureCard->setDiSEqCId ( query.
value(25).toUInt() );
160 pCaptureCard->setDVBEITScan ( query.
value(26).toBool() );
161 pCaptureCard->setInputName ( query.
value(27).toString() );
162 pCaptureCard->setSourceId ( query.
value(28).toInt() );
163 pCaptureCard->setExternalCommand ( query.
value(29).toString() );
164 pCaptureCard->setChangerDevice ( query.
value(30).toString() );
165 pCaptureCard->setChangerModel ( query.
value(31).toString() );
166 pCaptureCard->setTuneChannel ( query.
value(32).toString() );
167 pCaptureCard->setStartChannel ( query.
value(33).toString() );
168 pCaptureCard->setDisplayName ( query.
value(34).toString() );
169 pCaptureCard->setDishnetEit ( query.
value(35).toBool() );
170 pCaptureCard->setRecPriority ( query.
value(36).toInt() );
171 pCaptureCard->setQuickTune ( query.
value(37).toBool() );
172 pCaptureCard->setSchedOrder ( query.
value(38).toUInt() );
173 pCaptureCard->setLiveTVOrder ( query.
value(39).toUInt() );
174 pCaptureCard->setRecLimit ( query.
value(40).toUInt() );
175 pCaptureCard->setSchedGroup ( query.
value(41).toBool() );
188 throw( QString(
"The Card ID is invalid."));
193 throw( QString(
"Database not open while trying to list "
194 "V2Capture Cards."));
196 QString str =
"SELECT cardid, parentid, videodevice, audiodevice, vbidevice, "
197 "cardtype, defaultinput, audioratelimit, hostname, "
198 "dvb_swfilter, dvb_sat_type, dvb_wait_for_seqstart, "
199 "skipbtaudio, dvb_on_demand, dvb_diseqc_type, "
200 "firewire_speed, firewire_model, firewire_connection, "
201 "signal_timeout, channel_timeout, dvb_tuning_delay, "
202 "contrast, brightness, colour, hue, diseqcid, dvb_eitscan, "
203 "inputname, sourceid, externalcommand, changer_device, "
204 "changer_model, tunechan, startchan, displayname, "
205 "dishnet_eit, recpriority, quicktune, schedorder, "
206 "livetvorder, reclimit, schedgroup "
207 "from capturecard WHERE cardid = :CARDID";
215 throw( QString(
"Database Error executing query." ));
222 pCaptureCard->setCardId ( query.
value(0).toInt() );
223 pCaptureCard->setParentId ( query.
value(1).toInt() );
224 pCaptureCard->setVideoDevice ( query.
value(2).toString() );
225 pCaptureCard->setAudioDevice ( query.
value(3).toString() );
226 pCaptureCard->setVBIDevice ( query.
value(4).toString() );
227 pCaptureCard->setCardType ( query.
value(5).toString() );
228 pCaptureCard->setDefaultInput ( query.
value(6).toString() );
229 pCaptureCard->setAudioRateLimit ( query.
value(7).toUInt() );
230 pCaptureCard->setHostName ( query.
value(8).toString() );
231 pCaptureCard->setDVBSWFilter ( query.
value(9).toUInt() );
232 pCaptureCard->setDVBSatType ( query.
value(10).toUInt() );
233 pCaptureCard->setDVBWaitForSeqStart( query.
value(11).toBool() );
234 pCaptureCard->setSkipBTAudio ( query.
value(12).toBool() );
235 pCaptureCard->setDVBOnDemand ( query.
value(13).toBool() );
236 pCaptureCard->setDVBDiSEqCType ( query.
value(14).toUInt() );
237 pCaptureCard->setFirewireSpeed ( query.
value(15).toUInt() );
238 pCaptureCard->setFirewireModel ( query.
value(16).toString() );
239 pCaptureCard->setFirewireConnection( query.
value(17).toUInt() );
240 pCaptureCard->setSignalTimeout ( query.
value(18).toUInt() );
241 pCaptureCard->setChannelTimeout ( query.
value(19).toUInt() );
242 pCaptureCard->setDVBTuningDelay ( query.
value(20).toUInt() );
243 pCaptureCard->setContrast ( query.
value(21).toUInt() );
244 pCaptureCard->setBrightness ( query.
value(22).toUInt() );
245 pCaptureCard->setColour ( query.
value(23).toUInt() );
246 pCaptureCard->setHue ( query.
value(24).toUInt() );
247 pCaptureCard->setDiSEqCId ( query.
value(25).toUInt() );
248 pCaptureCard->setDVBEITScan ( query.
value(26).toBool() );
249 pCaptureCard->setInputName ( query.
value(27).toString() );
250 pCaptureCard->setSourceId ( query.
value(28).toInt() );
251 pCaptureCard->setExternalCommand ( query.
value(29).toString() );
252 pCaptureCard->setChangerDevice ( query.
value(30).toString() );
253 pCaptureCard->setChangerModel ( query.
value(31).toString() );
254 pCaptureCard->setTuneChannel ( query.
value(32).toString() );
255 pCaptureCard->setStartChannel ( query.
value(33).toString() );
256 pCaptureCard->setDisplayName ( query.
value(34).toString() );
257 pCaptureCard->setDishnetEit ( query.
value(35).toBool() );
258 pCaptureCard->setRecPriority ( query.
value(36).toInt() );
259 pCaptureCard->setQuickTune ( query.
value(37).toBool() );
260 pCaptureCard->setSchedOrder ( query.
value(38).toUInt() );
261 pCaptureCard->setLiveTVOrder ( query.
value(39).toUInt() );
262 pCaptureCard->setRecLimit ( query.
value(40).toUInt() );
263 pCaptureCard->setSchedGroup ( query.
value(41).toBool() );
282 #endif // USING_SATIP
284 bool HDHRdoesDVBC =
false;
285 bool HDHRdoesDVB =
false;
287 #ifdef USING_HDHOMERUN
294 #endif // USING_HDHOMERUN
296 pCardType->setCardId(CardId);
297 pCardType->setSubType (subtype);
301 QMetaEnum meta = QMetaEnum::fromType<CardUtil::INPUT_TYPES>();
302 QString key = meta.valueToKeys(
static_cast<uint>(cardType));
303 QStringList keyList = key.split(
"|");
305 if (keyList.length() > 1 && keyList[1].startsWith(
"DV"))
308 pCardType->setInputType (key);
309 pCardType->setHDHRdoesDVBC (HDHRdoesDVBC);
310 pCardType->setHDHRdoesDVB (HDHRdoesDVB);
327 throw( QString(
"The Card ID is invalid."));
339 const QString &sAudioDevice,
340 const QString &sVBIDevice,
342 const uint nAudioRateLimit,
343 const QString &sHostName,
344 const uint nDVBSWFilter,
345 const uint nDVBSatType,
346 bool bDVBWaitForSeqStart,
349 const uint nDVBDiSEqCType,
350 const uint nFirewireSpeed,
351 const QString &sFirewireModel,
352 const uint nFirewireConnection,
353 const uint nSignalTimeout,
354 const uint nChannelTimeout,
355 const uint nDVBTuningDelay,
356 const uint nContrast,
357 const uint nBrightness,
360 const uint nDiSEqCId,
363 if ( sVideoDevice.isEmpty() ||
CardType.isEmpty() || sHostName.isEmpty() )
364 throw( QString(
"This API requires at least a video device node, a card type, "
365 "and a hostname." ));
368 sVBIDevice,
CardType, nAudioRateLimit,
369 sHostName, nDVBSWFilter, nDVBSatType, bDVBWaitForSeqStart,
370 bSkipBTAudio, bDVBOnDemand, nDVBDiSEqCType, nFirewireSpeed,
371 sFirewireModel, nFirewireConnection, std::chrono::milliseconds(nSignalTimeout),
372 std::chrono::milliseconds(nChannelTimeout), nDVBTuningDelay, nContrast, nBrightness,
373 nColour, nHue, nDiSEqCId, bDVBEITScan);
376 throw( QString(
"Unable to create capture device." ));
382 const QString &sSetting,
383 const QString &sValue )
385 if ( nCardId < 1 || sSetting.isEmpty() || sValue.isEmpty() )
386 throw( QString(
"Card ID, Setting Name, and Value are required." ));
395 if ( nCardInputId < 1 )
396 throw( QString(
"The Input ID is invalid."));
404 const uint nSourceId,
405 const QString &sInputName,
406 const QString &sExternalCommand,
407 const QString &sChangerDevice,
408 const QString &sChangerModel,
409 const QString &sHostName,
410 const QString &sTuneChan,
411 const QString &sStartChan,
412 const QString &sDisplayName,
414 const uint nRecPriority,
415 const uint nQuicktune,
416 const uint nSchedOrder,
417 const uint nLiveTVOrder)
419 if ( nCardId < 1 || nSourceId < 1 ||
420 sInputName.isEmpty() || sInputName ==
"None" )
421 throw( QString(
"This API requires at least a card ID, a source ID, "
422 "and an input name." ));
425 throw QString(
" DisplayName is not set or is not unique.");
428 sExternalCommand, sChangerDevice, sChangerModel,
429 sHostName, sTuneChan, sStartChan, sDisplayName,
430 bDishnetEIT, nRecPriority, nQuicktune, nSchedOrder,
437 const QString &sSetting,
438 const QString &sValue )
440 if ( nCardInputId < 1 || sSetting.isEmpty() || sValue.isEmpty() )
441 throw( QString(
"Input ID, Setting Name, and Value are required." ));
451 pCardTypeList->AddCardType(
452 QObject::tr(
"DVB-T/S/C, ATSC or ISDB-T tuner card"),
"DVB");
456 pCardTypeList->AddCardType(
457 QObject::tr(
"V4L2 encoder"),
"V4L2ENC");
458 pCardTypeList->AddCardType(
459 QObject::tr(
"HD-PVR H.264 encoder"),
"HDPVR");
462 #ifdef USING_HDHOMERUN
463 pCardTypeList->AddCardType(
464 QObject::tr(
"HDHomeRun networked tuner"),
"HDHOMERUN");
465 #endif // USING_HDHOMERUN
468 pCardTypeList->AddCardType(
469 QObject::tr(
"Sat>IP networked tuner"),
"SATIP");
470 #endif // USING_SATIP
473 pCardTypeList->AddCardType(
474 QObject::tr(
"V@Box TV Gateway networked tuner"),
"VBOX");
477 #ifdef USING_FIREWIRE
478 pCardTypeList->AddCardType(
479 QObject::tr(
"FireWire cable box"),
"FIREWIRE");
480 #endif // USING_FIREWIRE
483 pCardTypeList->AddCardType(
484 QObject::tr(
"Ceton Cablecard tuner"),
"CETON");
485 #endif // USING_CETON
488 pCardTypeList->AddCardType(QObject::tr(
"IPTV recorder"),
"FREEBOX");
492 pCardTypeList->AddCardType(
493 QObject::tr(
"Analog to MPEG-2 encoder card (PVR-150/250/350, etc)"),
"MPEG");
494 pCardTypeList->AddCardType(
495 QObject::tr(
"Analog to MJPEG encoder card (Matrox G200, DC10, etc)"),
"MJPEG");
496 pCardTypeList->AddCardType(
497 QObject::tr(
"Analog to MPEG-4 encoder (Plextor ConvertX USB, etc)"),
499 pCardTypeList->AddCardType(
500 QObject::tr(
"Analog capture card"),
"V4L");
504 pCardTypeList->AddCardType(QObject::tr(
"DVEO ASI recorder"),
"ASI");
507 pCardTypeList->AddCardType(QObject::tr(
"Import test recorder"),
"IMPORT");
508 pCardTypeList->AddCardType(QObject::tr(
"Demo test recorder"),
"DEMO");
509 #if !defined( USING_MINGW ) && !defined( _MSC_VER )
510 pCardTypeList->AddCardType(QObject::tr(
"External (black box) recorder"),
513 return pCardTypeList;
523 throw( QString(
"Database not open while trying to list "
526 QString q =
"SELECT cardinputid,inputgroupid,inputgroupname "
527 "FROM inputgroup WHERE inputgroupname LIKE 'user:%' "
528 "ORDER BY inputgroupid, cardinputid";
534 return pInputGroupList;
539 pInputGroupList->AddInputGroup(query.
value(0).toUInt(),
540 query.
value(1).toUInt(),
541 query.
value(2).toString());
544 return pInputGroupList;
550 throw( QString(
"Input group name cannot be empty." ) );
552 QString new_name = QString(
"user:") +
Name;
556 if (inputgroupid == 0)
558 throw( QString(
"Failed to add or retrieve %1" ).arg(new_name) );
565 const uint InputGroupId)
568 throw( QString (
"Failed to link input %1 to group %2" )
569 .arg(InputId).arg(InputGroupId));
575 const uint InputGroupId)
578 throw( QString (
"Failed to unlink input %1 from group %2" )
579 .arg(InputId).arg(InputGroupId));
594 QString short_name = name;
595 if (short_name.startsWith(
"LG Electronics"))
596 short_name = short_name.right(short_name.length() - 15);
597 if (short_name.startsWith(
"Oren"))
598 short_name = short_name.right(short_name.length() - 5);
599 if (short_name.startsWith(
"Nextwave"))
600 short_name = short_name.right(short_name.length() - 9);
601 if (short_name.startsWith(
"frontend", Qt::CaseInsensitive))
602 short_name = short_name.left(short_name.length() - 9);
603 if (short_name.endsWith(
"VSB/QAM"))
604 short_name = short_name.left(short_name.length() - 8);
605 if (short_name.endsWith(
"VSB"))
606 short_name = short_name.left(short_name.length() - 4);
607 if (short_name.endsWith(
"DVB-T"))
608 short_name = short_name.left(short_name.length() - 6);
614 short_name = short_name.simplified();
615 if (short_name.startsWith(
"or51211", Qt::CaseInsensitive))
616 short_name =
"pcHDTV HD-2000";
617 else if (short_name.startsWith(
"or51132", Qt::CaseInsensitive))
618 short_name =
"pcHDTV HD-3000";
619 else if (short_name.startsWith(
"bcm3510", Qt::CaseInsensitive))
620 short_name =
"Air2PC v1";
621 else if (short_name.startsWith(
"nxt2002", Qt::CaseInsensitive) ||
622 short_name.startsWith(
"nxt200x", Qt::CaseInsensitive))
623 short_name =
"Air2PC v2";
624 else if (short_name.startsWith(
"lgdt3302", Qt::CaseInsensitive))
625 short_name =
"DViCO HDTV3";
626 else if (short_name.startsWith(
"lgdt3303", Qt::CaseInsensitive))
627 short_name =
"DViCO v2 or Air2PC v3 or pcHDTV HD-5500";
639 QRegularExpression drv {
"^(?!ivtv|hdpvr|(saa7164(.*))).*$" };
643 QRegularExpression drv {
"^hdpvr$" };
654 for (
const auto & it : std::as_const(sdevs))
656 auto* pDev = pList->AddCaptureDevice();
658 pDev->setVideoDevice (it);
667 int signalTimeout = 0;
668 int channelTimeout = 0;
670 QString err_open = tr(
"Could not open card %1").arg(it);
671 QString err_other = tr(
"Could not get card info for card %1").arg(it);
676 frontendName = err_open;
677 subType = strerror(errno);
680 frontendName = err_other;
681 subType =
"Unknown error";
684 frontendName = err_other;
685 subType = strerror(errno);
689 signalTimeout = 7000;
690 channelTimeout = 10000;
694 signalTimeout = 7000;
695 channelTimeout = 10000;
699 signalTimeout = 3000;
700 channelTimeout = 6000;
704 signalTimeout = 3000;
705 channelTimeout = 6000;
710 signalTimeout = 3000;
711 channelTimeout = 6000;
712 if (frontendName.toLower().indexOf(
"usb") >= 0)
714 signalTimeout = 40000;
715 channelTimeout = 42500;
719 if ((frontendName ==
"DiBcom 3000P/M-C DVB-T") ||
721 "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver"))
731 frontendName = short_name;
732 signalTimeout = 2000;
733 channelTimeout = 4000;
737 if (frontendName ==
"Nextwave NXT200X VSB/QAM frontend")
739 signalTimeout = 3000;
740 channelTimeout = 5500;
748 pDev->setFrontendName ( frontendName );
749 pDev->setSubType ( subType );
750 pDev->setSignalTimeout ( signalTimeout );
751 pDev->setChannelTimeout ( channelTimeout );
752 pDev->setTuningDelay ( tuningDelay );
757 pDev->setSignalTimeout ( 3000 );
758 pDev->setChannelTimeout ( 6000 );
763 pDev->setSignalTimeout ( 7000 );
764 pDev->setChannelTimeout ( 10000 );
767 auto word = it.split(
' ');
769 if (word.size() == 5) {
770 pDev->setVideoDevice(QString(
"%1:%2:%3").arg(word[0], word[4], word[3]));
771 pDev->setVideoDevicePrompt(QString(
"%1, %2, Tuner #%3").arg(word[0], word[4], word[3]));
772 pDev->setDescription(word[1]);
773 pDev->setIPAddress(word[2]);
774 pDev->setTunerType(word[4]);
775 pDev->setTunerNumber(word[3].toUInt());
778 #endif // USING_SATIP
782 pDev->setSignalTimeout ( 7000 );
783 pDev->setChannelTimeout ( 10000 );
786 auto word = it.split(
" ");
787 if (word.size() == 4) {
788 QString device = QString(
"%1-%2-%3").arg(word[0], word[2], word[3]);
789 pDev->setVideoDevice(device);
790 pDev->setVideoDevicePrompt(device);
792 pDev->setDescription(desc);
793 pDev->setIPAddress(word[1]);
794 pDev->setTunerType(word[3]);
795 pDev->setTunerNumber(word[2].toUInt());
810 throw( QString(
"Database not open while trying to list "
813 QString str =
"SELECT diseqcid, "
832 "FROM diseqc_tree ORDER BY diseqcid";
839 throw( QString(
"Database Error executing query." ));
850 auto *pRec = pList->AddDiseqcTree();
851 pRec->setDiSEqCId ( query.
value( 0 ).toUInt() );
852 pRec->setParentId ( query.
value( 1 ).toUInt() );
853 pRec->setOrdinal ( query.
value( 2 ).toUInt() );
854 pRec->setType ( query.
value( 3 ).toString() );
855 pRec->setSubType ( query.
value( 4 ).toString() );
856 pRec->setDescription ( query.
value( 5 ).toString() );
857 pRec->setSwitchPorts ( query.
value( 6 ).toUInt() );
858 pRec->setRotorHiSpeed ( query.
value( 7 ).toFloat() );
859 pRec->setRotorLoSpeed ( query.
value( 8 ).toFloat() );
860 pRec->setRotorPositions ( query.
value( 9 ).toString() );
861 pRec->setLnbLofSwitch ( query.
value( 10 ).toInt() );
862 pRec->setLnbLofHi ( query.
value( 11 ).toInt() );
863 pRec->setLnbLofLo ( query.
value( 12 ).toInt() );
864 pRec->setCmdRepeat ( query.
value( 13 ).toInt() );
865 pRec->setLnbPolInv ( query.
value( 14 ).toBool() );
866 pRec->setAddress ( query.
value( 15 ).toInt() );
867 pRec->setScrUserband ( query.
value( 16 ).toUInt() );
868 pRec->setScrFrequency ( query.
value( 17 ).toUInt() );
869 pRec->setScrPin ( query.
value( 18 ).toInt() );
878 const QString& SubType,
879 const QString& Description,
883 const QString& RotorPositions,
897 "INSERT INTO diseqc_tree "
938 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
939 query.
bindValue(
":PARENTID", QVariant(QVariant::UInt));
941 query.
bindValue(
":PARENTID", QVariant(QMetaType(QMetaType::UInt)));
951 query.
bindValue(
":DESCRIPTION", Description);
952 query.
bindValue(
":SWITCH_PORTS", SwitchPorts);
953 query.
bindValue(
":ROTOR_HI_SPEED", RotorHiSpeed);
954 query.
bindValue(
":ROTOR_LO_SPEED", RotorLoSpeed);
955 query.
bindValue(
":ROTOR_POSITIONS", RotorPositions);
956 query.
bindValue(
":LNB_LOF_SWITCH", LnbLofSwitch);
957 query.
bindValue(
":LNB_LOF_HI", LnbLofHi);
958 query.
bindValue(
":LNB_LOF_LO", LnbLofLo);
959 query.
bindValue(
":CMD_REPEAT", CmdRepeat);
960 query.
bindValue(
":LNB_POL_INV", LnbPolInv);
962 query.
bindValue(
":SCR_USERBAND", ScrUserband);
963 query.
bindValue(
":SCR_FREQUENCY", ScrFrequency);
969 throw( QString(
"Database Error executing query." ));
979 const QString& SubType,
980 const QString& Description,
984 const QString& RotorPositions,
998 "UPDATE diseqc_tree SET "
999 "parentid = :PARENTID, "
1000 "ordinal = :ORDINAL, "
1002 "subtype = :SUBTYPE, "
1003 "description = :DESCRIPTION, "
1004 "switch_ports = :SWITCH_PORTS, "
1005 "rotor_hi_speed = :ROTOR_HI_SPEED, "
1006 "rotor_lo_speed = :ROTOR_LO_SPEED, "
1007 "rotor_positions = :ROTOR_POSITIONS, "
1008 "lnb_lof_switch = :LNB_LOF_SWITCH, "
1009 "lnb_lof_hi = :LNB_LOF_HI, "
1010 "lnb_lof_lo = :LNB_LOF_LO, "
1011 "cmd_repeat = :CMD_REPEAT, "
1012 "lnb_pol_inv = :LNB_POL_INV, "
1013 "address = :ADDRESS, "
1014 "scr_userband = :SCR_USERBAND, "
1015 "scr_frequency = :SCR_FREQUENCY, "
1016 "scr_pin = :SCR_PIN "
1017 "WHERE diseqcid = :DISEQCID " );
1022 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
1023 query.
bindValue(
":PARENTID", QVariant(QVariant::UInt));
1025 query.
bindValue(
":PARENTID", QVariant(QMetaType(QMetaType::UInt)));
1035 query.
bindValue(
":DESCRIPTION", Description);
1036 query.
bindValue(
":SWITCH_PORTS", SwitchPorts);
1037 query.
bindValue(
":ROTOR_HI_SPEED", RotorHiSpeed);
1038 query.
bindValue(
":ROTOR_LO_SPEED", RotorLoSpeed);
1039 query.
bindValue(
":ROTOR_POSITIONS", RotorPositions);
1040 query.
bindValue(
":LNB_LOF_SWITCH", LnbLofSwitch);
1041 query.
bindValue(
":LNB_LOF_HI", LnbLofHi);
1042 query.
bindValue(
":LNB_LOF_LO", LnbLofLo);
1043 query.
bindValue(
":CMD_REPEAT", CmdRepeat);
1044 query.
bindValue(
":LNB_POL_INV", LnbPolInv);
1046 query.
bindValue(
":SCR_USERBAND", ScrUserband);
1047 query.
bindValue(
":SCR_FREQUENCY", ScrFrequency);
1053 throw( QString(
"Database Error executing query." ));
1062 query.
prepare(
"SELECT diseqcid FROM diseqc_tree WHERE parentid = :PARENTID ");
1068 throw( QString(
"Database Error executing query." ));
1071 bool childOK =
true;
1072 while (query.
next())
1079 query2.
prepare(
"DELETE FROM diseqc_tree WHERE diseqcid = :DISEQCID ");
1080 query2.
bindValue(
":DISEQCID", DiSEqCId);
1084 throw( QString(
"Database Error executing query." ));
1087 return numrows > 0 && childOK;
1097 throw( QString(
"Database not open while trying to list "
1100 QString str =
"SELECT cardinputid, "
1103 "FROM diseqc_config ORDER BY cardinputid, diseqcid";
1110 throw( QString(
"Database Error executing query." ));
1119 while (query.
next())
1121 auto *pRec = pList->AddDiseqcConfig();
1122 pRec->setCardId ( query.
value( 0 ).toUInt() );
1123 pRec->setDiSEqCId ( query.
value( 1 ).toUInt() );
1124 pRec->setValue ( query.
value( 2 ).toString() );
1131 const QString& Value)
1136 "INSERT INTO diseqc_config "
1152 throw( QString(
"Database Error executing query." ));
1161 query.
prepare(
"DELETE FROM diseqc_config WHERE cardinputid = :CARDID ");
1166 throw( QString(
"Database Error executing query." ));
1178 "SELECT profilegroups.id, profilegroups.name, cardtype, recordingprofiles.id, recordingprofiles.name, "
1179 "videocodec, audiocodec, "
1180 "codecparams.name, codecparams.value "
1181 "FROM profilegroups "
1182 "INNER JOIN recordingprofiles on profilegroups.id = recordingprofiles.profilegroup "
1183 "LEFT OUTER JOIN codecparams on codecparams.profile = recordingprofiles.id ";
1184 QString where =
"WHERE ";
1187 str.append(where).append(
"CARDTYPE = 'TRANSCODE' OR (cardtype in (SELECT cardtype FROM capturecard)) ");
1192 str.append(where).append(
"profilegroups.id = :GROUPID ");
1197 str.append(where).append(
"recordingprofiles.id = :PROFILEID ");
1202 "ORDER BY IF(cardtype = 'TRANSCODE', 9999, profilegroups.id), recordingprofiles.id, codecparams.name ");
1209 query.
bindValue(
":PROFILEID", ProfileId);
1214 throw( QString(
"Database Error executing query." ));
1223 int prevGroupId = -1;
1224 int prevProfileId = -1;
1229 while (query.
next())
1231 int groupId = query.
value(0).toInt();
1232 if (groupId != prevGroupId)
1234 pGroup = pList->AddProfileGroup();
1235 pGroup->setId ( groupId );
1236 pGroup->setName ( query.
value(1).toString() );
1237 pGroup->setCardType ( query.
value(2).toString() );
1238 prevGroupId = groupId;
1240 int profileId = query.
value(3).toInt();
1244 if (profileId != prevProfileId && pGroup !=
nullptr)
1247 pProfile->setId ( profileId );
1248 pProfile->setName ( query.
value(4).toString() );
1249 pProfile->setVideoCodec ( query.
value(5).toString() );
1250 pProfile->setAudioCodec ( query.
value(6).toString() );
1251 prevProfileId = profileId;
1256 if (!query.
isNull(7) && pProfile !=
nullptr)
1258 auto *pParam = pProfile->
AddParam();
1259 pParam->setName ( query.
value(7).toString() );
1260 pParam->setValue ( query.
value(8).toString() );
1268 const QString& VideoCodec,
const QString& AudioCodec )
1270 if (GroupId == 0 || ProfileName.isEmpty())
1272 LOG(VB_GENERAL, LOG_ERR,
1273 QString(
"AddRecProfile: GroupId and ProfileName are required." ));
1282 "FROM recordingprofiles "
1283 "WHERE name = :NAME AND profilegroup = :PROFILEGROUP;");
1285 query.
bindValue(
":PROFILEGROUP", GroupId);
1289 throw( QString(
"Database Error executing SELECT." ));
1293 int id = query.
value(0).toInt();
1294 LOG(VB_GENERAL, LOG_ERR,
1295 QString(
"Profile %1 already exists in group id %2 with id %3").arg(ProfileName).arg(GroupId).arg(
id));
1300 "INSERT INTO recordingprofiles "
1301 "(name, videocodec, audiocodec, profilegroup) "
1303 "(:NAME, :VIDEOCODEC, :AUDIOCODEC, :PROFILEGROUP);");
1305 query.
bindValue(
":VIDEOCODEC", VideoCodec);
1306 query.
bindValue(
":AUDIOCODEC", AudioCodec);
1307 query.
bindValue(
":PROFILEGROUP", GroupId);
1311 throw( QString(
"Database Error executing INSERT." ));
1322 const QString& VideoCodec,
1323 const QString& AudioCodec )
1327 "SELECT id from recordingprofiles "
1328 "WHERE id = :ID; ");
1333 throw( QString(
"Database Error executing SELECT." ));
1338 id = query.
value(0).toUInt();
1340 if (
id != ProfileId)
1342 LOG(VB_GENERAL, LOG_ERR,
1343 QString(
"UpdateRecProfile: Profile id %1 does not exist").arg(ProfileId));
1347 "UPDATE recordingprofiles "
1348 "SET videocodec = :VIDEOCODEC, "
1349 "audiocodec = :AUDIOCODEC "
1350 "WHERE id = :ID; ");
1351 query.
bindValue(
":VIDEOCODEC", VideoCodec);
1352 query.
bindValue(
":AUDIOCODEC", AudioCodec);
1357 throw( QString(
"Database Error executing UPDATE." ));
1371 "DELETE from codecparams "
1372 "WHERE profile = :ID; ");
1377 throw( QString(
"Database Error executing DELETE." ));
1381 "DELETE from recordingprofiles "
1382 "WHERE id = :ID; ");
1387 throw( QString(
"Database Error executing DELETE." ));
1398 "REPLACE INTO codecparams "
1399 "(profile, name, value) "
1401 "(:PROFILE, :NAME, :VALUE);");
1408 throw( QString(
"Database Error executing REPLACE." ));