Ticket #13455: 20190919-atsc-eit-ett-13455-v0.patch

File 20190919-atsc-eit-ett-13455-v0.patch, 6.1 KB (added by Klaas de Waal, 5 years ago)

Remove ETT caching; process ETT event only after the corresponding EIT event has been received.

  • mythtv/libs/libmythtv/eithelper.cpp

    diff --git a/mythtv/libs/libmythtv/eithelper.cpp b/mythtv/libs/libmythtv/eithelper.cpp
    index b982ecee26..339f13e218 100644
    a b uint EITHelper::ProcessEvents(void) 
    8989    if (!insertCount)
    9090        return 0;
    9191
    92     if (!incomplete_events.empty() || !unmatched_etts.empty())
     92    if (!incomplete_events.empty())
    9393    {
    9494        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")
    9796                .arg(insertCount).arg(db_events.size())
    98                 .arg(incomplete_events.size()).arg(unmatched_etts.size()));
     97                .arg(incomplete_events.size()));
    9998    }
    10099    else
    101100    {
    void EITHelper::AddEIT(uint atsc_major, uint atsc_minor, 
    147146{
    148147    uint atsc_key = (atsc_major << 16) | atsc_minor;
    149148    EventIDToATSCEvent &events = incomplete_events[atsc_key];
    150     EventIDToETT &etts = unmatched_etts[atsc_key];
    151149
    152150    for (uint i = 0; i < eit->EventCount(); i++)
    153151    {
    void EITHelper::AddEIT(uint atsc_major, uint atsc_minor, 
    156154                     eit->title(i).GetBestMatch(languagePreferences),
    157155                     eit->Descriptors(i), eit->DescriptorsLength(i));
    158156
    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)
    164161        {
    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, "");
    179163        }
    180164        else
    181165        {
     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.
    182175            unsigned char *tmp = new unsigned char[ev.m_desc_length];
    183176            memcpy(tmp, eit->Descriptors(i), ev.m_desc_length);
    184177            ev.m_desc = tmp;
    void EITHelper::AddEIT(uint atsc_major, uint atsc_minor, 
    190183void EITHelper::AddETT(uint atsc_major, uint atsc_minor,
    191184                       const ExtendedTextTable *ett)
    192185{
     186    // Find the matching incomplete EIT event for this ETT
     187    // If we have no EIT event then just discard the ETT.
    193188    uint atsc_key = (atsc_major << 16) | atsc_minor;
    194     // Try to match up the ett with an eit event.
    195189    ATSCSRCToEvents::iterator eits_it = incomplete_events.find(atsc_key);
    196190    if (eits_it != incomplete_events.end())
    197191    {
    198192        EventIDToATSCEvent::iterator it = (*eits_it).find(ett->EventID());
    199193        if (it != (*eits_it).end())
    200194        {
    201             bool completed_event = false;
    202             // Only consider eit events from the recent past.
     195            // Only consider EIT events from the very recent past.
    203196            if (!it->IsStale()) {
    204               completed_event = true;
    205197              CompleteEvent(
    206198                  atsc_major, atsc_minor, *it,
    207199                  ett->ExtendedTextMessage().GetBestMatch(languagePreferences));
    208200            }
    209201
     202            // Remove EIT event from the incomplete_event list.
    210203            delete [] (*it).m_desc;
    211 
    212204            (*eits_it).erase(it);
    213 
    214             if (completed_event) return;
    215205        }
    216206    }
    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));
    238207}
    239208
    240209static void parse_dvb_event_descriptors(const desc_list_t& list, FixupValue fix,
  • mythtv/libs/libmythtv/eithelper.h

    diff --git a/mythtv/libs/libmythtv/eithelper.h b/mythtv/libs/libmythtv/eithelper.h
    index 283d0c0095..06c8cc5b90 100644
    a b class ATSCEtt 
    6868    time_t m_scan_time;
    6969};
    7070
    71 
    7271typedef QMap<uint,ATSCEvent>               EventIDToATSCEvent;
    7372typedef QMap<uint,ATSCEtt>                 EventIDToETT;
    7473typedef QMap<uint,EventIDToATSCEvent>      ATSCSRCToEvents;
    75 typedef QMap<uint,EventIDToETT>            ATSCSRCToETTs;
    7674typedef QMap<unsigned long long,uint>      ServiceToChanID;
    7775
    7876typedef uint64_t                           FixupKey;
    class EITHelper 
    154152
    155153    FixupMap fixup;
    156154    ATSCSRCToEvents         incomplete_events;
    157     ATSCSRCToETTs           unmatched_etts;
    158155
    159156    MythDeque<DBEventEIT*>     db_events;
    160157