Ticket #10784: 0007-Handle-EIT-events-of-the-active-transport-without-lo.patch
File 0007-Handle-EIT-events-of-the-active-transport-without-lo.patch, 10.4 KB (added by , 12 years ago) |
---|
-
mythtv/libs/libmythtv/eithelper.cpp
From 59509b4e918123e1faeaae46b5ae8c6506f36dfc Mon Sep 17 00:00:00 2001 From: Karl Dietz <dekarl@users.sourceforge.net> Date: Tue, 22 May 2012 23:30:38 +0200 Subject: [PATCH 7/7] Handle EIT events of the active transport without looking at original_network_id or transport_id Refs #10217 --- mythtv/libs/libmythtv/eithelper.cpp | 112 ++++++++++++++++++++++++++++++---- mythtv/libs/libmythtv/eithelper.h | 6 ++ mythtv/libs/libmythtv/eitscanner.cpp | 3 + mythtv/libs/libmythtv/tv_rec.cpp | 10 +++ mythtv/libs/libmythtv/tv_rec.h | 1 + 5 files changed, 120 insertions(+), 12 deletions(-) diff --git a/mythtv/libs/libmythtv/eithelper.cpp b/mythtv/libs/libmythtv/eithelper.cpp index df145fc..dd82960 100644
a b using namespace std; 25 25 const uint EITHelper::kChunkSize = 20; 26 26 EITCache *EITHelper::eitcache = new EITCache(); 27 27 28 static uint get_chan_id_from_db(uint sourceid, 29 uint atscmajor, uint atscminor); 30 static uint get_chan_id_from_db(uint sourceid, uint serviceid, 31 uint networkid, uint transportid); 28 static uint get_chan_id_from_db_atsc(uint sourceid, 29 uint atscmajor, uint atscminor); 30 static uint get_chan_id_from_db_dvb(uint sourceid, uint serviceid, 31 uint networkid, uint transportid); 32 static uint get_chan_id_from_db_dtv(uint sourceid, 33 uint programnumber, uint tunedchanid); 32 34 static void init_fixup(QMap<uint64_t,uint> &fix); 33 35 static int calc_eit_utc_offset(void); 34 36 … … static int calc_eit_utc_offset(void); 37 39 EITHelper::EITHelper() : 38 40 eitfixup(new EITFixUp()), 39 41 gps_offset(-1 * GPS_LEAP_SECONDS), utc_offset(0), 40 sourceid(0) 42 sourceid(0), channelid(0) 41 43 { 42 44 init_fixup(fixup); 43 45 … … void EITHelper::SetSourceID(uint _sourceid) 146 148 sourceid = _sourceid; 147 149 } 148 150 151 void EITHelper::SetChannelID(uint _channelid) 152 { 153 QMutexLocker locker(&eitList_lock); 154 channelid = _channelid; 155 } 156 149 157 void EITHelper::AddEIT(uint atsc_major, uint atsc_minor, 150 158 const EventInformationTable *eit) 151 159 { … … void EITHelper::AddEIT(const DVBEventInformationTable *eit) 318 326 (uint64_t)eit->ServiceID()); 319 327 fix |= EITFixUp::kFixGenericDVB; 320 328 321 uint chanid = GetChanID(eit->ServiceID(), eit->OriginalNetworkID(), 322 eit->TSID()); 329 uint chanid = 0; 330 if ((eit->TableID() == TableID::PF_EIT) || 331 ((eit->TableID() >= TableID::SC_EITbeg) && (eit->TableID() <= TableID::SC_EITend))) 332 { 333 // EITa(ctive) 334 chanid = GetChanID(eit->ServiceID()); 335 } 336 else 337 { 338 // EITo(ther) 339 chanid = GetChanID(eit->ServiceID(), eit->OriginalNetworkID(), eit->TSID()); 340 } 323 341 if (!chanid) 324 342 return; 325 343 … … uint EITHelper::GetChanID(uint atsc_major, uint atsc_minor) 684 702 if (it != srv_to_chanid.end()) 685 703 return max(*it, 0); 686 704 687 uint chanid = get_chan_id_from_db (sourceid, atsc_major, atsc_minor);705 uint chanid = get_chan_id_from_db_atsc(sourceid, atsc_major, atsc_minor); 688 706 if (chanid) 689 707 srv_to_chanid[key] = chanid; 690 708 … … uint EITHelper::GetChanID(uint serviceid, uint networkid, uint tsid) 703 721 if (it != srv_to_chanid.end()) 704 722 return max(*it, 0); 705 723 706 uint chanid = get_chan_id_from_db (sourceid, serviceid, networkid, tsid);724 uint chanid = get_chan_id_from_db_dvb(sourceid, serviceid, networkid, tsid); 707 725 if (chanid) 708 726 srv_to_chanid[key] = chanid; 709 727 710 728 return chanid; 711 729 } 712 730 713 static uint get_chan_id_from_db(uint sourceid, 731 uint EITHelper::GetChanID(uint program_number) 732 { 733 uint64_t key; 734 key = ((uint64_t) sourceid); 735 key |= ((uint64_t) program_number) << 16; 736 key |= ((uint64_t) channelid) << 32; 737 738 ServiceToChanID::const_iterator it = srv_to_chanid.find(key); 739 if (it != srv_to_chanid.end()) 740 return max(*it, 0); 741 742 uint chanid = get_chan_id_from_db_dtv(sourceid, program_number, channelid); 743 if (chanid) 744 srv_to_chanid[key] = chanid; 745 746 return chanid; 747 } 748 749 static uint get_chan_id_from_db_atsc(uint sourceid, 714 750 uint atsc_major, uint atsc_minor) 715 751 { 716 752 MSqlQuery query(MSqlQuery::InitCon()); … … static uint get_chan_id_from_db(uint sourceid, 736 772 } 737 773 738 774 // Figure out the chanid for this channel 739 static uint get_chan_id_from_db (uint sourceid, uint serviceid,775 static uint get_chan_id_from_db_dvb(uint sourceid, uint serviceid, 740 776 uint networkid, uint transportid) 741 777 { 742 778 uint chanid = 0; … … static uint get_chan_id_from_db(uint sourceid, uint serviceid, 769 805 return useOnAirGuide ? chanid : 0; 770 806 } 771 807 772 if (query.size() > 1) { 808 if (query.size() > 1) 809 { 773 810 LOG(VB_EIT, LOG_INFO, 774 811 LOC + QString("found %1 channels for networdid %2, " 775 812 "transportid %3, serviceid %4 but none " … … static uint get_chan_id_from_db(uint sourceid, uint serviceid, 781 818 return useOnAirGuide ? chanid : 0; 782 819 } 783 820 821 /* Figure out the chanid for this channel from the sourceid, 822 * program_number/service_id and the chanid of the channel we are tuned to 823 * 824 * TODO for SPTS (e.g. HLS / IPTV) it would be useful to match without an entry 825 * in dtv_multiplex 826 */ 827 static uint get_chan_id_from_db_dtv(uint sourceid, uint serviceid, 828 uint tunedchanid) 829 { 830 uint chanid = 0; 831 bool useOnAirGuide = false; 832 MSqlQuery query(MSqlQuery::InitCon()); 833 834 // DVB Link to chanid 835 QString qstr = 836 "SELECT c1.chanid, c1.useonairguide, c1.sourceid " 837 "FROM channel c1, dtv_multiplex m, channel c2 " 838 "WHERE c1.serviceid = :SERVICEID AND " 839 " c1.mplexid = m.mplexid AND " 840 " m.mplexid = c2.mplexid AND " 841 " c2.chanid = :CHANID"; 842 843 query.prepare(qstr); 844 query.bindValue(":SERVICEID", serviceid); 845 query.bindValue(":CHANID", tunedchanid); 846 847 if (!query.exec() || !query.isActive()) 848 MythDB::DBError("Looking up chanID", query); 849 850 while (query.next()) 851 { 852 // Check to see if we are interested in this channel 853 chanid = query.value(0).toUInt(); 854 useOnAirGuide = query.value(1).toBool(); 855 if (sourceid == query.value(2).toUInt()) 856 return useOnAirGuide ? chanid : 0; 857 } 858 859 if (query.size() > 1) 860 { 861 LOG(VB_EIT, LOG_INFO, 862 LOC + QString("found %1 channels for multiplex of chanid %2, " 863 "serviceid %3 but none " 864 "for current sourceid %4.") 865 .arg(query.size()).arg(tunedchanid) 866 .arg(serviceid).arg(sourceid)); 867 } 868 869 return useOnAirGuide ? chanid : 0; 870 } 871 784 872 static void init_fixup(QMap<uint64_t,uint> &fix) 785 873 { 786 874 /////////////////////////////////////////////////////////////////////////// -
mythtv/libs/libmythtv/eithelper.h
diff --git a/mythtv/libs/libmythtv/eithelper.h b/mythtv/libs/libmythtv/eithelper.h index 6fca7d5..e83244a 100644
a b class EITHelper 66 66 67 67 uint GetGPSOffset(void) const { return (uint) (0 - gps_offset); } 68 68 69 void SetChannelID(uint _channelid); 69 70 void SetGPSOffset(uint _gps_offset) { gps_offset = 0 - _gps_offset; } 70 71 void SetFixup(uint atsc_major, uint atsc_minor, uint eitfixup); 71 72 void SetLanguagePreferences(const QStringList &langPref); … … class EITHelper 90 91 void WriteEITCache(void); 91 92 92 93 private: 94 // only ATSC 93 95 uint GetChanID(uint atsc_major, uint atsc_minor); 96 // only DVB 94 97 uint GetChanID(uint serviceid, uint networkid, uint transportid); 98 // any DTV 99 uint GetChanID(uint program_number); 95 100 96 101 void CompleteEvent(uint atsc_major, uint atsc_minor, 97 102 const ATSCEvent &event, … … class EITHelper 107 112 int gps_offset; 108 113 int utc_offset; 109 114 uint sourceid; 115 uint channelid; 110 116 QMap<uint64_t,uint> fixup; 111 117 ATSCSRCToEvents incomplete_events; 112 118 ATSCSRCToETTs unmatched_etts; -
mythtv/libs/libmythtv/eitscanner.cpp
diff --git a/mythtv/libs/libmythtv/eitscanner.cpp b/mythtv/libs/libmythtv/eitscanner.cpp index 2e42bd5..8acf7e9 100644
a b void EITScanner::run(void) 134 134 { 135 135 eitHelper->WriteEITCache(); 136 136 rec->SetChannel(*activeScanNextChan, TVRec::kFlagEITScan); 137 eitHelper->SetChannelID(ChannelUtil::GetChanID(rec->GetSourceID(), 138 *activeScanNextChan)); 137 139 LOG(VB_EIT, LOG_INFO, 138 140 LOC_ID + QString("Now looking for EIT data on " 139 141 "multiplex of channel %1") … … void EITScanner::StartPassiveScan(ChannelBase *_channel, 204 206 eitHelper->SetSourceID(sourceid); 205 207 eitSource->SetEITHelper(eitHelper); 206 208 eitSource->SetEITRate(1.0f); 209 eitHelper->SetChannelID(_channel->GetChanID()); 207 210 208 211 LOG(VB_EIT, LOG_INFO, LOC_ID + "Started passive scan."); 209 212 } -
mythtv/libs/libmythtv/tv_rec.cpp
diff --git a/mythtv/libs/libmythtv/tv_rec.cpp b/mythtv/libs/libmythtv/tv_rec.cpp index a5d4986..fc9e96c 100644
a b QString TVRec::GetInput(void) const 2934 2934 return QString::null; 2935 2935 } 2936 2936 2937 /** \fn TVRec::GetSourceID(void) const 2938 * \brief Returns current source id. 2939 */ 2940 uint TVRec::GetSourceID(void) const 2941 { 2942 if (channel) 2943 return channel->GetCurrentSourceID(); 2944 return 0; 2945 } 2946 2937 2947 /** \fn TVRec::SetInput(QString, uint) 2938 2948 * \brief Changes to the specified input. 2939 2949 * -
mythtv/libs/libmythtv/tv_rec.h
diff --git a/mythtv/libs/libmythtv/tv_rec.h b/mythtv/libs/libmythtv/tv_rec.h index ce54bff..6c2aaf8 100644
a b class MTV_PUBLIC TVRec : public SignalMonitorListener, public QRunnable 192 192 193 193 vector<InputInfo> GetFreeInputs(const vector<uint> &excluded_cards) const; 194 194 QString GetInput(void) const; 195 uint GetSourceID(void) const; 195 196 QString SetInput(QString input, uint requestType = kFlagDetect); 196 197 197 198 /// Changes to a channel in the 'dir' channel change direction.