diff --git a/mythtv/libs/libmythtv/eithelper.cpp b/mythtv/libs/libmythtv/eithelper.cpp
index b982ecee26..339f13e218 100644
a
|
b
|
uint EITHelper::ProcessEvents(void) |
89 | 89 | if (!insertCount) |
90 | 90 | return 0; |
91 | 91 | |
92 | | if (!incomplete_events.empty() || !unmatched_etts.empty()) |
| 92 | if (!incomplete_events.empty()) |
93 | 93 | { |
94 | 94 | LOG(VB_EIT, LOG_INFO, |
95 | | LOC + QString("Added %1 events -- complete(%2) " |
96 | | "incomplete(%3) unmatched(%4)") |
| 95 | LOC + QString("Added %1 events -- complete: %2 incomplete: %3") |
97 | 96 | .arg(insertCount).arg(db_events.size()) |
98 | | .arg(incomplete_events.size()).arg(unmatched_etts.size())); |
| 97 | .arg(incomplete_events.size())); |
99 | 98 | } |
100 | 99 | else |
101 | 100 | { |
… |
… |
void EITHelper::AddEIT(uint atsc_major, uint atsc_minor, |
147 | 146 | { |
148 | 147 | uint atsc_key = (atsc_major << 16) | atsc_minor; |
149 | 148 | EventIDToATSCEvent &events = incomplete_events[atsc_key]; |
150 | | EventIDToETT &etts = unmatched_etts[atsc_key]; |
151 | 149 | |
152 | 150 | for (uint i = 0; i < eit->EventCount(); i++) |
153 | 151 | { |
… |
… |
void EITHelper::AddEIT(uint atsc_major, uint atsc_minor, |
156 | 154 | eit->title(i).GetBestMatch(languagePreferences), |
157 | 155 | eit->Descriptors(i), eit->DescriptorsLength(i)); |
158 | 156 | |
159 | | // Look to see if there has been a recent ett message with the same event id. |
160 | | EventIDToETT::iterator it = etts.find(eit->EventID(i)); |
161 | | QString ett_text; |
162 | | bool found_matching_ett = false; |
163 | | if (it != etts.end()) |
| 157 | // Create an event immediately if the ETM_location specifies |
| 158 | // that there is no ETT event coming; otherwise save the EIT |
| 159 | // event in the incomplete_events for this channel. |
| 160 | if (!ev.m_etm) |
164 | 161 | { |
165 | | // Don't use an ett description if it was scanned long in the past. |
166 | | if (!it->IsStale()) { |
167 | | ett_text = it->m_ett_text; |
168 | | found_matching_ett = true; |
169 | | } |
170 | | etts.erase(it); |
171 | | } |
172 | | |
173 | | // Create an event immediately if a matching ett description was found, |
174 | | // or if item is false, indicating that no ett description should be |
175 | | // expected. |
176 | | if (found_matching_ett || !ev.m_etm) |
177 | | { |
178 | | CompleteEvent(atsc_major, atsc_minor, ev, ett_text); |
| 162 | CompleteEvent(atsc_major, atsc_minor, ev, ""); |
179 | 163 | } |
180 | 164 | else |
181 | 165 | { |
| 166 | // If there is an existing EIT event with this event_id then |
| 167 | // delete the descriptor to avoid a memory leak. |
| 168 | EventIDToATSCEvent::iterator it = events.find(eit->EventID(i)); |
| 169 | if (it != events.end()) |
| 170 | { |
| 171 | delete [] (*it).m_desc; |
| 172 | } |
| 173 | |
| 174 | // Save the EIT event in the incomplete_events for this channel. |
182 | 175 | unsigned char *tmp = new unsigned char[ev.m_desc_length]; |
183 | 176 | memcpy(tmp, eit->Descriptors(i), ev.m_desc_length); |
184 | 177 | ev.m_desc = tmp; |
… |
… |
void EITHelper::AddEIT(uint atsc_major, uint atsc_minor, |
190 | 183 | void EITHelper::AddETT(uint atsc_major, uint atsc_minor, |
191 | 184 | const ExtendedTextTable *ett) |
192 | 185 | { |
| 186 | // Find the matching incomplete EIT event for this ETT |
| 187 | // If we have no EIT event then just discard the ETT. |
193 | 188 | uint atsc_key = (atsc_major << 16) | atsc_minor; |
194 | | // Try to match up the ett with an eit event. |
195 | 189 | ATSCSRCToEvents::iterator eits_it = incomplete_events.find(atsc_key); |
196 | 190 | if (eits_it != incomplete_events.end()) |
197 | 191 | { |
198 | 192 | EventIDToATSCEvent::iterator it = (*eits_it).find(ett->EventID()); |
199 | 193 | if (it != (*eits_it).end()) |
200 | 194 | { |
201 | | bool completed_event = false; |
202 | | // Only consider eit events from the recent past. |
| 195 | // Only consider EIT events from the very recent past. |
203 | 196 | if (!it->IsStale()) { |
204 | | completed_event = true; |
205 | 197 | CompleteEvent( |
206 | 198 | atsc_major, atsc_minor, *it, |
207 | 199 | ett->ExtendedTextMessage().GetBestMatch(languagePreferences)); |
208 | 200 | } |
209 | 201 | |
| 202 | // Remove EIT event from the incomplete_event list. |
210 | 203 | delete [] (*it).m_desc; |
211 | | |
212 | 204 | (*eits_it).erase(it); |
213 | | |
214 | | if (completed_event) return; |
215 | 205 | } |
216 | 206 | } |
217 | | |
218 | | // Report if an unmatched ett was previously noted and overwrite it. |
219 | | // See also https://code.mythtv.org/trac/ticket/11739 |
220 | | EventIDToETT &elist = unmatched_etts[atsc_key]; |
221 | | EventIDToETT::iterator existing_unmatched_ett_it = |
222 | | elist.find(ett->EventID()); |
223 | | const QString next_ett_text = ett->ExtendedTextMessage() |
224 | | .GetBestMatch(languagePreferences); |
225 | | if (existing_unmatched_ett_it != elist.end() && |
226 | | existing_unmatched_ett_it->m_ett_text != next_ett_text) |
227 | | { |
228 | | LOG(VB_EIT, LOG_DEBUG, LOC + |
229 | | QString("Overwriting previously unmatched ett. stale: %1 major: %2 " |
230 | | "minor: %3 old ett: %4 new ett: %5") |
231 | | .arg(existing_unmatched_ett_it->IsStale()) |
232 | | .arg(atsc_major) |
233 | | .arg(atsc_minor) |
234 | | .arg(existing_unmatched_ett_it->m_ett_text) |
235 | | .arg(next_ett_text)); |
236 | | } |
237 | | elist.insert(ett->EventID(), ATSCEtt(next_ett_text)); |
238 | 207 | } |
239 | 208 | |
240 | 209 | static void parse_dvb_event_descriptors(const desc_list_t& list, FixupValue fix, |
diff --git a/mythtv/libs/libmythtv/eithelper.h b/mythtv/libs/libmythtv/eithelper.h
index 283d0c0095..06c8cc5b90 100644
a
|
b
|
class ATSCEtt |
68 | 68 | time_t m_scan_time; |
69 | 69 | }; |
70 | 70 | |
71 | | |
72 | 71 | typedef QMap<uint,ATSCEvent> EventIDToATSCEvent; |
73 | 72 | typedef QMap<uint,ATSCEtt> EventIDToETT; |
74 | 73 | typedef QMap<uint,EventIDToATSCEvent> ATSCSRCToEvents; |
75 | | typedef QMap<uint,EventIDToETT> ATSCSRCToETTs; |
76 | 74 | typedef QMap<unsigned long long,uint> ServiceToChanID; |
77 | 75 | |
78 | 76 | typedef uint64_t FixupKey; |
… |
… |
class EITHelper |
154 | 152 | |
155 | 153 | FixupMap fixup; |
156 | 154 | ATSCSRCToEvents incomplete_events; |
157 | | ATSCSRCToETTs unmatched_etts; |
158 | 155 | |
159 | 156 | MythDeque<DBEventEIT*> db_events; |
160 | 157 | |