diff --git a/src/eitd/SIsections.cpp b/src/eitd/SIsections.cpp index 862030700..352c63a83 100644 --- a/src/eitd/SIsections.cpp +++ b/src/eitd/SIsections.cpp @@ -476,277 +476,6 @@ void SIsectionEIT::parse(void) parsed = 1; } - -//----------------------------------------------------------------------- -// Da es vorkommen kann das defekte Packete empfangen werden -// sollte hier alles ueberprueft werden. -// Leider ist das noch nicht bei allen Descriptoren so. -//----------------------------------------------------------------------- -#ifdef ENABLE_PPT -void SIsectionPPT::parseLinkageDescriptor(const char *buf, SIevent &e, unsigned maxlen) -{ - if(maxlen>=sizeof(struct descr_linkage_header)) - { - SIlinkage l((const struct descr_linkage_header *)buf); - e.linkage_descs.insert(e.linkage_descs.end(), l); -// printf("LinkName: %s\n", l.name.c_str()); - } -} - -void SIsectionPPT::parseComponentDescriptor(const char *buf, SIevent &e, unsigned maxlen) -{ - if(maxlen>=sizeof(struct descr_component_header)) - e.components.insert(SIcomponent((const struct descr_component_header *)buf)); -} - -void SIsectionPPT::parseContentDescriptor(const char *buf, SIevent &e, unsigned maxlen) -{ - struct descr_generic_header *cont=(struct descr_generic_header *)buf; - if(cont->descriptor_length+sizeof(struct descr_generic_header)>maxlen) - return; // defekt - const char *classification=buf+sizeof(struct descr_generic_header); - while(classification<=buf+sizeof(struct descr_generic_header)+cont->descriptor_length-2) { - e.contentClassification+=std::string(classification, 1); -// printf("Content: 0x%02hhx\n", *classification); - e.userClassification+=std::string(classification+1, 1); -// printf("User: 0x%02hhx\n", *(classification+1)); - classification+=2; - } -} - -void SIsectionPPT::parseParentalRatingDescriptor(const char *buf, SIevent &e, unsigned maxlen) -{ - struct descr_generic_header *cont=(struct descr_generic_header *)buf; - if(cont->descriptor_length+sizeof(struct descr_generic_header)>maxlen) - return; // defekt - const char *s=buf+sizeof(struct descr_generic_header); - while(sdescriptor_length-4) { - e.ratings.insert(SIparentalRating(std::string(s, 3), *(s+3))); - s+=4; - } -} - -void SIsectionPPT::parseExtendedEventDescriptor(const char *buf, SIevent &e, unsigned maxlen) -{ - struct descr_extended_event_header *evt=(struct descr_extended_event_header *)buf; - if((evt->descriptor_length+sizeof(descr_generic_header)>maxlen) || (evt->descriptor_lengthiso_639_2_language_code_hi + evt->iso_639_2_language_code_mid + evt->iso_639_2_language_code_lo; - - unsigned char *items=(unsigned char *)(buf+sizeof(struct descr_extended_event_header)); - while(items<(unsigned char *)(buf+sizeof(struct descr_extended_event_header)+evt->length_of_items)) { - if(*items) { - if(*(items+1) < 0x06) // other code table - e.itemDescription=std::string((const char *)(items+2), min(maxlen-((const char *)items+2-buf), (*items)-1)); - else - e.itemDescription=std::string((const char *)(items+1), min(maxlen-((const char *)items+1-buf), *items)); -// printf("Item Description: %s\n", e.itemDescription.c_str()); - } - items+=1+*items; - if(*items) { - e.item=std::string((const char *)(items+1), min(maxlen-((const char *)items+1-buf), *items)); -// printf("Item: %s\n", e.item.c_str()); - } - items+=1+*items; - } - if(*items) { - if(*(items+1) < 0x06) // other code table - e.appendExtendedText(language, std::string((const char *)(items+2),min(maxlen-((const char *)items+2-buf), (*items)-1))); - else - e.appendExtendedText(language, std::string((const char *)(items+1), min(maxlen-((const char *)items+1-buf), *items))); -// printf("Extended Text: %s\n", e.extendedText.c_str()); - } -} - -void SIsectionPPT::parseShortEventDescriptor(const char *buf, SIevent &e, unsigned maxlen) -{ - struct descr_short_event_header *evt=(struct descr_short_event_header *)buf; - if((evt->descriptor_length+sizeof(descr_generic_header)>maxlen) || (evt->descriptor_lengthlanguage_code_hi + evt->language_code_mid + evt->language_code_lo; - - buf+=sizeof(struct descr_short_event_header); - if(evt->event_name_length) { - if(*buf < 0x06) // other code table - e.setName(language, std::string(buf+1, evt->event_name_length-1)); - else - e.setName(language, std::string(buf, evt->event_name_length)); - } - - buf+=evt->event_name_length; - unsigned char textlength=*((unsigned char *)buf); - if(textlength > 2) { - if(*(buf+1) < 0x06) // other code table - e.setText(language, std::string((++buf)+1, textlength-1)); - else - e.setText(language, std::string(++buf, textlength)); - } - -// printf("Name: %s\n", e.name.c_str()); -// printf("Text: %s\n", e.text.c_str()); - -} - -void SIsectionPPT::parsePrivateContentOrderDescriptor(const char *buf, SIevent &e, unsigned maxlen) -{ - struct descr_short_event_header *evt=(struct descr_short_event_header *)buf; - if((evt->descriptor_length+sizeof(descr_generic_header)>maxlen) || (evt->descriptor_lengthdescriptor_length+sizeof(descr_generic_header)>maxlen) || (evt->descriptor_lengthdescriptor_length) { - e.ratings.insert(SIparentalRating(std::string("", 0), *(buf))); - } -#if 0 - unsigned char rating; - unsigned char Controll_time_t1[3]; // BCD coded - unsigned char Controll_time_t2[3]; // BCD coded - unsigned char Parental_information_length; - unsigned char Parental_information[Parental_information_length]; -#endif -} - -void SIsectionPPT::parsePrivateContentTransmissionDescriptor(const char *buf, SIevent &e, unsigned maxlen) -{ - unsigned short starttime_loop_length = 0; - unsigned char tm_buf[6]; - int i; - - struct descr_short_event_header *evt=(struct descr_short_event_header *)buf; - if((evt->descriptor_length+sizeof(descr_generic_header)>maxlen) || (evt->descriptor_lengthdescriptor_length + sizeof(struct descr_generic_header)) {// at least one startdate/looplength/time entry - tm_buf[0] = *(p); - tm_buf[1] = *(p+1); - starttime_loop_length = (*(p+2))/3; - for (i=0; i=sizeof(struct descr_generic_header)) { - desc=(struct descr_generic_header *)des; - -// printf("Type: %s\n", decode_descr(desc->descriptor_tag)); - if(desc->descriptor_tag==0x4D) - parseShortEventDescriptor((const char *)desc, e, len); - else if(desc->descriptor_tag==0x4E) - parseExtendedEventDescriptor((const char *)desc, e, len); - else if(desc->descriptor_tag==0x54) - parseContentDescriptor((const char *)desc, e, len); - else if(desc->descriptor_tag==0x50) - parseComponentDescriptor((const char *)desc, e, len); - else if(desc->descriptor_tag==0x55) - parseParentalRatingDescriptor((const char *)desc, e, len); - else if(desc->descriptor_tag==0x4A) - parseLinkageDescriptor((const char *)desc, e, len); - else if(desc->descriptor_tag==0xF0) - parsePrivateContentOrderDescriptor((const char *)desc, e, len); - else if(desc->descriptor_tag==0xF1) - parsePrivateParentalInformationDescriptor((const char *)desc, e, len); - else if(desc->descriptor_tag==0xF2) { - if (linkage_alreadyseen) { - // Private EPG can have two linkage descriptors with their own date/time parameters for one event - // not sure if current event system supports it therefore: - // Generate additional Event(s) if there are more than one linkage descriptor (for repeated transmission) - SIevent e2(e); - e2.linkage_descs.clear(); - e2.times.clear(); - parsePrivateContentTransmissionDescriptor((const char *)desc, e2, len); - evts.insert(e2); - } else { - parsePrivateContentTransmissionDescriptor((const char *)desc, e, len); - linkage_alreadyseen = true; - } - } - if((unsigned)(desc->descriptor_length+2)>len) - break; - len-=desc->descriptor_length+2; - des+=desc->descriptor_length+2; - } -} - -// Die infos aus dem Puffer holen -void SIsectionPPT::parse(void) -{ - const char *actPos; - unsigned short descriptors_loop_length; - - if (!buffer || parsed) - return; - - if (bufferLength < sizeof(SI_section_PPT_header)) { - bufferLength=0; - return; - } - - actPos = &buffer[sizeof(SI_section_PPT_header)]; - - /*while (actPos < &buffer[bufferLength])*/ - { - SIevent e; - descriptors_loop_length = (((SI_section_PPT_header*)buffer)->descriptor_section_length_hi << 8) | ((SI_section_PPT_header*)buffer)->descriptor_section_length_lo; - e.eventID = (unsigned short)(content_id()); // ?? - parseDescriptors(actPos, min((unsigned)(buffer + bufferLength - actPos), descriptors_loop_length), e); - evts.insert(e); - actPos += descriptors_loop_length; - } - - parsed = 1; -} -#endif - /********************/ void SIsectionSDT::parseNVODreferenceDescriptor(const char *buf, SIservice &s) { diff --git a/src/eitd/SIsections.hpp b/src/eitd/SIsections.hpp index 4e67b3955..e857fb460 100644 --- a/src/eitd/SIsections.hpp +++ b/src/eitd/SIsections.hpp @@ -200,52 +200,6 @@ struct SI_section_header { unsigned last_section_number : 8; } __attribute__ ((packed)) ; // 8 bytes -#ifdef ENABLE_PPT -struct SI_section_PPT_header { // Premiere Private Table - unsigned table_id : 8; -#if __BYTE_ORDER == __BIG_ENDIAN - unsigned section_syntax_indicator : 1; - unsigned reserved_future_use : 1; - unsigned reserved1 : 2; - unsigned section_length_hi : 4; -#else - unsigned section_length_hi : 4; - unsigned reserved1 : 2; - unsigned reserved_future_use : 1; - unsigned section_syntax_indicator : 1; -#endif - unsigned section_length_lo : 8; - unsigned table_id_extension_hi : 8; - unsigned table_id_extension_lo : 8; -#if __BYTE_ORDER == __BIG_ENDIAN - unsigned reserved2 : 2; - unsigned version_number : 5; - unsigned current_next_indicator : 1; -#else - unsigned current_next_indicator : 1; - unsigned version_number : 5; - unsigned reserved2 : 2; -#endif - unsigned section_number : 8; - unsigned last_section_number : 8; - - unsigned content_id_32_25 : 8; - unsigned content_id_24_17 : 8; - unsigned content_id_16_9 : 8; - unsigned content_id_8_0 : 8; - unsigned duration_hi : 8; - unsigned duration_mid : 8; - unsigned duration_lo : 8; - unsigned reserved3 : 4; -#if __BYTE_ORDER == __BIG_ENDIAN - unsigned descriptor_section_length_hi : 4; - unsigned descriptor_section_length_lo : 8; -#else - unsigned descriptor_section_length_lo : 8; - unsigned descriptor_section_length_hi : 4; -#endif -} __attribute__ ((packed)) ; // 8 bytes -#endif class SIsection { @@ -508,106 +462,6 @@ protected: #endif }; -#ifdef ENABLE_PPT -class SIsectionPPT : public SIsection -{ -public: - SIsectionPPT(const SIsection &s) : SIsection(s) { - parsed = 0; - parse(); - } - - // Std-Copy - SIsectionPPT(const SIsectionPPT &s) : SIsection(s) { - evts = s.evts; - parsed = s.parsed; - } - - // Benutzt den uebergebenen Puffer (sollte mit new char[n] allokiert sein) - SIsectionPPT(unsigned bufLength, char *buf) : SIsection(bufLength, buf) { - parsed = 0; - parse(); - } - - long content_id(void) const { - return buffer ? ((((struct SI_section_PPT_header *)buffer)->content_id_32_25<< 24) | - (((struct SI_section_PPT_header *)buffer)->content_id_24_17<< 16) | - (((struct SI_section_PPT_header *)buffer)->content_id_16_9<< 8) | - ((struct SI_section_PPT_header *)buffer)->content_id_8_0): 0; - } - - long duration(void) const { - - if (!buffer) return(0); - - if (!((((struct SI_section_PPT_header *)buffer)->duration_hi == 0xff) && - (((struct SI_section_PPT_header *)buffer)->duration_mid == 0xff) && - (((struct SI_section_PPT_header *)buffer)->duration_lo == 0xff))) - return ((((struct SI_section_PPT_header *)buffer)->duration_hi)>>4)*10*3600L + ((((struct SI_section_PPT_header *)buffer)->duration_hi)&0x0f)*3600L + - ((((struct SI_section_PPT_header *)buffer)->duration_mid)>>4)*10*60L + ((((struct SI_section_PPT_header *)buffer)->duration_mid)&0x0f)*60L + - ((((struct SI_section_PPT_header *)buffer)->duration_lo)>>4)*10 + ((((struct SI_section_PPT_header *)buffer)->duration_lo)&0x0f); - return(0); - } - - short int descriptor_section_length(void) const { - return buffer ? ((((struct SI_section_PPT_header *)buffer)->descriptor_section_length_hi << 8) | - ((struct SI_section_PPT_header *)buffer)->descriptor_section_length_lo) : 0; - } - - struct SI_section_PPT_header const *header(void) const { - return (struct SI_section_PPT_header *)buffer; - } - - static void dump(const struct SI_section_PPT_header *header) { - if (!header) - return; - SIsection::dump1((const struct SI_section_header *)header); - printf("table_id_extension: 0x%02x%02x\n", header->table_id_extension_hi, header->table_id_extension_lo); - SIsection::dump1((const struct SI_section_header *)header); - printf("content id 0x%02x%02x%02x%02x\n", header->content_id_32_25, header->content_id_24_17, header->content_id_16_9, header->content_id_8_0); - printf("duration 0x%02x%02x%02x\n", header->duration_hi, header->duration_mid, header->duration_lo); - printf("reserved3 0x%02x\n", header->reserved3); - printf("descriptor section length 0x%02x%02x\n", header->descriptor_section_length_hi, header->descriptor_section_length_lo); - } - - static void dump(const SIsectionPPT &s) { - dump((struct SI_section_PPT_header *)s.buffer); - for_each(s.evts.begin(), s.evts.end(), printSIevent()); - } - - void dump(void) const { - dump((struct SI_section_PPT_header *)buffer); - for_each(evts.begin(), evts.end(), printSIevent()); - } - - const SIevents &events(void) const { - //if(!parsed) - // parse(); -> nicht const - return evts; - } - - int is_parsed(void) const { - return parsed; - } - -protected: - SIevents evts; - int parsed; - void parse(void); - void parseDescriptors(const char *desc, unsigned len, SIevent &e); - void parseShortEventDescriptor(const char *buf, SIevent &e, unsigned maxlen); - void parseExtendedEventDescriptor(const char *buf, SIevent &e, unsigned maxlen); - void parseContentDescriptor(const char *buf, SIevent &e, unsigned maxlen); - void parseComponentDescriptor(const char *buf, SIevent &e, unsigned maxlen); - void parseParentalRatingDescriptor(const char *buf, SIevent &e, unsigned maxlen); - void parseLinkageDescriptor(const char *buf, SIevent &e, unsigned maxlen); - - void parsePrivateContentOrderDescriptor(const char *buf, SIevent &e, unsigned maxlen); - void parsePrivateParentalInformationDescriptor(const char *buf, SIevent &e, unsigned maxlen); - void parsePrivateContentTransmissionDescriptor(const char *buf, SIevent &e, unsigned maxlen); - -}; -#endif class SIsectionSDT : public SIsection { diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index bd5741315..ef5809d25 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -165,11 +165,6 @@ static DMX dmxEIT(0x12, 3000 /*320*/); static DMX dmxFSEIT(3842, 320); #endif static DMX dmxCN(0x12, 512, false, 1); -#ifdef ENABLE_PPT -// Houdini: added for Premiere Private EPG section for Sport/Direkt Portal -static DMX dmxPPT(0x00, 256); -unsigned int privatePid=0; -#endif int sectionsd_stop = 0; static bool slow_addevent = true; @@ -828,48 +823,6 @@ static void addEvent(const SIevent &evt, const time_t zeit, bool cn = false) unlockEvents(); } -#ifdef ENABLE_PPT -// Fuegt zusaetzliche Zeiten in ein Event ein -static void addEventTimes(const SIevent &evt) -{ - if (evt.times.size()) - { - readLockEvents(); - // D.h. wir fuegen die Zeiten in das richtige Event ein - MySIeventsOrderUniqueKey::iterator e = mySIeventsOrderUniqueKey.find(evt.uniqueKey()); - - if (e != mySIeventsOrderUniqueKey.end()) - { - // Event vorhanden - // Falls das Event in den beiden Mengen mit Zeiten vorhanden ist, dieses dort loeschen - unlockEvents(); - writeLockEvents(); - if (e->second->times.size()) - { - mySIeventsOrderFirstEndTimeServiceIDEventUniqueKey.erase(e->second); - mySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey.erase(e->second); - //unlockEvents(); - } - - // Und die Zeiten im Event updaten - e->second->times.insert(evt.times.begin(), evt.times.end()); - - // Und das Event in die beiden Mengen mit Zeiten (wieder) einfuegen - mySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey.insert(e->second); - mySIeventsOrderFirstEndTimeServiceIDEventUniqueKey.insert(e->second); - unlockEvents(); -// printf("Updating: %04x times.size() = %d\n", (int) evt.uniqueKey(), e->second->times.size()); - } - else - { - unlockEvents(); - // Event nicht vorhanden -> einfuegen - addEvent(evt, 0); - } - } -} -#endif - static void addNVODevent(const SIevent &evt) { SIevent *eptr = new SIevent(evt); @@ -1175,9 +1128,6 @@ static void commandPauseScanning(int connfd, char *data, const unsigned dataLeng dmxEIT.request_pause(); #ifdef ENABLE_FREESATEPG dmxFSEIT.request_pause(); -#endif -#ifdef ENABLE_PPT - dmxPPT.request_pause(); #endif scanning = 0; } @@ -1187,9 +1137,6 @@ static void commandPauseScanning(int connfd, char *data, const unsigned dataLeng dmxEIT.request_unpause(); #ifdef ENABLE_FREESATEPG dmxFSEIT.request_unpause(); -#endif -#ifdef ENABLE_PPT - dmxPPT.request_unpause(); #endif writeLockEvents(); if (myCurrentEvent) { @@ -1695,9 +1642,6 @@ static void commandserviceChanged(int connfd, char *data, const unsigned dataLen channel_is_blacklisted = true; dmxCN.request_pause(); dmxEIT.request_pause(); -#ifdef ENABLE_PPT - dmxPPT.request_pause(); -#endif } xprintf("[sectionsd] commandserviceChanged: service is filtered!\n"); } @@ -1707,9 +1651,6 @@ static void commandserviceChanged(int connfd, char *data, const unsigned dataLen channel_is_blacklisted = false; dmxCN.request_unpause(); dmxEIT.request_unpause(); -#ifdef ENABLE_PPT - dmxPPT.request_unpause(); -#endif xprintf("[sectionsd] commandserviceChanged: service is no longer filtered!\n"); } } @@ -2587,32 +2528,6 @@ static void commandUnRegisterEventClient(int /*connfd*/, char *data, const unsig } -#ifdef ENABLE_PPT -static void commandSetPrivatePid(int connfd, char *data, const unsigned dataLength) -{ - unsigned short pid; - - if (dataLength != 2) - goto out; - - pid = *((unsigned short*)data); -// if (privatePid != pid) - { - privatePid = pid; - if (pid != 0) { - dprintf("[sectionsd] wakeup PPT Thread, pid=%x\n", pid); - dmxPPT.change( 0 ); - } - } - -out: - struct sectionsd::msgResponseHeader responseHeader; - responseHeader.dataLength = 0; - writeNbytes(connfd, (const char *)&responseHeader, sizeof(responseHeader), WRITE_TIMEOUT_IN_SECONDS); - return ; -} -#endif - static void commandSetConfig(int connfd, char *data, const unsigned /*dataLength*/) { struct sectionsd::msgResponseHeader responseHeader; @@ -3071,11 +2986,7 @@ static s_cmd_table connectionCommands[sectionsd::numberOfCommands] = { { commandLinkageDescriptorsUniqueKey, "commandLinkageDescriptorsUniqueKey" }, { commandRegisterEventClient, "commandRegisterEventClient" }, { commandUnRegisterEventClient, "commandUnRegisterEventClient" }, -#ifdef ENABLE_PPT - { commandSetPrivatePid, "commandSetPrivatePid" }, -#else { commandDummy2, "commandSetPrivatePid" }, -#endif { commandFreeMemory, "commandFreeMemory" }, { commandReadSIfromXML, "commandReadSIfromXML" }, { commandWriteSI2XML, "commandWriteSI2XML" }, @@ -4033,303 +3944,6 @@ static void *cnThread(void *) pthread_exit(NULL); } -#ifdef ENABLE_PPT - -//--------------------------------------------------------------------- -// Premiere Private EPG Thread -// reads EPG-datas -//--------------------------------------------------------------------- - -static void *pptThread(void *) -{ - struct SI_section_header *header; - unsigned timeoutInMSeconds = EIT_READ_TIMEOUT; - bool sendToSleepNow = false; - unsigned short start_section = 0; - unsigned short pptpid=0; - long first_content_id = 0; - long previous_content_id = 0; - long current_content_id = 0; - bool already_exists = false; - - // dmxPPT.addfilter( 0xa0, (0xff - 0x01) ); - dmxPPT.addfilter( 0xa0, (0xff)); - dprintf("[%sThread] pid %d (%lu) start\n", "ppt", getpid(), pthread_self()); - int timeoutsDMX = 0; - char *static_buf = new char[MAX_SECTION_LENGTH]; - int rc; - - if (static_buf == NULL) - throw std::bad_alloc(); - - time_t lastRestarted = time_monotonic(); - time_t lastData = time_monotonic(); - - dmxPPT.start(); // -> unlock - if (!scanning) - dmxPPT.request_pause(); - - waitForTimeset(); - dmxPPT.lastChanged = time_monotonic(); - - while (!sectionsd_stop) { - time_t zeit = time_monotonic(); - - if (timeoutsDMX >= CHECK_RESTART_DMX_AFTER_TIMEOUTS && scanning && !channel_is_blacklisted) - { - if (zeit > lastRestarted + 3) // last restart older than 3secs, therefore do NOT decrease cache - { - dmxPPT.stop(); // -> lock - dmxPPT.start(); // -> unlock - dprintf("[pptThread] dmxPPT restarted, cache NOT decreased (dt=%ld)\n", (int)zeit - lastRestarted); - } - else - { - - // sectionsd ist zu langsam, da zu viele events -> cache kleiner machen - dmxPPT.stop(); // -> lock - /* lockEvents(); - if(secondsToCache>24*60L*60L && mySIeventsOrderUniqueKey.size()>3000) - { - // kleiner als 1 Tag machen wir den Cache nicht, - // da die timeouts ja auch von einem Sender ohne EPG kommen koennen - // Die 3000 sind ne Annahme und beruhen auf (wenigen) Erfahrungswerten - // Man koennte auch ab 3000 Events nur noch jedes 3 Event o.ae. einsortieren - dmxSDT.real_pause(); - lockServices(); - unsigned anzEventsAlt=mySIeventsOrderUniqueKey.size(); - secondsToCache-=5*60L*60L; // 5h weniger - dprintf("[eitThread] decreasing cache 5h (now %ldh)\n", secondsToCache/(60*60L)); - removeNewEvents(); - removeOldEvents(oldEventsAre); - if(anzEventsAlt>mySIeventsOrderUniqueKey.size()) - dprintf("[eitThread] Removed %u Events (%u -> %u)\n", anzEventsAlt-mySIeventsOrderUniqueKey.size(), anzEventsAlt, mySIeventsOrderUniqueKey.size()); - unlockServices(); - dmxSDT.real_unpause(); - } - unlockEvents(); - */ - dmxPPT.start(); // -> unlock - // dputs("[pptThread] dmxPPT restarted"); - - } - - lastRestarted = zeit; - timeoutsDMX = 0; - lastData = zeit; - } - - if (sendToSleepNow || !scanning || channel_is_blacklisted) - { - sendToSleepNow = false; - - dmxPPT.real_pause(); - - int rs; - do { - pthread_mutex_lock( &dmxPPT.start_stop_mutex ); - - if (0 != privatePid) - { - struct timespec abs_wait; - struct timeval now; - - gettimeofday(&now, NULL); - TIMEVAL_TO_TIMESPEC(&now, &abs_wait); - abs_wait.tv_sec += (TIME_EIT_SCHEDULED_PAUSE); - dprintf("[pptThread] going to sleep for %d seconds...\n", TIME_EIT_SCHEDULED_PAUSE); - rs = pthread_cond_timedwait(&dmxPPT.change_cond, &dmxPPT.start_stop_mutex, &abs_wait); - } - else - { - dprintf("[pptThread] going to sleep until wakeup...\n"); - rs = pthread_cond_wait(&dmxPPT.change_cond, &dmxPPT.start_stop_mutex); - } - - pthread_mutex_unlock( &dmxPPT.start_stop_mutex ); - } while (channel_is_blacklisted); - - if (rs == ETIMEDOUT) - { - dprintf("dmxPPT: waking up again - looking for new events :)\n"); - if (0 != privatePid) - { - dmxPPT.change( 0 ); // -> restart - } - } - else if (rs == 0) - { - dprintf("dmxPPT: waking up again - requested from .change()\n"); - } - else - { - dprintf("dmxPPT: waking up again - unknown reason?!\n"); - dmxPPT.real_unpause(); - } - // after sleeping get current time - zeit = time_monotonic(); - start_section = 0; // fetch new? events - lastData = zeit; // restart timer - first_content_id = 0; - previous_content_id = 0; - current_content_id = 0; - } - - if (0 == privatePid) - { - sendToSleepNow = true; // if there is no valid pid -> sleep - dprintf("dmxPPT: no valid pid 0\n"); - sleep(1); - continue; - } - - if (!scanning) - continue; // go to sleep again... - - if (pptpid != privatePid) - { - pptpid = privatePid; - dprintf("Setting PrivatePid %x\n", pptpid); - dmxPPT.setPid(pptpid); - } - - rc = dmxPPT.getSection(static_buf, timeoutInMSeconds, timeoutsDMX); - - if (rc < 0) { - if (zeit > lastData + 5) - { - sendToSleepNow = true; // if there are no data for 5 seconds -> sleep - dprintf("dmxPPT: no data for 5 seconds\n"); - } - continue; - } - - if (rc < (int)sizeof(struct SI_section_header)) - { - xprintf("%s: ret < sizeof(SI_Section_header) (%d < %d)\n", __FUNCTION__, rc, sizeof(struct SI_section_header)); - continue; - } - - lastData = zeit; - - header = (SI_section_header*)static_buf; - unsigned short section_length = header->section_length_hi << 8 | header->section_length_lo; - - if (header->current_next_indicator) - { - // Wir wollen nur aktuelle sections - if (start_section == 0) - start_section = header->section_number; - else if (start_section == header->section_number) - { - sendToSleepNow = true; // no more scanning - dprintf("[pptThread] got all sections\n"); - continue; - } - - // SIsectionPPT ppt(SIsection(section_length + 3, buf)); - SIsectionPPT ppt(section_length + 3, static_buf); - if (ppt.is_parsed()) - if (ppt.header()) - { - // == 0 -> kein event - // dprintf("[pptThread] adding %d events [table 0x%x] (begin)\n", ppt.events().size(), header.table_id); - // dprintf("got %d: ", header.section_number); - zeit = time(NULL); - - // Hintereinander vorkommende sections mit gleicher contentID herausfinden - current_content_id = ppt.content_id(); - if (first_content_id == 0) - { - // aktuelle section ist die erste - already_exists = false; - first_content_id = current_content_id; - } - else if ((first_content_id == current_content_id) || (previous_content_id == current_content_id)) - { - // erste und aktuelle bzw. vorherige und aktuelle section sind gleich - already_exists = true; - } - else - { - // erste und aktuelle bzw. vorherige und aktuelle section sind nicht gleich - already_exists = false; - previous_content_id = current_content_id; - } - - // Nicht alle Events speichern - for (SIevents::iterator e = ppt.events().begin(); e != ppt.events().end(); e++) - { - if (!(e->times.empty())) - { - for (SItimes::iterator t = e->times.begin(); t != e->times.end(); t++) { - // if ( ( e->times.begin()->startzeit < zeit + secondsToCache ) && - // ( ( e->times.begin()->startzeit + (long)e->times.begin()->dauer ) > zeit - oldEventsAre ) ) - // add the event if at least one starttime matches - if ( ( t->startzeit < zeit + secondsToCache ) && - ( ( t->startzeit + (long)t->dauer ) > zeit - oldEventsAre ) ) - { - // dprintf("chId: " PRINTF_CHANNEL_ID_TYPE " Dauer: %ld, Startzeit: %s", e->get_channel_id(), (long)e->times.begin()->dauer, ctime(&e->times.begin()->startzeit)); - // writeLockEvents(); - - if (already_exists) - { - // Zusaetzliche Zeiten in ein Event einfuegen - addEventTimes(*e); - } - else - { - // Ein Event in alle Mengen einfuegen - addEvent(*e, zeit); - } - - // unlockEvents(); - break; // only add the event once - } -#if 0 - // why is the following not compiling, fuXX STL - else { - // remove unusable times in event - SItimes::iterator kt = t; - t--; // the iterator t points to the last element - e->times.erase(kt); - } -#endif - } - } - else - { - // pruefen ob nvod event - readLockServices(); - MySIservicesNVODorderUniqueKey::iterator si = mySIservicesNVODorderUniqueKey.find(e->get_channel_id()); - - if (si != mySIservicesNVODorderUniqueKey.end()) - { - // Ist ein nvod-event - writeLockEvents(); - - for (SInvodReferences::iterator i = si->second->nvods.begin(); i != si->second->nvods.end(); i++) - mySIeventUniqueKeysMetaOrderServiceUniqueKey.insert(std::make_pair(i->uniqueKey(), e->uniqueKey())); - - addNVODevent(*e); - unlockEvents(); - } - unlockServices(); - } - } // for - //dprintf("[pptThread] added %d events (end)\n", ppt.events().size()); - } // if - } // if - } // for - delete[] static_buf; - - dputs("[pptThread] end"); - - pthread_exit(NULL); -} - -#endif - /* helper function for the housekeeping-thread */ static void print_meminfo(void) { @@ -4493,9 +4107,6 @@ void sectionsd_main_thread(void */*data*/) pthread_t threadTOT, threadEIT, threadCN, threadHouseKeeping; #ifdef ENABLE_FREESATEPG pthread_t threadFSEIT; -#endif -#ifdef ENABLE_PPT - pthread_t threadPPT; #endif int rc; @@ -4589,16 +4200,6 @@ printf("SIevent size: %d\n", sizeof(SIevent)); } #endif -#ifdef ENABLE_PPT - // premiere private epg -Thread starten - rc = pthread_create(&threadPPT, 0, pptThread, 0); - - if (rc) { - fprintf(stderr, "[sectionsd] failed to create ppt-thread (rc=%d)\n", rc); - return; - } -#endif - // housekeeping-Thread starten rc = pthread_create(&threadHouseKeeping, 0, houseKeepingThread, 0); @@ -4663,17 +4264,9 @@ printf("SIevent size: %d\n", sizeof(SIevent)); pthread_mutex_lock(&dmxCN.start_stop_mutex); pthread_cond_broadcast(&dmxCN.change_cond); pthread_mutex_unlock(&dmxCN.start_stop_mutex); -#ifdef ENABLE_PPT - pthread_mutex_lock(&dmxPPT.start_stop_mutex); - pthread_cond_broadcast(&dmxPPT.change_cond); - pthread_mutex_unlock(&dmxPPT.start_stop_mutex); -#endif printf("pausing...\n"); dmxEIT.request_pause(); dmxCN.request_pause(); -#ifdef ENABLE_PPT - dmxPPT.request_pause(); -#endif #ifdef ENABLE_FREESATEPG dmxFSEIT.request_pause(); #endif @@ -4690,10 +4283,6 @@ printf("SIevent size: %d\n", sizeof(SIevent)); pthread_join(threadEIT, NULL); printf("join 3\n"); pthread_join(threadCN, NULL); -#ifdef ENABLE_PPT - printf("join 3\n"); - pthread_join(threadPPT, NULL); -#endif eit_stop_update_filter(&eit_update_fd); if(eitDmx) @@ -4705,9 +4294,6 @@ printf("SIevent size: %d\n", sizeof(SIevent)); dmxCN.close(); #ifdef ENABLE_FREESATEPG dmxFSEIT.close(); -#endif -#ifdef ENABLE_PPT - dmxPPT.close(); #endif printf("[sectionsd] ended\n"); @@ -5249,13 +4835,6 @@ bool sectionsd_getNVODTimesServiceKey(const t_channel_id uniqueServiceKey, CSect void sectionsd_setPrivatePid(unsigned short /*pid*/) { -#ifdef ENABLE_PPT - privatePid = pid; - if (pid != 0) { - dprintf("[sectionsd] wakeup PPT Thread, pid=%x\n", pid); - dmxPPT.change( 0 ); - } -#endif } void sectionsd_set_languages(const std::vector& newLanguages)