Ticket #2416: eitmapping.diff

File eitmapping.diff, 3.8 KB (added by mythtv@…, 6 years ago)
  • libs/libmythtv/eithelper.cpp

     
    2121                                uint atscmajor, uint atscminor); 
    2222static uint get_chan_id_from_db(uint sourceid,  uint serviceid, 
    2323                                uint networkid, uint transportid); 
     24static uint get_mapped_chan_id_from_db(uint serviceid); 
    2425static void init_fixup(QMap<uint64_t,uint> &fix); 
    2526static int calc_eit_utc_offset(void); 
    2627 
     
    343344                                     false,     subtitled, 
    344345                                     stereo,    hdtv); 
    345346        db_events.enqueue(event); 
     347         
     348        uint mapped_chanid = GetMappedChanID(serviceid); 
     349         
     350        if (mapped_chanid > 0) 
     351        { 
     352            DBEvent *event = new DBEvent(mapped_chanid, 
     353                                         title,     subtitle,      description, 
     354                                         category,  category_type, 
     355                                         starttime, endtime,       fix, 
     356                                         false,     subtitled, 
     357                                         stereo,    hdtv); 
     358            db_events.enqueue(event); 
     359        } 
    346360    } 
    347361} 
    348362 
     
    414428 
    415429    uint chanid = get_chan_id_from_db(sourceid, serviceid, networkid, tsid); 
    416430    if (chanid) 
     431    { 
    417432        srv_to_chanid[key] = chanid; 
     433         
     434        uint mapped_chanid = get_mapped_chan_id_from_db(serviceid); 
     435        if(mapped_chanid) 
     436            serviceid_to_mapped_chanid[serviceid] = mapped_chanid; 
     437    } 
    418438 
    419439    return chanid; 
    420440} 
    421441 
     442uint EITHelper::GetMappedChanID(uint serviceid) 
     443{ 
     444    ServiceIDToMappedChanID::const_iterator it = serviceid_to_mapped_chanid.find(serviceid); 
     445    if (it != serviceid_to_mapped_chanid.end()) 
     446        return max(*it, 0); 
     447    return 0; 
     448}  
     449 
    422450static uint get_chan_id_from_db(uint sourceid, 
    423451                                uint atsc_major, uint atsc_minor) 
    424452{ 
     
    482510    return 0; 
    483511} 
    484512 
     513static uint get_mapped_chan_id_from_db(uint serviceid) 
     514{ 
     515    MSqlQuery query(MSqlQuery::InitCon()); 
     516 
     517    QString qstr = 
     518        "SELECT mapped_chanid " 
     519        "FROM eit_mapping " 
     520        "WHERE serviceid = :SERVICEID"; 
     521     
     522    query.prepare(qstr); 
     523    query.bindValue(":SERVICEID", serviceid); 
     524    if (!query.exec() || !query.isActive()) 
     525        MythContext::DBError("Looking up mapped chanID", query); 
     526     
     527    if (query.next()) 
     528    { 
     529        return query.value(0).toUInt(); 
     530    } 
     531     
     532    return 0; 
     533} 
     534 
    485535static void init_fixup(QMap<uint64_t,uint> &fix) 
    486536{ 
    487537    // transport_id<<32 | netword_id<<16 | service_id 
  • libs/libmythtv/eithelper.h

     
    3939typedef QMap<uint,EventIDToATSCEvent>      ATSCSRCToEvents; 
    4040typedef QMap<uint,EventIDToETT>            ATSCSRCToETTs; 
    4141typedef QMap<unsigned long long,int>       ServiceToChanID; 
     42typedef QMap<int,int>                      ServiceIDToMappedChanID; 
    4243 
    4344class DBEvent; 
    4445class EITFixUp; 
     
    8182  private: 
    8283    uint GetChanID(uint atsc_major, uint atsc_minor); 
    8384    uint GetChanID(uint serviceid, uint networkid, uint transportid); 
     85    uint GetMappedChanID(uint serviceid); 
    8486 
    8587    void CompleteEvent(uint atsc_major, uint atsc_minor, 
    8688                       const ATSCEvent &event, 
     
    8991        //QListList_Events  eitList;      ///< Event Information Tables List 
    9092    mutable QMutex    eitList_lock; ///< EIT List lock 
    9193    mutable ServiceToChanID srv_to_chanid; 
     94    mutable ServiceIDToMappedChanID serviceid_to_mapped_chanid; 
    9295 
    9396    EITFixUp               *eitfixup; 
    9497    EITCache               *eitcache;