MythTV master
channelsettings.cpp
Go to the documentation of this file.
1// C/C++ headers
2#include <utility>
3
4// Qt headers
5#include <QCoreApplication>
6#include <QFile>
7#include <QWidget>
8
9// MythTV headers
12#include "libmythbase/programinfo.h" // for COMM_DETECT*, GetPreferredSkipTypeCombinations()
13
14#include "cardutil.h"
15#include "channelsettings.h"
16#include "channelutil.h"
17#include "mpeg/mpegtables.h"
18
20{
21 if (getValue().toInt() == 0) {
23
25
26 QString querystr = QString("SELECT %1 FROM %2 WHERE %3='%4'")
28 query.prepare(querystr);
29
30 if (!query.exec() && !query.isActive())
31 MythDB::DBError("ChannelID::save", query);
32
33 if (query.size())
34 return;
35
36 querystr = QString("INSERT INTO %1 (%2) VALUES ('%3')")
37 .arg(m_table, m_field, getValue());
38 query.prepare(querystr);
39
40 if (!query.exec() || !query.isActive())
41 MythDB::DBError("ChannelID::save", query);
42
43 if (query.numRowsAffected() != 1)
44 {
45 LOG(VB_GENERAL, LOG_ERR, QString("ChannelID, Error: ") +
46 QString("Failed to insert into: %1").arg(m_table));
47 }
48 }
49}
50
52{
53 QString fieldTag = (":WHERE" + m_id.getField().toUpper());
54 QString query(m_id.getField() + " = " + fieldTag);
55
56 bindings.insert(fieldTag, m_id.getValue());
57
58 return query;
59}
60
62{
63 QString fieldTag = (":SET" + m_id.getField().toUpper());
64 QString nameTag = (":SET" + GetColumnName().toUpper());
65
66 QString query(m_id.getField() + " = " + fieldTag + ", " +
67 GetColumnName() + " = " + nameTag);
68
69 bindings.insert(fieldTag, m_id.getValue());
70 bindings.insert(nameTag, m_user->GetDBValue());
71
72 return query;
73}
74
76{
77 QString fieldTag = (":WHERE" + m_id.getField().toUpper());
78 QString query(m_id.getField() + " = " + fieldTag);
79
80 bindings.insert(fieldTag, m_id.getValue());
81
82 return query;
83}
84
86{
87 QString fieldTag = (":SET" + m_id.getField().toUpper());
88 QString nameTag = (":SET" + GetColumnName().toUpper());
89
90 QString query(m_id.getField() + " = " + fieldTag + ", " +
91 GetColumnName() + " = " + nameTag);
92
93 bindings.insert(fieldTag, m_id.getValue());
94 bindings.insert(nameTag, m_user->GetDBValue());
95
96 return query;
97}
98
99/*****************************************************************************
100 Channel Options - Common
101 *****************************************************************************/
102
104{
105 public:
106 explicit Name(const ChannelID &id) :
107 MythUITextEditSetting(new ChannelDBStorage(this, id, "name"))
108 {
109 setLabel(QCoreApplication::translate("(Common)", "Channel Name"));
110 }
111
112 ~Name() override
113 {
114 delete GetStorage();
115 }
116};
117
119{
120 public:
121 explicit Channum(const ChannelID &id) :
122 MythUITextEditSetting(new ChannelDBStorage(this, id, "channum"))
123 {
124 setLabel(QCoreApplication::translate("(Common)", "Channel Number"));
125 setHelpText(QCoreApplication::translate("(Common)",
126 "This is the number by which the channel is known to MythTV."));
127 }
128
129 ~Channum() override
130 {
131 delete GetStorage();
132 }
133};
134
136{
137 public:
138 Source(const ChannelID &id, uint _default_sourceid) :
139 MythUIComboBoxSetting(new ChannelDBStorage(this, id, "sourceid")),
140 m_defaultSourceId(_default_sourceid)
141 {
142 setLabel(QCoreApplication::translate("(Common)", "Video Source"));
143 setHelpText(QCoreApplication::translate("(Common)",
144 "It is NOT a good idea to change this value as it only changes "
145 "the sourceid in table channel but not in dtv_multiplex. "
146 "The sourceid in dtv_multiplex cannot and should not be changed."));
147 }
148
149 ~Source() override
150 {
151 delete GetStorage();
152 }
153
154 void Load(void) override // StandardSetting
155 {
158
159 if ((m_defaultSourceId != 0U) && (getValue().toUInt() == 0U))
160 {
162 if (which)
163 setValue(which);
164 }
165 }
166
167 void fillSelections(void)
168 {
169 addSelection(QCoreApplication::translate("(ChannelSettings)",
170 "[Not Selected]"), "0");
171
173 query.prepare("SELECT name, sourceid "
174 "FROM videosource "
175 "ORDER BY sourceid");
176
177 if (!query.exec() || !query.isActive())
178 {
179 MythDB::DBError("Source::fillSelections", query);
180 }
181 else
182 {
183 for (uint i = 1; query.next(); i++)
184 {
185 m_sourceIdToIndex[query.value(1).toUInt()] = i;
186 addSelection(query.value(0).toString(),
187 query.value(1).toString());
188 }
189 }
190
191 m_sourceIdToIndex[0] = 0; // Not selected entry.
192 }
193
194 private:
196 QMap<uint,uint> m_sourceIdToIndex;
197};
198
200{
201 public:
202 explicit Callsign(const ChannelID &id) :
203 MythUITextEditSetting(new ChannelDBStorage(this, id, "callsign"))
204 {
205 setLabel(QCoreApplication::translate("(Common)", "Callsign"));
206 }
207
208 ~Callsign() override
209 {
210 delete GetStorage();
211 }
212};
213
215 MythUIComboBoxSetting(new ChannelDBStorage(this, id, "tvformat"))
216{
217 setLabel(QCoreApplication::translate("(ChannelSettings)", "TV Format"));
218 setHelpText(QCoreApplication::translate("(ChannelSettings)",
219 "If this channel uses a format other than TV Format in the General "
220 "Backend Setup screen, set it here."));
221
222 addSelection(QCoreApplication::translate("(Common)", "Default"), "Default");
223
224 QStringList list = GetFormats();
225 for (const QString& format : std::as_const(list))
226 addSelection(format);
227}
228
230{
231 delete GetStorage();
232}
233
235{
236 QStringList list;
237
238 list.push_back("NTSC");
239 list.push_back("NTSC-JP");
240 list.push_back("PAL");
241 list.push_back("PAL-60");
242 list.push_back("PAL-BG");
243 list.push_back("PAL-DK");
244 list.push_back("PAL-D");
245 list.push_back("PAL-I");
246 list.push_back("PAL-M");
247 list.push_back("PAL-N");
248 list.push_back("PAL-NC");
249 list.push_back("SECAM");
250 list.push_back("SECAM-D");
251 list.push_back("SECAM-DK");
252
253 return list;
254}
255
257{
258 public:
259 explicit TimeOffset(const ChannelID &id) :
260 MythUISpinBoxSetting(new ChannelDBStorage(this, id, "tmoffset"),
261 -1440, 1440, 1)
262 {
263 setLabel(QCoreApplication::translate("(ChannelSettings)",
264 "DataDirect Time Offset"));
265
266 setHelpText(QCoreApplication::translate("(ChannelSettings)",
267 "Offset (in minutes) to apply to the program guide data during "
268 "import. This can be used when the listings for a particular "
269 "channel are in a different time zone."));
270 }
271
272 ~TimeOffset() override
273 {
274 delete GetStorage();
275 }
276};
277
279{
280 public:
281 explicit Priority(const ChannelID &id) :
282 MythUISpinBoxSetting(new ChannelDBStorage(this, id, "recpriority"),
283 -99, 99, 1)
284 {
285 setLabel(QCoreApplication::translate("(ChannelSettings)", "Priority"));
286
287 setHelpText(QCoreApplication::translate("(ChannelSettings)",
288 "Number of priority points to be added to any recording on this "
289 "channel during scheduling. Use a positive number as the priority "
290 "if you want this to be a preferred channel, a negative one to "
291 "depreciate this channel."));
292 }
293
294 ~Priority() override
295 {
296 delete GetStorage();
297 }
298};
299
301{
302 public:
303 explicit Icon(const ChannelID &id) :
304 MythUITextEditSetting(new ChannelDBStorage(this, id, "icon"))
305 {
306 setLabel(QCoreApplication::translate("(ChannelSettings)", "Icon"));
307
308 setHelpText(QCoreApplication::translate("(ChannelSettings)",
309 "Image file to use as the icon for this channel on various MythTV "
310 "displays."));
311 }
312
313 ~Icon() override
314 {
315 delete GetStorage();
316 }
317};
318
320{
321 public:
322 explicit VideoFilters(const ChannelID &id) :
323 MythUITextEditSetting(new ChannelDBStorage(this, id, "videofilters"))
324 {
325 setLabel(QCoreApplication::translate("(ChannelSettings)",
326 "Video filters"));
327
328 setHelpText(QCoreApplication::translate("(ChannelSettings)",
329 "Filters to be used when recording from this channel. Not used "
330 "with hardware encoding cards."));
331
332 }
333
334 ~VideoFilters() override
335 {
336 delete GetStorage();
337 }
338};
339
340
342{
343 public:
344 explicit OutputFilters(const ChannelID &id) :
345 MythUITextEditSetting(new ChannelDBStorage(this, id, "outputfilters"))
346 {
347 setLabel(QCoreApplication::translate("(ChannelSettings)",
348 "Playback filters"));
349
350 setHelpText(QCoreApplication::translate("(ChannelSettings)",
351 "Filters to be used when recordings from this channel are viewed. "
352 "Start with a plus to append to the global playback filters."));
353 }
354
355 ~OutputFilters() override
356 {
357 delete GetStorage();
358 }
359};
360
362{
363 public:
364 XmltvID(const ChannelID &id, QString _sourceName) :
365 MythUIComboBoxSetting(new ChannelDBStorage(this, id, "xmltvid"), true),
366 m_sourceName(std::move(_sourceName))
367 {
368 setLabel(QCoreApplication::translate("(Common)", "XMLTV ID"));
369
370 setHelpText(QCoreApplication::translate("(ChannelSettings)",
371 "ID used by listing services to get an exact correspondence "
372 "between a channel in your line-up and a channel in their "
373 "database. Normally this is set automatically when "
374 "'mythfilldatabase' is run."));
375 }
376
377 ~XmltvID() override
378 {
379 delete GetStorage();
380 }
381
382 void Load(void) override // StandardSetting
383 {
386 }
387
388 void fillSelections(void)
389 {
391
392 QString xmltvFile = GetConfDir() + '/' + m_sourceName + ".xmltv";
393
394 if (QFile::exists(xmltvFile))
395 {
396 QFile file(xmltvFile);
397 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
398 return;
399
400 QStringList idList;
401
402 while (!file.atEnd())
403 {
404 QByteArray line = file.readLine();
405
406 if (line.startsWith("channel="))
407 {
408 QString id = line.mid(8, -1).trimmed();
409 idList.append(id);
410 }
411 }
412
413 idList.sort();
414
415 for (const QString& idName : std::as_const(idList))
416 addSelection(idName, idName);
417 }
418 }
419
420 private:
422};
423
425{
426 public:
427 explicit ServiceID(const ChannelID &id)
428 : MythUISpinBoxSetting(new ChannelDBStorage(this, id, "serviceid"),
429 -1, UINT16_MAX, 1, 1, "NULL")
430 {
431 setLabel(QCoreApplication::translate("(ChannelSettings)", "Service ID"));
432
433 setHelpText(QCoreApplication::translate("(ChannelSettings)",
434 "Service ID (Program Number) of desired channel within the transport stream. "
435 "If there is only one channel, then setting this to anything will still find it."));
436 }
437
438 ~ServiceID() override
439 {
440 delete GetStorage();
441 }
442
443 void Load(void) override // StandardSetting
444 {
446
447 if (getValue().isNull())
448 setValue("-1");
449 }
450
451 QString getValue(void) const override // StandardSetting
452 {
453 if (StandardSetting::getValue().toInt() == -1)
454 return {};
456 }
457};
458
459// Transport ID in Channel Options
461{
462 public:
464 {
465 setLabel(QObject::tr("Transport ID"));
467 QObject::tr("The transport stream ID (tid) can be used to identify "
468 "the transport of this channel in the Transport Editor."));
469 }
470};
471
472// Frequency in Channel Options
474{
475 public:
477 {
478 setLabel(QObject::tr("Frequency"));
480 QObject::tr("Frequency of the transport of this channel in Hz for "
481 "DVB-T/T2/C or in kHz plus polarization H or V for DVB-S/S2."));
482 }
483};
484
486{
487 public:
488 explicit CommMethod(const ChannelID &id) :
489 MythUIComboBoxSetting(new ChannelDBStorage(this, id, "commmethod"))
490 {
491 setLabel(QCoreApplication::translate("(ChannelSettings)",
492 "Commercial Detection Method"));
493
494 setHelpText(QCoreApplication::translate("(ChannelSettings)",
495 "Changes the method of commercial detection used for recordings on "
496 "this channel or skips detection by marking the channel as "
497 "Commercial Free."));
498
499 std::deque<int> tmp = GetPreferredSkipTypeCombinations();
500 tmp.push_front(COMM_DETECT_UNINIT);
501 tmp.push_back(COMM_DETECT_COMMFREE);
502
503 for (int pref : tmp)
504 addSelection(SkipTypeToString(pref), QString::number(pref));
505 }
506
507 ~CommMethod() override
508 {
509 delete GetStorage();
510 }
511};
512
514{
515 public:
516 explicit Visible(const ChannelID &id) :
517 MythUIComboBoxSetting(new ChannelDBStorage(this, id, "visible"))
518 {
520
521 setLabel(QCoreApplication::translate("(ChannelSettings)", "Visible"));
522
523 setHelpText(QCoreApplication::translate("(ChannelSettings)",
524 "If set to Always Visible or Visible, the channel will be visible in the "
525 "EPG. Set to Always Visible or Never Visible to prevent MythTV and other "
526 "utilities from automatically managing the value for this "
527 "channel."));
528
529 addSelection(QCoreApplication::translate("(Common)", "Always Visible"),
530 QString::number(kChannelAlwaysVisible));
531 addSelection(QCoreApplication::translate("(Common)", "Visible"),
532 QString::number(kChannelVisible));
533 addSelection(QCoreApplication::translate("(Common)", "Not Visible"),
534 QString::number(kChannelNotVisible));
535 addSelection(QCoreApplication::translate("(Common)", "Never Visible"),
536 QString::number(kChannelNeverVisible));
537 }
538
539 ~Visible() override
540 {
541 delete GetStorage();
542 }
543};
544
546{
547 public:
548 explicit OnAirGuide(const ChannelID &id) :
549 MythUICheckBoxSetting(new ChannelDBStorage(this, id, "useonairguide"))
550 {
551 setLabel(QCoreApplication::translate("(ChannelSettings)",
552 "Use on air guide"));
553
554 setHelpText(QCoreApplication::translate("(ChannelSettings)",
555 "If enabled, guide information for this channel will be updated "
556 "using 'Over-the-Air' program listings."));
557 }
558
559 ~OnAirGuide() override
560 {
561 delete GetStorage();
562 }
563};
564
565/*****************************************************************************
566 Channel Options - IPTV
567 *****************************************************************************/
569{
570 public:
571 explicit ChannelURL(const ChannelID &id) :
572 MythUITextEditSetting(new IPTVChannelDBStorage(this, id, "url"))
573 {
574 setLabel(QCoreApplication::translate("(ChannelSettings)", "URL"));
575 setHelpText(QCoreApplication::translate("(ChannelSettings)",
576 "URL for streaming of this channel. Used by the IPTV "
577 "capture card and obtained with an \"M3U Import\" or "
578 "with a \"HDHomeRun Channel Import\" loading of an XML file."));
579 }
580
581 ~ChannelURL() override
582 {
583 delete GetStorage();
584 }
585};
586
587/*****************************************************************************
588 Channel Options - Video 4 Linux
589 *****************************************************************************/
590
592{
593 public:
594 explicit Freqid(const ChannelID &id) :
595 MythUITextEditSetting(new ChannelDBStorage(this, id, "freqid"))
596 {
597 setLabel(QCoreApplication::translate("(ChannelSettings)",
598 "Freq/Channel"));
599 setHelpText(QCoreApplication::translate("(ChannelSettings)",
600 "N.B. This setting is only used for analog channels. "
601 "Depending on the tuner type, specify either the exact "
602 "frequency (in kHz) or a valid channel "
603 "number that will be understood by your tuners."));
604 }
605
606 ~Freqid() override
607 {
608 delete GetStorage();
609 }
610};
611
613{
614 public:
615 explicit Finetune(const ChannelID& id)
616 : MythUISpinBoxSetting(new ChannelDBStorage(this, id, "finetune"),
617 -300, 300, 1)
618 {
619 setLabel(QCoreApplication::translate("(ChannelSettings)",
620 "Finetune (kHz)"));
621
622 setHelpText(QCoreApplication::translate("(ChannelSettings)",
623 "Value to be added to your desired frequency (in kHz) for "
624 "'fine tuning'."));
625
626 setValue("0");
627 }
628
629 ~Finetune() override
630 {
631 delete GetStorage();
632 }
633};
634
636{
637 public:
638 explicit Contrast(const ChannelID &id) :
639 MythUISpinBoxSetting(new ChannelDBStorage(this, id, "contrast"),
640 0, 65535, 655)
641 {
642 setLabel(QCoreApplication::translate("(Common)", "Contrast"));
643 }
644
645 ~Contrast() override
646 {
647 delete GetStorage();
648 }
649};
650
652{
653 public:
654 explicit Brightness(const ChannelID &id) :
655 MythUISpinBoxSetting(new ChannelDBStorage(this, id, "brightness"),
656 0, 65535, 655)
657 {
658 setLabel(QCoreApplication::translate("(Common)", "Brightness"));
659 }
660
661 ~Brightness() override
662 {
663 delete GetStorage();
664 }
665};
666
668{
669 public:
670 explicit Colour(const ChannelID &id) :
671 MythUISpinBoxSetting(new ChannelDBStorage(this, id, "colour"),
672 0, 65535, 655)
673 {
674 setLabel(QCoreApplication::translate("(Common)", "Color"));
675 }
676
677 ~Colour() override
678 {
679 delete GetStorage();
680 }
681};
682
684{
685 public:
686 explicit Hue(const ChannelID &id) :
687 MythUISpinBoxSetting(new ChannelDBStorage(this, id, "hue"),
688 0, 65535, 655)
689 {
690 setLabel(QCoreApplication::translate("(Common)", "Hue"));
691 }
692
693 ~Hue() override
694 {
695 delete GetStorage();
696 }
697};
698
700 uint default_sourceid, bool add_freqid)
701{
702 setLabel(QCoreApplication::translate("(ChannelSettings)",
703 "Channel Options - Common"));
704 addChild(new Name(id));
705
706 auto *source = new Source(id, default_sourceid);
707
708 auto *channum = new Channum(id);
709 addChild(channum);
710 if (add_freqid)
711 {
712 m_freqId = new Freqid(id);
714 }
715 else
716 {
717 m_freqId = nullptr;
718 }
719 addChild(new Callsign(id));
720
721
722
723 addChild(new Visible(id));
724 addChild(new ServiceID(id));
725
728
729 addChild(source);
730 addChild(new ChannelTVFormat(id));
731 addChild(new Priority(id));
732
734 addChild(m_xmltvID = new XmltvID(id, source->getValueLabel()));
735 addChild(new TimeOffset(id));
736
737 addChild(new CommMethod(id));
738 addChild(new Icon(id));
739
742 connect(source, qOverload<const QString&>(&StandardSetting::valueChanged),
744
745 // Transport stream ID and frequency from dtv_multiplex
747 query.prepare(
748 "SELECT transportid, frequency, polarity, mod_sys FROM dtv_multiplex "
749 "JOIN channel ON channel.mplexid = dtv_multiplex.mplexid "
750 "WHERE channel.chanid = :CHANID");
751
752 query.bindValue(":CHANID", id.getValue().toUInt());
753
754 if (!query.exec() || !query.isActive())
755 {
756 MythDB::DBError("ChannelOptionsCommon::ChannelOptionsCommon", query);
757 }
758 else if (query.next())
759 {
760 QString frequency = query.value(1).toString();
761 DTVModulationSystem modSys;
762 modSys.Parse(query.value(3).toString());
765 {
766 QString polarization = query.value(2).toString().toUpper();
767 frequency.append(polarization);
768 }
769 m_transportId->setValue(query.value(0).toString());
770 m_frequency->setValue(frequency);
771 }
772};
773
774void ChannelOptionsCommon::onAirGuideChanged([[maybe_unused]] bool fValue)
775{
776}
777
778void ChannelOptionsCommon::sourceChanged(const QString& sourceid)
779{
780 bool supports_eit = true;
781 bool uses_eit_only = false;
782
784 query.prepare("SELECT cardtype "
785 "FROM capturecard, videosource "
786 "WHERE capturecard.sourceid = videosource.sourceid AND "
787 " videosource.sourceid = :SOURCEID");
788 query.bindValue(":SOURCEID", sourceid);
789
790 if (!query.exec() || !query.isActive())
791 MythDB::DBError("sourceChanged -- supports eit", query);
792 else
793 {
794 supports_eit = (query.size() == 0);
795 while (query.next())
796 {
797 supports_eit |= CardUtil::IsEITCapable(
798 query.value(0).toString().toUpper());
799 }
800
801 query.prepare("SELECT xmltvgrabber "
802 "FROM videosource "
803 "WHERE sourceid = :SOURCEID");
804 query.bindValue(":SOURCEID", sourceid);
805
806 if (!query.exec() || !query.isActive())
807 MythDB::DBError("sourceChanged -- eit only", query);
808 else
809 {
810 uses_eit_only = (query.size() != 0);
811 while (query.next())
812 {
813 uses_eit_only &= (query.value(0).toString() == "eitonly");
814 }
815 }
816 }
817
818 m_onAirGuide->setEnabled(supports_eit);
819 m_xmltvID->setEnabled(!uses_eit_only);
820 m_xmltvID->Load();
821}
822
824{
825 setLabel(QCoreApplication::translate("(ChannelSettings)",
826 "Channel Options - Filters"));
827
828 addChild(new VideoFilters(id));
829 addChild(new OutputFilters(id));
830}
831
833{
834 setLabel(QCoreApplication::translate("(ChannelSettings)",
835 "Channel Options - IPTV"));
836
837 addChild(new Name(id));
838 addChild(new Channum(id));
839 addChild(new ChannelURL(id));
840}
841
843{
844 setLabel(QCoreApplication::translate("(ChannelSettings)",
845 "Channel Options - Video4Linux"));
846
847 addChild(new Freqid(id));
848 addChild(new Finetune(id));
849 addChild(new Contrast(id));
850 addChild(new Brightness(id));
851 addChild(new Colour(id));
852 addChild(new Hue(id));
853};
854
855/*****************************************************************************
856 Channel Options - Video 4 Linux
857 *****************************************************************************/
858
860 m_cid(id)
861{
862 setLabel(QCoreApplication::translate("(ChannelSettings)",
863 "Channel Options - Raw Transport Stream"));
864
865 const uint mx = kMaxPIDs;
866 m_pids.resize(mx);
867 m_sids.resize(mx);
868 m_pcrs.resize(mx);
869
870 for (uint i = 0; i < mx; i++)
871 {
873 m_pids[i]->setLabel("PID");
875 m_sids[i]->setLabel(" StreamID");
876 for (uint j = 0x101; j <= 0x1ff; j++)
877 {
878 QString desc = StreamID::GetDescription(j&0xff);
879 if (!desc.isEmpty())
880 {
881 m_sids[i]->addSelection(
882 QString("%1 (0x%2)")
883 .arg(desc).arg(j&0xff,2,16,QLatin1Char('0')),
884 QString::number(j), false);
885 }
886 }
887 for (uint j = 0x101; j <= 0x1ff; j++)
888 {
889 QString desc = StreamID::GetDescription(j&0xff);
890 if (desc.isEmpty())
891 {
892 m_sids[i]->addSelection(
893 QString("0x%1").arg(j&0xff,2,16,QLatin1Char('0')),
894 QString::number(j), false);
895 }
896 }
897/* we don't allow tables right now, PAT & PMT generated on the fly
898 for (uint j = 0; j <= 0xff; j++)
899 {
900 QString desc = TableID::GetDescription(j);
901 if (!desc.isEmpty())
902 {
903 m_sids[i]->addSelection(
904 QString("%1 (0x%2)").arg(j,0,16,QLatin1Char('0')),
905 QString::number(j),
906 false);
907 }
908 }
909*/
911 m_pcrs[i]->setLabel(" Is PCR");
912 }
913};
914
916{
917 uint chanid = m_cid.getValue().toUInt();
918
919 pid_cache_t pid_cache;
920 if (!ChannelUtil::GetCachedPids(chanid, pid_cache))
921 return;
922
923 auto it = pid_cache.begin();
924 for (uint i = 0; i < kMaxPIDs && it != pid_cache.end(); )
925 {
926 if (!(it->IsPermanent()))
927 {
928 ++it;
929 continue;
930 }
931
932 m_pids[i]->setValue(QString("0x%1")
933 .arg(it->GetPID(),2,16,QLatin1Char('0')));
934 m_sids[i]->setValue(QString::number(it->GetComposite()&0x1ff));
935 m_pcrs[i]->setValue(it->IsPCRPID());
936
937 ++it;
938 ++i;
939 }
940}
941
943{
944 uint chanid = m_cid.getValue().toUInt();
945
946 pid_cache_t pid_cache;
947 for (uint i = 0; i < kMaxPIDs; i++)
948 {
949 bool ok = false;
950 uint pid = m_pids[i]->getValue().toUInt(&ok, 0);
951 if (!ok || (m_sids[i]->getValue().toUInt() == 0U))
952 continue;
953
954 pid_cache.emplace_back(
955 pid, m_sids[i]->getValue().toUInt() | 0x10000 |
956 (m_pcrs[i]->getValue().toUInt() ? 0x200 : 0x0));
957 }
958
959 ChannelUtil::SaveCachedPids(chanid, pid_cache, true /* delete_all */);
960}
961
962/* vim: set expandtab tabstop=4 shiftwidth=4: */
@ kChannelNeverVisible
Definition: channelinfo.h:25
@ kChannelNotVisible
Definition: channelinfo.h:24
@ kChannelAlwaysVisible
Definition: channelinfo.h:22
@ kChannelVisible
Definition: channelinfo.h:23
std::vector< pid_cache_item_t > pid_cache_t
Definition: channelutil.h:43
Brightness(const ChannelID &id)
~Brightness() override
~Callsign() override
Callsign(const ChannelID &id)
static bool IsEITCapable(const QString &rawtype)
Definition: cardutil.h:170
const ChannelID & m_id
QString GetWhereClause(MSqlBindings &bindings) const override
QString GetSetClause(MSqlBindings &bindings) const override
void Save() override
const QString & getField(void) const
QString m_field
int findHighest(int floor=1000)
QString m_table
void sourceChanged(const QString &sourceid)
Frequency_CO * m_frequency
TransportID_CO * m_transportId
ChannelOptionsCommon(const ChannelID &id, uint default_sourceid, bool add_freqid)
OnAirGuide * m_onAirGuide
static void onAirGuideChanged(bool fValue)
ChannelOptionsFilters(const ChannelID &id)
ChannelOptionsIPTV(const ChannelID &id)
std::vector< TransMythUICheckBoxSetting * > m_pcrs
const ChannelID & m_cid
ChannelOptionsRawTS(const ChannelID &id)
void Load(void) override
std::vector< TransTextEditSetting * > m_pids
std::vector< TransMythUIComboBoxSetting * > m_sids
void Save(void) override
static const uint kMaxPIDs
ChannelOptionsV4L(const ChannelID &id)
static QStringList GetFormats(void)
ChannelTVFormat(const ChannelID &id)
~ChannelTVFormat() override
ChannelURL(const ChannelID &id)
~ChannelURL() override
static bool GetCachedPids(uint chanid, pid_cache_t &pid_cache)
Returns cached MPEG PIDs when given a Channel ID.
static bool SaveCachedPids(uint chanid, const pid_cache_t &_pid_cache, bool delete_all=false)
Saves PIDs for PSIP tables to database.
Channum(const ChannelID &id)
~Channum() override
Colour(const ChannelID &id)
~Colour() override
CommMethod(const ChannelID &id)
~CommMethod() override
Contrast(const ChannelID &id)
~Contrast() override
QString GetColumnName(void) const
Definition: mythstorage.h:47
StorageUser * m_user
Definition: mythstorage.h:50
bool Parse(const QString &_value)
Finetune(const ChannelID &id)
~Finetune() override
Freqid(const ChannelID &id)
~Freqid() override
Hue(const ChannelID &id)
~Hue() override
const ChannelID & m_id
QString GetSetClause(MSqlBindings &bindings) const override
QString GetWhereClause(MSqlBindings &bindings) const override
Icon(const ChannelID &id)
~Icon() override
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:128
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:837
QVariant value(int i) const
Definition: mythdbcon.h:204
int size(void) const
Definition: mythdbcon.h:214
int numRowsAffected() const
Definition: mythdbcon.h:217
bool isActive(void) const
Definition: mythdbcon.h:215
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:618
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:888
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:812
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:550
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:226
void addSelection(const QString &label, QString value=QString(), bool select=false)
void setValue(int value) override
Name(const ChannelID &id)
~Name() override
OnAirGuide(const ChannelID &id)
~OnAirGuide() override
~OutputFilters() override
OutputFilters(const ChannelID &id)
Priority(const ChannelID &id)
~Priority() override
QString getValue(void) const override
void Load(void) override
~ServiceID() override
ServiceID(const ChannelID &id)
uint m_defaultSourceId
void fillSelections(void)
QMap< uint, uint > m_sourceIdToIndex
void Load(void) override
~Source() override
Source(const ChannelID &id, uint _default_sourceid)
virtual void addChild(StandardSetting *child)
virtual void Load(void)
virtual void setHelpText(const QString &str)
virtual void setValue(const QString &newValue)
Storage * GetStorage(void) const
void valueChanged(const QString &newValue)
virtual QString getValue(void) const
virtual void setEnabled(bool enabled)
virtual void setLabel(QString str)
virtual QString GetDBValue(void) const =0
static QString GetDescription(uint stream_id)
TimeOffset(const ChannelID &id)
~TimeOffset() override
~VideoFilters() override
VideoFilters(const ChannelID &id)
Visible(const ChannelID &id)
~Visible() override
void Load(void) override
void fillSelections(void)
~XmltvID() override
XmltvID(const ChannelID &id, QString _sourceName)
QString m_sourceName
unsigned int uint
Definition: freesurround.h:24
static guint32 * tmp
Definition: goom_core.cpp:26
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.
Definition: mythdbcon.h:100
QString GetConfDir(void)
Definition: mythdirs.cpp:263
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
STL namespace.
bool exists(str path)
Definition: xbmcvfs.py:51
static QString Source(const QNetworkRequest &request)
Definition: netstream.cpp:139
std::deque< int > GetPreferredSkipTypeCombinations(void)
QString SkipTypeToString(int flags)
@ COMM_DETECT_COMMFREE
Definition: programtypes.h:128
@ COMM_DETECT_UNINIT
Definition: programtypes.h:129
static constexpr uint8_t Brightness
Definition: synaesthesia.h:18
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:95