1 #include <lib/dvb/epgcache.h>
2 #include <lib/dvb/dvb.h>
7 #include <lib/service/event.h>
11 #include <unistd.h> // for usleep
12 #include <sys/vfs.h> // for statfs
13 // #include <libmd5sum.h>
14 #include <lib/base/eerror.h>
15 #include <lib/base/estring.h>
16 #include <lib/dvb/pmt.h>
17 #include <lib/dvb/db.h>
18 #include <lib/python/python.h>
19 #include <dvbsi++/descriptor_tag.h>
21 int eventData::CacheSize=0;
22 descriptorMap eventData::descriptors;
23 __u8 eventData::data[4108];
24 extern const uint32_t crc32_table[256];
26 const eServiceReference &handleGroup(const eServiceReference &ref)
28 if (ref.flags & eServiceReference::isGroup)
30 ePtr<eDVBResourceManager> res;
31 if (!eDVBResourceManager::getInstance(res))
33 ePtr<iDVBChannelList> db;
34 if (!res->getChannelList(db))
37 if (!db->getBouquet(ref, bouquet))
39 std::list<eServiceReference>::iterator it(bouquet->m_services.begin());
40 if (it != bouquet->m_services.end())
49 eventData::eventData(const eit_event_struct* e, int size, int type)
50 :ByteSize(size&0xFF), type(type&0xFF)
58 __u8 *data = (__u8*)e;
64 __u8 *descr = data+ptr;
65 int descr_len = descr[1];
67 if (size >= descr_len)
71 case EXTENDED_EVENT_DESCRIPTOR:
72 case SHORT_EVENT_DESCRIPTOR:
73 case LINKAGE_DESCRIPTOR:
74 case COMPONENT_DESCRIPTOR:
78 while(cnt++ < descr_len)
79 crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ data[ptr++]) & 0xFF];
81 descriptorMap::iterator it =
82 descriptors.find(crc);
83 if ( it == descriptors.end() )
86 __u8 *d = new __u8[descr_len];
87 memcpy(d, descr, descr_len);
88 descriptors[crc] = descriptorPair(1, d);
95 default: // do not cache all other descriptors
104 ASSERT(pdescr <= &descr[65]);
105 ByteSize = 10+((pdescr-descr)*4);
106 EITdata = new __u8[ByteSize];
108 memcpy(EITdata, (__u8*) e, 10);
109 memcpy(EITdata+10, descr, ByteSize-10);
112 const eit_event_struct* eventData::get() const
115 int tmp = ByteSize-10;
116 memcpy(data, EITdata, 10);
117 int descriptors_length=0;
118 __u32 *p = (__u32*)(EITdata+10);
121 descriptorMap::iterator it =
122 descriptors.find(*p++);
123 if ( it != descriptors.end() )
125 int b = it->second.second[1]+2;
126 memcpy(data+pos, it->second.second, b );
128 descriptors_length += b;
131 eFatal("LINE %d descriptor not found in descriptor cache %08x!!!!!!", __LINE__, *(p-1));
135 data[10] = (descriptors_length >> 8) & 0x0F;
136 data[11] = descriptors_length & 0xFF;
137 return (eit_event_struct*)data;
140 eventData::~eventData()
144 CacheSize -= ByteSize;
145 __u32 *d = (__u32*)(EITdata+10);
149 descriptorMap::iterator it =
150 descriptors.find(*d++);
151 if ( it != descriptors.end() )
153 descriptorPair &p = it->second;
154 if (!--p.first) // no more used descriptor
156 CacheSize -= it->second.second[1];
157 delete [] it->second.second; // free descriptor memory
158 descriptors.erase(it); // remove entry from descriptor map
162 eFatal("LINE %d descriptor not found in descriptor cache %08x!!!!!!", __LINE__, *(d-1));
169 void eventData::load(FILE *f)
175 fread(&size, sizeof(int), 1, f);
178 fread(&id, sizeof(__u32), 1, f);
179 fread(&p.first, sizeof(int), 1, f);
180 fread(header, 2, 1, f);
181 int bytes = header[1]+2;
182 p.second = new __u8[bytes];
183 p.second[0] = header[0];
184 p.second[1] = header[1];
185 fread(p.second+2, bytes-2, 1, f);
192 void eventData::save(FILE *f)
194 int size=descriptors.size();
195 descriptorMap::iterator it(descriptors.begin());
196 fwrite(&size, sizeof(int), 1, f);
199 fwrite(&it->first, sizeof(__u32), 1, f);
200 fwrite(&it->second.first, sizeof(int), 1, f);
201 fwrite(it->second.second, it->second.second[1]+2, 1, f);
207 eEPGCache* eEPGCache::instance;
208 pthread_mutex_t eEPGCache::cache_lock=
209 PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
210 pthread_mutex_t eEPGCache::channel_map_lock=
211 PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
213 DEFINE_REF(eEPGCache)
215 eEPGCache::eEPGCache()
216 :messages(this,1), cleanTimer(eTimer::create(this))//, paused(0)
218 eDebug("[EPGC] Initialized EPGCache");
220 CONNECT(messages.recv_msg, eEPGCache::gotMessage);
221 CONNECT(eDVBLocalTimeHandler::getInstance()->m_timeUpdated, eEPGCache::timeUpdated);
222 CONNECT(cleanTimer->timeout, eEPGCache::cleanLoop);
224 ePtr<eDVBResourceManager> res_mgr;
225 eDVBResourceManager::getInstance(res_mgr);
227 eDebug("[eEPGCache] no resource manager !!!!!!!");
230 res_mgr->connectChannelAdded(slot(*this,&eEPGCache::DVBChannelAdded), m_chanAddedConn);
231 if (eDVBLocalTimeHandler::getInstance()->ready())
237 void eEPGCache::timeUpdated()
241 eDebug("[EPGC] time updated.. start EPG Mainloop");
244 messages.send(Message(Message::timeChanged));
247 void eEPGCache::DVBChannelAdded(eDVBChannel *chan)
251 // eDebug("[eEPGCache] add channel %p", chan);
252 channel_data *data = new channel_data(this);
253 data->channel = chan;
254 data->prevChannelState = -1;
255 #ifdef ENABLE_PRIVATE_EPG
256 data->m_PrivatePid = -1;
258 singleLock s(channel_map_lock);
259 m_knownChannels.insert( std::pair<iDVBChannel*, channel_data* >(chan, data) );
260 chan->connectStateChange(slot(*this, &eEPGCache::DVBChannelStateChanged), data->m_stateChangedConn);
264 void eEPGCache::DVBChannelRunning(iDVBChannel *chan)
266 channelMapIterator it =
267 m_knownChannels.find(chan);
268 if ( it == m_knownChannels.end() )
269 eDebug("[eEPGCache] will start non existing channel %p !!!", chan);
272 channel_data &data = *it->second;
273 ePtr<eDVBResourceManager> res_mgr;
274 if ( eDVBResourceManager::getInstance( res_mgr ) )
275 eDebug("[eEPGCache] no res manager!!");
278 ePtr<iDVBDemux> demux;
279 if ( data.channel->getDemux(demux, 0) )
281 eDebug("[eEPGCache] no demux!!");
286 RESULT res = demux->createSectionReader( this, data.m_NowNextReader );
289 eDebug("[eEPGCache] couldnt initialize nownext reader!!");
293 res = demux->createSectionReader( this, data.m_ScheduleReader );
296 eDebug("[eEPGCache] couldnt initialize schedule reader!!");
300 res = demux->createSectionReader( this, data.m_ScheduleOtherReader );
303 eDebug("[eEPGCache] couldnt initialize schedule other reader!!");
307 res = demux->createSectionReader( this, data.m_ViasatReader );
310 eDebug("[eEPGCache] couldnt initialize viasat reader!!");
313 #ifdef ENABLE_PRIVATE_EPG
314 res = demux->createSectionReader( this, data.m_PrivateReader );
317 eDebug("[eEPGCache] couldnt initialize private reader!!");
321 #ifdef ENABLE_MHW_EPG
322 res = demux->createSectionReader( this, data.m_MHWReader );
325 eDebug("[eEPGCache] couldnt initialize mhw reader!!");
328 res = demux->createSectionReader( this, data.m_MHWReader2 );
331 eDebug("[eEPGCache] couldnt initialize mhw reader!!");
335 messages.send(Message(Message::startChannel, chan));
336 // -> gotMessage -> changedService
342 void eEPGCache::DVBChannelStateChanged(iDVBChannel *chan)
344 channelMapIterator it =
345 m_knownChannels.find(chan);
346 if ( it != m_knownChannels.end() )
349 chan->getState(state);
350 if ( it->second->prevChannelState != state )
354 case iDVBChannel::state_ok:
356 eDebug("[eEPGCache] channel %p running", chan);
357 DVBChannelRunning(chan);
360 case iDVBChannel::state_release:
362 eDebug("[eEPGCache] remove channel %p", chan);
363 messages.send(Message(Message::leaveChannel, chan));
364 pthread_mutex_lock(&it->second->channel_active);
365 singleLock s(channel_map_lock);
366 m_knownChannels.erase(it);
367 pthread_mutex_unlock(&it->second->channel_active);
370 // -> gotMessage -> abortEPG
373 default: // ignore all other events
377 it->second->prevChannelState = state;
382 bool eEPGCache::FixOverlapping(std::pair<eventMap,timeMap> &servicemap, time_t TM, int duration, const timeMap::iterator &tm_it, const uniqueEPGKey &service)
385 timeMap::iterator tmp = tm_it;
386 while ((tmp->first+tmp->second->getDuration()-300) > TM)
389 #ifdef ENABLE_PRIVATE_EPG
390 && tmp->second->type != PRIVATE
393 && tmp->second->type != MHW
397 __u16 event_id = tmp->second->getEventID();
398 servicemap.first.erase(event_id);
400 Event evt((uint8_t*)tmp->second->get());
402 event.parseFrom(&evt, service.sid<<16|service.onid);
403 eDebug("(1)erase no more used event %04x %d\n%s %s\n%s",
404 service.sid, event_id,
405 event.getBeginTimeString().c_str(),
406 event.getEventName().c_str(),
407 event.getExtendedDescription().c_str());
410 if (tmp == servicemap.second.begin())
412 servicemap.second.erase(tmp);
416 servicemap.second.erase(tmp--);
421 if (tmp == servicemap.second.begin())
428 while(tmp->first < (TM+duration-300))
430 if (tmp->first != TM && tmp->second->type != PRIVATE)
432 __u16 event_id = tmp->second->getEventID();
433 servicemap.first.erase(event_id);
435 Event evt((uint8_t*)tmp->second->get());
437 event.parseFrom(&evt, service.sid<<16|service.onid);
438 eDebug("(2)erase no more used event %04x %d\n%s %s\n%s",
439 service.sid, event_id,
440 event.getBeginTimeString().c_str(),
441 event.getEventName().c_str(),
442 event.getExtendedDescription().c_str());
445 servicemap.second.erase(tmp++);
450 if (tmp == servicemap.second.end())
456 void eEPGCache::sectionRead(const __u8 *data, int source, channel_data *channel)
458 eit_t *eit = (eit_t*) data;
460 int len=HILO(eit->section_length)-1;//+3-4;
465 // This fixed the EPG on the Multichoice irdeto systems
466 // the EIT packet is non-compliant.. their EIT packet stinks
467 if ( data[ptr-1] < 0x40 )
470 // Cablecom HACK .. tsid / onid in eit data are incorrect.. so we use
471 // it from running channel (just for current transport stream eit data)
472 bool use_transponder_chid = source == SCHEDULE || (source == NOWNEXT && data[0] == 0x4E);
473 eDVBChannelID chid = channel->channel->getChannelID();
474 uniqueEPGKey service( HILO(eit->service_id),
475 use_transponder_chid ? chid.original_network_id.get() : HILO(eit->original_network_id),
476 use_transponder_chid ? chid.transport_stream_id.get() : HILO(eit->transport_stream_id));
478 eit_event_struct* eit_event = (eit_event_struct*) (data+ptr);
482 time_t TM = parseDVBtime(
483 eit_event->start_time_1,
484 eit_event->start_time_2,
485 eit_event->start_time_3,
486 eit_event->start_time_4,
487 eit_event->start_time_5);
488 time_t now = ::time(0);
490 if ( TM != 3599 && TM > -1)
491 channel->haveData |= source;
493 singleLock s(cache_lock);
494 // hier wird immer eine eventMap zurück gegeben.. entweder eine vorhandene..
495 // oder eine durch [] erzeugte
496 std::pair<eventMap,timeMap> &servicemap = eventDB[service];
497 eventMap::iterator prevEventIt = servicemap.first.end();
498 timeMap::iterator prevTimeIt = servicemap.second.end();
503 eit_event_size = HILO(eit_event->descriptors_loop_length)+EIT_LOOP_SIZE;
505 duration = fromBCD(eit_event->duration_1)*3600+fromBCD(eit_event->duration_2)*60+fromBCD(eit_event->duration_3);
507 eit_event->start_time_1,
508 eit_event->start_time_2,
509 eit_event->start_time_3,
510 eit_event->start_time_4,
511 eit_event->start_time_5,
517 if ( TM != 3599 && (TM+duration < now || TM > now+14*24*60*60) )
520 if ( now <= (TM+duration) || TM == 3599 /*NVOD Service*/ ) // old events should not be cached
522 __u16 event_id = HILO(eit_event->event_id);
524 int ev_erase_count = 0;
525 int tm_erase_count = 0;
528 // hack for some polsat services on 13.0E..... but this also replaces other valid event_ids with value 0..
529 // but we dont care about it...
530 event_id = event_hash;
531 eit_event->event_id_hi = event_hash >> 8;
532 eit_event->event_id_lo = event_hash & 0xFF;
535 // search in eventmap
536 eventMap::iterator ev_it =
537 servicemap.first.find(event_id);
539 // eDebug("event_id is %d sid is %04x", event_id, service.sid);
541 // entry with this event_id is already exist ?
542 if ( ev_it != servicemap.first.end() )
544 if ( source > ev_it->second->type ) // update needed ?
545 goto next; // when not.. then skip this entry
547 // search this event in timemap
548 timeMap::iterator tm_it_tmp =
549 servicemap.second.find(ev_it->second->getStartTime());
551 if ( tm_it_tmp != servicemap.second.end() )
553 if ( tm_it_tmp->first == TM ) // just update eventdata
556 eventData *tmp = ev_it->second;
557 ev_it->second = tm_it_tmp->second =
558 new eventData(eit_event, eit_event_size, source);
559 if (FixOverlapping(servicemap, TM, duration, tm_it_tmp, service))
561 prevEventIt = servicemap.first.end();
562 prevTimeIt = servicemap.second.end();
567 else // event has new event begin time
570 // delete the found record from timemap
571 servicemap.second.erase(tm_it_tmp);
572 prevTimeIt=servicemap.second.end();
577 // search in timemap, for check of a case if new time has coincided with time of other event
578 // or event was is not found in eventmap
579 timeMap::iterator tm_it =
580 servicemap.second.find(TM);
582 if ( tm_it != servicemap.second.end() )
584 // event with same start time but another event_id...
585 if ( source > tm_it->second->type &&
586 ev_it == servicemap.first.end() )
587 goto next; // when not.. then skip this entry
589 // search this time in eventmap
590 eventMap::iterator ev_it_tmp =
591 servicemap.first.find(tm_it->second->getEventID());
593 if ( ev_it_tmp != servicemap.first.end() )
596 // delete the found record from eventmap
597 servicemap.first.erase(ev_it_tmp);
598 prevEventIt=servicemap.first.end();
601 evt = new eventData(eit_event, eit_event_size, source);
603 bool consistencyCheck=true;
605 if (ev_erase_count > 0 && tm_erase_count > 0) // 2 different pairs have been removed
608 delete ev_it->second;
609 delete tm_it->second;
613 else if (ev_erase_count == 0 && tm_erase_count > 0)
616 delete ev_it->second;
617 tm_it=prevTimeIt=servicemap.second.insert( prevTimeIt, std::pair<const time_t, eventData*>( TM, evt ) );
620 else if (ev_erase_count > 0 && tm_erase_count == 0)
623 delete tm_it->second;
624 ev_it=prevEventIt=servicemap.first.insert( prevEventIt, std::pair<const __u16, eventData*>( event_id, evt) );
627 else // added new eventData
630 consistencyCheck=false;
632 ev_it=prevEventIt=servicemap.first.insert( prevEventIt, std::pair<const __u16, eventData*>( event_id, evt) );
633 tm_it=prevTimeIt=servicemap.second.insert( prevTimeIt, std::pair<const time_t, eventData*>( TM, evt ) );
637 if ( consistencyCheck )
639 if ( tm_it->second != evt || ev_it->second != evt )
640 eFatal("tm_it->second != ev_it->second");
641 else if ( tm_it->second->getStartTime() != tm_it->first )
642 eFatal("event start_time(%d) non equal timemap key(%d)",
643 tm_it->second->getStartTime(), tm_it->first );
644 else if ( tm_it->first != TM )
645 eFatal("timemap key(%d) non equal TM(%d)",
647 else if ( ev_it->second->getEventID() != ev_it->first )
648 eFatal("event_id (%d) non equal event_map key(%d)",
649 ev_it->second->getEventID(), ev_it->first);
650 else if ( ev_it->first != event_id )
651 eFatal("eventmap key(%d) non equal event_id(%d)",
652 ev_it->first, event_id );
655 if (FixOverlapping(servicemap, TM, duration, tm_it, service))
657 prevEventIt = servicemap.first.end();
658 prevTimeIt = servicemap.second.end();
663 if ( servicemap.first.size() != servicemap.second.size() )
665 FILE *f = fopen("/hdd/event_map.txt", "w+");
667 for (eventMap::iterator it(servicemap.first.begin())
668 ; it != servicemap.first.end(); ++it )
669 fprintf(f, "%d(key %d) -> time %d, event_id %d, data %p\n",
670 i++, (int)it->first, (int)it->second->getStartTime(), (int)it->second->getEventID(), it->second );
672 f = fopen("/hdd/time_map.txt", "w+");
674 for (timeMap::iterator it(servicemap.second.begin())
675 ; it != servicemap.second.end(); ++it )
676 fprintf(f, "%d(key %d) -> time %d, event_id %d, data %p\n",
677 i++, (int)it->first, (int)it->second->getStartTime(), (int)it->second->getEventID(), it->second );
680 eFatal("(1)map sizes not equal :( sid %04x tsid %04x onid %04x size %d size2 %d",
681 service.sid, service.tsid, service.onid,
682 servicemap.first.size(), servicemap.second.size() );
685 ptr += eit_event_size;
686 eit_event=(eit_event_struct*)(((__u8*)eit_event)+eit_event_size);
690 void eEPGCache::flushEPG(const uniqueEPGKey & s)
692 eDebug("[EPGC] flushEPG %d", (int)(bool)s);
693 singleLock l(cache_lock);
694 if (s) // clear only this service
696 eventCache::iterator it = eventDB.find(s);
697 if ( it != eventDB.end() )
699 eventMap &evMap = it->second.first;
700 timeMap &tmMap = it->second.second;
702 for (eventMap::iterator i = evMap.begin(); i != evMap.end(); ++i)
707 // TODO .. search corresponding channel for removed service and remove this channel from lastupdated map
708 #ifdef ENABLE_PRIVATE_EPG
709 contentMaps::iterator it =
710 content_time_tables.find(s);
711 if ( it != content_time_tables.end() )
714 content_time_tables.erase(it);
719 else // clear complete EPG Cache
721 for (eventCache::iterator it(eventDB.begin());
722 it != eventDB.end(); ++it)
724 eventMap &evMap = it->second.first;
725 timeMap &tmMap = it->second.second;
726 for (eventMap::iterator i = evMap.begin(); i != evMap.end(); ++i)
732 #ifdef ENABLE_PRIVATE_EPG
733 content_time_tables.clear();
735 channelLastUpdated.clear();
736 singleLock m(channel_map_lock);
737 for (channelMapIterator it(m_knownChannels.begin()); it != m_knownChannels.end(); ++it)
738 it->second->startEPG();
740 eDebug("[EPGC] %i bytes for cache used", eventData::CacheSize);
743 void eEPGCache::cleanLoop()
745 singleLock s(cache_lock);
746 if (!eventDB.empty())
748 eDebug("[EPGC] start cleanloop");
750 time_t now = ::time(0);
752 for (eventCache::iterator DBIt = eventDB.begin(); DBIt != eventDB.end(); DBIt++)
754 bool updated = false;
755 for (timeMap::iterator It = DBIt->second.second.begin(); It != DBIt->second.second.end() && It->first < now;)
757 if ( now > (It->first+It->second->getDuration()) ) // outdated normal entry (nvod references to)
759 // remove entry from eventMap
760 eventMap::iterator b(DBIt->second.first.find(It->second->getEventID()));
761 if ( b != DBIt->second.first.end() )
763 // release Heap Memory for this entry (new ....)
764 // eDebug("[EPGC] delete old event (evmap)");
765 DBIt->second.first.erase(b);
768 // remove entry from timeMap
769 // eDebug("[EPGC] release heap mem");
771 DBIt->second.second.erase(It++);
772 // eDebug("[EPGC] delete old event (timeMap)");
778 #ifdef ENABLE_PRIVATE_EPG
781 contentMaps::iterator x =
782 content_time_tables.find( DBIt->first );
783 if ( x != content_time_tables.end() )
785 timeMap &tmMap = DBIt->second.second;
786 for ( contentMap::iterator i = x->second.begin(); i != x->second.end(); )
788 for ( contentTimeMap::iterator it(i->second.begin());
789 it != i->second.end(); )
791 if ( tmMap.find(it->second.first) == tmMap.end() )
792 i->second.erase(it++);
796 if ( i->second.size() )
799 x->second.erase(i++);
805 eDebug("[EPGC] stop cleanloop");
806 eDebug("[EPGC] %i bytes for cache used", eventData::CacheSize);
808 cleanTimer->start(CLEAN_INTERVAL,true);
811 eEPGCache::~eEPGCache()
813 messages.send(Message::quit);
814 kill(); // waiting for thread shutdown
815 singleLock s(cache_lock);
816 for (eventCache::iterator evIt = eventDB.begin(); evIt != eventDB.end(); evIt++)
817 for (eventMap::iterator It = evIt->second.first.begin(); It != evIt->second.first.end(); It++)
821 void eEPGCache::gotMessage( const Message &msg )
826 flushEPG(msg.service);
828 case Message::startChannel:
830 singleLock s(channel_map_lock);
831 channelMapIterator channel =
832 m_knownChannels.find(msg.channel);
833 if ( channel != m_knownChannels.end() )
834 channel->second->startChannel();
837 case Message::leaveChannel:
839 singleLock s(channel_map_lock);
840 channelMapIterator channel =
841 m_knownChannels.find(msg.channel);
842 if ( channel != m_knownChannels.end() )
843 channel->second->abortEPG();
849 #ifdef ENABLE_PRIVATE_EPG
850 case Message::got_private_pid:
852 singleLock s(channel_map_lock);
853 for (channelMapIterator it(m_knownChannels.begin()); it != m_knownChannels.end(); ++it)
855 eDVBChannel *channel = (eDVBChannel*) it->first;
856 channel_data *data = it->second;
857 eDVBChannelID chid = channel->getChannelID();
858 if ( chid.transport_stream_id.get() == msg.service.tsid &&
859 chid.original_network_id.get() == msg.service.onid &&
860 data->m_PrivatePid == -1 )
862 data->m_PrevVersion = -1;
863 data->m_PrivatePid = msg.pid;
864 data->m_PrivateService = msg.service;
865 int onid = chid.original_network_id.get();
866 onid |= 0x80000000; // we use highest bit as private epg indicator
867 chid.original_network_id = onid;
868 updateMap::iterator It = channelLastUpdated.find( chid );
869 int update = ( It != channelLastUpdated.end() ? ( UPDATE_INTERVAL - ( (::time(0)-It->second) * 1000 ) ) : ZAP_DELAY );
870 if (update < ZAP_DELAY)
872 data->startPrivateTimer->start(update, 1);
874 eDebug("[EPGC] next private update in %i min", update/60000);
875 else if (update >= 1000)
876 eDebug("[EPGC] next private update in %i sec", update/1000);
883 case Message::timeChanged:
887 eDebug("unhandled EPGCache Message!!");
892 void eEPGCache::thread()
902 void eEPGCache::load()
904 FILE *f = fopen("/hdd/epg.dat", "r");
907 unlink("/hdd/epg.dat");
911 unsigned char md5_saved[16];
912 unsigned char md5[16];
915 if (!md5_file("/hdd/epg.dat", 1, md5))
917 FILE *f = fopen("/hdd/epg.dat.md5", "r");
920 fread( md5_saved, 16, 1, f);
922 if ( !memcmp(md5_saved, md5, 16) )
929 unsigned int magic=0;
930 fread( &magic, sizeof(int), 1, f);
931 if (magic != 0x98765432)
933 eDebug("[EPGC] epg file has incorrect byte order.. dont read it");
938 fread( text1, 13, 1, f);
939 if ( !strncmp( text1, "ENIGMA_EPG_V7", 13) )
941 singleLock s(cache_lock);
942 fread( &size, sizeof(int), 1, f);
949 fread( &key, sizeof(uniqueEPGKey), 1, f);
950 fread( &size, sizeof(int), 1, f);
956 fread( &type, sizeof(__u8), 1, f);
957 fread( &len, sizeof(__u8), 1, f);
958 event = new eventData(0, len, type);
959 event->EITdata = new __u8[len];
960 eventData::CacheSize+=len;
961 fread( event->EITdata, len, 1, f);
962 evMap[ event->getEventID() ]=event;
963 tmMap[ event->getStartTime() ]=event;
966 eventDB[key]=std::pair<eventMap,timeMap>(evMap,tmMap);
969 eDebug("[EPGC] %d events read from /hdd/epg.dat", cnt);
970 #ifdef ENABLE_PRIVATE_EPG
972 fread( text2, 11, 1, f);
973 if ( !strncmp( text2, "PRIVATE_EPG", 11) )
976 fread( &size, sizeof(int), 1, f);
981 fread( &key, sizeof(uniqueEPGKey), 1, f);
982 eventMap &evMap=eventDB[key].first;
983 fread( &size, sizeof(int), 1, f);
988 fread( &content_id, sizeof(int), 1, f);
989 fread( &size, sizeof(int), 1, f);
994 fread( &time1, sizeof(time_t), 1, f);
995 fread( &time2, sizeof(time_t), 1, f);
996 fread( &event_id, sizeof(__u16), 1, f);
997 content_time_tables[key][content_id][time1]=std::pair<time_t, __u16>(time2, event_id);
998 eventMap::iterator it =
999 evMap.find(event_id);
1000 if (it != evMap.end())
1001 it->second->type = PRIVATE;
1006 #endif // ENABLE_PRIVATE_EPG
1009 eDebug("[EPGC] don't read old epg database");
1015 void eEPGCache::save()
1019 if (statfs("/hdd", &s)<0)
1027 // prevent writes to builtin flash
1028 if ( tmp < 1024*1024*50 ) // storage size < 50MB
1031 // check for enough free space on storage
1034 if ( tmp < (eventData::CacheSize*12)/10 ) // 20% overhead
1037 FILE *f = fopen("/hdd/epg.dat", "w");
1041 unsigned int magic = 0x98765432;
1042 fwrite( &magic, sizeof(int), 1, f);
1043 const char *text = "UNFINISHED_V7";
1044 fwrite( text, 13, 1, f );
1045 int size = eventDB.size();
1046 fwrite( &size, sizeof(int), 1, f );
1047 for (eventCache::iterator service_it(eventDB.begin()); service_it != eventDB.end(); ++service_it)
1049 timeMap &timemap = service_it->second.second;
1050 fwrite( &service_it->first, sizeof(uniqueEPGKey), 1, f);
1051 size = timemap.size();
1052 fwrite( &size, sizeof(int), 1, f);
1053 for (timeMap::iterator time_it(timemap.begin()); time_it != timemap.end(); ++time_it)
1055 __u8 len = time_it->second->ByteSize;
1056 fwrite( &time_it->second->type, sizeof(__u8), 1, f );
1057 fwrite( &len, sizeof(__u8), 1, f);
1058 fwrite( time_it->second->EITdata, len, 1, f);
1062 eDebug("[EPGC] %d events written to /hdd/epg.dat", cnt);
1064 #ifdef ENABLE_PRIVATE_EPG
1065 const char* text3 = "PRIVATE_EPG";
1066 fwrite( text3, 11, 1, f );
1067 size = content_time_tables.size();
1068 fwrite( &size, sizeof(int), 1, f);
1069 for (contentMaps::iterator a = content_time_tables.begin(); a != content_time_tables.end(); ++a)
1071 contentMap &content_time_table = a->second;
1072 fwrite( &a->first, sizeof(uniqueEPGKey), 1, f);
1073 int size = content_time_table.size();
1074 fwrite( &size, sizeof(int), 1, f);
1075 for (contentMap::iterator i = content_time_table.begin(); i != content_time_table.end(); ++i )
1077 int size = i->second.size();
1078 fwrite( &i->first, sizeof(int), 1, f);
1079 fwrite( &size, sizeof(int), 1, f);
1080 for ( contentTimeMap::iterator it(i->second.begin());
1081 it != i->second.end(); ++it )
1083 fwrite( &it->first, sizeof(time_t), 1, f);
1084 fwrite( &it->second.first, sizeof(time_t), 1, f);
1085 fwrite( &it->second.second, sizeof(__u16), 1, f);
1090 // write version string after binary data
1091 // has been written to disk.
1093 fseek(f, sizeof(int), SEEK_SET);
1094 fwrite("ENIGMA_EPG_V7", 13, 1, f);
1097 unsigned char md5[16];
1098 if (!md5_file("/hdd/epg.dat", 1, md5))
1100 FILE *f = fopen("/hdd/epg.dat.md5", "w");
1103 fwrite( md5, 16, 1, f);
1111 eEPGCache::channel_data::channel_data(eEPGCache *ml)
1113 ,abortTimer(eTimer::create(ml)), zapTimer(eTimer::create(ml)), state(0)
1114 ,isRunning(0), haveData(0)
1115 #ifdef ENABLE_PRIVATE_EPG
1116 ,startPrivateTimer(eTimer::create(ml))
1118 #ifdef ENABLE_MHW_EPG
1119 ,m_MHWTimeoutTimer(eTimer::create(ml))
1122 #ifdef ENABLE_MHW_EPG
1123 CONNECT(m_MHWTimeoutTimer->timeout, eEPGCache::channel_data::MHWTimeout);
1125 CONNECT(zapTimer->timeout, eEPGCache::channel_data::startEPG);
1126 CONNECT(abortTimer->timeout, eEPGCache::channel_data::abortNonAvail);
1127 #ifdef ENABLE_PRIVATE_EPG
1128 CONNECT(startPrivateTimer->timeout, eEPGCache::channel_data::startPrivateReader);
1130 pthread_mutex_init(&channel_active, 0);
1133 bool eEPGCache::channel_data::finishEPG()
1135 if (!isRunning) // epg ready
1137 eDebug("[EPGC] stop caching events(%ld)", ::time(0));
1138 zapTimer->start(UPDATE_INTERVAL, 1);
1139 eDebug("[EPGC] next update in %i min", UPDATE_INTERVAL / 60000);
1140 for (unsigned int i=0; i < sizeof(seenSections)/sizeof(tidMap); ++i)
1142 seenSections[i].clear();
1143 calcedSections[i].clear();
1145 singleLock l(cache->cache_lock);
1146 cache->channelLastUpdated[channel->getChannelID()] = ::time(0);
1147 #ifdef ENABLE_MHW_EPG
1155 void eEPGCache::channel_data::startEPG()
1157 eDebug("[EPGC] start caching events(%ld)", ::time(0));
1160 for (unsigned int i=0; i < sizeof(seenSections)/sizeof(tidMap); ++i)
1162 seenSections[i].clear();
1163 calcedSections[i].clear();
1166 eDVBSectionFilterMask mask;
1167 memset(&mask, 0, sizeof(mask));
1169 #ifdef ENABLE_MHW_EPG
1171 mask.data[0] = 0x91;
1172 mask.mask[0] = 0xFF;
1173 m_MHWReader->connectRead(slot(*this, &eEPGCache::channel_data::readMHWData), m_MHWConn);
1174 m_MHWReader->start(mask);
1176 memcpy(&m_MHWFilterMask, &mask, sizeof(eDVBSectionFilterMask));
1179 mask.data[0] = 0xC8;
1180 mask.mask[0] = 0xFF;
1182 mask.mask[1] = 0xFF;
1183 m_MHWReader2->connectRead(slot(*this, &eEPGCache::channel_data::readMHWData2), m_MHWConn2);
1184 m_MHWReader2->start(mask);
1186 memcpy(&m_MHWFilterMask2, &mask, sizeof(eDVBSectionFilterMask));
1192 mask.flags = eDVBSectionFilterMask::rfCRC;
1194 mask.data[0] = 0x4E;
1195 mask.mask[0] = 0xFE;
1196 m_NowNextReader->connectRead(slot(*this, &eEPGCache::channel_data::readData), m_NowNextConn);
1197 m_NowNextReader->start(mask);
1198 isRunning |= NOWNEXT;
1200 mask.data[0] = 0x50;
1201 mask.mask[0] = 0xF0;
1202 m_ScheduleReader->connectRead(slot(*this, &eEPGCache::channel_data::readData), m_ScheduleConn);
1203 m_ScheduleReader->start(mask);
1204 isRunning |= SCHEDULE;
1206 mask.data[0] = 0x60;
1207 m_ScheduleOtherReader->connectRead(slot(*this, &eEPGCache::channel_data::readData), m_ScheduleOtherConn);
1208 m_ScheduleOtherReader->start(mask);
1209 isRunning |= SCHEDULE_OTHER;
1213 mask.data[0] = 0x40;
1214 mask.mask[0] = 0x40;
1215 m_ViasatReader->connectRead(slot(*this, &eEPGCache::channel_data::readDataViasat), m_ViasatConn);
1216 m_ViasatReader->start(mask);
1217 isRunning |= VIASAT;
1219 abortTimer->start(7000,true);
1222 void eEPGCache::channel_data::abortNonAvail()
1226 if ( !(haveData&NOWNEXT) && (isRunning&NOWNEXT) )
1228 eDebug("[EPGC] abort non avail nownext reading");
1229 isRunning &= ~NOWNEXT;
1230 m_NowNextReader->stop();
1233 if ( !(haveData&SCHEDULE) && (isRunning&SCHEDULE) )
1235 eDebug("[EPGC] abort non avail schedule reading");
1236 isRunning &= ~SCHEDULE;
1237 m_ScheduleReader->stop();
1240 if ( !(haveData&SCHEDULE_OTHER) && (isRunning&SCHEDULE_OTHER) )
1242 eDebug("[EPGC] abort non avail schedule other reading");
1243 isRunning &= ~SCHEDULE_OTHER;
1244 m_ScheduleOtherReader->stop();
1245 m_ScheduleOtherConn=0;
1247 if ( !(haveData&VIASAT) && (isRunning&VIASAT) )
1249 eDebug("[EPGC] abort non avail viasat reading");
1250 isRunning &= ~VIASAT;
1251 m_ViasatReader->stop();
1254 #ifdef ENABLE_MHW_EPG
1255 if ( !(haveData&MHW) && (isRunning&MHW) )
1257 eDebug("[EPGC] abort non avail mhw reading");
1259 m_MHWReader->stop();
1261 m_MHWReader2->stop();
1265 if ( isRunning & VIASAT )
1266 abortTimer->start(300000, true);
1267 else if ( isRunning )
1268 abortTimer->start(90000, true);
1272 for (unsigned int i=0; i < sizeof(seenSections)/sizeof(tidMap); ++i)
1274 seenSections[i].clear();
1275 calcedSections[i].clear();
1282 void eEPGCache::channel_data::startChannel()
1284 pthread_mutex_lock(&channel_active);
1285 updateMap::iterator It = cache->channelLastUpdated.find( channel->getChannelID() );
1287 int update = ( It != cache->channelLastUpdated.end() ? ( UPDATE_INTERVAL - ( (::time(0)-It->second) * 1000 ) ) : ZAP_DELAY );
1289 if (update < ZAP_DELAY)
1292 zapTimer->start(update, 1);
1293 if (update >= 60000)
1294 eDebug("[EPGC] next update in %i min", update/60000);
1295 else if (update >= 1000)
1296 eDebug("[EPGC] next update in %i sec", update/1000);
1299 void eEPGCache::channel_data::abortEPG()
1301 for (unsigned int i=0; i < sizeof(seenSections)/sizeof(tidMap); ++i)
1303 seenSections[i].clear();
1304 calcedSections[i].clear();
1310 eDebug("[EPGC] abort caching events !!");
1311 if (isRunning & SCHEDULE)
1313 isRunning &= ~SCHEDULE;
1314 m_ScheduleReader->stop();
1317 if (isRunning & NOWNEXT)
1319 isRunning &= ~NOWNEXT;
1320 m_NowNextReader->stop();
1323 if (isRunning & SCHEDULE_OTHER)
1325 isRunning &= ~SCHEDULE_OTHER;
1326 m_ScheduleOtherReader->stop();
1327 m_ScheduleOtherConn=0;
1329 if (isRunning & VIASAT)
1331 isRunning &= ~VIASAT;
1332 m_ViasatReader->stop();
1335 #ifdef ENABLE_MHW_EPG
1336 if (isRunning & MHW)
1339 m_MHWReader->stop();
1341 m_MHWReader2->stop();
1346 #ifdef ENABLE_PRIVATE_EPG
1347 if (m_PrivateReader)
1348 m_PrivateReader->stop();
1352 pthread_mutex_unlock(&channel_active);
1356 void eEPGCache::channel_data::readDataViasat( const __u8 *data)
1359 memcpy(&d, &data, sizeof(__u8*));
1364 void eEPGCache::channel_data::readData( const __u8 *data)
1368 iDVBSectionReader *reader=NULL;
1372 reader=m_NowNextReader;
1377 reader=m_ScheduleReader;
1382 reader=m_ScheduleOtherReader;
1383 source=SCHEDULE_OTHER;
1388 reader=m_ViasatReader;
1393 eDebug("[EPGC] unknown table_id !!!");
1396 tidMap &seenSections = this->seenSections[map];
1397 tidMap &calcedSections = this->calcedSections[map];
1398 if ( state == 1 && calcedSections == seenSections || state > 1 )
1400 eDebugNoNewLine("[EPGC] ");
1405 eDebugNoNewLine("nownext");
1409 eDebugNoNewLine("schedule");
1411 case SCHEDULE_OTHER:
1412 m_ScheduleOtherConn=0;
1413 eDebugNoNewLine("schedule other");
1417 eDebugNoNewLine("viasat");
1419 default: eDebugNoNewLine("unknown");break;
1421 eDebug(" finished(%ld)", ::time(0));
1424 isRunning &= ~source;
1430 eit_t *eit = (eit_t*) data;
1431 __u32 sectionNo = data[0] << 24;
1432 sectionNo |= data[3] << 16;
1433 sectionNo |= data[4] << 8;
1434 sectionNo |= eit->section_number;
1436 tidMap::iterator it =
1437 seenSections.find(sectionNo);
1439 if ( it == seenSections.end() )
1441 seenSections.insert(sectionNo);
1442 calcedSections.insert(sectionNo);
1443 __u32 tmpval = sectionNo & 0xFFFFFF00;
1444 __u8 incr = source == NOWNEXT ? 1 : 8;
1445 for ( int i = 0; i <= eit->last_section_number; i+=incr )
1447 if ( i == eit->section_number )
1449 for (int x=i; x <= eit->segment_last_section_number; ++x)
1450 calcedSections.insert(tmpval|(x&0xFF));
1453 calcedSections.insert(tmpval|(i&0xFF));
1455 cache->sectionRead(data, source, this);
1460 RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, const eventData *&result, int direction)
1461 // if t == -1 we search the current event...
1463 singleLock s(cache_lock);
1464 uniqueEPGKey key(handleGroup(service));
1466 // check if EPG for this service is ready...
1467 eventCache::iterator It = eventDB.find( key );
1468 if ( It != eventDB.end() && !It->second.first.empty() ) // entrys cached ?
1472 timeMap::iterator i = direction <= 0 ? It->second.second.lower_bound(t) : // find > or equal
1473 It->second.second.upper_bound(t); // just >
1474 if ( i != It->second.second.end() )
1476 if ( direction < 0 || (direction == 0 && i->first > t) )
1478 timeMap::iterator x = i;
1480 if ( x != It->second.second.end() )
1482 time_t start_time = x->first;
1487 if (t > (start_time+x->second->getDuration()))
1502 RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, const eit_event_struct *&result, int direction)
1504 singleLock s(cache_lock);
1505 const eventData *data=0;
1506 RESULT ret = lookupEventTime(service, t, data, direction);
1508 result = data->get();
1512 RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, Event *& result, int direction)
1514 singleLock s(cache_lock);
1515 const eventData *data=0;
1516 RESULT ret = lookupEventTime(service, t, data, direction);
1518 result = new Event((uint8_t*)data->get());
1522 RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, ePtr<eServiceEvent> &result, int direction)
1524 singleLock s(cache_lock);
1525 const eventData *data=0;
1526 RESULT ret = lookupEventTime(service, t, data, direction);
1529 Event ev((uint8_t*)data->get());
1530 result = new eServiceEvent();
1531 const eServiceReferenceDVB &ref = (const eServiceReferenceDVB&)service;
1532 ret = result->parseFrom(&ev, (ref.getTransportStreamID().get()<<16)|ref.getOriginalNetworkID().get());
1537 RESULT eEPGCache::lookupEventId(const eServiceReference &service, int event_id, const eventData *&result )
1539 singleLock s(cache_lock);
1540 uniqueEPGKey key(handleGroup(service));
1542 eventCache::iterator It = eventDB.find( key );
1543 if ( It != eventDB.end() && !It->second.first.empty() ) // entrys cached?
1545 eventMap::iterator i( It->second.first.find( event_id ));
1546 if ( i != It->second.first.end() )
1554 eDebug("[EPGC] event %04x not found in epgcache", event_id);
1560 RESULT eEPGCache::lookupEventId(const eServiceReference &service, int event_id, const eit_event_struct *&result)
1562 singleLock s(cache_lock);
1563 const eventData *data=0;
1564 RESULT ret = lookupEventId(service, event_id, data);
1566 result = data->get();
1570 RESULT eEPGCache::lookupEventId(const eServiceReference &service, int event_id, Event *& result)
1572 singleLock s(cache_lock);
1573 const eventData *data=0;
1574 RESULT ret = lookupEventId(service, event_id, data);
1576 result = new Event((uint8_t*)data->get());
1580 RESULT eEPGCache::lookupEventId(const eServiceReference &service, int event_id, ePtr<eServiceEvent> &result)
1582 singleLock s(cache_lock);
1583 const eventData *data=0;
1584 RESULT ret = lookupEventId(service, event_id, data);
1587 Event ev((uint8_t*)data->get());
1588 result = new eServiceEvent();
1589 const eServiceReferenceDVB &ref = (const eServiceReferenceDVB&)service;
1590 ret = result->parseFrom(&ev, (ref.getTransportStreamID().get()<<16)|ref.getOriginalNetworkID().get());
1595 RESULT eEPGCache::startTimeQuery(const eServiceReference &service, time_t begin, int minutes)
1597 singleLock s(cache_lock);
1598 const eServiceReferenceDVB &ref = (const eServiceReferenceDVB&)handleGroup(service);
1601 eventCache::iterator It = eventDB.find(ref);
1602 if ( It != eventDB.end() && It->second.second.size() )
1604 m_timemap_cursor = It->second.second.lower_bound(begin);
1605 if ( m_timemap_cursor != It->second.second.end() )
1607 if ( m_timemap_cursor->first != begin )
1609 timeMap::iterator x = m_timemap_cursor;
1611 if ( x != It->second.second.end() )
1613 time_t start_time = x->first;
1614 if ( begin > start_time && begin < (start_time+x->second->getDuration()))
1615 m_timemap_cursor = x;
1621 m_timemap_end = It->second.second.lower_bound(begin+minutes*60);
1623 m_timemap_end = It->second.second.end();
1625 currentQueryTsidOnid = (ref.getTransportStreamID().get()<<16) | ref.getOriginalNetworkID().get();
1626 return m_timemap_cursor == m_timemap_end ? -1 : 0;
1631 RESULT eEPGCache::getNextTimeEntry(const eventData *& result)
1633 if ( m_timemap_cursor != m_timemap_end )
1635 result = m_timemap_cursor++->second;
1641 RESULT eEPGCache::getNextTimeEntry(const eit_event_struct *&result)
1643 if ( m_timemap_cursor != m_timemap_end )
1645 result = m_timemap_cursor++->second->get();
1651 RESULT eEPGCache::getNextTimeEntry(Event *&result)
1653 if ( m_timemap_cursor != m_timemap_end )
1655 result = new Event((uint8_t*)m_timemap_cursor++->second->get());
1661 RESULT eEPGCache::getNextTimeEntry(ePtr<eServiceEvent> &result)
1663 if ( m_timemap_cursor != m_timemap_end )
1665 Event ev((uint8_t*)m_timemap_cursor++->second->get());
1666 result = new eServiceEvent();
1667 return result->parseFrom(&ev, currentQueryTsidOnid);
1672 void fillTuple(ePyObject tuple, const char *argstring, int argcount, ePyObject service, eServiceEvent *ptr, ePyObject nowTime, ePyObject service_name )
1677 while(spos < argcount)
1679 bool inc_refcount=false;
1680 switch((c=argstring[spos++]))
1682 case '0': // PyLong 0
1683 tmp = PyLong_FromLong(0);
1685 case 'I': // Event Id
1686 tmp = ptr ? PyLong_FromLong(ptr->getEventId()) : ePyObject();
1688 case 'B': // Event Begin Time
1689 tmp = ptr ? PyLong_FromLong(ptr->getBeginTime()) : ePyObject();
1691 case 'D': // Event Duration
1692 tmp = ptr ? PyLong_FromLong(ptr->getDuration()) : ePyObject();
1694 case 'T': // Event Title
1695 tmp = ptr ? PyString_FromString(ptr->getEventName().c_str()) : ePyObject();
1697 case 'S': // Event Short Description
1698 tmp = ptr ? PyString_FromString(ptr->getShortDescription().c_str()) : ePyObject();
1700 case 'E': // Event Extended Description
1701 tmp = ptr ? PyString_FromString(ptr->getExtendedDescription().c_str()) : ePyObject();
1703 case 'C': // Current Time
1705 inc_refcount = true;
1707 case 'R': // service reference string
1709 inc_refcount = true;
1711 case 'n': // short service name
1712 case 'N': // service name
1714 inc_refcount = true;
1719 default: // ignore unknown
1720 eDebug("fillTuple unknown '%c'... insert 'None' in result", c);
1725 inc_refcount = true;
1729 PyTuple_SET_ITEM(tuple, tpos++, tmp);
1733 int handleEvent(eServiceEvent *ptr, ePyObject dest_list, const char* argstring, int argcount, ePyObject service, ePyObject nowTime, ePyObject service_name, ePyObject convertFunc, ePyObject convertFuncArgs)
1737 fillTuple(convertFuncArgs, argstring, argcount, service, ptr, nowTime, service_name);
1738 ePyObject result = PyObject_CallObject(convertFunc, convertFuncArgs);
1742 Py_DECREF(service_name);
1745 Py_DECREF(convertFuncArgs);
1746 Py_DECREF(dest_list);
1747 PyErr_SetString(PyExc_StandardError,
1748 "error in convertFunc execute");
1749 eDebug("error in convertFunc execute");
1752 PyList_Append(dest_list, result);
1757 ePyObject tuple = PyTuple_New(argcount);
1758 fillTuple(tuple, argstring, argcount, service, ptr, nowTime, service_name);
1759 PyList_Append(dest_list, tuple);
1765 // here we get a python list
1766 // the first entry in the list is a python string to specify the format of the returned tuples (in a list)
1769 // B = Event Begin Time
1770 // D = Event Duration
1772 // S = Event Short Description
1773 // E = Event Extended Description
1775 // R = Service Reference
1777 // n = Short Service Name
1778 // X = Return a minimum of one tuple per service in the result list... even when no event was found.
1779 // The returned tuple is filled with all available infos... non avail is filled as None
1780 // The position and existence of 'X' in the format string has no influence on the result tuple... its completely ignored..
1781 // then for each service follows a tuple
1782 // first tuple entry is the servicereference (as string... use the ref.toString() function)
1783 // the second is the type of query
1785 // -1 = event before given start_time
1786 // 0 = event intersects given start_time
1787 // +1 = event after given start_time
1789 // when type is eventid it is the event_id
1790 // when type is time then it is the start_time ( -1 for now_time )
1791 // the fourth is the end_time .. ( optional .. for query all events in time range)
1793 PyObject *eEPGCache::lookupEvent(ePyObject list, ePyObject convertFunc)
1795 ePyObject convertFuncArgs;
1797 const char *argstring=NULL;
1798 if (!PyList_Check(list))
1800 PyErr_SetString(PyExc_StandardError,
1806 int listSize=PyList_Size(list);
1809 PyErr_SetString(PyExc_StandardError,
1810 "not params given");
1811 eDebug("not params given");
1816 ePyObject argv=PyList_GET_ITEM(list, 0); // borrowed reference!
1817 if (PyString_Check(argv))
1819 argstring = PyString_AS_STRING(argv);
1823 argstring = "I"; // just event id as default
1824 argcount = strlen(argstring);
1825 // eDebug("have %d args('%s')", argcount, argstring);
1828 bool forceReturnOne = strchr(argstring, 'X') ? true : false;
1834 if (!PyCallable_Check(convertFunc))
1836 PyErr_SetString(PyExc_StandardError,
1837 "convertFunc must be callable");
1838 eDebug("convertFunc is not callable");
1841 convertFuncArgs = PyTuple_New(argcount);
1844 ePyObject nowTime = strchr(argstring, 'C') ?
1845 PyLong_FromLong(::time(0)) :
1848 int must_get_service_name = strchr(argstring, 'N') ? 1 : strchr(argstring, 'n') ? 2 : 0;
1851 ePyObject dest_list=PyList_New(0);
1852 while(listSize > listIt)
1854 ePyObject item=PyList_GET_ITEM(list, listIt++); // borrowed reference!
1855 if (PyTuple_Check(item))
1857 bool service_changed=false;
1862 int tupleSize=PyTuple_Size(item);
1865 while(tupleSize > tupleIt) // parse query args
1867 ePyObject entry=PyTuple_GET_ITEM(item, tupleIt); // borrowed reference!
1872 if (!PyString_Check(entry))
1874 eDebug("tuple entry 0 is no a string");
1881 type=PyInt_AsLong(entry);
1882 if (type < -1 || type > 2)
1884 eDebug("unknown type %d", type);
1889 event_id=stime=PyInt_AsLong(entry);
1892 minutes=PyInt_AsLong(entry);
1895 eDebug("unneeded extra argument");
1900 if (minutes && stime == -1)
1903 eServiceReference ref(handleGroup(eServiceReference(PyString_AS_STRING(service))));
1904 if (ref.type != eServiceReference::idDVB)
1906 eDebug("service reference for epg query is not valid");
1910 // redirect subservice querys to parent service
1911 eServiceReferenceDVB &dvb_ref = (eServiceReferenceDVB&)ref;
1912 if (dvb_ref.getParentTransportStreamID().get()) // linkage subservice
1914 eServiceCenterPtr service_center;
1915 if (!eServiceCenter::getPrivInstance(service_center))
1917 dvb_ref.setTransportStreamID( dvb_ref.getParentTransportStreamID() );
1918 dvb_ref.setServiceID( dvb_ref.getParentServiceID() );
1919 dvb_ref.setParentTransportStreamID(eTransportStreamID(0));
1920 dvb_ref.setParentServiceID(eServiceID(0));
1922 service = PyString_FromString(dvb_ref.toString().c_str());
1923 service_changed = true;
1927 ePyObject service_name;
1928 if (must_get_service_name)
1930 ePtr<iStaticServiceInformation> sptr;
1931 eServiceCenterPtr service_center;
1932 eServiceCenter::getPrivInstance(service_center);
1935 service_center->info(ref, sptr);
1939 sptr->getName(ref, name);
1941 if (must_get_service_name == 1)
1944 // filter short name brakets
1945 while((pos = name.find("\xc2\x86")) != std::string::npos)
1947 while((pos = name.find("\xc2\x87")) != std::string::npos)
1951 name = buildShortName(name);
1954 service_name = PyString_FromString(name.c_str());
1958 service_name = PyString_FromString("<n/a>");
1962 singleLock s(cache_lock);
1963 if (!startTimeQuery(ref, stime, minutes))
1965 while ( m_timemap_cursor != m_timemap_end )
1967 Event ev((uint8_t*)m_timemap_cursor++->second->get());
1969 evt.parseFrom(&ev, currentQueryTsidOnid);
1970 if (handleEvent(&evt, dest_list, argstring, argcount, service, nowTime, service_name, convertFunc, convertFuncArgs))
1974 else if (forceReturnOne && handleEvent(0, dest_list, argstring, argcount, service, nowTime, service_name, convertFunc, convertFuncArgs))
1980 const eventData *ev_data=0;
1983 singleLock s(cache_lock);
1985 lookupEventId(ref, event_id, ev_data);
1987 lookupEventTime(ref, stime, ev_data, type);
1990 const eServiceReferenceDVB &dref = (const eServiceReferenceDVB&)ref;
1991 Event ev((uint8_t*)ev_data->get());
1992 evt.parseFrom(&ev, (dref.getTransportStreamID().get()<<16)|dref.getOriginalNetworkID().get());
1997 if (handleEvent(&evt, dest_list, argstring, argcount, service, nowTime, service_name, convertFunc, convertFuncArgs))
2000 else if (forceReturnOne && handleEvent(0, dest_list, argstring, argcount, service, nowTime, service_name, convertFunc, convertFuncArgs))
2003 if (service_changed)
2006 Py_DECREF(service_name);
2011 if (convertFuncArgs)
2012 Py_DECREF(convertFuncArgs);
2018 void fillTuple2(ePyObject tuple, const char *argstring, int argcount, eventData *evData, eServiceEvent *ptr, ePyObject service_name, ePyObject service_reference)
2022 while(pos < argcount)
2024 bool inc_refcount=false;
2025 switch(argstring[pos])
2027 case '0': // PyLong 0
2028 tmp = PyLong_FromLong(0);
2030 case 'I': // Event Id
2031 tmp = PyLong_FromLong(evData->getEventID());
2033 case 'B': // Event Begin Time
2035 tmp = ptr ? PyLong_FromLong(ptr->getBeginTime()) : ePyObject();
2037 tmp = PyLong_FromLong(evData->getStartTime());
2039 case 'D': // Event Duration
2041 tmp = ptr ? PyLong_FromLong(ptr->getDuration()) : ePyObject();
2043 tmp = PyLong_FromLong(evData->getDuration());
2045 case 'T': // Event Title
2046 tmp = ptr ? PyString_FromString(ptr->getEventName().c_str()) : ePyObject();
2048 case 'S': // Event Short Description
2049 tmp = ptr ? PyString_FromString(ptr->getShortDescription().c_str()) : ePyObject();
2051 case 'E': // Event Extended Description
2052 tmp = ptr ? PyString_FromString(ptr->getExtendedDescription().c_str()) : ePyObject();
2054 case 'R': // service reference string
2055 tmp = service_reference;
2056 inc_refcount = true;
2058 case 'n': // short service name
2059 case 'N': // service name
2061 inc_refcount = true;
2063 default: // ignore unknown
2064 eDebug("fillTuple2 unknown '%c'... insert None in Result", argstring[pos]);
2069 inc_refcount = true;
2073 PyTuple_SET_ITEM(tuple, pos++, tmp);
2077 // here we get a python tuple
2078 // the first entry in the tuple is a python string to specify the format of the returned tuples (in a list)
2080 // B = Event Begin Time
2081 // D = Event Duration
2083 // S = Event Short Description
2084 // E = Event Extended Description
2085 // R = Service Reference
2087 // n = Short Service Name
2088 // the second tuple entry is the MAX matches value
2089 // the third tuple entry is the type of query
2090 // 0 = search for similar broadcastings (SIMILAR_BROADCASTINGS_SEARCH)
2091 // 1 = search events with exactly title name (EXAKT_TITLE_SEARCH)
2092 // 2 = search events with text in title name (PARTIAL_TITLE_SEARCH)
2093 // when type is 0 (SIMILAR_BROADCASTINGS_SEARCH)
2094 // the fourth is the servicereference string
2095 // the fifth is the eventid
2096 // when type is 1 or 2 (EXAKT_TITLE_SEARCH or PARTIAL_TITLE_SEARCH)
2097 // the fourth is the search text
2099 // 0 = case sensitive (CASE_CHECK)
2100 // 1 = case insensitive (NO_CASECHECK)
2102 PyObject *eEPGCache::search(ePyObject arg)
2108 const char *argstring=0;
2112 bool needServiceEvent=false;
2114 int must_get_service_name = 0;
2115 bool must_get_service_reference = false;
2117 if (PyTuple_Check(arg))
2119 int tuplesize=PyTuple_Size(arg);
2122 ePyObject obj = PyTuple_GET_ITEM(arg,0);
2123 if (PyString_Check(obj))
2125 #if PY_VERSION_HEX < 0x02060000
2126 argcount = PyString_GET_SIZE(obj);
2128 argcount = PyString_Size(obj);
2130 argstring = PyString_AS_STRING(obj);
2131 for (int i=0; i < argcount; ++i)
2132 switch(argstring[i])
2137 needServiceEvent=true;
2140 must_get_service_name = 1;
2143 must_get_service_name = 2;
2146 must_get_service_reference = true;
2154 PyErr_SetString(PyExc_StandardError,
2156 eDebug("tuple arg 0 is not a string");
2161 maxmatches = PyLong_AsLong(PyTuple_GET_ITEM(arg, 1));
2164 querytype = PyLong_AsLong(PyTuple_GET_ITEM(arg, 2));
2165 if (tuplesize > 4 && querytype == 0)
2167 ePyObject obj = PyTuple_GET_ITEM(arg, 3);
2168 if (PyString_Check(obj))
2170 refstr = PyString_AS_STRING(obj);
2171 eServiceReferenceDVB ref(refstr);
2174 eventid = PyLong_AsLong(PyTuple_GET_ITEM(arg, 4));
2175 singleLock s(cache_lock);
2176 const eventData *evData = 0;
2177 lookupEventId(ref, eventid, evData);
2180 __u8 *data = evData->EITdata;
2181 int tmp = evData->ByteSize-10;
2182 __u32 *p = (__u32*)(data+10);
2183 // search short and extended event descriptors
2187 descriptorMap::iterator it =
2188 eventData::descriptors.find(crc);
2189 if (it != eventData::descriptors.end())
2191 __u8 *descr_data = it->second.second;
2192 switch(descr_data[0])
2195 descr[++descridx]=crc;
2204 eDebug("event not found");
2208 PyErr_SetString(PyExc_StandardError, "type error");
2209 eDebug("tuple arg 4 is not a valid service reference string");
2215 PyErr_SetString(PyExc_StandardError, "type error");
2216 eDebug("tuple arg 4 is not a string");
2220 else if (tuplesize > 4 && (querytype == 1 || querytype == 2) )
2222 ePyObject obj = PyTuple_GET_ITEM(arg, 3);
2223 if (PyString_Check(obj))
2225 int casetype = PyLong_AsLong(PyTuple_GET_ITEM(arg, 4));
2226 const char *str = PyString_AS_STRING(obj);
2227 #if PY_VERSION_HEX < 0x02060000
2228 int textlen = PyString_GET_SIZE(obj);
2230 int textlen = PyString_Size(obj);
2233 eDebug("lookup for events with '%s' as title(%s)", str, casetype?"ignore case":"case sensitive");
2235 eDebug("lookup for events with '%s' in title(%s)", str, casetype?"ignore case":"case sensitive");
2236 singleLock s(cache_lock);
2237 for (descriptorMap::iterator it(eventData::descriptors.begin());
2238 it != eventData::descriptors.end() && descridx < 511; ++it)
2240 __u8 *data = it->second.second;
2241 if ( data[0] == 0x4D ) // short event descriptor
2243 int title_len = data[5];
2244 if ( querytype == 1 )
2247 // skip DVB-Text Encoding!
2248 if (data[6] == 0x10)
2253 else if(data[6] > 0 && data[6] < 0x20)
2258 if (title_len != textlen)
2262 if ( !strncasecmp((const char*)data+offs, str, title_len) )
2264 // std::string s((const char*)data+offs, title_len);
2265 // eDebug("match1 %s %s", str, s.c_str() );
2266 descr[++descridx] = it->first;
2269 else if ( !strncmp((const char*)data+offs, str, title_len) )
2271 // std::string s((const char*)data+offs, title_len);
2272 // eDebug("match2 %s %s", str, s.c_str() );
2273 descr[++descridx] = it->first;
2279 while((title_len-idx) >= textlen)
2283 if (!strncasecmp((const char*)data+6+idx, str, textlen) )
2285 descr[++descridx] = it->first;
2286 // std::string s((const char*)data+6, title_len);
2287 // eDebug("match 3 %s %s", str, s.c_str() );
2291 else if (!strncmp((const char*)data+6+idx, str, textlen) )
2293 descr[++descridx] = it->first;
2294 // std::string s((const char*)data+6, title_len);
2295 // eDebug("match 4 %s %s", str, s.c_str() );
2306 PyErr_SetString(PyExc_StandardError,
2308 eDebug("tuple arg 4 is not a string");
2314 PyErr_SetString(PyExc_StandardError,
2316 eDebug("tuple arg 3(%d) is not a known querytype(0, 1, 2)", querytype);
2322 PyErr_SetString(PyExc_StandardError,
2324 eDebug("not enough args in tuple");
2330 PyErr_SetString(PyExc_StandardError,
2332 eDebug("arg 0 is not a tuple");
2338 int maxcount=maxmatches;
2339 eServiceReferenceDVB ref(refstr?(const eServiceReferenceDVB&)handleGroup(eServiceReference(refstr)):eServiceReferenceDVB(""));
2340 // ref is only valid in SIMILAR_BROADCASTING_SEARCH
2341 // in this case we start searching with the base service
2342 bool first = ref.valid() ? true : false;
2343 singleLock s(cache_lock);
2344 eventCache::iterator cit(ref.valid() ? eventDB.find(ref) : eventDB.begin());
2345 while(cit != eventDB.end() && maxcount)
2347 if ( ref.valid() && !first && cit->first == ref )
2349 // do not scan base service twice ( only in SIMILAR BROADCASTING SEARCH )
2353 ePyObject service_name;
2354 ePyObject service_reference;
2355 timeMap &evmap = cit->second.second;
2357 for (timeMap::iterator evit(evmap.begin()); evit != evmap.end() && maxcount; ++evit)
2359 int evid = evit->second->getEventID();
2360 if ( evid == eventid)
2362 __u8 *data = evit->second->EITdata;
2363 int tmp = evit->second->ByteSize-10;
2364 __u32 *p = (__u32*)(data+10);
2365 // check if any of our descriptor used by this event
2370 for ( int i=0; i <= descridx; ++i)
2372 if (descr[i] == crc32) // found...
2377 if ( (querytype == 0 && cnt == descridx) ||
2378 ((querytype == 1 || querytype == 2) && cnt != -1) )
2380 const uniqueEPGKey &service = cit->first;
2381 eServiceReference ref =
2382 eDVBDB::getInstance()->searchReference(service.tsid, service.onid, service.sid);
2385 // create servive event
2387 const eventData *ev_data=0;
2388 if (needServiceEvent)
2390 if (lookupEventId(ref, evid, ev_data))
2391 eDebug("event not found !!!!!!!!!!!");
2394 const eServiceReferenceDVB &dref = (const eServiceReferenceDVB&)ref;
2395 Event ev((uint8_t*)ev_data->get());
2396 ptr.parseFrom(&ev, (dref.getTransportStreamID().get()<<16)|dref.getOriginalNetworkID().get());
2399 // create service name
2400 if (must_get_service_name && !service_name)
2402 ePtr<iStaticServiceInformation> sptr;
2403 eServiceCenterPtr service_center;
2404 eServiceCenter::getPrivInstance(service_center);
2407 service_center->info(ref, sptr);
2411 sptr->getName(ref, name);
2413 if (must_get_service_name == 1)
2416 // filter short name brakets
2417 while((pos = name.find("\xc2\x86")) != std::string::npos)
2419 while((pos = name.find("\xc2\x87")) != std::string::npos)
2423 name = buildShortName(name);
2426 service_name = PyString_FromString(name.c_str());
2430 service_name = PyString_FromString("<n/a>");
2432 // create servicereference string
2433 if (must_get_service_reference && !service_reference)
2434 service_reference = PyString_FromString(ref.toString().c_str());
2437 ret = PyList_New(0);
2439 ePyObject tuple = PyTuple_New(argcount);
2441 fillTuple2(tuple, argstring, argcount, evit->second, ev_data ? &ptr : 0, service_name, service_reference);
2442 PyList_Append(ret, tuple);
2449 Py_DECREF(service_name);
2450 if (service_reference)
2451 Py_DECREF(service_reference);
2454 // now start at first service in epgcache database ( only in SIMILAR BROADCASTING SEARCH )
2456 cit=eventDB.begin();
2469 #ifdef ENABLE_PRIVATE_EPG
2470 #include <dvbsi++/descriptor_tag.h>
2471 #include <dvbsi++/unknown_descriptor.h>
2472 #include <dvbsi++/private_data_specifier_descriptor.h>
2474 void eEPGCache::PMTready(eDVBServicePMTHandler *pmthandler)
2476 ePtr<eTable<ProgramMapSection> > ptr;
2477 if (!pmthandler->getPMT(ptr) && ptr)
2479 std::vector<ProgramMapSection*>::const_iterator i;
2480 for (i = ptr->getSections().begin(); i != ptr->getSections().end(); ++i)
2482 const ProgramMapSection &pmt = **i;
2484 ElementaryStreamInfoConstIterator es;
2485 for (es = pmt.getEsInfo()->begin(); es != pmt.getEsInfo()->end(); ++es)
2488 switch ((*es)->getType())
2490 case 0x05: // private
2491 for (DescriptorConstIterator desc = (*es)->getDescriptors()->begin();
2492 desc != (*es)->getDescriptors()->end(); ++desc)
2494 switch ((*desc)->getTag())
2496 case PRIVATE_DATA_SPECIFIER_DESCRIPTOR:
2497 if (((PrivateDataSpecifierDescriptor*)(*desc))->getPrivateDataSpecifier() == 190)
2502 UnknownDescriptor *descr = (UnknownDescriptor*)*desc;
2503 int descr_len = descr->getLength();
2506 uint8_t data[descr_len+2];
2507 descr->writeToBuffer(data);
2508 if ( !data[2] && !data[3] && data[4] == 0xFF && data[5] == 0xFF )
2522 eServiceReferenceDVB ref;
2523 if (!pmthandler->getServiceReference(ref))
2525 int pid = (*es)->getPid();
2526 messages.send(Message(Message::got_private_pid, ref, pid));
2534 eDebug("PMTready but no pmt!!");
2541 date_time( const date_time &a )
2543 memcpy(data, a.data, 5);
2546 date_time( const __u8 data[5])
2548 memcpy(this->data, data, 5);
2549 tm = parseDVBtime(data[0], data[1], data[2], data[3], data[4]);
2554 const __u8& operator[](int pos) const
2560 struct less_datetime
2562 bool operator()( const date_time &a, const date_time &b ) const
2564 return abs(a.tm-b.tm) < 360 ? false : a.tm < b.tm;
2568 void eEPGCache::privateSectionRead(const uniqueEPGKey ¤t_service, const __u8 *data)
2570 contentMap &content_time_table = content_time_tables[current_service];
2571 singleLock s(cache_lock);
2572 std::map< date_time, std::list<uniqueEPGKey>, less_datetime > start_times;
2573 eventMap &evMap = eventDB[current_service].first;
2574 timeMap &tmMap = eventDB[current_service].second;
2576 int content_id = data[ptr++] << 24;
2577 content_id |= data[ptr++] << 16;
2578 content_id |= data[ptr++] << 8;
2579 content_id |= data[ptr++];
2581 contentTimeMap &time_event_map =
2582 content_time_table[content_id];
2583 for ( contentTimeMap::iterator it( time_event_map.begin() );
2584 it != time_event_map.end(); ++it )
2586 eventMap::iterator evIt( evMap.find(it->second.second) );
2587 if ( evIt != evMap.end() )
2589 delete evIt->second;
2592 tmMap.erase(it->second.first);
2594 time_event_map.clear();
2597 memcpy(duration, data+ptr, 3);
2600 fromBCD(duration[0])*3600+fromBCD(duration[1])*60+fromBCD(duration[2]);
2602 const __u8 *descriptors[65];
2603 const __u8 **pdescr = descriptors;
2605 int descriptors_length = (data[ptr++]&0x0F) << 8;
2606 descriptors_length |= data[ptr++];
2607 while ( descriptors_length > 1 )
2609 int descr_type = data[ptr];
2610 int descr_len = data[ptr+1];
2611 descriptors_length -= 2;
2612 if (descriptors_length >= descr_len)
2614 descriptors_length -= descr_len;
2615 if ( descr_type == 0xf2 && descr_len > 5)
2618 int tsid = data[ptr++] << 8;
2619 tsid |= data[ptr++];
2620 int onid = data[ptr++] << 8;
2621 onid |= data[ptr++];
2622 int sid = data[ptr++] << 8;
2625 // WORKAROUND for wrong transmitted epg data (01.10.2007)
2628 switch( (tsid << 16) | sid )
2630 case 0x01030b: sid = 0x1b; tsid = 4; break; // Premiere Win
2631 case 0x0300f0: sid = 0xe0; tsid = 2; break;
2632 case 0x0300f1: sid = 0xe1; tsid = 2; break;
2633 case 0x0300f5: sid = 0xdc; break;
2634 case 0x0400d2: sid = 0xe2; tsid = 0x11; break;
2635 case 0x1100d3: sid = 0xe3; break;
2636 case 0x0100d4: sid = 0xe4; tsid = 4; break;
2639 ////////////////////////////////////////////
2641 uniqueEPGKey service( sid, onid, tsid );
2643 while( descr_len > 2 )
2646 datetime[0] = data[ptr++];
2647 datetime[1] = data[ptr++];
2648 int tmp_len = data[ptr++];
2650 if (descr_len >= tmp_len)
2652 descr_len -= tmp_len;
2653 while( tmp_len > 2 )
2655 memcpy(datetime+2, data+ptr, 3);
2658 start_times[datetime].push_back(service);
2671 ASSERT(pdescr <= &descriptors[65]);
2673 eit_event_struct *ev_struct = (eit_event_struct*) event;
2674 ev_struct->running_status = 0;
2675 ev_struct->free_CA_mode = 1;
2676 memcpy(event+7, duration, 3);
2678 const __u8 **d=descriptors;
2679 while ( d < pdescr )
2681 memcpy(event+ptr, *d, ((*d)[1])+2);
2685 ASSERT(ptr <= 4098);
2686 for ( std::map< date_time, std::list<uniqueEPGKey> >::iterator it(start_times.begin()); it != start_times.end(); ++it )
2688 time_t now = ::time(0);
2689 if ( (it->first.tm + duration_sec) < now )
2691 memcpy(event+2, it->first.data, 5);
2694 for (std::list<uniqueEPGKey>::iterator i(it->second.begin()); i != it->second.end(); ++i)
2696 event[bptr++] = 0x4A;
2697 __u8 *len = event+(bptr++);
2698 event[bptr++] = (i->tsid & 0xFF00) >> 8;
2699 event[bptr++] = (i->tsid & 0xFF);
2700 event[bptr++] = (i->onid & 0xFF00) >> 8;
2701 event[bptr++] = (i->onid & 0xFF);
2702 event[bptr++] = (i->sid & 0xFF00) >> 8;
2703 event[bptr++] = (i->sid & 0xFF);
2704 event[bptr++] = 0xB0;
2705 bptr += sprintf((char*)(event+bptr), "Option %d", ++cnt);
2706 *len = ((event+bptr) - len)-1;
2708 int llen = bptr - 12;
2709 ev_struct->descriptors_loop_length_hi = (llen & 0xF00) >> 8;
2710 ev_struct->descriptors_loop_length_lo = (llen & 0xFF);
2712 time_t stime = it->first.tm;
2713 while( tmMap.find(stime) != tmMap.end() )
2715 event[6] += (stime - it->first.tm);
2717 while( evMap.find(event_id) != evMap.end() )
2719 event[0] = (event_id & 0xFF00) >> 8;
2720 event[1] = (event_id & 0xFF);
2721 time_event_map[it->first.tm]=std::pair<time_t, __u16>(stime, event_id);
2722 eventData *d = new eventData( ev_struct, bptr, PRIVATE );
2723 evMap[event_id] = d;
2725 ASSERT(bptr <= 4098);
2729 void eEPGCache::channel_data::startPrivateReader()
2731 eDVBSectionFilterMask mask;
2732 memset(&mask, 0, sizeof(mask));
2733 mask.pid = m_PrivatePid;
2734 mask.flags = eDVBSectionFilterMask::rfCRC;
2735 mask.data[0] = 0xA0;
2736 mask.mask[0] = 0xFF;
2737 eDebug("[EPGC] start privatefilter for pid %04x and version %d", m_PrivatePid, m_PrevVersion);
2738 if (m_PrevVersion != -1)
2740 mask.data[3] = m_PrevVersion << 1;
2741 mask.mask[3] = 0x3E;
2742 mask.mode[3] = 0x3E;
2744 seenPrivateSections.clear();
2746 m_PrivateReader->connectRead(slot(*this, &eEPGCache::channel_data::readPrivateData), m_PrivateConn);
2747 m_PrivateReader->start(mask);
2750 void eEPGCache::channel_data::readPrivateData( const __u8 *data)
2752 if ( seenPrivateSections.find(data[6]) == seenPrivateSections.end() )
2754 cache->privateSectionRead(m_PrivateService, data);
2755 seenPrivateSections.insert(data[6]);
2757 if ( seenPrivateSections.size() == (unsigned int)(data[7] + 1) )
2759 eDebug("[EPGC] private finished");
2760 eDVBChannelID chid = channel->getChannelID();
2761 int tmp = chid.original_network_id.get();
2762 tmp |= 0x80000000; // we use highest bit as private epg indicator
2763 chid.original_network_id = tmp;
2764 cache->channelLastUpdated[chid] = ::time(0);
2765 m_PrevVersion = (data[5] & 0x3E) >> 1;
2766 startPrivateReader();
2770 #endif // ENABLE_PRIVATE_EPG
2772 #ifdef ENABLE_MHW_EPG
2773 void eEPGCache::channel_data::cleanup()
2778 m_program_ids.clear();
2781 __u8 *eEPGCache::channel_data::delimitName( __u8 *in, __u8 *out, int len_in )
2783 // Names in mhw structs are not strings as they are not '\0' terminated.
2784 // This function converts the mhw name into a string.
2785 // Constraint: "length of out" = "length of in" + 1.
2787 for ( i=0; i < len_in; i++ )
2791 while ( ( i >=0 ) && ( out[i] == 0x20 ) )
2798 void eEPGCache::channel_data::timeMHW2DVB( u_char hours, u_char minutes, u_char *return_time)
2801 return_time[0] = toBCD( hours );
2802 return_time[1] = toBCD( minutes );
2806 void eEPGCache::channel_data::timeMHW2DVB( int minutes, u_char *return_time)
2808 timeMHW2DVB( int(minutes/60), minutes%60, return_time );
2811 void eEPGCache::channel_data::timeMHW2DVB( u_char day, u_char hours, u_char minutes, u_char *return_time)
2812 // For date plus time of day
2814 char tz_saved[1024];
2815 // Remove offset in mhw time.
2816 __u8 local_hours = hours;
2819 else if ( hours >= 8 )
2822 // As far as we know all mhw time data is sent in central Europe time zone.
2823 // So, temporarily set timezone to western europe
2824 time_t dt = ::time(0);
2826 char *old_tz = getenv( "TZ" );
2828 strcpy(tz_saved, old_tz);
2829 putenv("TZ=CET-1CEST,M3.5.0/2,M10.5.0/3");
2833 localtime_r(&dt, &localnow);
2837 if ( day + 1 < localnow.tm_wday ) // day + 1 to prevent old events to show for next week.
2839 if (local_hours <= 5)
2842 dt += 3600*24*(day - localnow.tm_wday); // Shift dt to the recording date (local time zone).
2843 dt += 3600*(local_hours - localnow.tm_hour); // Shift dt to the recording hour.
2846 gmtime_r( &dt, &recdate ); // This will also take care of DST.
2848 if ( old_tz == NULL )
2851 setenv("TZ", tz_saved, 1);
2854 // Calculate MJD according to annex in ETSI EN 300 468
2856 if ( recdate.tm_mon <= 1 ) // Jan or Feb
2858 int mjd = 14956 + recdate.tm_mday + int( (recdate.tm_year - l) * 365.25) +
2859 int( (recdate.tm_mon + 2 + l * 12) * 30.6001);
2861 return_time[0] = (mjd & 0xFF00)>>8;
2862 return_time[1] = mjd & 0xFF;
2864 timeMHW2DVB( recdate.tm_hour, minutes, return_time+2 );
2867 void eEPGCache::channel_data::storeTitle(std::map<__u32, mhw_title_t>::iterator itTitle, std::string sumText, const __u8 *data)
2868 // data is borrowed from calling proc to save memory space.
2872 // For each title a separate EIT packet will be sent to eEPGCache::sectionRead()
2873 bool isMHW2 = itTitle->second.mhw2_mjd_hi || itTitle->second.mhw2_mjd_lo ||
2874 itTitle->second.mhw2_duration_hi || itTitle->second.mhw2_duration_lo;
2876 eit_t *packet = (eit_t *) data;
2877 packet->table_id = 0x50;
2878 packet->section_syntax_indicator = 1;
2880 packet->service_id_hi = m_channels[ itTitle->second.channel_id - 1 ].channel_id_hi;
2881 packet->service_id_lo = m_channels[ itTitle->second.channel_id - 1 ].channel_id_lo;
2882 packet->version_number = 0; // eEPGCache::sectionRead() will dig this for the moment
2883 packet->current_next_indicator = 0;
2884 packet->section_number = 0; // eEPGCache::sectionRead() will dig this for the moment
2885 packet->last_section_number = 0; // eEPGCache::sectionRead() will dig this for the moment
2886 packet->transport_stream_id_hi = m_channels[ itTitle->second.channel_id - 1 ].transport_stream_id_hi;
2887 packet->transport_stream_id_lo = m_channels[ itTitle->second.channel_id - 1 ].transport_stream_id_lo;
2888 packet->original_network_id_hi = m_channels[ itTitle->second.channel_id - 1 ].network_id_hi;
2889 packet->original_network_id_lo = m_channels[ itTitle->second.channel_id - 1 ].network_id_lo;
2890 packet->segment_last_section_number = 0; // eEPGCache::sectionRead() will dig this for the moment
2891 packet->segment_last_table_id = 0x50;
2893 __u8 *title = isMHW2 ? ((__u8*)(itTitle->second.title))-4 : (__u8*)itTitle->second.title;
2894 std::string prog_title = (char *) delimitName( title, name, isMHW2 ? 33 : 23 );
2895 int prog_title_length = prog_title.length();
2897 int packet_length = EIT_SIZE + EIT_LOOP_SIZE + EIT_SHORT_EVENT_DESCRIPTOR_SIZE +
2898 prog_title_length + 1;
2900 eit_event_t *event_data = (eit_event_t *) (data + EIT_SIZE);
2901 event_data->event_id_hi = (( itTitle->first ) >> 8 ) & 0xFF;
2902 event_data->event_id_lo = ( itTitle->first ) & 0xFF;
2906 u_char *data = (u_char*) event_data;
2907 data[2] = itTitle->second.mhw2_mjd_hi;
2908 data[3] = itTitle->second.mhw2_mjd_lo;
2909 data[4] = itTitle->second.mhw2_hours;
2910 data[5] = itTitle->second.mhw2_minutes;
2911 data[6] = itTitle->second.mhw2_seconds;
2912 timeMHW2DVB( HILO(itTitle->second.mhw2_duration), data+7 );
2916 timeMHW2DVB( itTitle->second.dh.day, itTitle->second.dh.hours, itTitle->second.ms.minutes,
2917 (u_char *) event_data + 2 );
2918 timeMHW2DVB( HILO(itTitle->second.duration), (u_char *) event_data+7 );
2921 event_data->running_status = 0;
2922 event_data->free_CA_mode = 0;
2923 int descr_ll = EIT_SHORT_EVENT_DESCRIPTOR_SIZE + 1 + prog_title_length;
2925 eit_short_event_descriptor_struct *short_event_descriptor =
2926 (eit_short_event_descriptor_struct *) ( (u_char *) event_data + EIT_LOOP_SIZE);
2927 short_event_descriptor->descriptor_tag = EIT_SHORT_EVENT_DESCRIPTOR;
2928 short_event_descriptor->descriptor_length = EIT_SHORT_EVENT_DESCRIPTOR_SIZE +
2929 prog_title_length - 1;
2930 short_event_descriptor->language_code_1 = 'e';
2931 short_event_descriptor->language_code_2 = 'n';
2932 short_event_descriptor->language_code_3 = 'g';
2933 short_event_descriptor->event_name_length = prog_title_length;
2934 u_char *event_name = (u_char *) short_event_descriptor + EIT_SHORT_EVENT_DESCRIPTOR_SIZE;
2935 memcpy(event_name, prog_title.c_str(), prog_title_length);
2938 event_name[prog_title_length] = 0;
2940 if ( sumText.length() > 0 )
2941 // There is summary info
2943 unsigned int sum_length = sumText.length();
2944 if ( sum_length + short_event_descriptor->descriptor_length <= 0xff )
2945 // Store summary in short event descriptor
2947 // Increase all relevant lengths
2948 event_name[prog_title_length] = sum_length;
2949 short_event_descriptor->descriptor_length += sum_length;
2950 packet_length += sum_length;
2951 descr_ll += sum_length;
2952 sumText.copy( (char *) event_name+prog_title_length+1, sum_length );
2955 // Store summary in extended event descriptors
2957 int remaining_sum_length = sumText.length();
2958 int nbr_descr = int(remaining_sum_length/247) + 1;
2959 for ( int i=0; i < nbr_descr; i++)
2960 // Loop once per extended event descriptor
2962 eit_extended_descriptor_struct *ext_event_descriptor = (eit_extended_descriptor_struct *) (data + packet_length);
2963 sum_length = remaining_sum_length > 247 ? 247 : remaining_sum_length;
2964 remaining_sum_length -= sum_length;
2965 packet_length += 8 + sum_length;
2966 descr_ll += 8 + sum_length;
2968 ext_event_descriptor->descriptor_tag = EIT_EXTENDED_EVENT_DESCRIPOR;
2969 ext_event_descriptor->descriptor_length = sum_length + 6;
2970 ext_event_descriptor->descriptor_number = i;
2971 ext_event_descriptor->last_descriptor_number = nbr_descr - 1;
2972 ext_event_descriptor->iso_639_2_language_code_1 = 'e';
2973 ext_event_descriptor->iso_639_2_language_code_2 = 'n';
2974 ext_event_descriptor->iso_639_2_language_code_3 = 'g';
2975 u_char *the_text = (u_char *) ext_event_descriptor + 8;
2977 the_text[-1] = sum_length;
2978 sumText.copy( (char *) the_text, sum_length, sumText.length() - sum_length - remaining_sum_length );
2985 // Add content descriptor
2986 u_char *descriptor = (u_char *) data + packet_length;
2991 std::string content_descr = (char *) delimitName( m_themes[itTitle->second.theme_id].name, name, 15 );
2992 if ( content_descr.find( "FILM" ) != std::string::npos )
2994 else if ( content_descr.find( "SPORT" ) != std::string::npos )
2997 descriptor[0] = 0x54;
2999 descriptor[2] = content_id;
3003 event_data->descriptors_loop_length_hi = (descr_ll & 0xf00)>>8;
3004 event_data->descriptors_loop_length_lo = (descr_ll & 0xff);
3006 packet->section_length_hi = ((packet_length - 3)&0xf00)>>8;
3007 packet->section_length_lo = (packet_length - 3)&0xff;
3009 // Feed the data to eEPGCache::sectionRead()
3010 cache->sectionRead( data, MHW, this );
3013 void eEPGCache::channel_data::startTimeout(int msec)
3015 m_MHWTimeoutTimer->start(msec,true);
3016 m_MHWTimeoutet=false;
3019 void eEPGCache::channel_data::startMHWReader(__u16 pid, __u8 tid)
3021 m_MHWFilterMask.pid = pid;
3022 m_MHWFilterMask.data[0] = tid;
3023 m_MHWReader->start(m_MHWFilterMask);
3024 // eDebug("start 0x%02x 0x%02x", pid, tid);
3027 void eEPGCache::channel_data::startMHWReader2(__u16 pid, __u8 tid, int ext)
3029 m_MHWFilterMask2.pid = pid;
3030 m_MHWFilterMask2.data[0] = tid;
3033 m_MHWFilterMask2.data[1] = ext;
3034 m_MHWFilterMask2.mask[1] = 0xFF;
3035 // eDebug("start 0x%03x 0x%02x 0x%02x", pid, tid, ext);
3039 m_MHWFilterMask2.data[1] = 0;
3040 m_MHWFilterMask2.mask[1] = 0;
3041 // eDebug("start 0x%02x 0x%02x", pid, tid);
3043 m_MHWReader2->start(m_MHWFilterMask2);
3046 void eEPGCache::channel_data::readMHWData(const __u8 *data)
3049 m_MHWReader2->stop();
3051 if ( state > 1 || // aborted
3052 // have si data.. so we dont read mhw data
3053 (haveData & (SCHEDULE|SCHEDULE_OTHER|VIASAT)) )
3055 eDebug("[EPGC] mhw aborted %d", state);
3057 else if (m_MHWFilterMask.pid == 0xD3 && m_MHWFilterMask.data[0] == 0x91)
3060 int len = ((data[1]&0xf)<<8) + data[2] - 1;
3061 int record_size = sizeof( mhw_channel_name_t );
3062 int nbr_records = int (len/record_size);
3064 m_channels.resize(nbr_records);
3065 for ( int i = 0; i < nbr_records; i++ )
3067 mhw_channel_name_t *channel = (mhw_channel_name_t*) &data[4 + i*record_size];
3068 m_channels[i]=*channel;
3072 eDebug("[EPGC] mhw %d channels found", m_channels.size());
3074 // Channels table has been read, start reading the themes table.
3075 startMHWReader(0xD3, 0x92);
3078 else if (m_MHWFilterMask.pid == 0xD3 && m_MHWFilterMask.data[0] == 0x92)
3081 int len = ((data[1]&0xf)<<8) + data[2] - 16;
3082 int record_size = sizeof( mhw_theme_name_t );
3083 int nbr_records = int (len/record_size);
3085 __u8 next_idx = (__u8) *(data + 3 + idx_ptr);
3088 for ( int i = 0; i < nbr_records; i++ )
3090 mhw_theme_name_t *theme = (mhw_theme_name_t*) &data[19 + i*record_size];
3091 if ( i >= next_idx )
3095 next_idx = (__u8) *(data + 3 + idx_ptr);
3101 m_themes[idx+sub_idx] = *theme;
3103 eDebug("[EPGC] mhw %d themes found", m_themes.size());
3104 // Themes table has been read, start reading the titles table.
3105 startMHWReader(0xD2, 0x90);
3109 else if (m_MHWFilterMask.pid == 0xD2 && m_MHWFilterMask.data[0] == 0x90)
3112 mhw_title_t *title = (mhw_title_t*) data;
3114 if ( title->channel_id == 0xFF ) // Separator
3115 return; // Continue reading of the current table.
3118 // Create unique key per title
3119 __u32 title_id = ((title->channel_id)<<16)|((title->dh.day)<<13)|((title->dh.hours)<<8)|
3120 (title->ms.minutes);
3121 __u32 program_id = ((title->program_id_hi)<<24)|((title->program_id_mh)<<16)|
3122 ((title->program_id_ml)<<8)|(title->program_id_lo);
3124 if ( m_titles.find( title_id ) == m_titles.end() )
3127 title->mhw2_mjd_hi = 0;
3128 title->mhw2_mjd_lo = 0;
3129 title->mhw2_duration_hi = 0;
3130 title->mhw2_duration_lo = 0;
3131 m_titles[ title_id ] = *title;
3132 if ( (title->ms.summary_available) && (m_program_ids.find(program_id) == m_program_ids.end()) )
3133 // program_ids will be used to gather summaries.
3134 m_program_ids.insert(std::pair<__u32,__u32>(program_id,title_id));
3135 return; // Continue reading of the current table.
3137 else if (!checkTimeout())
3140 if ( !m_program_ids.empty())
3142 // Titles table has been read, there are summaries to read.
3143 // Start reading summaries, store corresponding titles on the fly.
3144 startMHWReader(0xD3, 0x90);
3145 eDebug("[EPGC] mhw %d titles(%d with summary) found",
3147 m_program_ids.size());
3152 else if (m_MHWFilterMask.pid == 0xD3 && m_MHWFilterMask.data[0] == 0x90)
3155 mhw_summary_t *summary = (mhw_summary_t*) data;
3157 // Create unique key per record
3158 __u32 program_id = ((summary->program_id_hi)<<24)|((summary->program_id_mh)<<16)|
3159 ((summary->program_id_ml)<<8)|(summary->program_id_lo);
3160 int len = ((data[1]&0xf)<<8) + data[2];
3162 // ugly workaround to convert const __u8* to char*
3164 memcpy(&tmp, &data, sizeof(void*));
3165 tmp[len+3] = 0; // Terminate as a string.
3167 std::multimap<__u32, __u32>::iterator itProgid( m_program_ids.find( program_id ) );
3168 if ( itProgid == m_program_ids.end() )
3169 { /* This part is to prevent to looping forever if some summaries are not received yet.
3170 There is a timeout of 4 sec. after the last successfully read summary. */
3171 if (!m_program_ids.empty() && !checkTimeout())
3172 return; // Continue reading of the current table.
3176 std::string the_text = (char *) (data + 11 + summary->nb_replays * 7);
3179 while((pos = the_text.find("\r\n")) != std::string::npos)
3180 the_text.replace(pos, 2, " ");
3182 // Find corresponding title, store title and summary in epgcache.
3183 std::map<__u32, mhw_title_t>::iterator itTitle( m_titles.find( itProgid->second ) );
3184 if ( itTitle != m_titles.end() )
3187 storeTitle( itTitle, the_text, data );
3188 m_titles.erase( itTitle );
3190 m_program_ids.erase( itProgid );
3191 if ( !m_program_ids.empty() )
3192 return; // Continue reading of the current table.
3195 eDebug("[EPGC] mhw finished(%ld) %d summaries not found",
3197 m_program_ids.size());
3198 // Summaries have been read, titles that have summaries have been stored.
3199 // Now store titles that do not have summaries.
3200 for (std::map<__u32, mhw_title_t>::iterator itTitle(m_titles.begin()); itTitle != m_titles.end(); itTitle++)
3201 storeTitle( itTitle, "", data );
3205 m_MHWReader->stop();
3210 void eEPGCache::channel_data::readMHWData2(const __u8 *data)
3212 int dataLen = (((data[1]&0xf) << 8) | data[2]) + 3;
3215 m_MHWReader->stop();
3217 if ( state > 1 || // aborted
3218 // have si data.. so we dont read mhw data
3219 (haveData & (SCHEDULE|SCHEDULE_OTHER|VIASAT)) )
3221 eDebug("[EPGC] mhw2 aborted %d", state);
3223 else if (m_MHWFilterMask2.pid == 0x231 && m_MHWFilterMask2.data[0] == 0xC8 && m_MHWFilterMask2.data[1] == 0)
3226 int num_channels = data[119];
3227 m_channels.resize(num_channels);
3230 int ptr = 120 + 8 * num_channels;
3233 for( int chid = 0; chid < num_channels; ++chid )
3235 ptr += ( data[ptr] & 0x0f ) + 1;
3245 // data seems consistent...
3246 const __u8 *tmp = data+120;
3247 for (int i=0; i < num_channels; ++i)
3249 mhw_channel_name_t channel;
3250 channel.network_id_hi = *(tmp++);
3251 channel.network_id_lo = *(tmp++);
3252 channel.transport_stream_id_hi = *(tmp++);
3253 channel.transport_stream_id_lo = *(tmp++);
3254 channel.channel_id_hi = *(tmp++);
3255 channel.channel_id_lo = *(tmp++);
3256 m_channels[i]=channel;
3259 for (int i=0; i < num_channels; ++i)
3261 mhw_channel_name_t &channel = m_channels[i];
3262 int channel_name_len=*(tmp++)&0x0f;
3264 for (; x < channel_name_len; ++x)
3265 channel.name[x]=*(tmp++);
3266 channel.name[x+1]=0;
3269 eDebug("[EPGC] mhw2 %d channels found", m_channels.size());
3271 else if (m_MHWFilterMask2.pid == 0x231 && m_MHWFilterMask2.data[0] == 0xC8 && m_MHWFilterMask2.data[1] == 1)
3274 eDebug("[EPGC] mhw2 themes nyi");
3276 else if (m_MHWFilterMask2.pid == 0x234 && m_MHWFilterMask2.data[0] == 0xe6)
3281 int len = ((data[1]&0xf)<<8) + data[2] - 16;
3283 if(data[dataLen-1] != 0xff)
3285 while( pos < dataLen )
3294 if( data[pos] > 0xc0 )
3296 pos += ( data[pos] - 0xc0 );
3300 if( data[pos] == 0xff )
3316 // data seems consistent...
3321 title.channel_id = data[pos]+1;
3322 title.program_id_ml = data[pos+1];
3323 title.program_id_lo = data[pos+2];
3324 title.mhw2_mjd_hi = data[pos+3];
3325 title.mhw2_mjd_lo = data[pos+4];
3326 title.mhw2_hours = data[pos+5];
3327 title.mhw2_minutes = data[pos+6];
3328 title.mhw2_seconds = data[pos+7];
3329 int duration = ((data[pos+8] << 8)|data[pos+9]) >> 4;
3330 title.mhw2_duration_hi = (duration&0xFF00) >> 8;
3331 title.mhw2_duration_lo = duration&0xFF;
3332 __u8 slen = data[pos+10] & 0x3f;
3333 __u8 *dest = ((__u8*)title.title)-4;
3334 memcpy(dest, &data[pos+11], slen>33 ? 33 : slen);
3335 memset(dest+slen, 0, 33-slen);
3337 // not used theme id (data[7] & 0x3f) + (data[pos] & 0x3f);
3338 __u32 summary_id = (data[pos+1] << 8) | data[pos+2];
3340 // Create unique key per title
3341 __u32 title_id = (title.channel_id<<16) | (title.program_id_ml<<8) | title.program_id_lo;
3345 std::map<__u32, mhw_title_t>::iterator it = m_titles.find( title_id );
3346 if ( it == m_titles.end() )
3349 m_titles[ title_id ] = title;
3350 if (summary_id != 0xFFFF)
3353 std::multimap<__u32, __u32>::iterator it(m_program_ids.lower_bound(summary_id));
3354 while (it != m_program_ids.end() && it->first == summary_id)
3356 if (it->second == title_id) {
3363 m_program_ids.insert(std::pair<__u32,__u32>(summary_id,title_id));
3368 if ( !checkTimeout() )
3369 continue; // Continue reading of the current table.
3377 eDebug("[EPGC] mhw2 %d titles(%d with summary) found", m_titles.size(), m_program_ids.size());
3378 if (!m_program_ids.empty())
3380 // Titles table has been read, there are summaries to read.
3381 // Start reading summaries, store corresponding titles on the fly.
3382 startMHWReader2(0x236, 0x96);
3383 startTimeout(15000);
3390 else if (m_MHWFilterMask2.pid == 0x236 && m_MHWFilterMask2.data[0] == 0x96)
3393 if (!checkTimeout())
3395 int len, loop, pos, lenline;
3404 loop = data[pos] & 0x0f;
3409 for( ; loop > 0; --loop )
3411 if( dataLen > (pos+len) )
3413 lenline = data[pos+len];
3423 return; // continue reading
3426 // data seems consistent...
3427 __u32 summary_id = (data[3]<<8)|data[4];
3429 // ugly workaround to convert const __u8* to char*
3431 memcpy(&tmp, &data, sizeof(void*));
3436 loop = tmp[pos] & 0x0f;
3438 for( ; loop > 0; loop -- )
3440 lenline = tmp[pos+len];
3449 std::multimap<__u32, __u32>::iterator itProgId( m_program_ids.lower_bound(summary_id) );
3450 if ( itProgId == m_program_ids.end() || itProgId->first != summary_id)
3451 { /* This part is to prevent to looping forever if some summaries are not received yet.
3452 There is a timeout of 4 sec. after the last successfully read summary. */
3453 if ( !m_program_ids.empty() )
3454 return; // Continue reading of the current table.
3458 startTimeout(15000);
3459 std::string the_text = (char *) (data + pos + 1);
3461 while( itProgId != m_program_ids.end() && itProgId->first == summary_id )
3463 // Find corresponding title, store title and summary in epgcache.
3464 std::map<__u32, mhw_title_t>::iterator itTitle( m_titles.find( itProgId->second ) );
3465 if ( itTitle != m_titles.end() )
3467 storeTitle( itTitle, the_text, data );
3468 m_titles.erase( itTitle );
3470 m_program_ids.erase( itProgId++ );
3472 if ( !m_program_ids.empty() )
3473 return; // Continue reading of the current table.
3477 return; // continue reading
3480 if (isRunning & eEPGCache::MHW)
3482 if ( m_MHWFilterMask2.pid == 0x231 && m_MHWFilterMask2.data[0] == 0xC8 && m_MHWFilterMask2.data[1] == 0)
3484 // Channels table has been read, start reading the themes table.
3485 startMHWReader2(0x231, 0xC8, 1);
3488 else if ( m_MHWFilterMask2.pid == 0x231 && m_MHWFilterMask2.data[0] == 0xC8 && m_MHWFilterMask2.data[1] == 1)
3490 // Themes table has been read, start reading the titles table.
3491 startMHWReader2(0x234, 0xe6);
3496 // Summaries have been read, titles that have summaries have been stored.
3497 // Now store titles that do not have summaries.
3498 for (std::map<__u32, mhw_title_t>::iterator itTitle(m_titles.begin()); itTitle != m_titles.end(); itTitle++)
3499 storeTitle( itTitle, "", data );
3500 eDebug("[EPGC] mhw2 finished(%ld) %d summaries not found",
3502 m_program_ids.size());
3509 m_MHWReader2->stop();