1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#include <lib/service/event.h>
#include <lib/base/estring.h>
#include <lib/dvb/dvbtime.h>
#include <dvbsi++/event_information_section.h>
#include <dvbsi++/short_event_descriptor.h>
#include <dvbsi++/extended_event_descriptor.h>
#include <dvbsi++/descriptor_tag.h>
DEFINE_REF(eServiceEvent);
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)
{
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;
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;
}
DEFINE_REF(eDebugClass);
|