Ticket #1848: mfdb_chanid_fix2.patch
File mfdb_chanid_fix2.patch, 5.1 KB (added by , 19 years ago) |
---|
-
sourceutil.h
16 16 QString &passwd, QString &lineupid); 17 17 static bool IsAnalog(uint sourceid); 18 18 static bool UpdateChannelsFromListings(uint sourceid); 19 static QString GetLineupType(uint sourceid); 19 20 }; 20 21 21 22 #endif //_SOURCEUTIL_H_ -
sourceutil.cpp
3 3 // Qt headers 4 4 #include <qregexp.h> 5 5 6 #include <map> 7 6 8 // MythTV headers 7 9 #include "sourceutil.h" 8 10 #include "mythdbcon.h" 9 11 #include "util.h" 12 #include "mythcontext.h" 10 13 11 14 QString SourceUtil::GetChannelSeparator(uint sourceid) 12 15 { … … 118 121 "--sourceid %1").arg(sourceid)); 119 122 return true; 120 123 } 124 125 /// Returns the lineup type given a source ID. 126 /// \param [in] sourceid The lineup source ID. 127 /// \returns A string with the TMSDataDirect lineup type or "Unknown" 128 /// \remarks This function relies on temporary tables which are only valid 129 /// when mythfilldatabase is processing a lineup. 130 QString SourceUtil::GetLineupType(uint sourceid) 131 { 132 typedef std::map<uint, QString> smap; 133 static smap sid_cache; 134 135 smap::iterator p = sid_cache.find(sourceid); 136 if (p != sid_cache.end()) 137 { 138 return p->second; 139 } 140 141 MSqlQuery query(MSqlQuery::DDCon()); 142 query.prepare( 143 "SELECT `type` FROM dd_lineup " 144 "LEFT JOIN videosource ON dd_lineup.lineupid = videosource.lineupid " 145 "WHERE sourceid = :SOURCEID;"); 146 query.bindValue(":SOURCEID", sourceid); 147 148 if (query.exec() && query.next()) 149 { 150 QString type(query.value(0).toString()); 151 sid_cache.insert(smap::value_type(sourceid, type)); 152 return type; 153 } 154 else 155 { 156 VERBOSE(VB_IMPORTANT, QString("Error: Source ID has no lineup type.")); 157 } 158 159 return "Unknown"; 160 } -
datadirect.cpp
31 31 static void get_atsc_stuff(QString channum, int sourceid, int freqid, 32 32 int &major, int &minor, long long &freq); 33 33 static uint create_atscsrcid(QString chan_major, QString chan_minor); 34 static QString process_dd_station(uint sourceid, 34 static QString process_dd_station(uint sourceid, QString lineup_type, 35 35 QString chan_major, QString chan_minor, 36 36 QString &tvformat, uint &freqid, 37 37 uint &atscsrcid); … … 675 675 if (dd_station_info.size() == 0) 676 676 return true; 677 677 678 QString lineup_type = SourceUtil::GetLineupType(sourceid); 679 678 680 MSqlQuery chan_update_q(MSqlQuery::DDCon()); 679 681 chan_update_q.prepare( 680 682 "UPDATE channel " … … 691 693 QString chan_minor = dd_station_info.value(5).toString(); 692 694 QString tvformat = QString::null; 693 695 QString channum = process_dd_station( 694 sourceid, chan_major, chan_minor, tvformat, freqid, atscsrcid); 696 sourceid, lineup_type, chan_major, chan_minor, tvformat, freqid, 697 atscsrcid); 695 698 696 699 chan_update_q.bindValue(":CALLSIGN", dd_station_info.value(0)); 697 700 chan_update_q.bindValue(":NAME", dd_station_info.value(1)); … … 1759 1762 static uint create_atscsrcid(QString chan_major, QString chan_minor) 1760 1763 { 1761 1764 bool ok; 1762 uint major = chan_major.toUInt(&ok), atscsrcid = 0;1765 uint atscsrcid = chan_major.toUInt(&ok); 1763 1766 if (!ok) 1764 return atscsrcid;1767 return 0; 1765 1768 1766 atscsrcid = major <<8;1769 atscsrcid <<= 8; 1767 1770 if (chan_minor.isEmpty()) 1768 1771 return atscsrcid; 1769 1772 … … 1771 1774 } 1772 1775 1773 1776 static QString process_dd_station( 1774 uint sourceid, QString chan_major, QString chan_minor,1777 uint sourceid, QString lineup_type, QString chan_major, QString chan_minor, 1775 1778 QString &tvformat, uint &freqid, uint &atscsrcid) 1776 1779 { 1777 1780 QString channum = chan_major; … … 1781 1784 if (atscsrcid & 0xff) 1782 1785 { 1783 1786 tvformat = "atsc"; 1784 channum += SourceUtil::GetChannelSeparator(sourceid)+ chan_minor;1787 channum += "_" + chan_minor; 1785 1788 } 1786 1789 1787 if (!freqid && !(atscsrcid & 0xff)) 1788 freqid = chan_major.toInt(); 1790 if (lineup_type == "LocalBroadcast") 1791 { 1792 if (!freqid && !(atscsrcid & 0xff)) 1793 freqid = chan_major.toInt(); 1794 } 1795 else 1796 { 1797 // lose the freqid lest someone be fool enough to use it 1798 freqid = channum.toInt(); 1799 } 1789 1800 1790 1801 return channum; 1791 1802 } … … 1800 1811 uint atscsrcid; 1801 1812 QString tvformat; 1802 1813 QString channum = process_dd_station( 1803 sourceid, chan_major, chan_minor, tvformat, freqid, atscsrcid); 1814 sourceid, SourceUtil::GetLineupType(sourceid), chan_major, chan_minor, 1815 tvformat, freqid, atscsrcid); 1804 1816 1805 1817 // First check if channel already in DB, but without xmltvid 1806 1818 MSqlQuery query(MSqlQuery::DDCon());