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
1721 eDebug("fillTuple unknown '%c'... insert 'None' in result", c);
1726 inc_refcount = true;
1730 PyTuple_SET_ITEM(tuple, tpos++, tmp);
1734 int handleEvent(eServiceEvent *ptr, ePyObject dest_list, const char* argstring, int argcount, ePyObject service, ePyObject nowTime, ePyObject service_name, ePyObject convertFunc, ePyObject convertFuncArgs)
1738 fillTuple(convertFuncArgs, argstring, argcount, service, ptr, nowTime, service_name);
1739 ePyObject result = PyObject_CallObject(convertFunc, convertFuncArgs);
1743 Py_DECREF(service_name);
1746 Py_DECREF(convertFuncArgs);
1747 Py_DECREF(dest_list);
1748 PyErr_SetString(PyExc_StandardError,
1749 "error in convertFunc execute");
1750 eDebug("error in convertFunc execute");
1753 PyList_Append(dest_list, result);
1758 ePyObject tuple = PyTuple_New(argcount);
1759 fillTuple(tuple, argstring, argcount, service, ptr, nowTime, service_name);
1760 PyList_Append(dest_list, tuple);
1766 // here we get a python list
1767 // the first entry in the list is a python string to specify the format of the returned tuples (in a list)
1770 // B = Event Begin Time
1771 // D = Event Duration
1773 // S = Event Short Description
1774 // E = Event Extended Description
1776 // R = Service Reference
1778 // n = Short Service Name
1779 // X = Return a minimum of one tuple per service in the result list... even when no event was found.
1780 // The returned tuple is filled with all available infos... non avail is filled as None
1781 // The position and existence of 'X' in the format string has no influence on the result tuple... its completely ignored..
1782 // then for each service follows a tuple
1783 // first tuple entry is the servicereference (as string... use the ref.toString() function)
1784 // the second is the type of query
1786 // -1 = event before given start_time
1787 // 0 = event intersects given start_time
1788 // +1 = event after given start_time
1790 // when type is eventid it is the event_id
1791 // when type is time then it is the start_time ( -1 for now_time )
1792 // the fourth is the end_time .. ( optional .. for query all events in time range)
1794 PyObject *eEPGCache::lookupEvent(ePyObject list, ePyObject convertFunc)
1796 ePyObject convertFuncArgs;
1798 const char *argstring=NULL;
1799 if (!PyList_Check(list))
1801 PyErr_SetString(PyExc_StandardError,
1807 int listSize=PyList_Size(list);
1810 PyErr_SetString(PyExc_StandardError,
1811 "not params given");
1812 eDebug("not params given");
1817 ePyObject argv=PyList_GET_ITEM(list, 0); // borrowed reference!
1818 if (PyString_Check(argv))
1820 argstring = PyString_AS_STRING(argv);
1824 argstring = "I"; // just event id as default
1825 argcount = strlen(argstring);
1826 // eDebug("have %d args('%s')", argcount, argstring);
1829 bool forceReturnOne = strchr(argstring, 'X') ? true : false;
1835 if (!PyCallable_Check(convertFunc))
1837 PyErr_SetString(PyExc_StandardError,
1838 "convertFunc must be callable");
1839 eDebug("convertFunc is not callable");
1842 convertFuncArgs = PyTuple_New(argcount);
1845 ePyObject nowTime = strchr(argstring, 'C') ?
1846 PyLong_FromLong(::time(0)) :
1849 int must_get_service_name = strchr(argstring, 'N') ? 1 : strchr(argstring, 'n') ? 2 : 0;
1852 ePyObject dest_list=PyList_New(0);
1853 while(listSize > listIt)
1855 ePyObject item=PyList_GET_ITEM(list, listIt++); // borrowed reference!
1856 if (PyTuple_Check(item))
1858 bool service_changed=false;
1863 int tupleSize=PyTuple_Size(item);
1866 while(tupleSize > tupleIt) // parse query args
1868 ePyObject entry=PyTuple_GET_ITEM(item, tupleIt); // borrowed reference!
1873 if (!PyString_Check(entry))
1875 eDebug("tuple entry 0 is no a string");
1882 type=PyInt_AsLong(entry);
1883 if (type < -1 || type > 2)
1885 eDebug("unknown type %d", type);
1890 event_id=stime=PyInt_AsLong(entry);
1893 minutes=PyInt_AsLong(entry);
1896 eDebug("unneeded extra argument");
1901 if (minutes && stime == -1)
1904 eServiceReference ref(handleGroup(eServiceReference(PyString_AS_STRING(service))));
1905 if (ref.type != eServiceReference::idDVB)
1907 eDebug("service reference for epg query is not valid");
1911 // redirect subservice querys to parent service
1912 eServiceReferenceDVB &dvb_ref = (eServiceReferenceDVB&)ref;
1913 if (dvb_ref.getParentTransportStreamID().get()) // linkage subservice
1915 eServiceCenterPtr service_center;
1916 if (!eServiceCenter::getPrivInstance(service_center))
1918 dvb_ref.setTransportStreamID( dvb_ref.getParentTransportStreamID() );
1919 dvb_ref.setServiceID( dvb_ref.getParentServiceID() );
1920 dvb_ref.setParentTransportStreamID(eTransportStreamID(0));
1921 dvb_ref.setParentServiceID(eServiceID(0));
1923 service = PyString_FromString(dvb_ref.toString().c_str());
1924 service_changed = true;
1928 ePyObject service_name;
1929 if (must_get_service_name)
1931 ePtr<iStaticServiceInformation> sptr;
1932 eServiceCenterPtr service_center;
1933 eServiceCenter::getPrivInstance(service_center);
1936 service_center->info(ref, sptr);
1940 sptr->getName(ref, name);
1942 if (must_get_service_name == 1)
1945 // filter short name brakets
1946 while((pos = name.find("\xc2\x86")) != std::string::npos)
1948 while((pos = name.find("\xc2\x87")) != std::string::npos)
1952 name = buildShortName(name);
1955 service_name = PyString_FromString(name.c_str());
1959 service_name = PyString_FromString("<n/a>");
1963 singleLock s(cache_lock);
1964 if (!startTimeQuery(ref, stime, minutes))
1966 while ( m_timemap_cursor != m_timemap_end )
1968 Event ev((uint8_t*)m_timemap_cursor++->second->get());
1970 evt.parseFrom(&ev, currentQueryTsidOnid);
1971 if (handleEvent(&evt, dest_list, argstring, argcount, service, nowTime, service_name, convertFunc, convertFuncArgs))
1975 else if (forceReturnOne && handleEvent(0, dest_list, argstring, argcount, service, nowTime, service_name, convertFunc, convertFuncArgs))
1981 const eventData *ev_data=0;
1984 singleLock s(cache_lock);
1986 lookupEventId(ref, event_id, ev_data);
1988 lookupEventTime(ref, stime, ev_data, type);
1991 const eServiceReferenceDVB &dref = (const eServiceReferenceDVB&)ref;
1992 Event ev((uint8_t*)ev_data->get());
1993 evt.parseFrom(&ev, (dref.getTransportStreamID().get()<<16)|dref.getOriginalNetworkID().get());
1998 if (handleEvent(&evt, dest_list, argstring, argcount, service, nowTime, service_name, convertFunc, convertFuncArgs))
2001 else if (forceReturnOne && handleEvent(0, dest_list, argstring, argcount, service, nowTime, service_name, convertFunc, convertFuncArgs))
2004 if (service_changed)
2007 Py_DECREF(service_name);
2012 if (convertFuncArgs)
2013 Py_DECREF(convertFuncArgs);
2019 void fillTuple2(ePyObject tuple, const char *argstring, int argcount, eventData *evData, eServiceEvent *ptr, ePyObject service_name, ePyObject service_reference)
2023 while(pos < argcount)
2025 bool inc_refcount=false;
2026 switch(argstring[pos])
2028 case '0': // PyLong 0
2029 tmp = PyLong_FromLong(0);
2031 case 'I': // Event Id
2032 tmp = PyLong_FromLong(evData->getEventID());
2034 case 'B': // Event Begin Time
2036 tmp = ptr ? PyLong_FromLong(ptr->getBeginTime()) : ePyObject();
2038 tmp = PyLong_FromLong(evData->getStartTime());
2040 case 'D': // Event Duration
2042 tmp = ptr ? PyLong_FromLong(ptr->getDuration()) : ePyObject();
2044 tmp = PyLong_FromLong(evData->getDuration());
2046 case 'T': // Event Title
2047 tmp = ptr ? PyString_FromString(ptr->getEventName().c_str()) : ePyObject();
2049 case 'S': // Event Short Description
2050 tmp = ptr ? PyString_FromString(ptr->getShortDescription().c_str()) : ePyObject();
2052 case 'E': // Event Extended Description
2053 tmp = ptr ? PyString_FromString(ptr->getExtendedDescription().c_str()) : ePyObject();
2055 case 'R': // service reference string
2056 tmp = service_reference;
2057 inc_refcount = true;
2059 case 'n': // short service name
2060 case 'N': // service name
2062 inc_refcount = true;
2064 default: // ignore unknown
2066 eDebug("fillTuple2 unknown '%c'... insert None in Result", argstring[pos]);
2071 inc_refcount = true;
2075 PyTuple_SET_ITEM(tuple, pos++, tmp);
2079 // here we get a python tuple
2080 // the first entry in the tuple is a python string to specify the format of the returned tuples (in a list)
2082 // B = Event Begin Time
2083 // D = Event Duration
2085 // S = Event Short Description
2086 // E = Event Extended Description
2087 // R = Service Reference
2089 // n = Short Service Name
2090 // the second tuple entry is the MAX matches value
2091 // the third tuple entry is the type of query
2092 // 0 = search for similar broadcastings (SIMILAR_BROADCASTINGS_SEARCH)
2093 // 1 = search events with exactly title name (EXAKT_TITLE_SEARCH)
2094 // 2 = search events with text in title name (PARTIAL_TITLE_SEARCH)
2095 // when type is 0 (SIMILAR_BROADCASTINGS_SEARCH)
2096 // the fourth is the servicereference string
2097 // the fifth is the eventid
2098 // when type is 1 or 2 (EXAKT_TITLE_SEARCH or PARTIAL_TITLE_SEARCH)
2099 // the fourth is the search text
2101 // 0 = case sensitive (CASE_CHECK)
2102 // 1 = case insensitive (NO_CASECHECK)
2104 PyObject *eEPGCache::search(ePyObject arg)
2110 const char *argstring=0;
2114 bool needServiceEvent=false;
2116 int must_get_service_name = 0;
2117 bool must_get_service_reference = false;
2119 if (PyTuple_Check(arg))
2121 int tuplesize=PyTuple_Size(arg);
2124 ePyObject obj = PyTuple_GET_ITEM(arg,0);
2125 if (PyString_Check(obj))
2127 #if PY_VERSION_HEX < 0x02060000
2128 argcount = PyString_GET_SIZE(obj);
2130 argcount = PyString_Size(obj);
2132 argstring = PyString_AS_STRING(obj);
2133 for (int i=0; i < argcount; ++i)
2134 switch(argstring[i])
2139 needServiceEvent=true;
2142 must_get_service_name = 1;
2145 must_get_service_name = 2;
2148 must_get_service_reference = true;
2156 PyErr_SetString(PyExc_StandardError,
2158 eDebug("tuple arg 0 is not a string");
2163 maxmatches = PyLong_AsLong(PyTuple_GET_ITEM(arg, 1));
2166 querytype = PyLong_AsLong(PyTuple_GET_ITEM(arg, 2));
2167 if (tuplesize > 4 && querytype == 0)
2169 ePyObject obj = PyTuple_GET_ITEM(arg, 3);
2170 if (PyString_Check(obj))
2172 refstr = PyString_AS_STRING(obj);
2173 eServiceReferenceDVB ref(refstr);
2176 eventid = PyLong_AsLong(PyTuple_GET_ITEM(arg, 4));
2177 singleLock s(cache_lock);
2178 const eventData *evData = 0;
2179 lookupEventId(ref, eventid, evData);
2182 __u8 *data = evData->EITdata;
2183 int tmp = evData->ByteSize-10;
2184 __u32 *p = (__u32*)(data+10);
2185 // search short and extended event descriptors
2189 descriptorMap::iterator it =
2190 eventData::descriptors.find(crc);
2191 if (it != eventData::descriptors.end())
2193 __u8 *descr_data = it->second.second;
2194 switch(descr_data[0])
2197 descr[++descridx]=crc;
2206 eDebug("event not found");
2210 PyErr_SetString(PyExc_StandardError, "type error");
2211 eDebug("tuple arg 4 is not a valid service reference string");
2217 PyErr_SetString(PyExc_StandardError, "type error");
2218 eDebug("tuple arg 4 is not a string");
2222 else if (tuplesize > 4 && (querytype == 1 || querytype == 2) )
2224 ePyObject obj = PyTuple_GET_ITEM(arg, 3);
2225 if (PyString_Check(obj))
2227 int casetype = PyLong_AsLong(PyTuple_GET_ITEM(arg, 4));
2228 const char *str = PyString_AS_STRING(obj);
2229 #if PY_VERSION_HEX < 0x02060000
2230 int textlen = PyString_GET_SIZE(obj);
2232 int textlen = PyString_Size(obj);
2235 eDebug("lookup for events with '%s' as title(%s)", str, casetype?"ignore case":"case sensitive");
2237 eDebug("lookup for events with '%s' in title(%s)", str, casetype?"ignore case":"case sensitive");
2238 singleLock s(cache_lock);
2239 for (descriptorMap::iterator it(eventData::descriptors.begin());
2240 it != eventData::descriptors.end() && descridx < 511; ++it)
2242 __u8 *data = it->second.second;
2243 if ( data[0] == 0x4D ) // short event descriptor
2245 int title_len = data[5];
2246 if ( querytype == 1 )
2249 // skip DVB-Text Encoding!
2250 if (data[6] == 0x10)
2255 else if(data[6] > 0 && data[6] < 0x20)
2260 if (title_len != textlen)
2264 if ( !strncasecmp((const char*)data+offs, str, title_len) )
2266 // std::string s((const char*)data+offs, title_len);
2267 // eDebug("match1 %s %s", str, s.c_str() );
2268 descr[++descridx] = it->first;
2271 else if ( !strncmp((const char*)data+offs, str, title_len) )
2273 // std::string s((const char*)data+offs, title_len);
2274 // eDebug("match2 %s %s", str, s.c_str() );
2275 descr[++descridx] = it->first;
2281 while((title_len-idx) >= textlen)
2285 if (!strncasecmp((const char*)data+6+idx, str, textlen) )
2287 descr[++descridx] = it->first;
2288 // std::string s((const char*)data+6, title_len);
2289 // eDebug("match 3 %s %s", str, s.c_str() );
2293 else if (!strncmp((const char*)data+6+idx, str, textlen) )
2295 descr[++descridx] = it->first;
2296 // std::string s((const char*)data+6, title_len);
2297 // eDebug("match 4 %s %s", str, s.c_str() );
2308 PyErr_SetString(PyExc_StandardError,
2310 eDebug("tuple arg 4 is not a string");
2316 PyErr_SetString(PyExc_StandardError,
2318 eDebug("tuple arg 3(%d) is not a known querytype(0, 1, 2)", querytype);
2324 PyErr_SetString(PyExc_StandardError,
2326 eDebug("not enough args in tuple");
2332 PyErr_SetString(PyExc_StandardError,
2334 eDebug("arg 0 is not a tuple");
2340 int maxcount=maxmatches;
2341 eServiceReferenceDVB ref(refstr?(const eServiceReferenceDVB&)handleGroup(eServiceReference(refstr)):eServiceReferenceDVB(""));
2342 // ref is only valid in SIMILAR_BROADCASTING_SEARCH
2343 // in this case we start searching with the base service
2344 bool first = ref.valid() ? true : false;
2345 singleLock s(cache_lock);
2346 eventCache::iterator cit(ref.valid() ? eventDB.find(ref) : eventDB.begin());
2347 while(cit != eventDB.end() && maxcount)
2349 if ( ref.valid() && !first && cit->first == ref )
2351 // do not scan base service twice ( only in SIMILAR BROADCASTING SEARCH )
2355 ePyObject service_name;
2356 ePyObject service_reference;
2357 timeMap &evmap = cit->second.second;
2359 for (timeMap::iterator evit(evmap.begin()); evit != evmap.end() && maxcount; ++evit)
2361 int evid = evit->second->getEventID();
2362 if ( evid == eventid)
2364 __u8 *data = evit->second->EITdata;
2365 int tmp = evit->second->ByteSize-10;
2366 __u32 *p = (__u32*)(data+10);
2367 // check if any of our descriptor used by this event
2372 for ( int i=0; i <= descridx; ++i)
2374 if (descr[i] == crc32) // found...
2379 if ( (querytype == 0 && cnt == descridx) ||
2380 ((querytype == 1 || querytype == 2) && cnt != -1) )
2382 const uniqueEPGKey &service = cit->first;
2383 eServiceReference ref =
2384 eDVBDB::getInstance()->searchReference(service.tsid, service.onid, service.sid);
2387 // create servive event
2389 const eventData *ev_data=0;
2390 if (needServiceEvent)
2392 if (lookupEventId(ref, evid, ev_data))
2393 eDebug("event not found !!!!!!!!!!!");
2396 const eServiceReferenceDVB &dref = (const eServiceReferenceDVB&)ref;
2397 Event ev((uint8_t*)ev_data->get());
2398 ptr.parseFrom(&ev, (dref.getTransportStreamID().get()<<16)|dref.getOriginalNetworkID().get());
2401 // create service name
2402 if (must_get_service_name && !service_name)
2404 ePtr<iStaticServiceInformation> sptr;
2405 eServiceCenterPtr service_center;
2406 eServiceCenter::getPrivInstance(service_center);
2409 service_center->info(ref, sptr);
2413 sptr->getName(ref, name);
2415 if (must_get_service_name == 1)
2418 // filter short name brakets
2419 while((pos = name.find("\xc2\x86")) != std::string::npos)
2421 while((pos = name.find("\xc2\x87")) != std::string::npos)
2425 name = buildShortName(name);
2428 service_name = PyString_FromString(name.c_str());
2432 service_name = PyString_FromString("<n/a>");
2434 // create servicereference string
2435 if (must_get_service_reference && !service_reference)
2436 service_reference = PyString_FromString(ref.toString().c_str());
2439 ret = PyList_New(0);
2441 ePyObject tuple = PyTuple_New(argcount);
2443 fillTuple2(tuple, argstring, argcount, evit->second, ev_data ? &ptr : 0, service_name, service_reference);
2444 PyList_Append(ret, tuple);
2451 Py_DECREF(service_name);
2452 if (service_reference)
2453 Py_DECREF(service_reference);
2456 // now start at first service in epgcache database ( only in SIMILAR BROADCASTING SEARCH )
2458 cit=eventDB.begin();
2471 #ifdef ENABLE_PRIVATE_EPG
2472 #include <dvbsi++/descriptor_tag.h>
2473 #include <dvbsi++/unknown_descriptor.h>
2474 #include <dvbsi++/private_data_specifier_descriptor.h>
2476 void eEPGCache::PMTready(eDVBServicePMTHandler *pmthandler)
2478 ePtr<eTable<ProgramMapSection> > ptr;
2479 if (!pmthandler->getPMT(ptr) && ptr)
2481 std::vector<ProgramMapSection*>::const_iterator i;
2482 for (i = ptr->getSections().begin(); i != ptr->getSections().end(); ++i)
2484 const ProgramMapSection &pmt = **i;
2486 ElementaryStreamInfoConstIterator es;
2487 for (es = pmt.getEsInfo()->begin(); es != pmt.getEsInfo()->end(); ++es)
2490 switch ((*es)->getType())
2492 case 0x05: // private
2493 for (DescriptorConstIterator desc = (*es)->getDescriptors()->begin();
2494 desc != (*es)->getDescriptors()->end(); ++desc)
2496 switch ((*desc)->getTag())
2498 case PRIVATE_DATA_SPECIFIER_DESCRIPTOR:
2499 if (((PrivateDataSpecifierDescriptor*)(*desc))->getPrivateDataSpecifier() == 190)
2504 UnknownDescriptor *descr = (UnknownDescriptor*)*desc;
2505 int descr_len = descr->getLength();
2508 uint8_t data[descr_len+2];
2509 descr->writeToBuffer(data);
2510 if ( !data[2] && !data[3] && data[4] == 0xFF && data[5] == 0xFF )
2524 eServiceReferenceDVB ref;
2525 if (!pmthandler->getServiceReference(ref))
2527 int pid = (*es)->getPid();
2528 messages.send(Message(Message::got_private_pid, ref, pid));
2536 eDebug("PMTready but no pmt!!");
2543 date_time( const date_time &a )
2545 memcpy(data, a.data, 5);
2548 date_time( const __u8 data[5])
2550 memcpy(this->data, data, 5);
2551 tm = parseDVBtime(data[0], data[1], data[2], data[3], data[4]);
2556 const __u8& operator[](int pos) const
2562 struct less_datetime
2564 bool operator()( const date_time &a, const date_time &b ) const
2566 return abs(a.tm-b.tm) < 360 ? false : a.tm < b.tm;
2570 void eEPGCache::privateSectionRead(const uniqueEPGKey ¤t_service, const __u8 *data)
2572 contentMap &content_time_table = content_time_tables[current_service];
2573 singleLock s(cache_lock);
2574 std::map< date_time, std::list<uniqueEPGKey>, less_datetime > start_times;
2575 eventMap &evMap = eventDB[current_service].first;
2576 timeMap &tmMap = eventDB[current_service].second;
2578 int content_id = data[ptr++] << 24;
2579 content_id |= data[ptr++] << 16;
2580 content_id |= data[ptr++] << 8;
2581 content_id |= data[ptr++];
2583 contentTimeMap &time_event_map =
2584 content_time_table[content_id];
2585 for ( contentTimeMap::iterator it( time_event_map.begin() );
2586 it != time_event_map.end(); ++it )
2588 eventMap::iterator evIt( evMap.find(it->second.second) );
2589 if ( evIt != evMap.end() )
2591 delete evIt->second;
2594 tmMap.erase(it->second.first);
2596 time_event_map.clear();
2599 memcpy(duration, data+ptr, 3);
2602 fromBCD(duration[0])*3600+fromBCD(duration[1])*60+fromBCD(duration[2]);
2604 const __u8 *descriptors[65];
2605 const __u8 **pdescr = descriptors;
2607 int descriptors_length = (data[ptr++]&0x0F) << 8;
2608 descriptors_length |= data[ptr++];
2609 while ( descriptors_length > 1 )
2611 int descr_type = data[ptr];
2612 int descr_len = data[ptr+1];
2613 descriptors_length -= 2;
2614 if (descriptors_length >= descr_len)
2616 descriptors_length -= descr_len;
2617 if ( descr_type == 0xf2 && descr_len > 5)
2620 int tsid = data[ptr++] << 8;
2621 tsid |= data[ptr++];
2622 int onid = data[ptr++] << 8;
2623 onid |= data[ptr++];
2624 int sid = data[ptr++] << 8;
2627 // WORKAROUND for wrong transmitted epg data (01.10.2007)
2630 switch( (tsid << 16) | sid )
2632 case 0x01030b: sid = 0x1b; tsid = 4; break; // Premiere Win
2633 case 0x0300f0: sid = 0xe0; tsid = 2; break;
2634 case 0x0300f1: sid = 0xe1; tsid = 2; break;
2635 case 0x0300f5: sid = 0xdc; break;
2636 case 0x0400d2: sid = 0xe2; tsid = 0x11; break;
2637 case 0x1100d3: sid = 0xe3; break;
2638 case 0x0100d4: sid = 0xe4; tsid = 4; break;
2641 ////////////////////////////////////////////
2643 uniqueEPGKey service( sid, onid, tsid );
2645 while( descr_len > 2 )
2648 datetime[0] = data[ptr++];
2649 datetime[1] = data[ptr++];
2650 int tmp_len = data[ptr++];
2652 if (descr_len >= tmp_len)
2654 descr_len -= tmp_len;
2655 while( tmp_len > 2 )
2657 memcpy(datetime+2, data+ptr, 3);
2660 start_times[datetime].push_back(service);
2673 ASSERT(pdescr <= &descriptors[65]);
2675 eit_event_struct *ev_struct = (eit_event_struct*) event;
2676 ev_struct->running_status = 0;
2677 ev_struct->free_CA_mode = 1;
2678 memcpy(event+7, duration, 3);
2680 const __u8 **d=descriptors;
2681 while ( d < pdescr )
2683 memcpy(event+ptr, *d, ((*d)[1])+2);
2687 ASSERT(ptr <= 4098);
2688 for ( std::map< date_time, std::list<uniqueEPGKey> >::iterator it(start_times.begin()); it != start_times.end(); ++it )
2690 time_t now = ::time(0);
2691 if ( (it->first.tm + duration_sec) < now )
2693 memcpy(event+2, it->first.data, 5);
2696 for (std::list<uniqueEPGKey>::iterator i(it->second.begin()); i != it->second.end(); ++i)
2698 event[bptr++] = 0x4A;
2699 __u8 *len = event+(bptr++);
2700 event[bptr++] = (i->tsid & 0xFF00) >> 8;
2701 event[bptr++] = (i->tsid & 0xFF);
2702 event[bptr++] = (i->onid & 0xFF00) >> 8;
2703 event[bptr++] = (i->onid & 0xFF);
2704 event[bptr++] = (i->sid & 0xFF00) >> 8;
2705 event[bptr++] = (i->sid & 0xFF);
2706 event[bptr++] = 0xB0;
2707 bptr += sprintf((char*)(event+bptr), "Option %d", ++cnt);
2708 *len = ((event+bptr) - len)-1;
2710 int llen = bptr - 12;
2711 ev_struct->descriptors_loop_length_hi = (llen & 0xF00) >> 8;
2712 ev_struct->descriptors_loop_length_lo = (llen & 0xFF);
2714 time_t stime = it->first.tm;
2715 while( tmMap.find(stime) != tmMap.end() )
2717 event[6] += (stime - it->first.tm);
2719 while( evMap.find(event_id) != evMap.end() )
2721 event[0] = (event_id & 0xFF00) >> 8;
2722 event[1] = (event_id & 0xFF);
2723 time_event_map[it->first.tm]=std::pair<time_t, __u16>(stime, event_id);
2724 eventData *d = new eventData( ev_struct, bptr, PRIVATE );
2725 evMap[event_id] = d;
2727 ASSERT(bptr <= 4098);
2731 void eEPGCache::channel_data::startPrivateReader()
2733 eDVBSectionFilterMask mask;
2734 memset(&mask, 0, sizeof(mask));
2735 mask.pid = m_PrivatePid;
2736 mask.flags = eDVBSectionFilterMask::rfCRC;
2737 mask.data[0] = 0xA0;
2738 mask.mask[0] = 0xFF;
2739 eDebug("[EPGC] start privatefilter for pid %04x and version %d", m_PrivatePid, m_PrevVersion);
2740 if (m_PrevVersion != -1)
2742 mask.data[3] = m_PrevVersion << 1;
2743 mask.mask[3] = 0x3E;
2744 mask.mode[3] = 0x3E;
2746 seenPrivateSections.clear();
2748 m_PrivateReader->connectRead(slot(*this, &eEPGCache::channel_data::readPrivateData), m_PrivateConn);
2749 m_PrivateReader->start(mask);
2752 void eEPGCache::channel_data::readPrivateData( const __u8 *data)
2754 if ( seenPrivateSections.find(data[6]) == seenPrivateSections.end() )
2756 cache->privateSectionRead(m_PrivateService, data);
2757 seenPrivateSections.insert(data[6]);
2759 if ( seenPrivateSections.size() == (unsigned int)(data[7] + 1) )
2761 eDebug("[EPGC] private finished");
2762 eDVBChannelID chid = channel->getChannelID();
2763 int tmp = chid.original_network_id.get();
2764 tmp |= 0x80000000; // we use highest bit as private epg indicator
2765 chid.original_network_id = tmp;
2766 cache->channelLastUpdated[chid] = ::time(0);
2767 m_PrevVersion = (data[5] & 0x3E) >> 1;
2768 startPrivateReader();
2772 #endif // ENABLE_PRIVATE_EPG
2774 #ifdef ENABLE_MHW_EPG
2775 void eEPGCache::channel_data::cleanup()
2780 m_program_ids.clear();
2783 __u8 *eEPGCache::channel_data::delimitName( __u8 *in, __u8 *out, int len_in )
2785 // Names in mhw structs are not strings as they are not '\0' terminated.
2786 // This function converts the mhw name into a string.
2787 // Constraint: "length of out" = "length of in" + 1.
2789 for ( i=0; i < len_in; i++ )
2793 while ( ( i >=0 ) && ( out[i] == 0x20 ) )
2800 void eEPGCache::channel_data::timeMHW2DVB( u_char hours, u_char minutes, u_char *return_time)
2803 return_time[0] = toBCD( hours );
2804 return_time[1] = toBCD( minutes );
2808 void eEPGCache::channel_data::timeMHW2DVB( int minutes, u_char *return_time)
2810 timeMHW2DVB( int(minutes/60), minutes%60, return_time );
2813 void eEPGCache::channel_data::timeMHW2DVB( u_char day, u_char hours, u_char minutes, u_char *return_time)
2814 // For date plus time of day
2816 char tz_saved[1024];
2817 // Remove offset in mhw time.
2818 __u8 local_hours = hours;
2821 else if ( hours >= 8 )
2824 // As far as we know all mhw time data is sent in central Europe time zone.
2825 // So, temporarily set timezone to western europe
2826 time_t dt = ::time(0);
2828 char *old_tz = getenv( "TZ" );
2830 strcpy(tz_saved, old_tz);
2831 putenv("TZ=CET-1CEST,M3.5.0/2,M10.5.0/3");
2835 localtime_r(&dt, &localnow);
2839 if ( day + 1 < localnow.tm_wday ) // day + 1 to prevent old events to show for next week.
2841 if (local_hours <= 5)
2844 dt += 3600*24*(day - localnow.tm_wday); // Shift dt to the recording date (local time zone).
2845 dt += 3600*(local_hours - localnow.tm_hour); // Shift dt to the recording hour.
2848 gmtime_r( &dt, &recdate ); // This will also take care of DST.
2850 if ( old_tz == NULL )
2853 setenv("TZ", tz_saved, 1);
2856 // Calculate MJD according to annex in ETSI EN 300 468
2858 if ( recdate.tm_mon <= 1 ) // Jan or Feb
2860 int mjd = 14956 + recdate.tm_mday + int( (recdate.tm_year - l) * 365.25) +
2861 int( (recdate.tm_mon + 2 + l * 12) * 30.6001);
2863 return_time[0] = (mjd & 0xFF00)>>8;
2864 return_time[1] = mjd & 0xFF;
2866 timeMHW2DVB( recdate.tm_hour, minutes, return_time+2 );
2869 void eEPGCache::channel_data::storeTitle(std::map<__u32, mhw_title_t>::iterator itTitle, std::string sumText, const __u8 *data)
2870 // data is borrowed from calling proc to save memory space.
2874 // For each title a separate EIT packet will be sent to eEPGCache::sectionRead()
2875 bool isMHW2 = itTitle->second.mhw2_mjd_hi || itTitle->second.mhw2_mjd_lo ||
2876 itTitle->second.mhw2_duration_hi || itTitle->second.mhw2_duration_lo;
2878 eit_t *packet = (eit_t *) data;
2879 packet->table_id = 0x50;
2880 packet->section_syntax_indicator = 1;
2882 packet->service_id_hi = m_channels[ itTitle->second.channel_id - 1 ].channel_id_hi;
2883 packet->service_id_lo = m_channels[ itTitle->second.channel_id - 1 ].channel_id_lo;
2884 packet->version_number = 0; // eEPGCache::sectionRead() will dig this for the moment
2885 packet->current_next_indicator = 0;
2886 packet->section_number = 0; // eEPGCache::sectionRead() will dig this for the moment
2887 packet->last_section_number = 0; // eEPGCache::sectionRead() will dig this for the moment
2888 packet->transport_stream_id_hi = m_channels[ itTitle->second.channel_id - 1 ].transport_stream_id_hi;
2889 packet->transport_stream_id_lo = m_channels[ itTitle->second.channel_id - 1 ].transport_stream_id_lo;
2890 packet->original_network_id_hi = m_channels[ itTitle->second.channel_id - 1 ].network_id_hi;
2891 packet->original_network_id_lo = m_channels[ itTitle->second.channel_id - 1 ].network_id_lo;
2892 packet->segment_last_section_number = 0; // eEPGCache::sectionRead() will dig this for the moment
2893 packet->segment_last_table_id = 0x50;
2895 __u8 *title = isMHW2 ? ((__u8*)(itTitle->second.title))-4 : (__u8*)itTitle->second.title;
2896 std::string prog_title = (char *) delimitName( title, name, isMHW2 ? 33 : 23 );
2897 int prog_title_length = prog_title.length();
2899 int packet_length = EIT_SIZE + EIT_LOOP_SIZE + EIT_SHORT_EVENT_DESCRIPTOR_SIZE +
2900 prog_title_length + 1;
2902 eit_event_t *event_data = (eit_event_t *) (data + EIT_SIZE);
2903 event_data->event_id_hi = (( itTitle->first ) >> 8 ) & 0xFF;
2904 event_data->event_id_lo = ( itTitle->first ) & 0xFF;
2908 u_char *data = (u_char*) event_data;
2909 data[2] = itTitle->second.mhw2_mjd_hi;
2910 data[3] = itTitle->second.mhw2_mjd_lo;
2911 data[4] = itTitle->second.mhw2_hours;
2912 data[5] = itTitle->second.mhw2_minutes;
2913 data[6] = itTitle->second.mhw2_seconds;
2914 timeMHW2DVB( HILO(itTitle->second.mhw2_duration), data+7 );
2918 timeMHW2DVB( itTitle->second.dh.day, itTitle->second.dh.hours, itTitle->second.ms.minutes,
2919 (u_char *) event_data + 2 );
2920 timeMHW2DVB( HILO(itTitle->second.duration), (u_char *) event_data+7 );
2923 event_data->running_status = 0;
2924 event_data->free_CA_mode = 0;
2925 int descr_ll = EIT_SHORT_EVENT_DESCRIPTOR_SIZE + 1 + prog_title_length;
2927 eit_short_event_descriptor_struct *short_event_descriptor =
2928 (eit_short_event_descriptor_struct *) ( (u_char *) event_data + EIT_LOOP_SIZE);
2929 short_event_descriptor->descriptor_tag = EIT_SHORT_EVENT_DESCRIPTOR;
2930 short_event_descriptor->descriptor_length = EIT_SHORT_EVENT_DESCRIPTOR_SIZE +
2931 prog_title_length - 1;
2932 short_event_descriptor->language_code_1 = 'e';
2933 short_event_descriptor->language_code_2 = 'n';
2934 short_event_descriptor->language_code_3 = 'g';
2935 short_event_descriptor->event_name_length = prog_title_length;
2936 u_char *event_name = (u_char *) short_event_descriptor + EIT_SHORT_EVENT_DESCRIPTOR_SIZE;
2937 memcpy(event_name, prog_title.c_str(), prog_title_length);
2940 event_name[prog_title_length] = 0;
2942 if ( sumText.length() > 0 )
2943 // There is summary info
2945 unsigned int sum_length = sumText.length();
2946 if ( sum_length + short_event_descriptor->descriptor_length <= 0xff )
2947 // Store summary in short event descriptor
2949 // Increase all relevant lengths
2950 event_name[prog_title_length] = sum_length;
2951 short_event_descriptor->descriptor_length += sum_length;
2952 packet_length += sum_length;
2953 descr_ll += sum_length;
2954 sumText.copy( (char *) event_name+prog_title_length+1, sum_length );
2957 // Store summary in extended event descriptors
2959 int remaining_sum_length = sumText.length();
2960 int nbr_descr = int(remaining_sum_length/247) + 1;
2961 for ( int i=0; i < nbr_descr; i++)
2962 // Loop once per extended event descriptor
2964 eit_extended_descriptor_struct *ext_event_descriptor = (eit_extended_descriptor_struct *) (data + packet_length);
2965 sum_length = remaining_sum_length > 247 ? 247 : remaining_sum_length;
2966 remaining_sum_length -= sum_length;
2967 packet_length += 8 + sum_length;
2968 descr_ll += 8 + sum_length;
2970 ext_event_descriptor->descriptor_tag = EIT_EXTENDED_EVENT_DESCRIPOR;
2971 ext_event_descriptor->descriptor_length = sum_length + 6;
2972 ext_event_descriptor->descriptor_number = i;
2973 ext_event_descriptor->last_descriptor_number = nbr_descr - 1;
2974 ext_event_descriptor->iso_639_2_language_code_1 = 'e';
2975 ext_event_descriptor->iso_639_2_language_code_2 = 'n';
2976 ext_event_descriptor->iso_639_2_language_code_3 = 'g';
2977 u_char *the_text = (u_char *) ext_event_descriptor + 8;
2979 the_text[-1] = sum_length;
2980 sumText.copy( (char *) the_text, sum_length, sumText.length() - sum_length - remaining_sum_length );
2987 // Add content descriptor
2988 u_char *descriptor = (u_char *) data + packet_length;
2993 std::string content_descr = (char *) delimitName( m_themes[itTitle->second.theme_id].name, name, 15 );
2994 if ( content_descr.find( "FILM" ) != std::string::npos )
2996 else if ( content_descr.find( "SPORT" ) != std::string::npos )
2999 descriptor[0] = 0x54;
3001 descriptor[2] = content_id;
3005 event_data->descriptors_loop_length_hi = (descr_ll & 0xf00)>>8;
3006 event_data->descriptors_loop_length_lo = (descr_ll & 0xff);
3008 packet->section_length_hi = ((packet_length - 3)&0xf00)>>8;
3009 packet->section_length_lo = (packet_length - 3)&0xff;
3011 // Feed the data to eEPGCache::sectionRead()
3012 cache->sectionRead( data, MHW, this );
3015 void eEPGCache::channel_data::startTimeout(int msec)
3017 m_MHWTimeoutTimer->start(msec,true);
3018 m_MHWTimeoutet=false;
3021 void eEPGCache::channel_data::startMHWReader(__u16 pid, __u8 tid)
3023 m_MHWFilterMask.pid = pid;
3024 m_MHWFilterMask.data[0] = tid;
3025 m_MHWReader->start(m_MHWFilterMask);
3026 // eDebug("start 0x%02x 0x%02x", pid, tid);
3029 void eEPGCache::channel_data::startMHWReader2(__u16 pid, __u8 tid, int ext)
3031 m_MHWFilterMask2.pid = pid;
3032 m_MHWFilterMask2.data[0] = tid;
3035 m_MHWFilterMask2.data[1] = ext;
3036 m_MHWFilterMask2.mask[1] = 0xFF;
3037 // eDebug("start 0x%03x 0x%02x 0x%02x", pid, tid, ext);
3041 m_MHWFilterMask2.data[1] = 0;
3042 m_MHWFilterMask2.mask[1] = 0;
3043 // eDebug("start 0x%02x 0x%02x", pid, tid);
3045 m_MHWReader2->start(m_MHWFilterMask2);
3048 void eEPGCache::channel_data::readMHWData(const __u8 *data)
3051 m_MHWReader2->stop();
3053 if ( state > 1 || // aborted
3054 // have si data.. so we dont read mhw data
3055 (haveData & (SCHEDULE|SCHEDULE_OTHER|VIASAT)) )
3057 eDebug("[EPGC] mhw aborted %d", state);
3059 else if (m_MHWFilterMask.pid == 0xD3 && m_MHWFilterMask.data[0] == 0x91)
3062 int len = ((data[1]&0xf)<<8) + data[2] - 1;
3063 int record_size = sizeof( mhw_channel_name_t );
3064 int nbr_records = int (len/record_size);
3066 m_channels.resize(nbr_records);
3067 for ( int i = 0; i < nbr_records; i++ )
3069 mhw_channel_name_t *channel = (mhw_channel_name_t*) &data[4 + i*record_size];
3070 m_channels[i]=*channel;
3074 eDebug("[EPGC] mhw %d channels found", m_channels.size());
3076 // Channels table has been read, start reading the themes table.
3077 startMHWReader(0xD3, 0x92);
3080 else if (m_MHWFilterMask.pid == 0xD3 && m_MHWFilterMask.data[0] == 0x92)
3083 int len = ((data[1]&0xf)<<8) + data[2] - 16;
3084 int record_size = sizeof( mhw_theme_name_t );
3085 int nbr_records = int (len/record_size);
3087 __u8 next_idx = (__u8) *(data + 3 + idx_ptr);
3090 for ( int i = 0; i < nbr_records; i++ )
3092 mhw_theme_name_t *theme = (mhw_theme_name_t*) &data[19 + i*record_size];
3093 if ( i >= next_idx )
3097 next_idx = (__u8) *(data + 3 + idx_ptr);
3103 m_themes[idx+sub_idx] = *theme;
3105 eDebug("[EPGC] mhw %d themes found", m_themes.size());
3106 // Themes table has been read, start reading the titles table.
3107 startMHWReader(0xD2, 0x90);
3111 else if (m_MHWFilterMask.pid == 0xD2 && m_MHWFilterMask.data[0] == 0x90)
3114 mhw_title_t *title = (mhw_title_t*) data;
3116 if ( title->channel_id == 0xFF ) // Separator
3117 return; // Continue reading of the current table.
3120 // Create unique key per title
3121 __u32 title_id = ((title->channel_id)<<16)|((title->dh.day)<<13)|((title->dh.hours)<<8)|
3122 (title->ms.minutes);
3123 __u32 program_id = ((title->program_id_hi)<<24)|((title->program_id_mh)<<16)|
3124 ((title->program_id_ml)<<8)|(title->program_id_lo);
3126 if ( m_titles.find( title_id ) == m_titles.end() )
3129 title->mhw2_mjd_hi = 0;
3130 title->mhw2_mjd_lo = 0;
3131 title->mhw2_duration_hi = 0;
3132 title->mhw2_duration_lo = 0;
3133 m_titles[ title_id ] = *title;
3134 if ( (title->ms.summary_available) && (m_program_ids.find(program_id) == m_program_ids.end()) )
3135 // program_ids will be used to gather summaries.
3136 m_program_ids.insert(std::pair<__u32,__u32>(program_id,title_id));
3137 return; // Continue reading of the current table.
3139 else if (!checkTimeout())
3142 if ( !m_program_ids.empty())
3144 // Titles table has been read, there are summaries to read.
3145 // Start reading summaries, store corresponding titles on the fly.
3146 startMHWReader(0xD3, 0x90);
3147 eDebug("[EPGC] mhw %d titles(%d with summary) found",
3149 m_program_ids.size());
3154 else if (m_MHWFilterMask.pid == 0xD3 && m_MHWFilterMask.data[0] == 0x90)
3157 mhw_summary_t *summary = (mhw_summary_t*) data;
3159 // Create unique key per record
3160 __u32 program_id = ((summary->program_id_hi)<<24)|((summary->program_id_mh)<<16)|
3161 ((summary->program_id_ml)<<8)|(summary->program_id_lo);
3162 int len = ((data[1]&0xf)<<8) + data[2];
3164 // ugly workaround to convert const __u8* to char*
3166 memcpy(&tmp, &data, sizeof(void*));
3167 tmp[len+3] = 0; // Terminate as a string.
3169 std::multimap<__u32, __u32>::iterator itProgid( m_program_ids.find( program_id ) );
3170 if ( itProgid == m_program_ids.end() )
3171 { /* This part is to prevent to looping forever if some summaries are not received yet.
3172 There is a timeout of 4 sec. after the last successfully read summary. */
3173 if (!m_program_ids.empty() && !checkTimeout())
3174 return; // Continue reading of the current table.
3178 std::string the_text = (char *) (data + 11 + summary->nb_replays * 7);
3181 while((pos = the_text.find("\r\n")) != std::string::npos)
3182 the_text.replace(pos, 2, " ");
3184 // Find corresponding title, store title and summary in epgcache.
3185 std::map<__u32, mhw_title_t>::iterator itTitle( m_titles.find( itProgid->second ) );
3186 if ( itTitle != m_titles.end() )
3189 storeTitle( itTitle, the_text, data );
3190 m_titles.erase( itTitle );
3192 m_program_ids.erase( itProgid );
3193 if ( !m_program_ids.empty() )
3194 return; // Continue reading of the current table.
3197 eDebug("[EPGC] mhw finished(%ld) %d summaries not found",
3199 m_program_ids.size());
3200 // Summaries have been read, titles that have summaries have been stored.
3201 // Now store titles that do not have summaries.
3202 for (std::map<__u32, mhw_title_t>::iterator itTitle(m_titles.begin()); itTitle != m_titles.end(); itTitle++)
3203 storeTitle( itTitle, "", data );
3207 m_MHWReader->stop();
3212 void eEPGCache::channel_data::readMHWData2(const __u8 *data)
3214 int dataLen = (((data[1]&0xf) << 8) | data[2]) + 3;
3217 m_MHWReader->stop();
3219 if ( state > 1 || // aborted
3220 // have si data.. so we dont read mhw data
3221 (haveData & (SCHEDULE|SCHEDULE_OTHER|VIASAT)) )
3223 eDebug("[EPGC] mhw2 aborted %d", state);
3225 else if (m_MHWFilterMask2.pid == 0x231 && m_MHWFilterMask2.data[0] == 0xC8 && m_MHWFilterMask2.data[1] == 0)
3228 int num_channels = data[119];
3229 m_channels.resize(num_channels);
3232 int ptr = 120 + 8 * num_channels;
3235 for( int chid = 0; chid < num_channels; ++chid )
3237 ptr += ( data[ptr] & 0x0f ) + 1;
3247 // data seems consistent...
3248 const __u8 *tmp = data+120;
3249 for (int i=0; i < num_channels; ++i)
3251 mhw_channel_name_t channel;
3252 channel.network_id_hi = *(tmp++);
3253 channel.network_id_lo = *(tmp++);
3254 channel.transport_stream_id_hi = *(tmp++);
3255 channel.transport_stream_id_lo = *(tmp++);
3256 channel.channel_id_hi = *(tmp++);
3257 channel.channel_id_lo = *(tmp++);
3258 m_channels[i]=channel;
3261 for (int i=0; i < num_channels; ++i)
3263 mhw_channel_name_t &channel = m_channels[i];
3264 int channel_name_len=*(tmp++)&0x0f;
3266 for (; x < channel_name_len; ++x)
3267 channel.name[x]=*(tmp++);
3268 channel.name[x+1]=0;
3271 eDebug("[EPGC] mhw2 %d channels found", m_channels.size());
3273 else if (m_MHWFilterMask2.pid == 0x231 && m_MHWFilterMask2.data[0] == 0xC8 && m_MHWFilterMask2.data[1] == 1)
3276 eDebug("[EPGC] mhw2 themes nyi");
3278 else if (m_MHWFilterMask2.pid == 0x234 && m_MHWFilterMask2.data[0] == 0xe6)
3283 int len = ((data[1]&0xf)<<8) + data[2] - 16;
3285 if(data[dataLen-1] != 0xff)
3287 while( pos < dataLen )
3296 if( data[pos] > 0xc0 )
3298 pos += ( data[pos] - 0xc0 );
3302 if( data[pos] == 0xff )
3318 // data seems consistent...
3323 title.channel_id = data[pos]+1;
3324 title.program_id_ml = data[pos+1];
3325 title.program_id_lo = data[pos+2];
3326 title.mhw2_mjd_hi = data[pos+3];
3327 title.mhw2_mjd_lo = data[pos+4];
3328 title.mhw2_hours = data[pos+5];
3329 title.mhw2_minutes = data[pos+6];
3330 title.mhw2_seconds = data[pos+7];
3331 int duration = ((data[pos+8] << 8)|data[pos+9]) >> 4;
3332 title.mhw2_duration_hi = (duration&0xFF00) >> 8;
3333 title.mhw2_duration_lo = duration&0xFF;
3334 __u8 slen = data[pos+10] & 0x3f;
3335 __u8 *dest = ((__u8*)title.title)-4;
3336 memcpy(dest, &data[pos+11], slen>33 ? 33 : slen);
3337 memset(dest+slen, 0, 33-slen);
3339 // not used theme id (data[7] & 0x3f) + (data[pos] & 0x3f);
3340 __u32 summary_id = (data[pos+1] << 8) | data[pos+2];
3342 // Create unique key per title
3343 __u32 title_id = (title.channel_id<<16) | (title.program_id_ml<<8) | title.program_id_lo;
3347 std::map<__u32, mhw_title_t>::iterator it = m_titles.find( title_id );
3348 if ( it == m_titles.end() )
3351 m_titles[ title_id ] = title;
3352 if (summary_id != 0xFFFF)
3355 std::multimap<__u32, __u32>::iterator it(m_program_ids.lower_bound(summary_id));
3356 while (it != m_program_ids.end() && it->first == summary_id)
3358 if (it->second == title_id) {
3365 m_program_ids.insert(std::pair<__u32,__u32>(summary_id,title_id));
3370 if ( !checkTimeout() )
3371 continue; // Continue reading of the current table.
3379 eDebug("[EPGC] mhw2 %d titles(%d with summary) found", m_titles.size(), m_program_ids.size());
3380 if (!m_program_ids.empty())
3382 // Titles table has been read, there are summaries to read.
3383 // Start reading summaries, store corresponding titles on the fly.
3384 startMHWReader2(0x236, 0x96);
3385 startTimeout(15000);
3392 else if (m_MHWFilterMask2.pid == 0x236 && m_MHWFilterMask2.data[0] == 0x96)
3395 if (!checkTimeout())
3397 int len, loop, pos, lenline;
3406 loop = data[pos] & 0x0f;
3411 for( ; loop > 0; --loop )
3413 if( dataLen > (pos+len) )
3415 lenline = data[pos+len];
3425 return; // continue reading
3428 // data seems consistent...
3429 __u32 summary_id = (data[3]<<8)|data[4];
3431 // ugly workaround to convert const __u8* to char*
3433 memcpy(&tmp, &data, sizeof(void*));
3438 loop = tmp[pos] & 0x0f;
3440 for( ; loop > 0; loop -- )
3442 lenline = tmp[pos+len];
3451 std::multimap<__u32, __u32>::iterator itProgId( m_program_ids.lower_bound(summary_id) );
3452 if ( itProgId == m_program_ids.end() || itProgId->first != summary_id)
3453 { /* This part is to prevent to looping forever if some summaries are not received yet.
3454 There is a timeout of 4 sec. after the last successfully read summary. */
3455 if ( !m_program_ids.empty() )
3456 return; // Continue reading of the current table.
3460 startTimeout(15000);
3461 std::string the_text = (char *) (data + pos + 1);
3463 while( itProgId != m_program_ids.end() && itProgId->first == summary_id )
3465 // Find corresponding title, store title and summary in epgcache.
3466 std::map<__u32, mhw_title_t>::iterator itTitle( m_titles.find( itProgId->second ) );
3467 if ( itTitle != m_titles.end() )
3469 storeTitle( itTitle, the_text, data );
3470 m_titles.erase( itTitle );
3472 m_program_ids.erase( itProgId++ );
3474 if ( !m_program_ids.empty() )
3475 return; // Continue reading of the current table.
3479 return; // continue reading
3482 if (isRunning & eEPGCache::MHW)
3484 if ( m_MHWFilterMask2.pid == 0x231 && m_MHWFilterMask2.data[0] == 0xC8 && m_MHWFilterMask2.data[1] == 0)
3486 // Channels table has been read, start reading the themes table.
3487 startMHWReader2(0x231, 0xC8, 1);
3490 else if ( m_MHWFilterMask2.pid == 0x231 && m_MHWFilterMask2.data[0] == 0xC8 && m_MHWFilterMask2.data[1] == 1)
3492 // Themes table has been read, start reading the titles table.
3493 startMHWReader2(0x234, 0xe6);
3498 // Summaries have been read, titles that have summaries have been stored.
3499 // Now store titles that do not have summaries.
3500 for (std::map<__u32, mhw_title_t>::iterator itTitle(m_titles.begin()); itTitle != m_titles.end(); itTitle++)
3501 storeTitle( itTitle, "", data );
3502 eDebug("[EPGC] mhw2 finished(%ld) %d summaries not found",
3504 m_program_ids.size());
3511 m_MHWReader2->stop();