]>
Commit | Line | Data |
---|---|---|
b91fb912 | 1 | Index: libs/libmythtv/siparser.cpp |
2 | =================================================================== | |
3 | --- libs/libmythtv/siparser.cpp.orig 2006-06-20 17:36:06.000000000 -0400 | |
4 | +++ libs/libmythtv/siparser.cpp 2006-06-20 17:37:17.000000000 -0400 | |
5 | @@ -80,6 +80,8 @@ | |
6 | ||
7 | Reset(); | |
8 | ||
9 | + FillEITMaps(); | |
10 | + | |
11 | // Get a list of wanted languages and set up their priorities | |
12 | // (Lowest number wins) | |
13 | QStringList langPref = iso639_get_language_list(); | |
14 | @@ -145,6 +147,60 @@ | |
15 | VERBOSE(VB_SIPARSER, LOC + "SIParser Reset due to channel change"); | |
16 | } | |
17 | ||
18 | +// Fill in our maps of channels/serviceID's we actually want EIT data for | |
19 | +void SIParser::FillEITMaps(void) | |
20 | +{ | |
21 | + MSqlQuery query(MSqlQuery::InitCon()); | |
22 | + | |
23 | + //TODO: Clean this.. maybe a couple defines? | |
24 | + // Should this be sourceid specific? | |
25 | + VERBOSE(VB_GENERAL, LOC + "FillEITMaps()"); | |
26 | + query.prepare("SELECT atscsrcid, mplexid, chanid FROM channel " | |
27 | + "WHERE useonairguide = 1"); | |
28 | + | |
29 | + if (!query.exec() || !query.isActive()) | |
30 | + MythContext::DBError("FillMaps ATSC ", query); | |
31 | + | |
32 | + while (query.next()) | |
33 | + { | |
34 | + int ServiceID = query.value(0).toInt(); | |
35 | + int mplexid = query.value(1).toInt(); | |
36 | + | |
37 | + eitATSCMap[mplexid][ServiceID] = query.value(2).toInt(); | |
38 | + } | |
39 | + | |
40 | + query.prepare("SELECT serviceid,networkid,transportid,chanid " | |
41 | + "FROM dtv_multiplex,channel WHERE " | |
42 | + "useonairguide = 1 AND " | |
43 | + "channel.mplexid = dtv_multiplex.mplexid;"); | |
44 | + | |
45 | + if (!query.exec() || !query.isActive()) | |
46 | + MythContext::DBError("FillMaps DVB ", query); | |
47 | + | |
48 | + // Check to see if we are interseted in this channel | |
49 | + while (query.next()) | |
50 | + { | |
51 | + int ServiceID = query.value(0).toInt(); | |
52 | + int NetworkID = query.value(1).toInt(); | |
53 | + int TransportID = query.value(2).toInt(); | |
54 | + | |
55 | + eitDVBMap[TransportID][NetworkID][ServiceID] = query.value(3).toInt(); | |
56 | + } | |
57 | +} | |
58 | + | |
59 | +/* Return true if we want EIT data for this channel, otherwise false */ | |
60 | +bool SIParser::WantEIT(Event *e) | |
61 | +{ | |
62 | + | |
63 | +// TODO: premap fill in a mplexid map for use here | |
64 | +// if (e.ATSC) | |
65 | +// { | |
66 | +// return (eitATSCMap[mplexid][e.ServiceID] > 0) | |
67 | +// } | |
68 | +// else | |
69 | + return (eitDVBMap[e->TransportID][e->NetworkID][e->ServiceID] > 0); | |
70 | +} | |
71 | + | |
72 | void SIParser::CheckTrackers() | |
73 | { | |
74 | ||
75 | @@ -1439,82 +1495,98 @@ | |
76 | { | |
77 | // Event to use temporarily to fill in data | |
78 | Event event; | |
79 | + event.TableID = head->table_id; | |
80 | event.ServiceID = head->table_id_ext; | |
81 | event.TransportID = buffer[0] << 8 | buffer[1]; | |
82 | event.NetworkID = buffer[2] << 8 | buffer[3]; | |
83 | event.EventID = buffer[pos] << 8 | buffer[pos+1]; | |
84 | - event.StartTime = ConvertDVBDate(&buffer[pos+2]); | |
85 | ||
86 | - uint lenInSeconds = ((bcdtoint(buffer[pos+7] & 0xFF) * 3600) + | |
87 | - (bcdtoint(buffer[pos+8] & 0xFF) * 60) + | |
88 | - (bcdtoint(buffer[pos+9] & 0xFF))); | |
89 | + if (WantEIT(&event) && | |
90 | + !(eitEventMap[head->table_id_ext][event.EventID] == event.EventID)) | |
91 | + { | |
92 | + VERBOSE(VB_EIT, QString(" WantEIT : %1 Event %2 ") | |
93 | + .arg(event.ServiceID).arg(event.EventID)); | |
94 | ||
95 | - event.EndTime = event.StartTime.addSecs(lenInSeconds); | |
96 | ||
97 | -#ifdef EIT_DEBUG_SID | |
98 | - if (event.ServiceID == EIT_DEBUG_SID) | |
99 | - { | |
100 | - VERBOSE(VB_EIT, "SIParser: DVB Events: " + | |
101 | - QString("ServiceID %1 EventID: %2 Time: %3 - %4") | |
102 | - .arg(event.ServiceID).arg(event.EventID) | |
103 | - .arg(event.StartTime.toString(QString("MM/dd hh:mm"))) | |
104 | - .arg(event.EndTime.toString(QString("hh:mm")))); | |
105 | - } | |
106 | -#endif | |
107 | + event.StartTime = ConvertDVBDate(&buffer[pos+2]); | |
108 | ||
109 | - // Hold short & extended event information from descriptors. | |
110 | - const unsigned char *bestDescriptorSE = NULL; | |
111 | - vector<const unsigned char*> bestDescriptorsEE; | |
112 | - | |
113 | - // Parse descriptors | |
114 | - descriptors_length = ((buffer[pos+10] & 0x0F) << 8) | buffer[pos+11]; | |
115 | - pos += 12; | |
116 | - des_pos = pos; | |
117 | + uint lenInSeconds = ((bcdtoint(buffer[pos+7] & 0xFF) * 3600) + | |
118 | + (bcdtoint(buffer[pos+8] & 0xFF) * 60) + | |
119 | + (bcdtoint(buffer[pos+9] & 0xFF))); | |
120 | ||
121 | - // Pick out EIT descriptors for later parsing, and parse others. | |
122 | - while ((des_pos < (pos + descriptors_length)) && (des_pos <= size)) | |
123 | - { | |
124 | - des_pos += ProcessDVBEventDescriptors( | |
125 | - pid, | |
126 | - &buffer[des_pos], | |
127 | - bestPrioritySE, bestDescriptorSE, | |
128 | - bestPriorityEE, bestDescriptorsEE, event); | |
129 | - } | |
130 | + event.EndTime = event.StartTime.addSecs(lenInSeconds); | |
131 | ||
132 | - // Parse extended event descriptions for the most preferred language | |
133 | - for (uint i = 0; i < bestDescriptorsEE.size(); ++i) | |
134 | - { | |
135 | - if (!bestDescriptorsEE[i]) | |
136 | - continue; | |
137 | +#ifdef EIT_DEBUG_SID | |
138 | + if (event.ServiceID == EIT_DEBUG_SID) | |
139 | + { | |
140 | + VERBOSE(VB_EIT, "SIParser: DVB Events: " + | |
141 | + QString("ServiceID %1 EventID: %2 Time: %3 - %4") | |
142 | + .arg(event.ServiceID).arg(event.EventID) | |
143 | + .arg(event.StartTime.toString(QString("MM/dd hh:mm"))) | |
144 | + .arg(event.EndTime.toString(QString("hh:mm")))); | |
145 | + } | |
146 | +#endif | |
147 | ||
148 | - uint8_t *desc = (uint8_t*) bestDescriptorsEE[i]; | |
149 | - uint descLen = desc[1]; | |
150 | - ProcessExtendedEventDescriptor(desc, descLen + 2, event); | |
151 | - } | |
152 | + // Hold short & extended event information from descriptors. | |
153 | + const unsigned char *bestDescriptorSE = NULL; | |
154 | + vector<const unsigned char*> bestDescriptorsEE; | |
155 | + | |
156 | + // Parse descriptors | |
157 | + descriptors_length = ((buffer[pos+10] & 0x0F) << 8) | buffer[pos+11]; | |
158 | + pos += 12; | |
159 | + des_pos = pos; | |
160 | + | |
161 | + // Pick out EIT descriptors for later parsing, and parse others. | |
162 | + while ((des_pos < (pos + descriptors_length)) && (des_pos <= size)) | |
163 | + { | |
164 | + des_pos += ProcessDVBEventDescriptors( | |
165 | + pid, | |
166 | + &buffer[des_pos], | |
167 | + bestPrioritySE, bestDescriptorSE, | |
168 | + bestPriorityEE, bestDescriptorsEE, event); | |
169 | + } | |
170 | ||
171 | - // Parse short event descriptor for the most preferred language | |
172 | - if (bestDescriptorSE) | |
173 | - { | |
174 | - uint8_t *desc = (uint8_t*) bestDescriptorSE; | |
175 | - uint descLen = desc[1]; | |
176 | - ProcessShortEventDescriptor(desc, descLen + 2, event); | |
177 | - } | |
178 | + // Parse extended event descriptions for the most preferred language | |
179 | + for (uint i = 0; i < bestDescriptorsEE.size(); ++i) | |
180 | + { | |
181 | + if (!bestDescriptorsEE[i]) | |
182 | + continue; | |
183 | ||
184 | - EITFixUp(event); | |
185 | + uint8_t *desc = (uint8_t*) bestDescriptorsEE[i]; | |
186 | + uint descLen = desc[1]; | |
187 | + ProcessExtendedEventDescriptor(desc, descLen + 2, event); | |
188 | + } | |
189 | + | |
190 | + // Parse short event descriptor for the most preferred language | |
191 | + if (bestDescriptorSE) | |
192 | + { | |
193 | + uint8_t *desc = (uint8_t*) bestDescriptorSE; | |
194 | + uint descLen = desc[1]; | |
195 | + ProcessShortEventDescriptor(desc, descLen + 2, event); | |
196 | + } | |
197 | + | |
198 | + EITFixUp(event); | |
199 | ||
200 | #ifdef EIT_DEBUG_SID | |
201 | - if (event.ServiceID == EIT_DEBUG_SID) | |
202 | - { | |
203 | - VERBOSE(VB_EIT, "SIParser: DVB Events: " + | |
204 | - QString("LanguageCode='%1' " | |
205 | - "\n\t\t\tEvent_Name='%2' Description='%3'") | |
206 | - .arg(event.LanguageCode).arg(event.Event_Name) | |
207 | - .arg(event.Description)); | |
208 | - } | |
209 | + if (event.ServiceID == EIT_DEBUG_SID) | |
210 | + { | |
211 | + VERBOSE(VB_EIT, "SIParser: DVB Events: " + | |
212 | + QString("LanguageCode='%1' " | |
213 | + "\n\t\t\tEvent_Name='%2' Description='%3'") | |
214 | + .arg(event.LanguageCode).arg(event.Event_Name) | |
215 | + .arg(event.Description)); | |
216 | + } | |
217 | #endif | |
218 | ||
219 | - QMap2D_Events &events = ((EventHandler*) Table[EVENTS])->Events; | |
220 | - events[head->table_id_ext][event.EventID] = event; | |
221 | + QMap2D_Events &events = ((EventHandler*) Table[EVENTS])->Events; | |
222 | + events[head->table_id_ext][event.EventID] = event; | |
223 | + | |
224 | + } // WantEIT | |
225 | + else | |
226 | + { | |
227 | + descriptors_length = ((buffer[pos+10] & 0x0F) << 8) | buffer[pos+11]; | |
228 | + pos += 12; | |
229 | + } | |
230 | pos += descriptors_length; | |
231 | } | |
232 | } | |
233 | Index: libs/libmythtv/sitypes.h | |
234 | =================================================================== | |
235 | --- libs/libmythtv/sitypes.h.orig 2006-06-20 17:31:10.000000000 -0400 | |
236 | +++ libs/libmythtv/sitypes.h 2006-06-20 17:36:06.000000000 -0400 | |
237 | @@ -78,6 +78,10 @@ | |
238 | typedef QMap<uint16_t,QMap_Events> QMap2D_Events; | |
239 | typedef QMap<uint16_t,pidHandler> QMap_pidHandler; | |
240 | ||
241 | +typedef QMap<uint16_t,int> QMap_intObject; | |
242 | +typedef QMap<uint16_t,QMap_intObject> QMap2D_intObject; | |
243 | +typedef QMap<uint16_t,QMap2D_intObject> QMap3D_intObject; | |
244 | + | |
245 | class pidHandler | |
246 | { | |
247 | public: | |
248 | @@ -350,6 +354,7 @@ | |
249 | uint SourcePID; | |
250 | uint TransportID; | |
251 | uint NetworkID; | |
252 | + uint TableID; | |
253 | uint ServiceID; ///< NOT the Virtual Channel Number used by ATSC | |
254 | uint EventID; | |
255 | bool Stereo; | |
256 | Index: libs/libmythtv/siparser.h | |
257 | =================================================================== | |
258 | --- libs/libmythtv/siparser.h.orig 2006-06-20 17:31:10.000000000 -0400 | |
259 | +++ libs/libmythtv/siparser.h 2006-06-20 17:37:17.000000000 -0400 | |
260 | @@ -87,6 +87,11 @@ | |
261 | ||
262 | bool ReinitSIParser(const QString &si_std, uint service_id); | |
263 | ||
264 | + // Functions to prepare and use a map of serviceid/transports we | |
265 | + // want EIT data from | |
266 | + void FillEITMaps(void); | |
267 | + bool WantEIT(Event *e); | |
268 | + | |
269 | // Stops all collection of data and clears all values (on a channel change for example) | |
270 | void Reset(void); | |
271 | ||
272 | @@ -279,6 +284,13 @@ | |
273 | // statistics | |
274 | QMap<uint,uint> descCount; | |
275 | mutable QMutex descLock; | |
276 | + | |
277 | + // EIT Service Maps | |
278 | + QMap2D_intObject eitATSCMap; | |
279 | + QMap3D_intObject eitDVBMap; | |
280 | + | |
281 | + // Previously Seen EIT event Maps | |
282 | + QMap2D_intObject eitEventMap; | |
283 | }; | |
284 | ||
285 | #endif // SIPARSER_H |