66 qRegisterMetaType<V2ChannelInfoList*>(
"V2ChannelInfoList");
67 qRegisterMetaType<V2ChannelInfo*>(
"V2ChannelInfo");
68 qRegisterMetaType<V2VideoSourceList*>(
"V2VideoSourceList");
69 qRegisterMetaType<V2VideoSource*>(
"V2VideoSource");
70 qRegisterMetaType<V2LineupList*>(
"V2LineupList");
71 qRegisterMetaType<V2Lineup*>(
"V2Lineup");
72 qRegisterMetaType<V2VideoMultiplexList*>(
"V2VideoMultiplexList");
73 qRegisterMetaType<V2VideoMultiplex*>(
"V2VideoMultiplex");
74 qRegisterMetaType<V2Program*>(
"V2Program");
75 qRegisterMetaType<V2RecordingInfo*>(
"V2RecordingInfo");
76 qRegisterMetaType<V2ArtworkInfoList*>(
"V2ArtworkInfoList");
77 qRegisterMetaType<V2ArtworkInfo*>(
"V2ArtworkInfo");
78 qRegisterMetaType<V2CastMemberList*>(
"V2CastMemberList");
79 qRegisterMetaType<V2CastMember*>(
"V2CastMember");
80 qRegisterMetaType<V2Grabber*>(
"V2Grabber");
81 qRegisterMetaType<V2GrabberList*>(
"V2GrabberList");
82 qRegisterMetaType<V2FreqTableList*>(
"V2FreqTableList");
98 bool bGroupByCallsign,
103 uint nTotalAvailable = 0;
108 nSourceID, nChannelGroupID,
false,
"",
117 nStartIndex = (nStartIndex > 0) ? std::min( nStartIndex, nTotalAvailable ) : 0;
118 nCount = (nCount > 0) ? std::min(nCount, (nTotalAvailable - nStartIndex)) :
119 (nTotalAvailable - nStartIndex);
121 ChannelInfoList::iterator chanIt;
122 auto chanItBegin = chanList.begin() + nStartIndex;
123 auto chanItEnd = chanItBegin + nCount;
125 for( chanIt = chanItBegin; chanIt < chanItEnd; ++chanIt )
127 V2ChannelInfo *pChannelInfo = pChannelInfos->AddNewChannelInfo();
134 delete pChannelInfos;
135 throw( QString(
"V2Channel ID appears invalid."));
144 nTotalPages = (int)std::ceil((
float)nTotalAvailable / nCount);
146 if (nTotalPages == 1)
150 nCurPage = (int)std::ceil((
float)nStartIndex / nCount) + 1;
153 pChannelInfos->setStartIndex ( nStartIndex );
154 pChannelInfos->setCount ( nCount );
155 pChannelInfos->setCurrentPage ( nCurPage );
156 pChannelInfos->setTotalPages ( nTotalPages );
157 pChannelInfos->setTotalAvailable( nTotalAvailable );
162 return pChannelInfos;
172 throw( QString(
"V2Channel ID appears invalid."));
189 const QString &CallSign,
190 const QString &ChannelName,
191 const QString &ChannelNumber,
193 uint ATSCMajorChannel,
194 uint ATSCMinorChannel,
197 const QString &ExtendedVisible,
198 const QString &FrequencyID,
201 const QString &XMLTVID,
202 const QString &DefaultAuthority,
206 throw QString(
"ChannelId is required");
209 throw QString(
"Nothing to update");
213 throw QString(
"ChannelId %1 doesn't exist");
222 channel.
m_name = ChannelName;
246 throw QString(
"Can't override Always/NeverVisible");
277 const QString &CallSign,
278 const QString &ChannelName,
279 const QString &ChannelNumber,
281 uint ATSCMajorChannel,
282 uint ATSCMinorChannel,
285 const QString &ExtendedVisible,
286 const QString &FrequencyID,
289 const QString &XMLTVID,
290 const QString &DefaultAuthority,
300 CallSign, ChannelName, ChannelNumber,
301 ServiceID, ATSCMajorChannel, ATSCMinorChannel,
302 UseEIT, chan_visible, FrequencyID,
325 throw( QString(
"Database not open while trying to list "
328 query.
prepare(
"SELECT sourceid, name, xmltvgrabber, userid, "
329 "freqtable, lineupid, password, useeit, configpath, "
330 "dvb_nit_id, bouquet_id, region_id, scanfrequency, "
331 "lcnoffset FROM videosource "
332 "ORDER BY sourceid" );
338 throw( QString(
"Database Error executing query." ));
352 pVideoSource->setId ( query.
value(0).toInt() );
353 pVideoSource->setSourceName ( query.
value(1).toString() );
354 pVideoSource->setGrabber ( query.
value(2).toString() );
355 pVideoSource->setUserId ( query.
value(3).toString() );
356 pVideoSource->setFreqTable ( query.
value(4).toString() );
357 pVideoSource->setLineupId ( query.
value(5).toString() );
358 pVideoSource->setPassword ( query.
value(6).toString() );
359 pVideoSource->setUseEIT ( query.
value(7).toBool() );
360 pVideoSource->setConfigPath ( query.
value(8).toString() );
361 pVideoSource->setNITId ( query.
value(9).toInt() );
362 pVideoSource->setBouquetId ( query.
value(10).toUInt() );
363 pVideoSource->setRegionId ( query.
value(11).toUInt() );
364 pVideoSource->setScanFrequency ( query.
value(12).toUInt() );
365 pVideoSource->setLCNOffset ( query.
value(13).toUInt() );
384 throw( QString(
"Database not open while trying to list "
387 query.
prepare(
"SELECT name, xmltvgrabber, userid, "
388 "freqtable, lineupid, password, useeit, configpath, "
389 "dvb_nit_id, bouquet_id, region_id, scanfrequency, "
391 "FROM videosource WHERE sourceid = :SOURCEID "
392 "ORDER BY sourceid" );
399 throw( QString(
"Database Error executing query." ));
410 pVideoSource->setId ( nSourceID );
411 pVideoSource->setSourceName ( query.
value(0).toString() );
412 pVideoSource->setGrabber ( query.
value(1).toString() );
413 pVideoSource->setUserId ( query.
value(2).toString() );
414 pVideoSource->setFreqTable ( query.
value(3).toString() );
415 pVideoSource->setLineupId ( query.
value(4).toString() );
416 pVideoSource->setPassword ( query.
value(5).toString() );
417 pVideoSource->setUseEIT ( query.
value(6).toBool() );
418 pVideoSource->setConfigPath ( query.
value(7).toString() );
419 pVideoSource->setNITId ( query.
value(8).toInt() );
420 pVideoSource->setBouquetId ( query.
value(9).toUInt() );
421 pVideoSource->setRegionId ( query.
value(10).toUInt() );
422 pVideoSource->setScanFrequency ( query.
value(11).toUInt() );
423 pVideoSource->setLCNOffset ( query.
value(12).toUInt() );
434 const QString &sSourceName,
435 const QString &sGrabber,
436 const QString &sUserId,
437 const QString &sFreqTable,
438 const QString &sLineupId,
439 const QString &sPassword,
441 const QString &sConfigPath,
451 LOG(VB_GENERAL, LOG_ERR,
"SourceId is required");
457 LOG(VB_GENERAL, LOG_ERR, QString(
"SourceId %1 doesn't exist")
464 LOG(VB_GENERAL, LOG_ERR, QString(
"SourceId=%1 was the only parameter")
470 MSqlBindings::const_iterator it;
474 ADD_SQLv2(settings, bindings,
"name",
"SourceName", sSourceName);
477 ADD_SQLv2(settings, bindings,
"xmltvgrabber",
"Grabber", sGrabber);
480 ADD_SQLv2(settings, bindings,
"userid",
"UserId", sUserId);
483 ADD_SQLv2(settings, bindings,
"freqtable",
"FreqTable", sFreqTable);
486 ADD_SQLv2(settings, bindings,
"lineupid",
"LineupId", sLineupId);
489 ADD_SQLv2(settings, bindings,
"password",
"Password", sPassword);
492 ADD_SQLv2(settings, bindings,
"useeit",
"UseEIT", bUseEIT);
496 if (sConfigPath.isEmpty())
497 settings +=
"configpath=NULL, ";
499 ADD_SQLv2(settings, bindings,
"configpath",
"ConfigPath", sConfigPath);
503 ADD_SQLv2(settings, bindings,
"dvb_nit_id",
"NITId", nNITId);
506 ADD_SQLv2(settings, bindings,
"bouquet_id",
"BouquetId", nBouquetId);
509 ADD_SQLv2(settings, bindings,
"region_id",
"RegionId", nRegionId);
512 ADD_SQLv2(settings, bindings,
"scanfrequency",
"ScanFrequency", nScanFrequency);
515 ADD_SQLv2(settings, bindings,
"lcnoffset",
"LCNOffset", nLCNOffset);
517 if ( settings.isEmpty() )
519 LOG(VB_GENERAL, LOG_ERR,
"No valid parameters were passed");
527 query.
prepare(QString(
"UPDATE videosource SET %1 WHERE sourceid=:SOURCEID")
529 bindings[
":SOURCEID"] = nSourceId;
531 for (it = bindings.cbegin(); it != bindings.cend(); ++it)
538 throw( QString(
"Database Error executing query." ));
549 const QString &sGrabber,
550 const QString &sUserId,
551 const QString &sFreqTable,
552 const QString &sLineupId,
553 const QString &sPassword,
555 const QString &sConfigPath,
563 sLineupId, sPassword, bUseEIT, sConfigPath,
564 nNITId, nBouquetId, nRegionId, nScanFrequency,
606 bool bWaitForFinish )
608 if ( nSourceId < 1 || nCardId < 1)
609 throw( QString(
"A source ID and card ID are both required."));
642 throw( QString(
"Database not open while trying to list "
645 query.
prepare(
"SELECT mplexid, sourceid, transportid, networkid, "
646 "frequency, inversion, symbolrate, fec, polarity, "
647 "modulation, bandwidth, lp_code_rate, transmission_mode, "
648 "guard_interval, visible, constellation, hierarchy, hp_code_rate, "
649 "mod_sys, rolloff, sistandard, serviceversion, updatetimestamp, "
650 "default_authority FROM dtv_multiplex WHERE sourceid = :SOURCEID "
651 "ORDER BY mplexid" );
658 throw( QString(
"Database Error executing query." ));
669 nStartIndex = (nStartIndex > 0) ? std::min( nStartIndex, muxCount ) : 0;
670 nCount = (nCount > 0) ? std::min( nCount, muxCount ) : muxCount;
671 int nEndIndex = std::min((nStartIndex + nCount), muxCount );
673 for(
int n = nStartIndex; n < nEndIndex; n++)
677 V2VideoMultiplex *pVideoMultiplex = pVideoMultiplexes->AddNewVideoMultiplex();
679 pVideoMultiplex->setMplexId( query.
value(0).toInt() );
680 pVideoMultiplex->setSourceId( query.
value(1).toInt() );
681 pVideoMultiplex->setTransportId( query.
value(2).toInt() );
682 pVideoMultiplex->setNetworkId( query.
value(3).toInt() );
683 pVideoMultiplex->setFrequency( query.
value(4).toLongLong() );
684 pVideoMultiplex->setInversion( query.
value(5).toString() );
685 pVideoMultiplex->setSymbolRate( query.
value(6).toLongLong() );
686 pVideoMultiplex->setFEC( query.
value(7).toString() );
687 pVideoMultiplex->setPolarity( query.
value(8).toString() );
688 pVideoMultiplex->setModulation( query.
value(9).toString() );
689 pVideoMultiplex->setBandwidth( query.
value(10).toString() );
690 pVideoMultiplex->setLPCodeRate( query.
value(11).toString() );
691 pVideoMultiplex->setTransmissionMode( query.
value(12).toString() );
692 pVideoMultiplex->setGuardInterval( query.
value(13).toString() );
693 pVideoMultiplex->setVisible( query.
value(14).toBool() );
694 pVideoMultiplex->setConstellation( query.
value(15).toString() );
695 pVideoMultiplex->setHierarchy( query.
value(16).toString() );
696 pVideoMultiplex->setHPCodeRate( query.
value(17).toString() );
697 pVideoMultiplex->setModulationSystem( query.
value(18).toString() );
698 pVideoMultiplex->setRollOff( query.
value(19).toString() );
699 pVideoMultiplex->setSIStandard( query.
value(20).toString() );
700 pVideoMultiplex->setServiceVersion( query.
value(21).toInt() );
701 pVideoMultiplex->setUpdateTimeStamp(
703 pVideoMultiplex->setDefaultAuthority( query.
value(23).toString() );
712 totalPages = (int)std::ceil((
float)muxCount / nCount);
718 curPage = (int)std::ceil((
float)nStartIndex / nCount) + 1;
721 pVideoMultiplexes->setStartIndex ( nStartIndex );
722 pVideoMultiplexes->setCount ( nCount );
723 pVideoMultiplexes->setCurrentPage ( curPage );
724 pVideoMultiplexes->setTotalPages ( totalPages );
725 pVideoMultiplexes->setTotalAvailable( muxCount );
730 return pVideoMultiplexes;
738 throw( QString(
"Database not open while trying to list "
739 "Video Multiplex."));
741 query.
prepare(
"SELECT sourceid, transportid, networkid, "
742 "frequency, inversion, symbolrate, fec, polarity, "
743 "modulation, bandwidth, lp_code_rate, transmission_mode, "
744 "guard_interval, visible, constellation, hierarchy, hp_code_rate, "
745 "mod_sys, rolloff, sistandard, serviceversion, updatetimestamp, "
746 "default_authority FROM dtv_multiplex WHERE mplexid = :MPLEXID "
747 "ORDER BY mplexid" );
754 throw( QString(
"Database Error executing query." ));
761 pVideoMultiplex->setMplexId( nMplexID );
762 pVideoMultiplex->setSourceId( query.
value(0).toInt() );
763 pVideoMultiplex->setTransportId( query.
value(1).toInt() );
764 pVideoMultiplex->setNetworkId( query.
value(2).toInt() );
765 pVideoMultiplex->setFrequency( query.
value(3).toLongLong() );
766 pVideoMultiplex->setInversion( query.
value(4).toString() );
767 pVideoMultiplex->setSymbolRate( query.
value(5).toLongLong() );
768 pVideoMultiplex->setFEC( query.
value(6).toString() );
769 pVideoMultiplex->setPolarity( query.
value(7).toString() );
770 pVideoMultiplex->setModulation( query.
value(8).toString() );
771 pVideoMultiplex->setBandwidth( query.
value(9).toString() );
772 pVideoMultiplex->setLPCodeRate( query.
value(10).toString() );
773 pVideoMultiplex->setTransmissionMode( query.
value(11).toString() );
774 pVideoMultiplex->setGuardInterval( query.
value(12).toString() );
775 pVideoMultiplex->setVisible( query.
value(13).toBool() );
776 pVideoMultiplex->setConstellation( query.
value(14).toString() );
777 pVideoMultiplex->setHierarchy( query.
value(15).toString() );
778 pVideoMultiplex->setHPCodeRate( query.
value(16).toString() );
779 pVideoMultiplex->setModulationSystem( query.
value(17).toString() );
780 pVideoMultiplex->setRollOff( query.
value(18).toString() );
781 pVideoMultiplex->setSIStandard( query.
value(19).toString() );
782 pVideoMultiplex->setServiceVersion( query.
value(20).toInt() );
783 pVideoMultiplex->setUpdateTimeStamp(
785 pVideoMultiplex->setDefaultAuthority( query.
value(22).toString() );
788 return pVideoMultiplex;
800 throw( QString(
"Database not open while trying to get source name."));
802 query.
prepare(
"SELECT name FROM videosource WHERE sourceid = :SOURCEID ");
809 throw( QString(
"Database Error executing query." ));
816 QString sourceName = query.
value(0).toString();
818 QString xmltvFile =
GetConfDir() +
'/' + sourceName +
".xmltv";
820 if (QFile::exists(xmltvFile))
822 QFile
file(xmltvFile);
823 if (!
file.open(QIODevice::ReadOnly | QIODevice::Text))
826 while (!
file.atEnd())
828 QByteArray line =
file.readLine();
830 if (line.startsWith(
"channel="))
832 QString
id = line.mid(8, -1).trimmed();
841 throw(QString(
"SourceID (%1) not found").arg(
SourceID));
860 V2Grabber *pGrabber = pGrabberList->AddNewGrabber();
861 pGrabber->setProgram(
"eitonly");
862 pGrabber->setDisplayName(QObject::tr(
"Transmitted guide only (EIT)"));
863 pGrabber = pGrabberList->AddNewGrabber();
864 pGrabber->setProgram(
"/bin/true");
865 pGrabber->setDisplayName(QObject::tr(
"No grabber"));
872 find_grabber_proc.
Run(25s);
873 LOG(VB_GENERAL, LOG_INFO,
874 "Running 'tv_find_grabbers " +
args.join(
" ") +
"'.");
875 uint status = find_grabber_proc.
Wait();
879 QTextStream ostream(find_grabber_proc.
ReadAll());
880 while (!ostream.atEnd())
882 QString grabber_list(ostream.readLine());
883 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
884 QStringList grabber_split =
885 grabber_list.split(
"|", QString::SkipEmptyParts);
887 QStringList grabber_split =
888 grabber_list.split(
"|", Qt::SkipEmptyParts);
890 QString grabber_name = grabber_split[1];
891 QFileInfo grabber_file(grabber_split[0]);
892 QString program = grabber_file.fileName();
894 if (!pGrabberList->containsProgram(program))
896 pGrabber = pGrabberList->AddNewGrabber();
897 pGrabber->setProgram(program);
898 pGrabber->setDisplayName(grabber_name);
900 LOG(VB_GENERAL, LOG_DEBUG,
"Found " + grabber_split[0]);
902 LOG(VB_GENERAL, LOG_INFO,
"Finished running tv_find_grabbers");
906 LOG(VB_GENERAL, LOG_ERR,
"Failed to run tv_find_grabbers");
915 QStringList freqList;
916 freqList.append(
"default");
919 freqList.append(freqEntry.name);