Ticket #2416: eitmapping_21_fixes.diff

File eitmapping_21_fixes.diff, 3.9 KB (added by Wolfgang <mythtv@…>, 16 years ago)

Patch against 21-fixes

  • libs/libmythtv/eithelper.cpp

     
    3131                                uint atscmajor, uint atscminor);
    3232static uint get_chan_id_from_db(uint sourceid,  uint serviceid,
    3333                                uint networkid, uint transportid);
     34static uint get_mapped_chan_id_from_db(uint serviceid);
    3435static void init_fixup(QMap<uint64_t,uint> &fix);
    3536static int calc_eit_utc_offset(void);
    3637
     
    405406                                     video_props,
    406407                                     seriesId,  programId);
    407408        db_events.enqueue(event);
     409       
     410        uint mapped_chanid = GetMappedChanID(eit->ServiceID());
     411       
     412        if (mapped_chanid > 0)
     413        {
     414            DBEvent *event = new DBEvent(mapped_chanid,
     415                                         title,     subtitle,      description,
     416                                         category,  category_type,
     417                                         starttime, endtime,       fix,
     418                                         subtitle_type,
     419                                         audio_props,
     420                                         video_props,
     421                                         seriesId,  programId);
     422            db_events.enqueue(event);
     423        }
    408424    }
    409425}
    410426
     
    603619
    604620    uint chanid = get_chan_id_from_db(sourceid, serviceid, networkid, tsid);
    605621    if (chanid)
     622    {
    606623        srv_to_chanid[key] = chanid;
     624       
     625        uint mapped_chanid = get_mapped_chan_id_from_db(serviceid);
     626        if(mapped_chanid)
     627            serviceid_to_mapped_chanid[serviceid] = mapped_chanid;
     628    }
    607629
    608630    return chanid;
    609631}
    610632
     633uint EITHelper::GetMappedChanID(uint serviceid)
     634{
     635    ServiceIDToMappedChanID::const_iterator it = serviceid_to_mapped_chanid.find(serviceid);
     636    if (it != serviceid_to_mapped_chanid.end())
     637        return max(*it, 0);
     638    return 0;
     639}
     640
    611641static uint get_chan_id_from_db(uint sourceid,
    612642                                uint atsc_major, uint atsc_minor)
    613643{
     
    671701    return 0;
    672702}
    673703
     704static uint get_mapped_chan_id_from_db(uint serviceid)
     705{
     706    MSqlQuery query(MSqlQuery::InitCon());
     707
     708    QString qstr =
     709        "SELECT mapped_chanid "
     710        "FROM eit_mapping "
     711        "WHERE serviceid = :SERVICEID";
     712   
     713    query.prepare(qstr);
     714    query.bindValue(":SERVICEID", serviceid);
     715    if (!query.exec() || !query.isActive())
     716        MythContext::DBError("Looking up mapped chanID", query);
     717   
     718    if (query.next())
     719    {
     720        return query.value(0).toUInt();
     721    }
     722   
     723    return 0;
     724}
     725
    674726static void init_fixup(QMap<uint64_t,uint> &fix)
    675727{
    676728    ///////////////////////////////////////////////////////////////////////////
  • 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;
     
    8687  private:
    8788    uint GetChanID(uint atsc_major, uint atsc_minor);
    8889    uint GetChanID(uint serviceid, uint networkid, uint transportid);
     90    uint GetMappedChanID(uint serviceid);
    8991
    9092    void CompleteEvent(uint atsc_major, uint atsc_minor,
    9193                       const ATSCEvent &event,
     
    9496        //QListList_Events  eitList;      ///< Event Information Tables List
    9597    mutable QMutex    eitList_lock; ///< EIT List lock
    9698    mutable ServiceToChanID srv_to_chanid;
     99    mutable ServiceIDToMappedChanID serviceid_to_mapped_chanid;
    97100
    98101    EITFixUp               *eitfixup;
    99102    static EITCache        *eitcache;