From: Andreas Monzner Date: Wed, 9 Nov 2005 16:54:59 +0000 (+0000) Subject: start_time is now valid in eServiceEvent, X-Git-Tag: 2.6.0~5396 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/26b93e5ee373462211802fe859bd6a6d9dc083a5 start_time is now valid in eServiceEvent, rename and add new members ( m_short_description, m_extended_description ) add ability to filter short/extended events (language code) --- diff --git a/lib/service/event.cpp b/lib/service/event.cpp index 96cc042b..45a27879 100644 --- a/lib/service/event.cpp +++ b/lib/service/event.cpp @@ -1,29 +1,115 @@ #include #include +#include #include #include +#include #include DEFINE_REF(eServiceEvent); -RESULT eServiceEvent::parseFrom(Event *evt) +const char MAX_LANG = 37; +/* OSD language (see /share/locales/locales) to iso639 conversion table */ +std::string ISOtbl[MAX_LANG][2] = +{ + {"ar_AE","ara"}, + {"C","eng"}, + {"cs_CZ","ces"}, /* or 'cze' */ + {"cs_CZ","cze"}, + {"da_DK","dan"}, + {"de_DE","deu"}, /* also 'ger' is valid iso639 code!! */ + {"de_DE","ger"}, + {"el_GR","gre"}, /* also 'ell' is valid */ + {"el_GR","ell"}, + {"es_ES","esl"}, /* also 'spa' is ok */ + {"es_ES","spa"}, + {"et_EE","est"}, + {"fi_FI","fin"}, + {"fr_FR","fra"}, + {"hr_HR","hrv"}, /* or 'scr' */ + {"hr_HR","scr"}, + {"hu_HU","hun"}, + {"is_IS","isl"}, /* or 'ice' */ + {"is_IS","ice"}, + {"it_IT","ita"}, + {"lt_LT","lit"}, + {"nl_NL","nld"}, /* or 'dut' */ + {"nl_NL","dut"}, + {"no_NO","nor"}, + {"pl_PL","pol"}, + {"pt_PT","por"}, + {"ro_RO","ron"}, /* or 'rum' */ + {"ro_RO","rum"}, + {"ru_RU","rus"}, + {"sk_SK","slk"}, /* or 'slo' */ + {"sk_SK","slo"}, + {"sl_SI","slv"}, + {"sr_YU","srp"}, /* or 'scc' */ + {"sr_YU","scc"}, + {"sv_SE","swe"}, + {"tr_TR","tur"}, + {"ur_IN","urd"} +}; + +/* search for the presence of language from given EIT event descriptors*/ +bool eServiceEvent::language_exists(Event *evt, std::string lang) { - m_begin = 0; // ich bin FAUL - m_duration = (evt->getDuration() & 0xFF) + ((evt->getDuration() >> 8) & 0xFF) * 60 + ((evt->getDuration() >> 16) & 0xFF) * 24 * 60; - + bool retval=0; for (DescriptorConstIterator desc = evt->getDescriptors()->begin(); desc != evt->getDescriptors()->end(); ++desc) { switch ((*desc)->getTag()) { - case SHORT_EVENT_DESCRIPTOR: - { - const ShortEventDescriptor *sed = (ShortEventDescriptor*)*desc; - m_event_name = convertDVBUTF8(sed->getEventName()); - m_description = convertDVBUTF8(sed->getText()); - break; - } + case SHORT_EVENT_DESCRIPTOR: + { + const ShortEventDescriptor *sed = (ShortEventDescriptor*)*desc; + if (lang.empty() || sed->getIso639LanguageCode() == lang) + { + m_event_name = convertDVBUTF8(sed->getEventName()); + m_short_description = convertDVBUTF8(sed->getText()); + retval=1; + } + break; + } + case EXTENDED_EVENT_DESCRIPTOR: + { + const ExtendedEventDescriptor *eed = (ExtendedEventDescriptor*)*desc; + if (lang.empty() || eed->getIso639LanguageCode() == lang) + { + m_extended_description += convertDVBUTF8(eed->getText()); + retval=1; + } + // TODO handling for extended event items? ( producer... ) + break; + } + default: + break; } } + return retval; +} + +RESULT eServiceEvent::parseFrom(Event *evt) +{ + uint16_t stime_mjd = evt->getStartTimeMjd(); + uint32_t stime_bcd = evt->getStartTimeBcd(); + uint16_t duration = evt->getDuration(); + m_begin = parseDVBtime( + stime_mjd >> 8, + stime_mjd&0xFF, + stime_bcd >> 16, + (stime_bcd >> 8)&0xFF, + stime_bcd & 0xFF + ); + m_duration = ((duration & 0xFF) + (duration >> 8) & 0xFF) * 24 * 60; + std::string country="de_DE"; // TODO use local data here + for (int i=0; i < MAX_LANG; i++) + if (country==ISOtbl[i][0]) + if (language_exists(evt,ISOtbl[i][1])) + return 0; + if (language_exists(evt,"eng")) + return 0; + if (language_exists(evt,std::string())) + return 0; return 0; } diff --git a/lib/service/event.h b/lib/service/event.h index 99ce5b24..57e5b821 100644 --- a/lib/service/event.h +++ b/lib/service/event.h @@ -12,9 +12,10 @@ DECLARE_REF(eServiceEvent); public: time_t m_begin; int m_duration; - std::string m_event_name, m_description; + std::string m_event_name, m_short_description, m_extended_description; // .. additional info - + + bool language_exists(Event *event, std::string lang); RESULT parseFrom(Event *evt); };