Index: libs/libmythtv/eithelper.cpp
===================================================================
--- libs/libmythtv/eithelper.cpp	(Revision 11241)
+++ libs/libmythtv/eithelper.cpp	(Arbeitskopie)
@@ -21,6 +21,7 @@
                                 uint atscmajor, uint atscminor);
 static uint get_chan_id_from_db(uint sourceid,  uint serviceid,
                                 uint networkid, uint transportid);
+static uint get_mapped_chan_id_from_db(uint serviceid);
 static void init_fixup(QMap<uint64_t,uint> &fix);
 static int calc_eit_utc_offset(void);
 
@@ -343,6 +344,19 @@
                                      false,     subtitled,
                                      stereo,    hdtv);
         db_events.enqueue(event);
+        
+        uint mapped_chanid = GetMappedChanID(serviceid);
+        
+        if (mapped_chanid > 0)
+        {
+            DBEvent *event = new DBEvent(mapped_chanid,
+                                         title,     subtitle,      description,
+                                         category,  category_type,
+                                         starttime, endtime,       fix,
+                                         false,     subtitled,
+                                         stereo,    hdtv);
+            db_events.enqueue(event);
+        }
     }
 }
 
@@ -414,11 +428,25 @@
 
     uint chanid = get_chan_id_from_db(sourceid, serviceid, networkid, tsid);
     if (chanid)
+    {
         srv_to_chanid[key] = chanid;
+        
+        uint mapped_chanid = get_mapped_chan_id_from_db(serviceid);
+        if(mapped_chanid)
+            serviceid_to_mapped_chanid[serviceid] = mapped_chanid;
+    }
 
     return chanid;
 }
 
+uint EITHelper::GetMappedChanID(uint serviceid)
+{
+    ServiceIDToMappedChanID::const_iterator it = serviceid_to_mapped_chanid.find(serviceid);
+    if (it != serviceid_to_mapped_chanid.end())
+        return max(*it, 0);
+    return 0;
+} 
+
 static uint get_chan_id_from_db(uint sourceid,
                                 uint atsc_major, uint atsc_minor)
 {
@@ -482,6 +510,28 @@
     return 0;
 }
 
+static uint get_mapped_chan_id_from_db(uint serviceid)
+{
+    MSqlQuery query(MSqlQuery::InitCon());
+
+    QString qstr =
+        "SELECT mapped_chanid "
+        "FROM eit_mapping "
+        "WHERE serviceid = :SERVICEID";
+    
+    query.prepare(qstr);
+    query.bindValue(":SERVICEID", serviceid);
+    if (!query.exec() || !query.isActive())
+        MythContext::DBError("Looking up mapped chanID", query);
+    
+    if (query.next())
+    {
+        return query.value(0).toUInt();
+    }
+    
+    return 0;
+}
+
 static void init_fixup(QMap<uint64_t,uint> &fix)
 {
     // transport_id<<32 | netword_id<<16 | service_id
Index: libs/libmythtv/eithelper.h
===================================================================
--- libs/libmythtv/eithelper.h	(Revision 11241)
+++ libs/libmythtv/eithelper.h	(Arbeitskopie)
@@ -39,6 +39,7 @@
 typedef QMap<uint,EventIDToATSCEvent>      ATSCSRCToEvents;
 typedef QMap<uint,EventIDToETT>            ATSCSRCToETTs;
 typedef QMap<unsigned long long,int>       ServiceToChanID;
+typedef QMap<int,int>                      ServiceIDToMappedChanID;
 
 class DBEvent;
 class EITFixUp;
@@ -81,6 +82,7 @@
   private:
     uint GetChanID(uint atsc_major, uint atsc_minor);
     uint GetChanID(uint serviceid, uint networkid, uint transportid);
+    uint GetMappedChanID(uint serviceid);
 
     void CompleteEvent(uint atsc_major, uint atsc_minor,
                        const ATSCEvent &event,
@@ -89,6 +91,7 @@
         //QListList_Events  eitList;      ///< Event Information Tables List
     mutable QMutex    eitList_lock; ///< EIT List lock
     mutable ServiceToChanID srv_to_chanid;
+    mutable ServiceIDToMappedChanID serviceid_to_mapped_chanid;
 
     EITFixUp               *eitfixup;
     EITCache               *eitcache;

