MythTV master
eithelper.cpp
Go to the documentation of this file.
1// -*- Mode: c++ -*-
2
3// Std C++ headers
4#include <algorithm>
5
6// MythTV includes
11
12#include "channelutil.h"
13#include "eitcache.h"
14#include "eitfixup.h"
15#include "eithelper.h"
16#include "mpeg/atsctables.h"
18#include "mpeg/dvbtables.h"
20#include "mpeg/premieretables.h"
21#include "programdata.h"
22#include "programinfo.h" // for subtitle types and audio and video properties
23#include "scheduledrecording.h" // for ScheduledRecording
24
25const uint EITHelper::kMaxQueueSize = 10000;
26
28
29static uint get_chan_id_from_db_atsc(uint sourceid,
30 uint atsc_major, uint atsc_minor);
31static uint get_chan_id_from_db_dvb(uint sourceid, uint serviceid,
32 uint networkid, uint transportid);
33static uint get_chan_id_from_db_dtv(uint sourceid,
34 uint serviceid, uint tunedchanid);
35static void init_fixup(FixupMap &fix);
36
37#define LOC QString("EITHelper: ")
38#define LOC_ID QString("EITHelper[%1]: ").arg(m_cardnum)
39
41 m_cardnum(cardnum)
42{
43 m_chunkSize = gCoreContext->GetNumSetting("EITEventChunkSize", 20);
44 m_queueSize = std::min(m_chunkSize * 50, kMaxQueueSize);
45 LOG(VB_EIT, LOG_INFO, LOC_ID +
46 QString("EITHelper chunk size %1 and queue size %2 events")
47 .arg(m_chunkSize).arg(m_queueSize));
48
49 // Save EIT cache in database table eit_cache iff true
50 bool persistent = gCoreContext->GetBoolSetting("EITCachePersistent", true);
51 s_eitCache->SetPersistent(persistent);
52 LOG(VB_EIT, LOG_INFO, LOC_ID +
53 QString("EITCache %1")
54 .arg(persistent ? "in memory, backup to database" : "in memory only"));
55
57}
58
60{
61 QMutexLocker locker(&m_eitListLock);
62 while (!m_dbEvents.empty())
63 delete m_dbEvents.dequeue();
64}
65
67{
68 QMutexLocker locker(&m_eitListLock);
69 return m_dbEvents.size();
70}
71
73{
74 uint listsize = GetListSize();
75 bool full = listsize > m_queueSize;
76 return full;
77}
78
88{
89 QMutexLocker locker(&m_eitListLock);
90
91 if (m_dbEvents.empty())
92 return 0;
93
95
96 uint eventCount = 0;
97 uint insertCount = 0;
98 for (; (eventCount < m_chunkSize) && (!m_dbEvents.empty()); eventCount++)
99 {
100 DBEventEIT *event = m_dbEvents.dequeue();
101 m_eitListLock.unlock();
102
103 EITFixUp::Fix(*event);
104
105 insertCount += event->UpdateDB(query, 1000);
106 m_maxStarttime = std::max (m_maxStarttime, event->m_starttime);
107
108 delete event;
109 m_eitListLock.lock();
110 }
111
112 if (!insertCount)
113 return 0;
114
115 if (!m_incompleteEvents.empty())
116 {
117 LOG(VB_EIT, LOG_DEBUG, LOC_ID +
118 QString("Added %1 events -- complete: %2 incomplete: %3")
119 .arg(insertCount).arg(m_dbEvents.size())
120 .arg(m_incompleteEvents.size()));
121 }
122 else
123 {
124 LOG(VB_EIT, LOG_DEBUG, LOC_ID +
125 QString("Added %1/%2 events, queued: %3")
126 .arg(insertCount).arg(eventCount).arg(m_dbEvents.size()));
127 }
128
129 return insertCount;
130}
131
132void EITHelper::SetFixup(uint atsc_major, uint atsc_minor, FixupValue eitfixup)
133{
134 QMutexLocker locker(&m_eitListLock);
135 FixupKey atsc_key = (atsc_major << 16) | atsc_minor;
136 m_fixup[atsc_key] = eitfixup;
137}
138
139void EITHelper::SetLanguagePreferences(const QStringList &langPref)
140{
141 QMutexLocker locker(&m_eitListLock);
142
143 uint priority = 1;
144 QStringList::const_iterator it;
145 for (it = langPref.begin(); it != langPref.end(); ++it)
146 {
147 if (!(*it).isEmpty())
148 {
149 uint language_key = iso639_str3_to_key(*it);
150 uint canonoical_key = iso639_key_to_canonical_key(language_key);
151 m_languagePreferences[canonoical_key] = priority++;
152 }
153 }
154}
155
157{
158 QMutexLocker locker(&m_eitListLock);
159 m_sourceid = sourceid;
160}
161
163{
164 QMutexLocker locker(&m_eitListLock);
165 m_channelid = channelid;
166}
167
168void EITHelper::AddEIT(uint atsc_major, uint atsc_minor,
169 const EventInformationTable *eit)
170{
171 uint atsc_key = (atsc_major << 16) | atsc_minor;
172 EventIDToATSCEvent &events = m_incompleteEvents[atsc_key];
173
174 for (uint i = 0; i < eit->EventCount(); i++)
175 {
176 ATSCEvent ev(eit->StartTimeRaw(i), eit->LengthInSeconds(i),
177 eit->ETMLocation(i),
179 eit->Descriptors(i), eit->DescriptorsLength(i));
180
181 // Create an event immediately if the ETM_location specifies
182 // that there is no ETT event coming; otherwise save the EIT
183 // event in the incomplete_events for this channel.
184 if (!ev.m_etm)
185 {
186 CompleteEvent(atsc_major, atsc_minor, ev, "");
187 }
188 else
189 {
190 // If there is an existing EIT event with this event_id then
191 // delete the descriptor to avoid a memory leak.
192 EventIDToATSCEvent::iterator it = events.find(eit->EventID(i));
193 if (it != events.end())
194 {
195 delete [] (*it).m_desc;
196 }
197
198 // Save the EIT event in the incomplete_events for this channel.
199 auto *tmp = new unsigned char[ev.m_descLength];
200 memcpy(tmp, eit->Descriptors(i), ev.m_descLength);
201 ev.m_desc = tmp;
202 events.insert(eit->EventID(i), ev);
203 }
204 }
205}
206
207void EITHelper::AddETT(uint atsc_major, uint atsc_minor,
208 const ExtendedTextTable *ett)
209{
210 // Find the matching incomplete EIT event for this ETT
211 // If we have no EIT event then just discard the ETT.
212 uint atsc_key = (atsc_major << 16) | atsc_minor;
213 ATSCSRCToEvents::iterator eits_it = m_incompleteEvents.find(atsc_key);
214 if (eits_it != m_incompleteEvents.end())
215 {
216 EventIDToATSCEvent::iterator it = (*eits_it).find(ett->EventID());
217 if (it != (*eits_it).end())
218 {
219 // Only consider EIT events from the very recent past.
220 if (!it->IsStale()) {
222 atsc_major, atsc_minor, *it,
224 }
225
226 // Remove EIT event from the incomplete_event list.
227 delete [] (*it).m_desc;
228 (*eits_it).erase(it);
229 }
230 }
231}
232
234 QMap<uint,uint> languagePreferences,
235 QString &title, QString &subtitle,
236 QString &description, QMultiMap<QString,QString> &items)
237{
238 const unsigned char *bestShortEvent =
240 list, DescriptorID::short_event, languagePreferences);
241
242 // from EN 300 468, Appendix A.2 - Selection of character table
243 const enc_override enc_1 { 0x10, 0x00, 0x01 };
244 const enc_override enc_2 { 0x10, 0x00, 0x02 };
245 const enc_override enc_7 { 0x10, 0x00, 0x07 }; // Latin/Greek Alphabet
246 const enc_override enc_9 { 0x10, 0x00, 0x09 }; // could use { 0x05 } instead
247 const enc_override enc_15 { 0x10, 0x00, 0x0f }; // could use { 0x0B } instead
248 const enc_override enc_none {};
249 enc_override enc = enc_none;
250
251 // Is this BellExpressVU EIT (Canada) ?
252 // Use an encoding override of ISO 8859-1 (Latin1)
254 {
255 enc = enc_1;
256 }
257
258 // Is this broken DVB provider in Central Europe?
259 // Use an encoding override of ISO 8859-2 (Latin2)
261 {
262 enc = enc_2;
263 }
264
265 // Is this broken DVB provider in Western Europe?
266 // Use an encoding override of ISO 8859-9 (Latin5)
268 {
269 enc = enc_9;
270 }
271
272 // Is this broken DVB provider in Western Europe?
273 // Use an encoding override of ISO 8859-15 (Latin9)
275 {
276 enc = enc_15;
277 }
278
279 // Is this broken DVB provider in Greece?
280 // Use an encoding override of ISO 8859-7 (Latin/Greek)
282 {
283 enc = enc_7;
284 }
285
286 if (bestShortEvent)
287 {
288 ShortEventDescriptor sed(bestShortEvent);
289 if (sed.IsValid())
290 {
291 title = sed.EventName(enc);
292 subtitle = sed.Text(enc);
293 }
294 }
295
296 std::vector<const unsigned char*> bestExtendedEvents =
298 list, DescriptorID::extended_event, languagePreferences);
299
300 description = "";
301 for (auto & best_event : bestExtendedEvents)
302 {
303 if (!best_event)
304 {
305 description = "";
306 break;
307 }
308
309 ExtendedEventDescriptor eed(best_event);
310 if (eed.IsValid())
311 {
312 description += eed.Text(enc);
313 }
314 // add items from the descriptor to the items
315 items.unite (eed.Items());
316 }
317}
318
319static inline void parse_dvb_component_descriptors(const desc_list_t& list,
320 unsigned char &subtitle_type,
321 unsigned char &audio_properties,
322 unsigned char &video_properties)
323{
324 desc_list_t components =
326 for (auto & comp : components)
327 {
328 ComponentDescriptor component(comp);
329 if (!component.IsValid())
330 continue;
331 video_properties |= component.VideoProperties();
332 audio_properties |= component.AudioProperties();
333 subtitle_type |= component.SubtitleType();
334 }
335}
336
338{
339 // Discard event if incoming event queue full
340 if (EventQueueFull())
341 return;
342
343 uint chanid = 0;
344 if ((eit->TableID() == TableID::PF_EIT) ||
345 ((eit->TableID() >= TableID::SC_EITbeg) && (eit->TableID() <= TableID::SC_EITend)))
346 {
347 // EITa(ctive)
348 chanid = GetChanID(eit->ServiceID());
349 }
350 else
351 {
352 // EITo(ther)
353 chanid = GetChanID(eit->ServiceID(), eit->OriginalNetworkID(), eit->TSID());
354 // do not reschedule if its only present+following
355 if (eit->TableID() != TableID::PF_EITo)
356 {
357 m_seenEITother = true;
358 }
359 }
360 if (!chanid)
361 return;
362
363 uint descCompression = (eit->TableID() > 0x80) ? 2 : 1;
364 FixupValue fix = m_fixup.value((FixupKey)eit->OriginalNetworkID() << 16);
365 fix |= m_fixup.value((((FixupKey)eit->TSID()) << 32) |
366 ((FixupKey)eit->OriginalNetworkID() << 16));
367 fix |= m_fixup.value(((FixupKey)eit->OriginalNetworkID() << 16) |
368 (FixupKey)eit->ServiceID());
369 fix |= m_fixup.value((((FixupKey)eit->TSID()) << 32) |
370 ((FixupKey)eit->OriginalNetworkID() << 16) |
371 (FixupKey)eit->ServiceID());
373
374 uint tableid = eit->TableID();
375 uint version = eit->Version();
376 for (uint i = 0; i < eit->EventCount(); i++)
377 {
378 // Skip event if we have already processed it before...
379 if (!s_eitCache->IsNewEIT(chanid, tableid, version, eit->EventID(i),
380 eit->EndTimeUnixUTC(i)))
381 {
382 continue;
383 }
384
385 QString title = QString("");
386 QString subtitle = QString("");
387 QString description = QString("");
388 QString category = QString("");
390 unsigned char subtitle_type=0;
391 unsigned char audio_props=0;
392 unsigned char video_props=0;
393 uint season = 0;
394 uint episode = 0;
395 uint totalepisodes = 0;
396 QMultiMap<QString,QString> items;
397
398 // Parse descriptors
400 eit->Descriptors(i), eit->DescriptorsLength(i));
401
402 const unsigned char *dish_event_name = nullptr;
403 if (EITFixUp::kFixDish & fix)
404 {
405 dish_event_name = MPEGDescriptor::Find(
407 }
408
409 if (dish_event_name)
410 {
411 DishEventNameDescriptor dend(dish_event_name);
412 if (dend.IsValid() && dend.HasName())
413 title = dend.Name(descCompression);
414
415 const unsigned char *dish_event_description =
418 if (dish_event_description)
419 {
420 DishEventDescriptionDescriptor dedd(dish_event_description);
421 if (dedd.IsValid() && dedd.HasDescription())
422 description = dedd.Description(descCompression);
423 }
424 }
425 else
426 {
428 title, subtitle, description, items);
429 }
430
431 parse_dvb_component_descriptors(list, subtitle_type, audio_props,
432 video_props);
433
434 QString programId = QString("");
435 QString seriesId = QString("");
436 QString rating = QString("");
437 QString rating_system = QString("");
438 QString advisory = QString("");
439 float stars = 0.0;
440 QDate originalairdate;
441
442 if (EITFixUp::kFixDish & fix)
443 {
444 const unsigned char *mpaa_data = MPEGDescriptor::Find(
446 if (mpaa_data)
447 {
448 DishEventMPAADescriptor mpaa(mpaa_data);
449 if (mpaa.IsValid())
450 stars = mpaa.stars();
451
452 if (stars != 0.0F) // Only movies for now
453 {
454 rating = mpaa.rating();
455 rating_system = "MPAA";
456 advisory = mpaa.advisory();
457 }
458 }
459
460 if (stars == 0.0F) // Not MPAA rated, check VCHIP
461 {
462 const unsigned char *vchip_data = MPEGDescriptor::Find(
464 if (vchip_data)
465 {
466 DishEventVCHIPDescriptor vchip(vchip_data);
467 rating = vchip.rating();
468 rating_system = "VCHIP";
469 advisory = vchip.advisory();
470 }
471 }
472
473 if (!advisory.isEmpty() && !rating.isEmpty())
474 {
475 rating += ", " + advisory;
476 }
477 else if (!advisory.isEmpty())
478 {
479 rating = advisory;
480 rating_system = "advisory";
481 }
482
483 const unsigned char *tags_data = MPEGDescriptor::Find(
485 if (tags_data)
486 {
487 DishEventTagsDescriptor tags(tags_data);
488 seriesId = tags.seriesid();
489 programId = tags.programid();
490 originalairdate = tags.originalairdate(); // future use
491
492 if (programId.startsWith("MV") || programId.startsWith("SP"))
493 seriesId = "";
494 }
495
496 const unsigned char *properties_data = MPEGDescriptor::Find(
498 if (properties_data)
499 {
500 DishEventPropertiesDescriptor properties(properties_data);
501 subtitle_type |= properties.SubtitleProperties(descCompression);
502 audio_props |= properties.AudioProperties(descCompression);
503 }
504 }
505
506 const unsigned char *content_data =
508 if (content_data)
509 {
510 if ((EITFixUp::kFixDish & fix) || (EITFixUp::kFixBell & fix))
511 {
512 DishContentDescriptor content(content_data);
513 switch (content.GetTheme())
514 {
515 case kThemeMovie :
516 category_type = ProgramInfo::kCategoryMovie;
517 break;
518 case kThemeSeries :
519 category_type = ProgramInfo::kCategorySeries;
520 break;
521 case kThemeSports :
522 category_type = ProgramInfo::kCategorySports;
523 break;
524 default :
525 category_type = ProgramInfo::kCategoryNone;
526 }
527 if (EITFixUp::kFixDish & fix)
528 category = content.GetCategory();
529 }
530 else if (EITFixUp::kFixAUDescription & fix)//AU Freeview assigned genres
531 {
532 static const std::array<const std::string,16> s_auGenres
533 {/* 0*/"Unknown", "Movie", "News", "Entertainment",
534 /* 4*/"Sport", "Children", "Music", "Arts/Culture",
535 /* 8*/"Current Affairs", "Education", "Infotainment",
536 /*11*/"Special", "Comedy", "Drama", "Documentary",
537 /*15*/"Unknown"};
538 ContentDescriptor content(content_data);
539 if (content.IsValid())
540 {
541 category = QString::fromStdString(s_auGenres[content.Nibble1(0)]);
542 category_type = content.GetMythCategory(0);
543 }
544 }
545 else if (EITFixUp::kFixGreekEIT & fix)//Greek
546 {
547 static const std::array<const std::string,16>s_grGenres
548 {/* 0*/"Unknown", "Ταινία", "Ενημερωτικό", "Unknown",
549 /* 4*/"Αθλητικό", "Παιδικό", "Unknown", "Unknown",
550 /* 8*/"Unknown", "Ντοκιμαντέρ", "Unknown", "Unknown",
551 /*12*/"Unknown", "Unknown", "Unknown", "Unknown"};
552 ContentDescriptor content(content_data);
553 if (content.IsValid())
554 {
555 category = QString::fromStdString(s_grGenres[content.Nibble2(0)]);
556 category_type = content.GetMythCategory(2);
557 }
558 }
559 else
560 {
561 ContentDescriptor content(content_data);
562 if (content.IsValid())
563 {
564 category = content.GetDescription(0);
565#if 0 /* there is no category_type in DVB EIT */
566 category_type = content.GetMythCategory(0);
567#endif
568 }
569 }
570 }
571
572 desc_list_t contentIds =
574 for (auto & id : contentIds)
575 {
577 if (!desc.IsValid())
578 continue;
579 for (size_t k = 0; k < desc.CRIDCount(); k++)
580 {
581 if (desc.ContentEncoding(k) == 0)
582 {
583 // The CRID is a URI. It could contain UTF8 sequences encoded
584 // as %XX but there's no advantage in decoding them.
585 // The BBC currently uses private types 0x31 and 0x32.
586 // IDs from the authority eventis.nl are not fit for our scheduler
587 if (desc.ContentType(k) == 0x01 || desc.ContentType(k) == 0x31)
588 {
589 if (!desc.ContentId(k).startsWith ("eventis.nl/"))
590 {
591 programId = desc.ContentId(k);
592 }
593 }
594 else if (desc.ContentType(k) == 0x02 || desc.ContentType(k) == 0x32)
595 {
596 if (!desc.ContentId(k).startsWith ("eventis.nl/"))
597 {
598 seriesId = desc.ContentId(k);
599 }
600 category_type = ProgramInfo::kCategorySeries;
601 }
602 }
603 }
604 }
605
606 /* if we don't have a subtitle, try to parse one from private descriptors */
607 if (subtitle.isEmpty()) {
608 bool isUPC = false;
609 /* is this event carrying UPC private data? */
611 for (auto & specifier : private_data_specifiers) {
612 PrivateDataSpecifierDescriptor desc(specifier);
613 if (!desc.IsValid())
614 continue;
615 if (desc.PrivateDataSpecifier() == PrivateDataSpecifierID::UPC1) {
616 isUPC = true;
617 }
618 }
619
620 if (isUPC) {
622 for (auto & st : subtitles) {
624 if (!desc.IsValid())
625 continue;
626 subtitle = desc.Text();
627 }
628 }
629 }
630
631
632 QDateTime starttime = eit->StartTimeUTC(i);
633 // fix starttime only if the duration is a multiple of a minute
634 if (!(eit->DurationInSeconds(i) % 60))
635 EITFixUp::TimeFix(starttime);
636 QDateTime endtime = starttime.addSecs(eit->DurationInSeconds(i));
637
638 auto *event = new DBEventEIT(
639 chanid,
640 title, subtitle, description,
641 category, category_type,
642 starttime, endtime, fix,
643 subtitle_type,
644 audio_props,
645 video_props, stars,
646 seriesId, programId,
647 season, episode, totalepisodes);
648 event->m_items = items;
649
650 m_dbEvents.enqueue(event);
651 }
652}
653
654// This function gets special EIT data from the German provider Premiere
655// for the option channels Premiere Sport and Premiere Direkt
657{
658 // Discard event if incoming event queue full
659 if (EventQueueFull())
660 return;
661
662 // set fixup for Premiere
663 FixupValue fix = m_fixup.value(133 << 16);
665
666 QString title = QString("");
667 QString subtitle = QString("");
668 QString description = QString("");
669 QString category = QString("");
671 unsigned char subtitle_type=0;
672 unsigned char audio_props=0;
673 unsigned char video_props=0;
674 uint season = 0;
675 uint episode = 0;
676 uint totalepisodes = 0;
677 QMultiMap<QString,QString> items;
678
679 // Parse descriptors
681 cit->Descriptors(), cit->DescriptorsLength());
682
684 title, subtitle, description, items);
685
686 parse_dvb_component_descriptors(list, subtitle_type, audio_props,
687 video_props);
688
689 const unsigned char *content_data =
691 if (content_data)
692 {
693 ContentDescriptor content(content_data);
694 // fix events without real content data
695 if (content.IsValid() && (content.Nibble(0)==0x00))
696 {
697 if(content.UserNibble(0)==0x1)
698 {
699 category_type = ProgramInfo::kCategoryMovie;
700 }
701 else if(content.UserNibble(0)==0x0)
702 {
703 category_type = ProgramInfo::kCategorySports;
704 category = QObject::tr("Sports");
705 }
706 }
707 else if (content.IsValid())
708 {
709 category_type = content.GetMythCategory(0);
710 category = content.GetDescription(0);
711 }
712 else
713 {
714 category_type = ProgramInfo::kCategoryNone;
715 category = "Unknown";
716 }
717 }
718
719 uint tableid = cit->TableID();
720 uint version = cit->Version();
721 uint contentid = cit->ContentID();
722 // fake endtime
723 uint endtime = MythDate::current().addDays(1).toSecsSinceEpoch();
724
725 // Find Transmissions
726 desc_list_t transmissions =
729 for (auto & trans : transmissions)
730 {
731 PremiereContentTransmissionDescriptor transmission(trans);
732 if (!transmission.IsValid())
733 continue;
734 uint networkid = transmission.OriginalNetworkID();
735 uint tsid = transmission.TSID();
736 uint serviceid = transmission.ServiceID();
737
738 uint chanid = GetChanID(serviceid, networkid, tsid);
739
740 if (!chanid)
741 {
742 LOG(VB_EIT, LOG_INFO, LOC_ID +
743 QString("Premiere EIT for NIT %1, TID %2, SID %3, "
744 "count %4, title: %5. Channel not found!")
745 .arg(networkid).arg(tsid).arg(serviceid)
746 .arg(transmission.TransmissionCount()).arg(title));
747 continue;
748 }
749
750 // Skip event if we have already processed it before...
751 if (!s_eitCache->IsNewEIT(chanid, tableid, version, contentid, endtime))
752 {
753 continue;
754 }
755
756 for (uint k=0; k<transmission.TransmissionCount(); ++k)
757 {
758 QDateTime txstart = transmission.StartTimeUTC(k);
759 // fix txstart only if the duration is a multiple of a minute
760 if (!(cit->DurationInSeconds() % 60))
761 EITFixUp::TimeFix(txstart);
762 QDateTime txend = txstart.addSecs(cit->DurationInSeconds());
763
764 auto *event = new DBEventEIT(
765 chanid,
766 title, subtitle, description,
767 category, category_type,
768 txstart, txend, fix,
769 subtitle_type,
770 audio_props,
771 video_props, 0.0,
772 "", "",
773 season, episode, totalepisodes);
774 event->m_items = items;
775
776 m_dbEvents.enqueue(event);
777 }
778 }
779}
780
781
783{
784 s_eitCache->PruneOldEntries(timestamp);
785}
786
788{
790}
791
793// private methods and functions below this line //
795
796void EITHelper::CompleteEvent(uint atsc_major, uint atsc_minor,
797 const ATSCEvent &event,
798 const QString &ett)
799{
800 // Discard event if incoming event queue full
801 if (EventQueueFull())
802 return;
803
804 uint chanid = GetChanID(atsc_major, atsc_minor);
805 if (!chanid)
806 return;
807
808 QDateTime starttime = MythDate::fromSecsSinceEpoch(
810
811 // fix starttime only if the duration is a multiple of a minute
812 if (!(event.m_length % 60))
813 EITFixUp::TimeFix(starttime);
814 QDateTime endtime = starttime.addSecs(event.m_length);
815
817 unsigned char subtitle_type =
819 SUB_HARDHEAR : SUB_UNKNOWN;
820 unsigned char audio_properties = AUD_UNKNOWN;
821 unsigned char video_properties = VID_UNKNOWN;
822
823 uint atsc_key = (atsc_major << 16) | atsc_minor;
824
825 QMutexLocker locker(&m_eitListLock);
826 QString title = event.m_title;
827 const QString& subtitle = ett;
828 m_dbEvents.enqueue(new DBEventEIT(chanid, title, subtitle,
829 starttime, endtime,
830 m_fixup.value(atsc_key), subtitle_type,
831 audio_properties, video_properties));
832}
833
834uint EITHelper::GetChanID(uint atsc_major, uint atsc_minor)
835{
836 uint sourceid = m_sourceid;
837 if (sourceid == 0)
838 return 0;
839
840 uint64_t key = sourceid;
841 key |= ((uint64_t) atsc_minor) << 16;
842 key |= ((uint64_t) atsc_major) << 32;
843
844 ServiceToChanID::const_iterator it = m_srvToChanid.constFind(key);
845 if (it != m_srvToChanid.constEnd())
846 return *it;
847
848 uint chanid = get_chan_id_from_db_atsc(sourceid, atsc_major, atsc_minor);
849 m_srvToChanid[key] = chanid;
850
851 return chanid;
852}
853
854uint EITHelper::GetChanID(uint serviceid, uint networkid, uint tsid)
855{
856 uint sourceid = m_sourceid;
857 if (sourceid == 0)
858 return 0;
859
860 uint64_t key = sourceid;
861 key |= ((uint64_t) serviceid) << 16;
862 key |= ((uint64_t) networkid) << 32;
863 key |= ((uint64_t) tsid) << 48;
864
865 ServiceToChanID::const_iterator it = m_srvToChanid.constFind(key);
866 if (it != m_srvToChanid.constEnd())
867 return *it;
868
869 uint chanid = get_chan_id_from_db_dvb(sourceid, serviceid, networkid, tsid);
870 m_srvToChanid[key] = chanid;
871
872 return chanid;
873}
874
876{
877 uint sourceid = m_sourceid;
878 if (sourceid == 0)
879 return 0;
880
881 uint64_t key = sourceid;
882 key |= ((uint64_t) program_number) << 16;
883 key |= ((uint64_t) m_channelid) << 32;
884
885 ServiceToChanID::const_iterator it = m_srvToChanid.constFind(key);
886 if (it != m_srvToChanid.constEnd())
887 return *it;
888
889 uint chanid = get_chan_id_from_db_dtv(sourceid, program_number, m_channelid);
890 m_srvToChanid[key] = chanid;
891
892 return chanid;
893}
894
896 uint atsc_major, uint atsc_minor)
897{
899 query.prepare(
900 "SELECT chanid, useonairguide "
901 "FROM channel "
902 "WHERE deleted IS NULL AND "
903 " atsc_major_chan = :MAJORCHAN AND "
904 " atsc_minor_chan = :MINORCHAN AND "
905 " sourceid = :SOURCEID");
906 query.bindValue(":MAJORCHAN", atsc_major);
907 query.bindValue(":MINORCHAN", atsc_minor);
908 query.bindValue(":SOURCEID", sourceid);
909
910 if (!query.exec() || !query.isActive())
911 {
912 MythDB::DBError("Looking up chanid 1", query);
913 }
914 else if (query.next())
915 {
916 bool useOnAirGuide = query.value(1).toBool();
917 return useOnAirGuide ? query.value(0).toUInt() : 0;
918 }
919
920 return 0;
921}
922
923// Figure out the chanid for this channel
924static uint get_chan_id_from_db_dvb(uint sourceid, uint serviceid,
925 uint networkid, uint transportid)
926{
928
929 // DVB Link to chanid
930 QString qstr =
931 "SELECT chanid, useonairguide "
932 "FROM channel, dtv_multiplex "
933 "WHERE deleted IS NULL AND "
934 " serviceid = :SERVICEID AND "
935 " networkid = :NETWORKID AND "
936 " transportid = :TRANSPORTID AND "
937 " channel.sourceid = :SOURCEID AND "
938 " channel.mplexid = dtv_multiplex.mplexid";
939
940 query.prepare(qstr);
941 query.bindValue(":SERVICEID", serviceid);
942 query.bindValue(":NETWORKID", networkid);
943 query.bindValue(":TRANSPORTID", transportid);
944 query.bindValue(":SOURCEID", sourceid);
945
946 if (!query.exec() || !query.isActive())
947 {
948 MythDB::DBError("Looking up chanID", query);
949 return 0;
950 }
951
952 if (query.size() > 1)
953 {
954 LOG(VB_EIT, LOG_ERR, LOC +
955 QString("Found %1 channels for sourceid %1 networkid %2 "
956 "transportid %3 serviceid %4 but only one expected")
957 .arg(query.size())
958 .arg(sourceid).arg(networkid).arg(transportid).arg(serviceid));
959 }
960
961 while (query.next())
962 {
963 uint chanid = query.value(0).toUInt();
964 bool useOnAirGuide = query.value(1).toBool();
965 return useOnAirGuide ? chanid : 0;
966 }
967
968 // EIT information for channels that are not present such as encrypted
969 // channels when only FTA channels are selected etc.
970 LOG(VB_EIT, LOG_DEBUG, LOC +
971 QString("No channel found for sourceid %1 networkid %2 "
972 "transportid %3 serviceid %4")
973 .arg(sourceid).arg(networkid).arg(transportid).arg(serviceid));
974
975 return 0;
976}
977
978/* Figure out the chanid for this channel from the sourceid,
979 * program_number/service_id and the chanid of the channel we are tuned to
980 *
981 * TODO for SPTS (e.g. HLS / IPTV) it would be useful to match without an entry
982 * in dtv_multiplex
983 */
984static uint get_chan_id_from_db_dtv(uint sourceid, uint serviceid,
985 uint tunedchanid)
986{
987 uint db_sourceid = 0;
989
990 // DVB Link to chanid
991 QString qstr =
992 "SELECT c1.chanid, c1.useonairguide, c1.sourceid "
993 "FROM channel c1, dtv_multiplex m, channel c2 "
994 "WHERE c1.deleted IS NULL AND "
995 " c1.serviceid = :SERVICEID AND "
996 " c1.mplexid = m.mplexid AND "
997 " m.mplexid = c2.mplexid AND "
998 " c2.chanid = :CHANID";
999
1000 query.prepare(qstr);
1001 query.bindValue(":SERVICEID", serviceid);
1002 query.bindValue(":CHANID", tunedchanid);
1003
1004 if (!query.exec() || !query.isActive())
1005 {
1006 MythDB::DBError("Looking up chanID", query);
1007 return 0;
1008 }
1009
1010 while (query.next())
1011 {
1012 // Check to see if we are interested in this channel
1013 uint chanid = query.value(0).toUInt();
1014 bool useOnAirGuide = query.value(1).toBool();
1015 db_sourceid = query.value(2).toUInt();
1016 if (sourceid == db_sourceid)
1017 return useOnAirGuide ? chanid : 0;
1018 }
1019
1020 if (query.size() > 0)
1021 {
1022 LOG(VB_EIT, LOG_DEBUG,
1023 LOC + QString("Found %1 channels for multiplex of chanid %2, "
1024 "serviceid %3, sourceid %4 in database but none "
1025 "for current sourceid %5.")
1026 .arg(query.size()).arg(tunedchanid)
1027 .arg(serviceid).arg(db_sourceid).arg(sourceid));
1028 }
1029
1030 return 0;
1031}
1032
1033static void init_fixup(FixupMap &fix)
1034{
1036 // Fixups to make EIT provided listings more useful
1037 // transport_id<<32 | original_network_id<<16 | service_id
1038
1039 // Bell Express VU Canada
1040 fix[ 256U << 16] = EITFixUp::kFixBell;
1041 fix[ 257U << 16] = EITFixUp::kFixBell;
1042 fix[ 4100U << 16] = EITFixUp::kFixBell;
1043 fix[ 4101U << 16] = EITFixUp::kFixBell;
1044 fix[ 4102U << 16] = EITFixUp::kFixBell;
1045 fix[ 4103U << 16] = EITFixUp::kFixBell;
1046 fix[ 4104U << 16] = EITFixUp::kFixBell;
1047 fix[ 4105U << 16] = EITFixUp::kFixBell;
1048 fix[ 4106U << 16] = EITFixUp::kFixBell;
1049 fix[ 4107U << 16] = EITFixUp::kFixBell;
1050 fix[ 4097U << 16] = EITFixUp::kFixBell;
1051 fix[ 4098U << 16] = EITFixUp::kFixBell;
1052
1053 // United Kingdom - DVB-T/T2
1054 fix[ 9018U << 16] = EITFixUp::kFixUK;
1055
1056 // UK - Astra 28.2
1057 for (int i = 2001; i <= 2035; ++i)
1058 fix[ (long long)i << 32 | 2U << 16] = EITFixUp::kFixUK;
1059
1060 fix[ 2036LL << 32 | 2U << 16] = EITFixUp::kFixUK | EITFixUp::kFixHTML;
1061
1062 for (int i = 2037; i <= 2057; ++i)
1063 fix[ (long long)i << 32 | 2U << 16] = EITFixUp::kFixUK;
1064 fix[ 2059LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1065 for (int i = 2061; i <= 2069; ++i)
1066 fix[ (long long)i << 32 | 2U << 16] = EITFixUp::kFixUK;
1067 fix[ 2071LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1068 fix[ 2076LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1069 fix[ 2081LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1070 for (int i = 2089; i <= 2116; ++i)
1071 fix[ (long long)i << 32 | 2U << 16] = EITFixUp::kFixUK;
1072 fix[ 2301LL << 32 | 2U << 16] = EITFixUp::kFixUK | EITFixUp::kFixHTML;
1073 fix[ 2302LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1074 fix[ 2303LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1075 fix[ 2304LL << 32 | 2U << 16] = EITFixUp::kFixUK | EITFixUp::kFixHTML;
1076 fix[ 2305LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1077 fix[ 2306LL << 32 | 2U << 16] = EITFixUp::kFixUK | EITFixUp::kFixHTML;
1078 fix[ 2311LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1079 fix[ 2312LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1080 fix[ 2313LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1081 fix[ 2314LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1082 fix[ 2315LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1083 fix[ 2316LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1084 for (int i = 2401; i <= 2413; ++i)
1085 fix[ (long long)i << 32 | 2U << 16] = EITFixUp::kFixUK;
1086 fix[ 2601LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1087 fix[ 2602LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1088 fix[ 2603LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1089 fix[ 2604LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1090 fix[ 2612LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1091 fix[ 2614LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1092 fix[ 2611LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1093 fix[ 2612LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1094 fix[ 2613LL << 32 | 2U << 16] = EITFixUp::kFixUK;
1095
1096 // R.caroline
1097 fix[ 2315LL << 32 | 59U << 16] = EITFixUp::kFixUK;
1098
1099 // ComHem Sweden
1100 fix[40999U << 16 ] = EITFixUp::kFixComHem;
1101 fix[40999U << 16 | 1070] = EITFixUp::kFixSubtitle;
1102 fix[40999U << 16 | 1308] = EITFixUp::kFixSubtitle;
1103 fix[40999U << 16 | 1041] = EITFixUp::kFixSubtitle;
1104 fix[40999U << 16 | 1306] = EITFixUp::kFixSubtitle;
1105 fix[40999U << 16 | 1307] = EITFixUp::kFixSubtitle;
1106 fix[40999U << 16 | 1030] = EITFixUp::kFixSubtitle;
1107 fix[40999U << 16 | 1016] = EITFixUp::kFixSubtitle;
1108 fix[40999U << 16 | 1131] = EITFixUp::kFixSubtitle;
1109 fix[40999U << 16 | 1068] = EITFixUp::kFixSubtitle;
1110 fix[40999U << 16 | 1069] = EITFixUp::kFixSubtitle;
1111
1112 // Australia
1113 fix[ 4096U << 16] = EITFixUp::kFixAUStar;
1114 fix[ 4112U << 16] = EITFixUp::kFixAUDescription | EITFixUp::kFixAUFreeview; // ABC Brisbane
1115 fix[ 4114U << 16] = EITFixUp::kFixAUDescription | EITFixUp::kFixAUFreeview | EITFixUp::kFixAUNine;; // Nine Brisbane
1116 fix[ 4115U << 16] = EITFixUp::kFixAUDescription | EITFixUp::kFixAUSeven; //Seven
1117 fix[ 4116U << 16] = EITFixUp::kFixAUDescription; //Ten
1118 fix[ 12801U << 16] = EITFixUp::kFixAUFreeview | EITFixUp::kFixAUDescription; //ABC
1119 fix[ 12802U << 16] = EITFixUp::kFixAUDescription; //SBS
1121 fix[ 12842U << 16] = EITFixUp::kFixAUDescription; // 31 Brisbane
1122 fix[ 12862U << 16] = EITFixUp::kFixAUDescription; //WestTV
1123
1124 // MultiChoice Africa
1125 fix[ 6144U << 16] = EITFixUp::kFixMCA;
1126
1127 // RTL Subtitle parsing
1128 fix[ 1089LL << 32 | 1 << 16] = // DVB-S
1129 fix[ 1041LL << 32 | 1 << 16] = // DVB-S RTL Group HD Austria Transponder
1130 fix[ 1057LL << 32 | 1 << 16] = // DVB-S RTL Group HD Transponder
1132
1133 // Mark HD+ channels as HDTV
1134 fix[ 1041LL << 32 | 1 << 16] = EITFixUp::kFixHDTV;
1135 fix[ 1055LL << 32 | 1 << 16] = EITFixUp::kFixHDTV;
1136 fix[ 1057LL << 32 | 1 << 16] = EITFixUp::kFixHDTV;
1137 fix[ 1109LL << 32 | 1 << 16] = EITFixUp::kFixHDTV;
1138
1139 // PRO7/SAT.1 DVB-S
1140 fix[ 1017LL << 32 | 1 << 16] = EITFixUp::kFixHDTV | EITFixUp::kFixP7S1; // DVB-S ProSiebenSat.1 Austria transponder
1141 fix[ 1031LL << 32 | 1 << 16 | 5300] = EITFixUp::kFixHDTV | EITFixUp::kFixP7S1; // SAT.1 HD Austria
1142 fix[ 1031LL << 32 | 1 << 16 | 5301] = EITFixUp::kFixHDTV | EITFixUp::kFixP7S1; // ProSieben HD Austria
1143 fix[ 1031LL << 32 | 1 << 16 | 5302] = EITFixUp::kFixHDTV | EITFixUp::kFixP7S1; // kabel eins HD Austria
1144 fix[ 1031LL << 32 | 1 << 16 | 5303] = EITFixUp::kFixHDTV | EITFixUp::kFixP7S1; // PULS 4 HD Austria
1145 fix[ 1031LL << 32 | 1 << 16 | 5310] = EITFixUp::kFixP7S1; // SAT.1 Gold Austria
1146 fix[ 1031LL << 32 | 1 << 16 | 5311] = EITFixUp::kFixP7S1; // Pro7 MAXX Austria
1147 fix[ 1107LL << 32 | 1 << 16] = EITFixUp::kFixP7S1; // DVB-S ProSiebenSat.1 Germany transponder
1148 fix[ 1082LL << 32 | 1 << 16] = EITFixUp::kFixP7S1; // DVB-S ProSiebenSat.1 Switzerland transponder
1149 fix[ 5LL << 32 | 133 << 16 | 776] = EITFixUp::kFixP7S1; // DVB-S ProSiebenSat.1 Germany transponder
1150
1151 // ATV / ATV2
1152 fix[ 1117LL << 32 | 1 << 16 | 13012 ] = EITFixUp::kFixATV; // ATV
1153 fix[ 1003LL << 32 | 1 << 16 | 13223 ] = EITFixUp::kFixATV; // ATV2
1154 fix[ 1003LL << 32 | 1 << 16 | 13228 ] = EITFixUp::kFixHDTV | EITFixUp::kFixATV; // ATV HD
1155
1156 // Disney Channel Germany
1157 fix[ 1055LL << 32 | 1 << 16 | 5500 ] = EITFixUp::kFixHDTV | EITFixUp::kFixDisneyChannel; // Disney Channel HD
1158 fix[ 1055LL << 32 | 1 << 16 | 5510 ] = EITFixUp::kFixHDTV | EITFixUp::kFixDisneyChannel; // Disney Channel HD Austria
1159 fix[ 5LL << 32 | 133 << 16 | 1793 ] = EITFixUp::kFixDisneyChannel; // Disney Channel HD Austria
1160 fix[ 1109LL << 32 | 1 << 16 | 5401 ] = EITFixUp::kFixHDTV | EITFixUp::kFixDisneyChannel; // Tele 5 HD
1161 fix[ 1109LL << 32 | 1 << 16 | 5421 ] = EITFixUp::kFixHDTV | EITFixUp::kFixDisneyChannel; // Tele 5 HD Austria
1162 fix[ 33LL << 32 | 133 << 16 | 51 ] = EITFixUp::kFixDisneyChannel; // Tele 5
1163
1164 // Premiere EIT processing
1165 fix[ 1LL << 32 | 133 << 16] = EITFixUp::kFixPremiere;
1166 fix[ 2LL << 32 | 133 << 16] = EITFixUp::kFixPremiere;
1167 fix[ 3LL << 32 | 133 << 16] = EITFixUp::kFixPremiere;
1168 fix[ 4LL << 32 | 133 << 16] = EITFixUp::kFixPremiere;
1169 fix[ 6LL << 32 | 133 << 16] = EITFixUp::kFixPremiere | EITFixUp::kFixHDTV;
1170 fix[ 8LL << 32 | 133 << 16] = EITFixUp::kFixPremiere | EITFixUp::kFixHDTV;
1171 fix[ 9LL << 32 | 133 << 16] = EITFixUp::kFixPremiere | EITFixUp::kFixHDTV;
1172 fix[ 10LL << 32 | 133 << 16] = EITFixUp::kFixPremiere | EITFixUp::kFixHDTV;
1173 fix[ 11LL << 32 | 133 << 16] = EITFixUp::kFixPremiere | EITFixUp::kFixHDTV;
1174 fix[ 12LL << 32 | 133 << 16] = EITFixUp::kFixPremiere | EITFixUp::kFixHDTV;
1175 fix[ 13LL << 32 | 133 << 16] = EITFixUp::kFixPremiere | EITFixUp::kFixHDTV;
1176 fix[ 14LL << 32 | 133 << 16] = EITFixUp::kFixPremiere | EITFixUp::kFixHDTV;
1177 fix[ 15LL << 32 | 133 << 16] = EITFixUp::kFixPremiere;
1178 fix[ 17LL << 32 | 133 << 16] = EITFixUp::kFixPremiere;
1179 // Mark Premiere HD, AXN HD and Discovery HD as HDTV
1180 fix[ 6LL << 32 | 133 << 16 | 129] = EITFixUp::kFixHDTV;
1181 fix[ 6LL << 32 | 133 << 16 | 130] = EITFixUp::kFixHDTV;
1182 fix[ 10LL << 32 | 133 << 16 | 125] = EITFixUp::kFixHDTV;
1183
1184 // Netherlands DVB-C
1185 fix[ 1000U << 16] = EITFixUp::kFixNL;
1186 // Canal Digitaal DVB-S 19.2 Dutch/Belgian ONID 53 covers all CanalDigitaal TiD
1187 fix[ 53U << 16] = EITFixUp::kFixNL;
1188 // Canal Digitaal DVB-S 23.5 Dutch/Belgian
1189 fix[ 3202LL << 32 | 3U << 16] = EITFixUp::kFixNL;
1190 fix[ 3208LL << 32 | 3U << 16] = EITFixUp::kFixNL;
1191 fix[ 3211LL << 32 | 3U << 16] = EITFixUp::kFixNL;
1192 fix[ 3222LL << 32 | 3U << 16] = EITFixUp::kFixNL;
1193 fix[ 3225LL << 32 | 3U << 16] = EITFixUp::kFixNL;
1194
1195 // Finland
1196 fix[ 8438U << 16] = // DVB-T Espoo
1197 fix[ 42249U << 16] = // DVB-C Welho
1198 fix[ 15U << 16] = // DVB-C Welho
1200
1201 // DVB-C YouSee (Denmark)
1202 fix[65024U << 16] = EITFixUp::kFixDK;
1203
1204 // DVB-S(2) Thor 0.8W Norwegian
1205 fix[70U << 16] = EITFixUp::kFixNO;
1206
1207 // DVB-T NTV/NRK (Norway)
1208 fix[910LL << 32 | 8770U << 16 | 0x006f] = EITFixUp::kFixNRK_DVBT; //NRK Folkemusikk
1209 fix[910LL << 32 | 8770U << 16 | 0x0070] = EITFixUp::kFixNRK_DVBT; //NRK Stortinget
1210 fix[910LL << 32 | 8770U << 16 | 0x0071] = EITFixUp::kFixNRK_DVBT; //NRK Super
1211 fix[910LL << 32 | 8770U << 16 | 0x0072] = EITFixUp::kFixNRK_DVBT; //NRK Sport
1212 fix[910LL << 32 | 8770U << 16 | 0x0073] = EITFixUp::kFixNRK_DVBT; //NRK Gull
1213 fix[910LL << 32 | 8770U << 16 | 0x0074] = EITFixUp::kFixNRK_DVBT; //NRK Jazz
1214 fix[910LL << 32 | 8770U << 16 | 0x0067] = EITFixUp::kFixNRK_DVBT; //NRK Super / NRK3
1215 fix[910LL << 32 | 8770U << 16 | 0x0068] = EITFixUp::kFixNRK_DVBT; //NRK Tegnspr�
1216 fix[910LL << 32 | 8770U << 16 | 0x0069] = EITFixUp::kFixNRK_DVBT; //NRK P2
1217 fix[910LL << 32 | 8770U << 16 | 0x006a] = EITFixUp::kFixNRK_DVBT; //NRK P3
1218 fix[910LL << 32 | 8770U << 16 | 0x006b] = EITFixUp::kFixNRK_DVBT; //NRK Alltid Nyheter
1219 fix[910LL << 32 | 8770U << 16 | 0x006c] = EITFixUp::kFixNRK_DVBT; //NRK mP3
1220 fix[910LL << 32 | 8770U << 16 | 0x006d] = EITFixUp::kFixNRK_DVBT; //NRK Klassisk
1221 fix[910LL << 32 | 8770U << 16 | 0x006e] = EITFixUp::kFixNRK_DVBT; //NRK S�i Radio
1222 fix[910LL << 32 | 8770U << 16 | 0x0066] = EITFixUp::kFixNRK_DVBT; //NRK2
1223 fix[910LL << 32 | 8770U << 16 | 0x03f0] = EITFixUp::kFixNRK_DVBT; //NRK1 M�e og Romsdal
1224 fix[910LL << 32 | 8770U << 16 | 0x0455] = EITFixUp::kFixNRK_DVBT; //NRK P1 Tr�delag
1225 fix[910LL << 32 | 8770U << 16 | 0x03f1] = EITFixUp::kFixNRK_DVBT; //NRK1 Midtnytt
1226
1228 // Special Early fixups for providers that break DVB EIT spec.
1229 // transport_id<<32 | network_id<<16 | service_id
1230
1231 // Bell Express VU Canada
1232 fix[ 256U << 16] |= EITFixUp::kEFixForceISO8859_1;
1233 fix[ 257U << 16] |= EITFixUp::kEFixForceISO8859_1;
1234 fix[4100U << 16] |= EITFixUp::kEFixForceISO8859_1;
1235 fix[4101U << 16] |= EITFixUp::kEFixForceISO8859_1;
1236 fix[4102U << 16] |= EITFixUp::kEFixForceISO8859_1;
1237 fix[4103U << 16] |= EITFixUp::kEFixForceISO8859_1;
1238 fix[4104U << 16] |= EITFixUp::kEFixForceISO8859_1;
1239 fix[4105U << 16] |= EITFixUp::kEFixForceISO8859_1;
1240 fix[4106U << 16] |= EITFixUp::kEFixForceISO8859_1;
1241 fix[4107U << 16] |= EITFixUp::kEFixForceISO8859_1;
1242 fix[4097U << 16] |= EITFixUp::kEFixForceISO8859_1;
1243 fix[4098U << 16] |= EITFixUp::kEFixForceISO8859_1;
1244
1245 // DVB-C Vodafone Germany
1246 fix[ 10002LL<<32 | 61441U << 16 | 53009 ] = EITFixUp::kFixP7S1; // ProSieben MAXX
1247 fix[ 10002LL<<32 | 61441U << 16 | 53324 ] = EITFixUp::kFixP7S1; // SAT.1 Gold
1248 fix[ 10005LL<<32 | 61441U << 16 | 50122 ] = EITFixUp::kFixP7S1; // kabel eins Doku
1249 fix[ 10005LL<<32 | 61441U << 16 | 50700 ] = EITFixUp::kFixP7S1; // sixx
1250 fix[ 10005LL<<32 | 61441U << 16 | 53621 ] = EITFixUp::kFixP7S1; // ProSieben
1251 fix[ 10005LL<<32 | 61441U << 16 | 53622 ] = EITFixUp::kFixP7S1; // kabel eins
1252 fix[ 10006LL<<32 | 61441U << 16 | 50019 ] = EITFixUp::kFixP7S1; // sixx HD
1253 fix[ 10011LL<<32 | 61441U << 16 | 50056 ] = EITFixUp::kFixP7S1; // kabel eins CLASSICS HD
1254 fix[ 10011LL<<32 | 61441U << 16 | 50058 ] = EITFixUp::kFixP7S1; // SAT.1 emotions HD
1255 fix[ 10013LL<<32 | 61441U << 16 | 50015 ] = EITFixUp::kFixP7S1; // ProSieben HD
1256 fix[ 10013LL<<32 | 61441U << 16 | 50057 ] = EITFixUp::kFixP7S1; // ProSieben FUN HD
1257 fix[ 10013LL<<32 | 61441U << 16 | 50086 ] = EITFixUp::kFixP7S1; // Kabel eins Doku HD
1258 fix[ 10014LL<<32 | 61441U << 16 | 50009 ] = EITFixUp::kFixP7S1; // kabel eins HD
1259 fix[ 10019LL<<32 | 61441U << 16 | 50018 ] = EITFixUp::kFixP7S1; // SAT.1 HD
1260 fix[ 10019LL<<32 | 61441U << 16 | 53626 ] = EITFixUp::kFixP7S1; // SAT.1
1261 fix[ 10020LL<<32 | 61441U << 16 | 50046 ] = EITFixUp::kFixP7S1; // ProSieben MAXX HD
1262 fix[ 10020LL<<32 | 61441U << 16 | 50074 ] = EITFixUp::kFixP7S1; // SAT.1 Gold HD
1263
1264 // DVB-C Unitymedia Germany
1265 fix[ 9999 << 16 | 161LL << 32 | 12101 ] = // RTL Television
1266 fix[ 9999 << 16 | 161LL << 32 | 12104 ] = // VOX
1267 fix[ 9999 << 16 | 161LL << 32 | 12107 ] = // Super RTL
1268 fix[ 9999 << 16 | 161LL << 32 | 12109 ] = // n-tv
1269 fix[ 9999 << 16 | 301LL << 32 | 30114 ] = // RTL NITRO
1271 fix[ 9999 << 16 | 191LL << 32 | 11102 ] = // DAS VIERTE
1273 // on this transport are only HD services, two TBD, arte and ServusTV, I think arte properly signals HD!
1274 fix[ 9999 << 16 | 401LL << 32 | 29109 ] = // ServusTV HD
1276 // generic Unitymedia / Liberty Global / Eventis.nl?
1277 fix[ 9999 << 16 | 121LL << 32 | 12107 ] = // Super RTL
1278 fix[ 9999 << 16 | 151LL << 32 | 15110 ] = // Bibel TV
1279 fix[ 9999 << 16 | 161LL << 32 | 12107 ] = // Super RTL
1280 fix[ 9999 << 16 | 161LL << 32 | 12109 ] = // n-tv
1281 fix[ 9999 << 16 | 171LL << 32 | 17119 ] = // RiC
1282 fix[ 9999 << 16 | 171LL << 32 | 27102 ] = // DELUXE MUSIC
1283 fix[ 9999 << 16 | 181LL << 32 | 24108 ] = // DMAX
1284 fix[ 9999 << 16 | 181LL << 32 | 25102 ] = // TV5MONDE Europe
1285 fix[ 9999 << 16 | 191LL << 32 | 11102 ] = // Disney SD
1286 fix[ 9999 << 16 | 191LL << 32 | 12110 ] = // N24
1287 fix[ 9999 << 16 | 191LL << 32 | 12111 ] = // Tele 5
1288 fix[ 9999 << 16 | 201LL << 32 | 27103 ] = // TLC
1289 fix[ 9999 << 16 | 211LL << 32 | 29108 ] = // Astro TV
1290 fix[ 9999 << 16 | 231LL << 32 | 23117 ] = // Deutsches Musik Fernsehen
1291 fix[ 9999 << 16 | 231LL << 32 | 23115 ] = // Family TV
1292 fix[ 9999 << 16 | 271LL << 32 | 27101 ] = // DIE NEUE ZEIT TV
1293 fix[ 9999 << 16 | 541LL << 32 | 54101 ] = // HR HD
1295
1296 // DVB-S Astra 19.2E DMAX Germany
1297 fix[ 1113LL << 32 | 1 << 16 | 12602] = EITFixUp::kEFixForceISO8859_15;
1298
1299 // Premiere
1300 fix[133 << 16] = EITFixUp::kEFixForceISO8859_15;
1301
1302 // DVB-S Astra 19.2E French channels
1303 fix[ 1022LL << 32 | 1 << 16 | 6901 ] = // DIRECT 8
1304 fix[ 1022LL << 32 | 1 << 16 | 6905 ] = // France 24 (en Francais)
1305 fix[ 1022LL << 32 | 1 << 16 | 6911 ] = // DIRECT 8
1306 fix[ 1072LL << 32 | 1 << 16 | 8201 ] = // CANAL+
1307 fix[ 1070LL << 32 | 1 << 16 | 8004 ] = // EURONEWS
1308 fix[ 1091LL << 32 | 1 << 16 | 31220 ] = // EuroNews
1309 fix[ 1094LL << 32 | 1 << 16 | 17027 ] = // LCP
1310 fix[ 1094LL << 32 | 1 << 16 | 17028 ] = // NT1
1311 fix[ 1100LL << 32 | 1 << 16 | 8710 ] = // NRJ 12
1313
1314 // DVB-C T-Kábel Hungary
1315 // FIXME this should be more specific. Is the encoding really wrong for all services?
1316 fix[ 100 << 16] = EITFixUp::kEFixForceISO8859_2;
1317
1318 // DVB-T Greece
1319 // Pelion Transmitter
1320 // transport_id<<32 | netword_id<<16 | service_id
1321 fix[ 100LL << 32 | 8492LL << 16 ] = // Ant1,Alpha,Art,10E
1322 fix[ 102LL << 32 | 8492LL << 16 ] = // Mega,Star,SKAI,M.tv
1323 fix[ 320LL << 32 | 8492LL << 16 ] = // Astra,Thessalia,TRT,TV10,ZEYS
1327 fix[ 2LL << 32 | 8492LL << 16 ] = // N1,Nplus,NHD,Vouli
1328 EITFixUp::kEFixForceISO8859_7 | // it is encoded in cp-1253
1329 EITFixUp::kFixGreekSubtitle | // Subtitle has too much info and is
1330 EITFixUp::kFixGreekEIT | // cut in db. Will move to descr.
1332
1333 //DVB-S & S2 Greek Nova Provider
1334 // Hotbird 11823H DVB-S
1335 fix[ 5500LL << 32 | 318LL << 16 ] = EITFixUp::kEFixForceISO8859_7;
1336 // Hotbird 11938H DVB-S
1337 fix[ 6100LL << 32 | 318LL << 16 ] = EITFixUp::kEFixForceISO8859_7;
1338 // Hotbird 12130H DVB-S2
1339 fix[ 7100LL << 32 | 318LL << 16 ] = EITFixUp::kEFixForceISO8859_7;
1340 // Hotbird 12169H DVB-S2
1341 fix[ 7300LL << 32 | 318LL << 16 ] = EITFixUp::kEFixForceISO8859_7;
1342
1343 // DVB-S Star One C2 70W (Brazil)
1344 // it has original_network_id = 1 like Astra on 19.2E, but transport_id does
1345 // not collide at the moment
1346 fix[ 1LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1347 fix[ 2LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1348 fix[ 3LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1349 fix[ 4LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1350 fix[ 50LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1351 fix[ 51LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1352 fix[ 52LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1353 fix[ 53LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1354 fix[ 54LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1355 fix[ 55LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1356 fix[ 56LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1357 fix[ 57LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1358 fix[ 58LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1359 fix[ 59LL << 32 | 1LL << 16 ] = EITFixUp::kEFixForceISO8859_1;
1360
1361 // Eutelsat Satellite System at 7°E
1362 fix[ 126U << 16 ] = EITFixUp::kEFixForceISO8859_9;
1363}
1364
1370{
1373 m_maxStarttime, "EITScanner");
1374 m_seenEITother = false;
1375 m_maxStarttime = QDateTime();
1376}
Overall structure.
static const std::array< const std::string, 4 > subtitles
uint32_t m_length
Definition: eithelper.h:43
uint32_t m_startTime
Definition: eithelper.h:42
const unsigned char * m_desc
Definition: eithelper.h:47
uint32_t m_descLength
Definition: eithelper.h:45
static uint GetMplexID(uint sourceid, const QString &channum)
uint VideoProperties(void) const
uint SubtitleType(void) const
uint AudioProperties(void) const
uint EventCount() const
Definition: dvbtables.h:335
uint EventID(uint i) const
Definition: dvbtables.h:339
uint ServiceID(void) const
Definition: dvbtables.h:318
uint OriginalNetworkID(void) const
Definition: dvbtables.h:325
const unsigned char * Descriptors(uint i) const
Definition: dvbtables.h:370
uint DescriptorsLength(uint i) const
Definition: dvbtables.h:366
time_t EndTimeUnixUTC(uint i) const
Definition: dvbtables.h:348
uint TSID(void) const
Definition: dvbtables.h:321
QDateTime StartTimeUTC(uint i) const
Definition: dvbtables.h:344
uint DurationInSeconds(uint i) const
Definition: dvbtables.h:355
uint PruneOldEntries(uint utc_timestamp)
Prunes entries that describe events ending before timestamp time.
Definition: eitcache.cpp:434
void SetPersistent(bool persistent)
Definition: eitcache.h:66
void WriteToDB(void)
Definition: eitcache.cpp:327
bool IsNewEIT(uint chanid, uint tableid, uint version, uint eventid, uint endtime)
Definition: eitcache.cpp:359
static void TimeFix(QDateTime &dt)
Corrects starttime to the multiple of a minute.
Definition: eitfixup.h:83
static void Fix(DBEventEIT &event)
Definition: eitfixup.cpp:46
@ kEFixForceISO8859_9
Definition: eitfixup.h:64
@ kEFixForceISO8859_15
Definition: eitfixup.h:65
@ kEFixForceISO8859_7
Definition: eitfixup.h:66
@ kFixNRK_DVBT
Definition: eitfixup.h:48
@ kFixPremiere
Definition: eitfixup.h:43
@ kFixMCA
Definition: eitfixup.h:40
@ kFixP7S1
Definition: eitfixup.h:55
@ kFixHTML
Definition: eitfixup.h:56
@ kFixFI
Definition: eitfixup.h:42
@ kFixGenericDVB
Definition: eitfixup.h:33
@ kFixUK
Definition: eitfixup.h:35
@ kFixGreekEIT
Definition: eitfixup.h:69
@ kFixAUSeven
Definition: eitfixup.h:54
@ kFixSubtitle
Definition: eitfixup.h:38
@ kEFixForceISO8859_2
Definition: eitfixup.h:63
@ kFixDisneyChannel
Definition: eitfixup.h:59
@ kFixComHem
Definition: eitfixup.h:37
@ kFixAUDescription
Definition: eitfixup.h:52
@ kFixAUNine
Definition: eitfixup.h:53
@ kFixDK
Definition: eitfixup.h:50
@ kFixNL
Definition: eitfixup.h:45
@ kFixGreekSubtitle
Definition: eitfixup.h:68
@ kFixDish
Definition: eitfixup.h:49
@ kFixAUFreeview
Definition: eitfixup.h:51
@ kFixGreekCategories
Definition: eitfixup.h:70
@ kFixATV
Definition: eitfixup.h:58
@ kFixAUStar
Definition: eitfixup.h:39
@ kFixBell
Definition: eitfixup.h:34
@ kFixRTL
Definition: eitfixup.h:41
@ kEFixForceISO8859_1
Definition: eitfixup.h:62
@ kFixUnitymedia
Definition: eitfixup.h:57
@ kFixNO
Definition: eitfixup.h:47
@ kFixHDTV
Definition: eitfixup.h:44
void SetSourceID(uint sourceid)
Definition: eithelper.cpp:156
static void PruneEITCache(uint timestamp)
Definition: eithelper.cpp:782
uint GetListSize(void) const
Definition: eithelper.cpp:66
void AddETT(uint, uint, const ExtendedTextTable *)
Definition: eithelper.h:123
uint ProcessEvents(void)
Get events from queue and insert into DB after processing.
Definition: eithelper.cpp:87
uint m_chunkSize
Definition: eithelper.h:154
void SetFixup(uint atsc_major, uint atsc_minor, FixupValue eitfixup)
Definition: eithelper.cpp:132
FixupMap m_fixup
Definition: eithelper.h:157
static EITCache * s_eitCache
Definition: eithelper.h:144
static const uint kMaxQueueSize
Definition: eithelper.h:164
EITHelper(uint cardnum)
Definition: eithelper.cpp:40
uint GetChanID(uint atsc_major, uint atsc_minor)
Definition: eithelper.cpp:834
void SetLanguagePreferences(const QStringList &langPref)
Definition: eithelper.cpp:139
ServiceToChanID m_srvToChanid
Definition: eithelper.h:142
void CompleteEvent(uint atsc_major, uint atsc_minor, const ATSCEvent &event, const QString &ett)
Definition: eithelper.cpp:796
QDateTime m_maxStarttime
Definition: eithelper.h:152
uint m_queueSize
Definition: eithelper.h:155
void RescheduleRecordings(void)
Tells scheduler about programming changes.
Definition: eithelper.cpp:1369
uint m_sourceid
Definition: eithelper.h:150
static void WriteEITCache(void)
Definition: eithelper.cpp:787
QMutex m_eitListLock
Definition: eithelper.h:141
MythDeque< DBEventEIT * > m_dbEvents
Definition: eithelper.h:160
ATSCSRCToEvents m_incompleteEvents
Definition: eithelper.h:158
bool m_seenEITother
Definition: eithelper.h:153
QMap< uint, uint > m_languagePreferences
Definition: eithelper.h:162
uint m_channelid
Definition: eithelper.h:151
virtual ~EITHelper(void)
Definition: eithelper.cpp:59
void AddEIT(uint, uint, const EventInformationTable *)
Definition: eithelper.h:122
bool EventQueueFull(void) const
Definition: eithelper.cpp:72
int m_gpsOffset
Definition: eithelper.h:146
void SetChannelID(uint channelid)
Definition: eithelper.cpp:162
EventInformationTables contain program titles, start times, and channel information.
Definition: atsctables.h:527
const unsigned char * Descriptors(uint i) const
Definition: atsctables.h:609
uint EventID(uint i) const
Definition: atsctables.h:564
uint StartTimeRaw(uint i) const
Definition: atsctables.h:569
MultipleStringStructure title(int i) const
Definition: atsctables.h:595
uint EventCount() const
Definition: atsctables.h:558
uint LengthInSeconds(uint i) const
Definition: atsctables.h:586
uint ETMLocation(uint i) const
Definition: atsctables.h:581
uint DescriptorsLength(uint i) const
Definition: atsctables.h:601
QString Text(void) const
QMultiMap< QString, QString > Items(void) const
ExtendedTextTable contain additional text not contained in EventInformationTables.
Definition: atsctables.h:628
uint EventID(void) const
Definition: atsctables.h:665
MultipleStringStructure ExtendedTextMessage() const
Definition: atsctables.h:669
static desc_list_t FindAll(const desc_list_t &parsed, uint desc_tag)
static desc_list_t Parse(const unsigned char *data, uint len)
bool IsValid(void) const
static desc_list_t FindBestMatches(const desc_list_t &parsed, uint desc_tag, QMap< uint, uint > &langPref)
static const unsigned char * FindBestMatch(const desc_list_t &parsed, uint desc_tag, QMap< uint, uint > &langPref)
static const unsigned char * Find(const desc_list_t &parsed, uint desc_tag)
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:838
QVariant value(int i) const
Definition: mythdbcon.h:204
int size(void) const
Definition: mythdbcon.h:214
bool isActive(void) const
Definition: mythdbcon.h:215
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:619
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:889
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:813
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:551
QString GetBestMatch(QMap< uint, uint > &langPrefs) const
int GetNumSetting(const QString &key, int defaultval=0)
bool GetBoolSetting(const QString &key, bool defaultval=false)
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:225
T dequeue()
Removes item from front of list and returns a copy. O(1).
Definition: mythdeque.h:31
void enqueue(const T &d)
Adds item to the back of the list. O(1).
Definition: mythdeque.h:41
uint Version(void) const
Definition: mpegtables.h:522
uint TableID(void) const
Definition: mpegtables.h:496
const unsigned char * Descriptors() const
static void RescheduleMatch(uint recordid, uint sourceid, uint mplexid, const QDateTime &maxstarttime, const QString &why)
QString Text(void) const
QString EventName(void) const
@ SC_EITbeg
Definition: mpegtables.h:280
@ SC_EITend
Definition: mpegtables.h:281
unsigned int uint
Definition: compat.h:60
@ kThemeMovie
@ kThemeSeries
@ kThemeSports
std::vector< uint8_t > enc_override
#define LOC
Definition: eithelper.cpp:37
static void parse_dvb_component_descriptors(const desc_list_t &list, unsigned char &subtitle_type, unsigned char &audio_properties, unsigned char &video_properties)
Definition: eithelper.cpp:319
static uint get_chan_id_from_db_dtv(uint sourceid, uint serviceid, uint tunedchanid)
Definition: eithelper.cpp:984
static void init_fixup(FixupMap &fix)
Definition: eithelper.cpp:1033
static uint get_chan_id_from_db_atsc(uint sourceid, uint atsc_major, uint atsc_minor)
Definition: eithelper.cpp:895
static uint get_chan_id_from_db_dvb(uint sourceid, uint serviceid, uint networkid, uint transportid)
Definition: eithelper.cpp:924
#define LOC_ID
Definition: eithelper.cpp:38
static void parse_dvb_event_descriptors(const desc_list_t &list, FixupValue fix, QMap< uint, uint > languagePreferences, QString &title, QString &subtitle, QString &description, QMultiMap< QString, QString > &items)
Definition: eithelper.cpp:233
uint64_t FixupValue
Definition: eithelper.h:81
uint64_t FixupKey
Definition: eithelper.h:80
QMap< FixupKey, FixupValue > FixupMap
Definition: eithelper.h:82
QMap< uint, ATSCEvent > EventIDToATSCEvent
Definition: eithelper.h:75
int iso639_key_to_canonical_key(int iso639_2)
Definition: iso639.cpp:123
static int iso639_str3_to_key(const unsigned char *iso639_2)
Definition: iso639.h:60
std::vector< const unsigned char * > desc_list_t
static constexpr qint64 GPS_EPOCH
Seconds between start of GPS time and the start of UNIX time.
Definition: mpegtables.h:31
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MBASE_PUBLIC QDateTime fromSecsSinceEpoch(int64_t seconds)
This function takes the number of seconds since the start of the epoch and returns a QDateTime with t...
Definition: mythdate.cpp:81
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:15
string version
Definition: giantbomb.py:185
def rating(profile, smoonURL, gate)
Definition: scan.py:36