37 #include "libmythbase/mythversion.h"
51 qRegisterMetaType<V2CaptureCardList*>(
"V2CaptureCardList");
52 qRegisterMetaType<V2CaptureCard*>(
"V2CaptureCard");
53 qRegisterMetaType<V2CardTypeList*>(
"V2CardTypeList");
54 qRegisterMetaType<V2CardType*>(
"V2CardType");
55 qRegisterMetaType<V2CaptureDeviceList*>(
"V2CaptureDeviceList");
56 qRegisterMetaType<V2CaptureDevice*>(
"V2CaptureDevice");
57 qRegisterMetaType<V2DiseqcTree*>(
"V2DiseqcTree");
58 qRegisterMetaType<V2DiseqcTreeList*>(
"V2DiseqcTreeList");
59 qRegisterMetaType<V2InputGroupList*>(
"V2InputGroupList");
60 qRegisterMetaType<V2InputGroup*>(
"V2InputGroup");
61 qRegisterMetaType<V2DiseqcConfig*>(
"V2DiseqcConfig");
62 qRegisterMetaType<V2DiseqcConfigList*>(
"V2DiseqcConfigList");
63 qRegisterMetaType<V2RecProfParam*>(
"V2RecProfParam");
64 qRegisterMetaType<V2RecProfile*>(
"V2RecProfile");
65 qRegisterMetaType<V2RecProfileGroup*>(
"V2RecProfileGroup");
66 qRegisterMetaType<V2RecProfileGroupList*>(
"V2RecProfileGroupList");
84 throw( QString(
"Database not open while trying to list "
87 QString str =
"SELECT cardid, parentid, videodevice, audiodevice, vbidevice, "
88 "cardtype, defaultinput, audioratelimit, hostname, "
89 "dvb_swfilter, dvb_sat_type, dvb_wait_for_seqstart, "
90 "skipbtaudio, dvb_on_demand, dvb_diseqc_type, "
91 "firewire_speed, firewire_model, firewire_connection, "
92 "signal_timeout, channel_timeout, dvb_tuning_delay, "
93 "contrast, brightness, colour, hue, diseqcid, dvb_eitscan, "
94 "inputname, sourceid, externalcommand, changer_device, "
95 "changer_model, tunechan, startchan, displayname, "
96 "dishnet_eit, recpriority, quicktune, schedorder, "
97 "livetvorder, reclimit, schedgroup "
100 if (!sHostName.isEmpty())
101 str +=
" WHERE hostname = :HOSTNAME";
103 str +=
" WHERE cardtype = :CARDTYPE";
105 if (!sHostName.isEmpty() && !
CardType.isEmpty())
106 str +=
" AND cardtype = :CARDTYPE";
110 if (!sHostName.isEmpty())
118 throw( QString(
"Database Error executing query." ));
132 pCaptureCard->setCardId ( query.
value(0).toInt() );
133 pCaptureCard->setParentId ( query.
value(1).toInt() );
134 pCaptureCard->setVideoDevice ( query.
value(2).toString() );
135 pCaptureCard->setAudioDevice ( query.
value(3).toString() );
136 pCaptureCard->setVBIDevice ( query.
value(4).toString() );
137 pCaptureCard->setCardType ( query.
value(5).toString() );
138 pCaptureCard->setDefaultInput ( query.
value(6).toString() );
139 pCaptureCard->setAudioRateLimit ( query.
value(7).toUInt() );
140 pCaptureCard->setHostName ( query.
value(8).toString() );
141 pCaptureCard->setDVBSWFilter ( query.
value(9).toUInt() );
142 pCaptureCard->setDVBSatType ( query.
value(10).toUInt() );
143 pCaptureCard->setDVBWaitForSeqStart( query.
value(11).toBool() );
144 pCaptureCard->setSkipBTAudio ( query.
value(12).toBool() );
145 pCaptureCard->setDVBOnDemand ( query.
value(13).toBool() );
146 pCaptureCard->setDVBDiSEqCType ( query.
value(14).toUInt() );
147 pCaptureCard->setFirewireSpeed ( query.
value(15).toUInt() );
148 pCaptureCard->setFirewireModel ( query.
value(16).toString() );
149 pCaptureCard->setFirewireConnection( query.
value(17).toUInt() );
150 pCaptureCard->setSignalTimeout ( query.
value(18).toUInt() );
151 pCaptureCard->setChannelTimeout ( query.
value(19).toUInt() );
152 pCaptureCard->setDVBTuningDelay ( query.
value(20).toUInt() );
153 pCaptureCard->setContrast ( query.
value(21).toUInt() );
154 pCaptureCard->setBrightness ( query.
value(22).toUInt() );
155 pCaptureCard->setColour ( query.
value(23).toUInt() );
156 pCaptureCard->setHue ( query.
value(24).toUInt() );
157 pCaptureCard->setDiSEqCId ( query.
value(25).toUInt() );
158 pCaptureCard->setDVBEITScan ( query.
value(26).toBool() );
159 pCaptureCard->setInputName ( query.
value(27).toString() );
160 pCaptureCard->setSourceId ( query.
value(28).toInt() );
161 pCaptureCard->setExternalCommand ( query.
value(29).toString() );
162 pCaptureCard->setChangerDevice ( query.
value(30).toString() );
163 pCaptureCard->setChangerModel ( query.
value(31).toString() );
164 pCaptureCard->setTuneChannel ( query.
value(32).toString() );
165 pCaptureCard->setStartChannel ( query.
value(33).toString() );
166 pCaptureCard->setDisplayName ( query.
value(34).toString() );
167 pCaptureCard->setDishnetEit ( query.
value(35).toBool() );
168 pCaptureCard->setRecPriority ( query.
value(36).toInt() );
169 pCaptureCard->setQuickTune ( query.
value(37).toBool() );
170 pCaptureCard->setSchedOrder ( query.
value(38).toUInt() );
171 pCaptureCard->setLiveTVOrder ( query.
value(39).toUInt() );
172 pCaptureCard->setRecLimit ( query.
value(40).toUInt() );
173 pCaptureCard->setSchedGroup ( query.
value(41).toBool() );
186 throw( QString(
"The Card ID is invalid."));
191 throw( QString(
"Database not open while trying to list "
192 "V2Capture Cards."));
194 QString str =
"SELECT cardid, parentid, videodevice, audiodevice, vbidevice, "
195 "cardtype, defaultinput, audioratelimit, hostname, "
196 "dvb_swfilter, dvb_sat_type, dvb_wait_for_seqstart, "
197 "skipbtaudio, dvb_on_demand, dvb_diseqc_type, "
198 "firewire_speed, firewire_model, firewire_connection, "
199 "signal_timeout, channel_timeout, dvb_tuning_delay, "
200 "contrast, brightness, colour, hue, diseqcid, dvb_eitscan, "
201 "inputname, sourceid, externalcommand, changer_device, "
202 "changer_model, tunechan, startchan, displayname, "
203 "dishnet_eit, recpriority, quicktune, schedorder, "
204 "livetvorder, reclimit, schedgroup "
205 "from capturecard WHERE cardid = :CARDID";
213 throw( QString(
"Database Error executing query." ));
220 pCaptureCard->setCardId ( query.
value(0).toInt() );
221 pCaptureCard->setParentId ( query.
value(1).toInt() );
222 pCaptureCard->setVideoDevice ( query.
value(2).toString() );
223 pCaptureCard->setAudioDevice ( query.
value(3).toString() );
224 pCaptureCard->setVBIDevice ( query.
value(4).toString() );
225 pCaptureCard->setCardType ( query.
value(5).toString() );
226 pCaptureCard->setDefaultInput ( query.
value(6).toString() );
227 pCaptureCard->setAudioRateLimit ( query.
value(7).toUInt() );
228 pCaptureCard->setHostName ( query.
value(8).toString() );
229 pCaptureCard->setDVBSWFilter ( query.
value(9).toUInt() );
230 pCaptureCard->setDVBSatType ( query.
value(10).toUInt() );
231 pCaptureCard->setDVBWaitForSeqStart( query.
value(11).toBool() );
232 pCaptureCard->setSkipBTAudio ( query.
value(12).toBool() );
233 pCaptureCard->setDVBOnDemand ( query.
value(13).toBool() );
234 pCaptureCard->setDVBDiSEqCType ( query.
value(14).toUInt() );
235 pCaptureCard->setFirewireSpeed ( query.
value(15).toUInt() );
236 pCaptureCard->setFirewireModel ( query.
value(16).toString() );
237 pCaptureCard->setFirewireConnection( query.
value(17).toUInt() );
238 pCaptureCard->setSignalTimeout ( query.
value(18).toUInt() );
239 pCaptureCard->setChannelTimeout ( query.
value(19).toUInt() );
240 pCaptureCard->setDVBTuningDelay ( query.
value(20).toUInt() );
241 pCaptureCard->setContrast ( query.
value(21).toUInt() );
242 pCaptureCard->setBrightness ( query.
value(22).toUInt() );
243 pCaptureCard->setColour ( query.
value(23).toUInt() );
244 pCaptureCard->setHue ( query.
value(24).toUInt() );
245 pCaptureCard->setDiSEqCId ( query.
value(25).toUInt() );
246 pCaptureCard->setDVBEITScan ( query.
value(26).toBool() );
247 pCaptureCard->setInputName ( query.
value(27).toString() );
248 pCaptureCard->setSourceId ( query.
value(28).toInt() );
249 pCaptureCard->setExternalCommand ( query.
value(29).toString() );
250 pCaptureCard->setChangerDevice ( query.
value(30).toString() );
251 pCaptureCard->setChangerModel ( query.
value(31).toString() );
252 pCaptureCard->setTuneChannel ( query.
value(32).toString() );
253 pCaptureCard->setStartChannel ( query.
value(33).toString() );
254 pCaptureCard->setDisplayName ( query.
value(34).toString() );
255 pCaptureCard->setDishnetEit ( query.
value(35).toBool() );
256 pCaptureCard->setRecPriority ( query.
value(36).toInt() );
257 pCaptureCard->setQuickTune ( query.
value(37).toBool() );
258 pCaptureCard->setSchedOrder ( query.
value(38).toUInt() );
259 pCaptureCard->setLiveTVOrder ( query.
value(39).toUInt() );
260 pCaptureCard->setRecLimit ( query.
value(40).toUInt() );
261 pCaptureCard->setSchedGroup ( query.
value(41).toBool() );
279 throw( QString(
"The Card ID is invalid."));
291 const QString &sAudioDevice,
292 const QString &sVBIDevice,
294 const uint nAudioRateLimit,
295 const QString &sHostName,
296 const uint nDVBSWFilter,
297 const uint nDVBSatType,
298 bool bDVBWaitForSeqStart,
301 const uint nDVBDiSEqCType,
302 const uint nFirewireSpeed,
303 const QString &sFirewireModel,
304 const uint nFirewireConnection,
305 const uint nSignalTimeout,
306 const uint nChannelTimeout,
307 const uint nDVBTuningDelay,
308 const uint nContrast,
309 const uint nBrightness,
312 const uint nDiSEqCId,
315 if ( sVideoDevice.isEmpty() ||
CardType.isEmpty() || sHostName.isEmpty() )
316 throw( QString(
"This API requires at least a video device node, a card type, "
317 "and a hostname." ));
320 sVBIDevice,
CardType, nAudioRateLimit,
321 sHostName, nDVBSWFilter, nDVBSatType, bDVBWaitForSeqStart,
322 bSkipBTAudio, bDVBOnDemand, nDVBDiSEqCType, nFirewireSpeed,
323 sFirewireModel, nFirewireConnection, std::chrono::milliseconds(nSignalTimeout),
324 std::chrono::milliseconds(nChannelTimeout), nDVBTuningDelay, nContrast, nBrightness,
325 nColour, nHue, nDiSEqCId, bDVBEITScan);
328 throw( QString(
"Unable to create capture device." ));
334 const QString &sSetting,
335 const QString &sValue )
337 if ( nCardId < 1 || sSetting.isEmpty() || sValue.isEmpty() )
338 throw( QString(
"Card ID, Setting Name, and Value are required." ));
347 if ( nCardInputId < 1 )
348 throw( QString(
"The Input ID is invalid."));
356 const uint nSourceId,
357 const QString &sInputName,
358 const QString &sExternalCommand,
359 const QString &sChangerDevice,
360 const QString &sChangerModel,
361 const QString &sHostName,
362 const QString &sTuneChan,
363 const QString &sStartChan,
364 const QString &sDisplayName,
366 const uint nRecPriority,
367 const uint nQuicktune,
368 const uint nSchedOrder,
369 const uint nLiveTVOrder)
371 if ( nCardId < 1 || nSourceId < 1 ||
372 sInputName.isEmpty() || sInputName ==
"None" )
373 throw( QString(
"This API requires at least a card ID, a source ID, "
374 "and an input name." ));
377 throw QString(
" DisplayName is not set or is not unique.");
380 sExternalCommand, sChangerDevice, sChangerModel,
381 sHostName, sTuneChan, sStartChan, sDisplayName,
382 bDishnetEIT, nRecPriority, nQuicktune, nSchedOrder,
389 const QString &sSetting,
390 const QString &sValue )
392 if ( nCardInputId < 1 || sSetting.isEmpty() || sValue.isEmpty() )
393 throw( QString(
"Input ID, Setting Name, and Value are required." ));
403 pCardTypeList->AddCardType(
404 QObject::tr(
"DVB-T/S/C, ATSC or ISDB-T tuner card"),
"DVB");
408 pCardTypeList->AddCardType(
409 QObject::tr(
"V4L2 encoder"),
"V4L2ENC");
410 pCardTypeList->AddCardType(
411 QObject::tr(
"HD-PVR H.264 encoder"),
"HDPVR");
414 #ifdef USING_HDHOMERUN
415 pCardTypeList->AddCardType(
416 QObject::tr(
"HDHomeRun networked tuner"),
"HDHOMERUN");
417 #endif // USING_HDHOMERUN
420 pCardTypeList->AddCardType(
421 QObject::tr(
"Sat>IP networked tuner"),
"SATIP");
422 #endif // USING_SATIP
425 pCardTypeList->AddCardType(
426 QObject::tr(
"V@Box TV Gateway networked tuner"),
"VBOX");
429 #ifdef USING_FIREWIRE
430 pCardTypeList->AddCardType(
431 QObject::tr(
"FireWire cable box"),
"FIREWIRE");
432 #endif // USING_FIREWIRE
435 pCardTypeList->AddCardType(
436 QObject::tr(
"Ceton Cablecard tuner"),
"CETON");
437 #endif // USING_CETON
440 pCardTypeList->AddCardType(QObject::tr(
"IPTV recorder"),
"FREEBOX");
444 pCardTypeList->AddCardType(
445 QObject::tr(
"Analog to MPEG-2 encoder card (PVR-150/250/350, etc)"),
"MPEG");
446 pCardTypeList->AddCardType(
447 QObject::tr(
"Analog to MJPEG encoder card (Matrox G200, DC10, etc)"),
"MJPEG");
448 pCardTypeList->AddCardType(
449 QObject::tr(
"Analog to MPEG-4 encoder (Plextor ConvertX USB, etc)"),
451 pCardTypeList->AddCardType(
452 QObject::tr(
"Analog capture card"),
"V4L");
456 pCardTypeList->AddCardType(QObject::tr(
"DVEO ASI recorder"),
"ASI");
459 pCardTypeList->AddCardType(QObject::tr(
"Import test recorder"),
"IMPORT");
460 pCardTypeList->AddCardType(QObject::tr(
"Demo test recorder"),
"DEMO");
461 #if !defined( USING_MINGW ) && !defined( _MSC_VER )
462 pCardTypeList->AddCardType(QObject::tr(
"External (black box) recorder"),
465 return pCardTypeList;
475 throw( QString(
"Database not open while trying to list "
478 QString q =
"SELECT cardinputid,inputgroupid,inputgroupname "
479 "FROM inputgroup WHERE inputgroupname LIKE 'user:%' "
480 "ORDER BY inputgroupid, cardinputid";
486 return pInputGroupList;
491 pInputGroupList->AddInputGroup(query.
value(0).toUInt(),
492 query.
value(1).toUInt(),
493 query.
value(2).toString());
496 return pInputGroupList;
502 throw( QString(
"Input group name cannot be empty." ) );
504 QString new_name = QString(
"user:") +
Name;
508 if (inputgroupid == 0)
510 throw( QString(
"Failed to add or retrieve %1" ).arg(new_name) );
517 const uint InputGroupId)
520 throw( QString (
"Failed to link input %1 to group %2" )
521 .arg(InputId).arg(InputGroupId));
527 const uint InputGroupId)
530 throw( QString (
"Failed to unlink input %1 from group %2" )
531 .arg(InputId).arg(InputGroupId));
546 QString short_name = name;
547 if (short_name.startsWith(
"LG Electronics"))
548 short_name = short_name.right(short_name.length() - 15);
549 if (short_name.startsWith(
"Oren"))
550 short_name = short_name.right(short_name.length() - 5);
551 if (short_name.startsWith(
"Nextwave"))
552 short_name = short_name.right(short_name.length() - 9);
553 if (short_name.startsWith(
"frontend", Qt::CaseInsensitive))
554 short_name = short_name.left(short_name.length() - 9);
555 if (short_name.endsWith(
"VSB/QAM"))
556 short_name = short_name.left(short_name.length() - 8);
557 if (short_name.endsWith(
"VSB"))
558 short_name = short_name.left(short_name.length() - 4);
559 if (short_name.endsWith(
"DVB-T"))
560 short_name = short_name.left(short_name.length() - 6);
566 short_name = short_name.simplified();
567 if (short_name.startsWith(
"or51211", Qt::CaseInsensitive))
568 short_name =
"pcHDTV HD-2000";
569 else if (short_name.startsWith(
"or51132", Qt::CaseInsensitive))
570 short_name =
"pcHDTV HD-3000";
571 else if (short_name.startsWith(
"bcm3510", Qt::CaseInsensitive))
572 short_name =
"Air2PC v1";
573 else if (short_name.startsWith(
"nxt2002", Qt::CaseInsensitive) ||
574 short_name.startsWith(
"nxt200x", Qt::CaseInsensitive))
575 short_name =
"Air2PC v2";
576 else if (short_name.startsWith(
"lgdt3302", Qt::CaseInsensitive))
577 short_name =
"DViCO HDTV3";
578 else if (short_name.startsWith(
"lgdt3303", Qt::CaseInsensitive))
579 short_name =
"DViCO v2 or Air2PC v3 or pcHDTV HD-5500";
591 QRegularExpression drv {
"^(?!ivtv|hdpvr|(saa7164(.*))).*$" };
598 for (
const auto & it : qAsConst(sdevs))
600 auto* pDev = pList->AddCaptureDevice();
602 pDev->setVideoDevice (it);
611 int signalTimeout = 0;
612 int channelTimeout = 0;
614 QString err_open = tr(
"Could not open card %1").arg(it);
615 QString err_other = tr(
"Could not get card info for card %1").arg(it);
620 frontendName = err_open;
621 subType = strerror(errno);
624 frontendName = err_other;
625 subType =
"Unknown error";
628 frontendName = err_other;
629 subType = strerror(errno);
633 signalTimeout = 7000;
634 channelTimeout = 10000;
638 signalTimeout = 7000;
639 channelTimeout = 10000;
643 signalTimeout = 3000;
644 channelTimeout = 6000;
648 signalTimeout = 3000;
649 channelTimeout = 6000;
654 signalTimeout = 3000;
655 channelTimeout = 6000;
656 if (frontendName.toLower().indexOf(
"usb") >= 0)
658 signalTimeout = 40000;
659 channelTimeout = 42500;
663 if ((frontendName ==
"DiBcom 3000P/M-C DVB-T") ||
665 "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver"))
675 frontendName = short_name;
676 signalTimeout = 2000;
677 channelTimeout = 4000;
681 if (frontendName ==
"Nextwave NXT200X VSB/QAM frontend")
683 signalTimeout = 3000;
684 channelTimeout = 5500;
692 pDev->setFrontendName ( frontendName );
693 pDev->setSubType ( subType );
694 pDev->setSignalTimeout ( signalTimeout );
695 pDev->setChannelTimeout ( channelTimeout );
696 pDev->setTuningDelay ( tuningDelay );
699 #ifdef USING_HDHOMERUN
702 pDev->setSignalTimeout ( 3000 );
703 pDev->setChannelTimeout ( 6000 );
705 #endif //USING_HDHOMERUN
717 throw( QString(
"Database not open while trying to list "
720 QString str =
"SELECT diseqcid, "
739 "FROM diseqc_tree ORDER BY diseqcid";
746 throw( QString(
"Database Error executing query." ));
757 auto *pRec = pList->AddDiseqcTree();
758 pRec->setDiSEqCId ( query.
value( 0 ).toUInt() );
759 pRec->setParentId ( query.
value( 1 ).toUInt() );
760 pRec->setOrdinal ( query.
value( 2 ).toUInt() );
761 pRec->setType ( query.
value( 3 ).toString() );
762 pRec->setSubType ( query.
value( 4 ).toString() );
763 pRec->setDescription ( query.
value( 5 ).toString() );
764 pRec->setSwitchPorts ( query.
value( 6 ).toUInt() );
765 pRec->setRotorHiSpeed ( query.
value( 7 ).toFloat() );
766 pRec->setRotorLoSpeed ( query.
value( 8 ).toFloat() );
767 pRec->setRotorPositions ( query.
value( 9 ).toString() );
768 pRec->setLnbLofSwitch ( query.
value( 10 ).toInt() );
769 pRec->setLnbLofHi ( query.
value( 11 ).toInt() );
770 pRec->setLnbLofLo ( query.
value( 12 ).toInt() );
771 pRec->setCmdRepeat ( query.
value( 13 ).toInt() );
772 pRec->setLnbPolInv ( query.
value( 14 ).toBool() );
773 pRec->setAddress ( query.
value( 15 ).toInt() );
774 pRec->setScrUserband ( query.
value( 16 ).toUInt() );
775 pRec->setScrFrequency ( query.
value( 17 ).toUInt() );
776 pRec->setScrPin ( query.
value( 18 ).toInt() );
785 const QString& SubType,
786 const QString& Description,
790 const QString& RotorPositions,
804 "INSERT INTO diseqc_tree "
845 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
846 query.
bindValue(
":PARENTID", QVariant(QVariant::UInt));
848 query.
bindValue(
":PARENTID", QVariant(QMetaType(QMetaType::UInt)));
856 query.
bindValue(
":DESCRIPTION", Description);
857 query.
bindValue(
":SWITCH_PORTS", SwitchPorts);
858 query.
bindValue(
":ROTOR_HI_SPEED", RotorHiSpeed);
859 query.
bindValue(
":ROTOR_LO_SPEED", RotorLoSpeed);
860 query.
bindValue(
":ROTOR_POSITIONS", RotorPositions);
861 query.
bindValue(
":LNB_LOF_SWITCH", LnbLofSwitch);
862 query.
bindValue(
":LNB_LOF_HI", LnbLofHi);
863 query.
bindValue(
":LNB_LOF_LO", LnbLofLo);
864 query.
bindValue(
":CMD_REPEAT", CmdRepeat);
865 query.
bindValue(
":LNB_POL_INV", LnbPolInv);
867 query.
bindValue(
":SCR_USERBAND", ScrUserband);
868 query.
bindValue(
":SCR_FREQUENCY", ScrFrequency);
874 throw( QString(
"Database Error executing query." ));
884 const QString& SubType,
885 const QString& Description,
889 const QString& RotorPositions,
903 "UPDATE diseqc_tree SET "
904 "parentid = :PARENTID, "
905 "ordinal = :ORDINAL, "
907 "subtype = :SUBTYPE, "
908 "description = :DESCRIPTION, "
909 "switch_ports = :SWITCH_PORTS, "
910 "rotor_hi_speed = :ROTOR_HI_SPEED, "
911 "rotor_lo_speed = :ROTOR_LO_SPEED, "
912 "rotor_positions = :ROTOR_POSITIONS, "
913 "lnb_lof_switch = :LNB_LOF_SWITCH, "
914 "lnb_lof_hi = :LNB_LOF_HI, "
915 "lnb_lof_lo = :LNB_LOF_LO, "
916 "cmd_repeat = :CMD_REPEAT, "
917 "lnb_pol_inv = :LNB_POL_INV, "
918 "address = :ADDRESS, "
919 "scr_userband = :SCR_USERBAND, "
920 "scr_frequency = :SCR_FREQUENCY, "
921 "scr_pin = :SCR_PIN "
922 "WHERE diseqcid = :DISEQCID " );
927 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
928 query.
bindValue(
":PARENTID", QVariant(QVariant::UInt));
930 query.
bindValue(
":PARENTID", QVariant(QMetaType(QMetaType::UInt)));
938 query.
bindValue(
":DESCRIPTION", Description);
939 query.
bindValue(
":SWITCH_PORTS", SwitchPorts);
940 query.
bindValue(
":ROTOR_HI_SPEED", RotorHiSpeed);
941 query.
bindValue(
":ROTOR_LO_SPEED", RotorLoSpeed);
942 query.
bindValue(
":ROTOR_POSITIONS", RotorPositions);
943 query.
bindValue(
":LNB_LOF_SWITCH", LnbLofSwitch);
944 query.
bindValue(
":LNB_LOF_HI", LnbLofHi);
945 query.
bindValue(
":LNB_LOF_LO", LnbLofLo);
946 query.
bindValue(
":CMD_REPEAT", CmdRepeat);
947 query.
bindValue(
":LNB_POL_INV", LnbPolInv);
949 query.
bindValue(
":SCR_USERBAND", ScrUserband);
950 query.
bindValue(
":SCR_FREQUENCY", ScrFrequency);
956 throw( QString(
"Database Error executing query." ));
965 query.
prepare(
"SELECT diseqcid FROM diseqc_tree WHERE parentid = :PARENTID ");
971 throw( QString(
"Database Error executing query." ));
982 query2.
prepare(
"DELETE FROM diseqc_tree WHERE diseqcid = :DISEQCID ");
987 throw( QString(
"Database Error executing query." ));
990 return numrows > 0 && childOK;
1000 throw( QString(
"Database not open while trying to list "
1003 QString str =
"SELECT cardinputid, "
1006 "FROM diseqc_config ORDER BY cardinputid, diseqcid";
1013 throw( QString(
"Database Error executing query." ));
1022 while (query.
next())
1024 auto *pRec = pList->AddDiseqcConfig();
1025 pRec->setCardId ( query.
value( 0 ).toUInt() );
1026 pRec->setDiSEqCId ( query.
value( 1 ).toUInt() );
1027 pRec->setValue ( query.
value( 2 ).toString() );
1034 const QString& Value)
1039 "INSERT INTO diseqc_config "
1055 throw( QString(
"Database Error executing query." ));
1064 query.
prepare(
"DELETE FROM diseqc_config WHERE cardinputid = :CARDID ");
1069 throw( QString(
"Database Error executing query." ));
1081 "SELECT profilegroups.id, profilegroups.name, cardtype, recordingprofiles.id, recordingprofiles.name, "
1082 "videocodec, audiocodec, "
1083 "codecparams.name, codecparams.value "
1084 "FROM profilegroups "
1085 "INNER JOIN recordingprofiles on profilegroups.id = recordingprofiles.profilegroup "
1086 "LEFT OUTER JOIN codecparams on codecparams.profile = recordingprofiles.id ";
1087 QString where =
"WHERE ";
1090 str.append(where).append(
"CARDTYPE = 'TRANSCODE' OR (cardtype in (SELECT cardtype FROM capturecard)) ");
1095 str.append(where).append(
"profilegroups.id = :GROUPID ");
1100 str.append(where).append(
"recordingprofiles.id = :PROFILEID ");
1105 "ORDER BY IF(cardtype = 'TRANSCODE', 9999, profilegroups.id), recordingprofiles.id, codecparams.name ");
1112 query.
bindValue(
":PROFILEID", ProfileId);
1117 throw( QString(
"Database Error executing query." ));
1126 int prevGroupId = -1;
1127 int prevProfileId = -1;
1132 while (query.
next())
1134 int groupId = query.
value(0).toInt();
1135 if (groupId != prevGroupId)
1137 pGroup = pList->AddProfileGroup();
1138 pGroup->setId ( groupId );
1139 pGroup->setName ( query.
value(1).toString() );
1140 pGroup->setCardType ( query.
value(2).toString() );
1141 prevGroupId = groupId;
1143 int profileId = query.
value(3).toInt();
1144 if (profileId != prevProfileId)
1147 pProfile->setId ( profileId );
1148 pProfile->setName ( query.
value(4).toString() );
1149 pProfile->setVideoCodec ( query.
value(5).toString() );
1150 pProfile->setAudioCodec ( query.
value(6).toString() );
1151 prevProfileId = profileId;
1155 auto *pParam = pProfile->
AddParam();
1156 pParam->setName ( query.
value(7).toString() );
1157 pParam->setValue ( query.
value(8).toString() );
1165 const QString& VideoCodec,
const QString& AudioCodec )
1167 if (GroupId == 0 || ProfileName.isEmpty())
1169 LOG(VB_GENERAL, LOG_ERR,
1170 QString(
"AddRecProfile: GroupId and ProfileName are required." ));
1179 "FROM recordingprofiles "
1180 "WHERE name = :NAME AND profilegroup = :PROFILEGROUP;");
1182 query.
bindValue(
":PROFILEGROUP", GroupId);
1186 throw( QString(
"Database Error executing SELECT." ));
1191 id = query.
value(0).toInt();
1192 LOG(VB_GENERAL, LOG_ERR,
1193 QString(
"Profile %1 already exists in group id %2 with id %3").arg(ProfileName).arg(GroupId).arg(
id));
1198 "INSERT INTO recordingprofiles "
1199 "(name, videocodec, audiocodec, profilegroup) "
1201 "(:NAME, :VIDEOCODEC, :AUDIOCODEC, :PROFILEGROUP);");
1203 query.
bindValue(
":VIDEOCODEC", VideoCodec);
1204 query.
bindValue(
":AUDIOCODEC", AudioCodec);
1205 query.
bindValue(
":PROFILEGROUP", GroupId);
1209 throw( QString(
"Database Error executing INSERT." ));
1220 const QString& VideoCodec,
1221 const QString& AudioCodec )
1225 "SELECT id from recordingprofiles "
1226 "WHERE id = :ID; ");
1231 throw( QString(
"Database Error executing SELECT." ));
1236 id = query.
value(0).toUInt();
1238 if (
id != ProfileId)
1240 LOG(VB_GENERAL, LOG_ERR,
1241 QString(
"UpdateRecProfile: Profile id %1 does not exist").arg(ProfileId));
1245 "UPDATE recordingprofiles "
1246 "SET videocodec = :VIDEOCODEC, "
1247 "audiocodec = :AUDIOCODEC "
1248 "WHERE id = :ID; ");
1249 query.
bindValue(
":VIDEOCODEC", VideoCodec);
1250 query.
bindValue(
":AUDIOCODEC", AudioCodec);
1255 throw( QString(
"Database Error executing UPDATE." ));
1269 "DELETE from codecparams "
1270 "WHERE profile = :ID; ");
1275 throw( QString(
"Database Error executing DELETE." ));
1279 "DELETE from recordingprofiles "
1280 "WHERE id = :ID; ");
1285 throw( QString(
"Database Error executing DELETE." ));
1296 "REPLACE INTO codecparams "
1297 "(profile, name, value) "
1299 "(:PROFILE, :NAME, :VALUE);");
1306 throw( QString(
"Database Error executing REPLACE." ));