Ticket #1512: eit_sourceid2.patch

File eit_sourceid2.patch, 12.3 KB (added by Mark.Buechler@…, 18 years ago)

Second patch - adds configuration option

  • libs/libmythtv/eithelper.cpp

     
    66
    77const uint EITHelper::kChunkSize = 20;
    88
    9 static int get_chan_id_from_db(int tid_db, const Event&);
     9static int get_chan_id_from_db(int tid_db, const Event&, bool ignore_source);
    1010static uint update_eit_in_db(MSqlQuery&, MSqlQuery&, int, const Event&);
    1111static uint delete_overlapping_in_db(MSqlQuery&, MSqlQuery&,
    1212                                     int, const Event&);
     
    6565 *  \param mplexid multiplex we are inserting events for.
    6666 *  \return Returns number of events inserted into DB.
    6767 */
    68 uint EITHelper::ProcessEvents(uint sourceid)
     68uint EITHelper::ProcessEvents(uint sourceid, bool ignore_source)
    6969{
    7070    QMutexLocker locker(&eitList_lock);
    7171
     
    7979        eitList.pop_front();
    8080
    8181        eitList_lock.unlock();
    82         insertCount += UpdateEITList(sourceid, *events);
     82        insertCount += UpdateEITList(sourceid, *events, ignore_source);
    8383        QList_Events::iterator it = events->begin();
    8484        for (; it != events->end(); ++it)
    8585            delete *it;
     
    9797        events->erase(events->begin(), subset_end);
    9898       
    9999        eitList_lock.unlock();
    100         insertCount += UpdateEITList(sourceid, subset);
     100        insertCount += UpdateEITList(sourceid, subset, ignore_source);
    101101        QList_Events::iterator it = subset.begin();
    102102        for (; it != subset.end(); ++it)
    103103            delete *it;
     
    112112    return insertCount;
    113113}
    114114
    115 int EITHelper::GetChanID(uint sourceid, const Event &event) const
     115int EITHelper::GetChanID(uint sourceid, const Event &event, bool ignore_source) const
    116116{
    117117    unsigned long long srv;
    118118    srv  = ((unsigned long long) sourceid);
     
    122122
    123123    int chanid = srv_to_chanid[srv];
    124124    if (chanid == 0)
    125         srv_to_chanid[srv] = chanid = get_chan_id_from_db(sourceid, event);
     125        srv_to_chanid[srv] = chanid = get_chan_id_from_db(sourceid, event, ignore_source);
    126126    return chanid;
    127127}
    128128
    129 uint EITHelper::UpdateEITList(uint sourceid, const QList_Events &events) const
     129uint EITHelper::UpdateEITList(uint sourceid, const QList_Events &events,
     130                              bool ignore_source) const
    130131{
    131132    MSqlQuery query1(MSqlQuery::InitCon());
    132133    MSqlQuery query2(MSqlQuery::InitCon());
     
    136137
    137138    QList_Events::const_iterator e = events.begin();
    138139    for (; e != events.end(); ++e)
    139         if ((chanid = GetChanID(sourceid, **e)) > 0)
     140        if ((chanid = GetChanID(sourceid, **e, ignore_source)) > 0)
    140141            counter += update_eit_in_db(query1, query2, chanid, **e);
    141142
    142143    return counter;
    143144}
    144145
    145146// Figure out the chanid for this channel
    146 static int get_chan_id_from_db(int sourceid, const Event &event)
     147static int get_chan_id_from_db(int sourceid, const Event &event, bool ignore_source)
    147148{
    148149    MSqlQuery query(MSqlQuery::InitCon());
    149150
     
    156157            "WHERE atscsrcid = :ATSCSRCID AND "
    157158            "      sourceid  = :SOURCEID");
    158159        query.bindValue(":ATSCSRCID", event.ServiceID);
     160        query.bindValue(":SOURCEID", sourceid);
    159161    }
    160162    else
    161163    {
    162164        // DVB Link to chanid
    163         query.prepare(
    164             "SELECT chanid, useonairguide "
    165             "FROM channel, dtv_multiplex "
    166             "WHERE serviceid        = :SERVICEID   AND "
    167             "      networkid        = :NETWORKID   AND "
    168             "      transportid      = :TRANSPORTID AND "
    169             "      channel.sourceid = :SOURCEID    AND "
    170             "      channel.mplexid = dtv_multiplex.mplexid");
     165       if (!ignore_source)
     166        {
     167            query.prepare(
     168                "SELECT chanid, useonairguide "
     169                "FROM channel, dtv_multiplex "
     170                "WHERE serviceid        = :SERVICEID   AND "
     171                "      networkid        = :NETWORKID   AND "
     172                "      transportid      = :TRANSPORTID AND "
     173                "      channel.sourceid = :SOURCEID    AND "
     174                "      channel.mplexid = dtv_multiplex.mplexid");
     175            query.bindValue(":SOURCEID", sourceid);
     176        }
     177        else
     178        {
     179            query.prepare(
     180                "SELECT chanid, useonairguide "
     181                "FROM channel, dtv_multiplex "
     182                "WHERE serviceid        = :SERVICEID   AND "
     183                "      networkid        = :NETWORKID   AND "
     184                "      transportid      = :TRANSPORTID AND "
     185                "      channel.mplexid = dtv_multiplex.mplexid");
     186        }
     187
    171188        query.bindValue(":SERVICEID",   event.ServiceID);
    172189        query.bindValue(":NETWORKID",   event.NetworkID);
    173190        query.bindValue(":TRANSPORTID", event.TransportID);
    174191    }
    175     query.bindValue(":SOURCEID", sourceid);
    176192
    177193    if (!query.exec() || !query.isActive())
    178194        MythContext::DBError("Looking up chanID", query);
     
    183199        return (useOnAirGuide) ? query.value(0).toInt() : -1;       
    184200    }
    185201
    186     VERBOSE(VB_EIT, "EITHelper: " +
    187             QString("chanid not found for service %1 on source %2,")
    188             .arg(event.ServiceID).arg(sourceid) +
    189             "\n\t\t\tso event updates were skipped.");
     202    if (event.ATSC || !ignore_source)
     203        VERBOSE(VB_EIT, "EITHelper: " +
     204                QString("chanid not found for service %1 on source %2,")
     205                .arg(event.ServiceID).arg(sourceid) +
     206                "\n\t\t\tso event updates were skipped.");
     207    else
     208        VERBOSE(VB_EIT, "EITHelper: " +
     209                QString("chanid not found for service %1 on network %2,")
     210                .arg(event.ServiceID).arg(event.NetworkID) +
     211                "\n\t\t\tso event updates were skipped.");
    190212
    191213    return -1;
    192214}
  • libs/libmythtv/eithelper.h

     
    2525
    2626    void ClearList(void);
    2727    uint GetListSize(void) const;
    28     uint ProcessEvents(uint sourceid);
     28    uint ProcessEvents(uint sourceid, bool ignore_source=false);
    2929
    3030  public slots:
    3131    void HandleEITs(QMap_Events* events);
    3232
    3333  private:
    34     int  GetChanID(uint sourceid, const Event &event) const;
    35     uint UpdateEITList(uint sourceid, const QList_Events &events) const;
     34    int  GetChanID(uint sourceid, const Event &event, bool ignore_source) const;
     35    uint UpdateEITList(uint sourceid, const QList_Events &events,
     36                       bool ignore_source) const;
    3637
    3738    QListList_Events  eitList;      ///< Event Information Tables List
    3839    mutable QMutex    eitList_lock; ///< EIT List lock
  • libs/libmythtv/eitscanner.h

     
    2424    EITScanner();
    2525    ~EITScanner() { TeardownAll(); }
    2626
    27     void StartPassiveScan(DVBChannel*, DVBSIParser*);
     27    void StartPassiveScan(DVBChannel*, DVBSIParser*,
     28                          bool ignore_source=false);
    2829    void StopPassiveScan(void);
    2930
    30     void StartActiveScan(TVRec*, uint max_seconds_per_source);
     31    void StartActiveScan(TVRec*, uint max_seconds_per_source,
     32                         bool ignore_source=false);
    3133    void StopActiveScan(void);       
    3234
    3335  private:
     
    5052    QStringList      activeScanChannels;
    5153    QStringList::iterator activeScanNextChan;
    5254
     55    bool             ignore_source;
     56
    5357    static QMutex    resched_lock;
    5458    static QDateTime resched_next_time;
    5559
  • libs/libmythtv/tv_rec.cpp

     
    10981098    }
    10991099
    11001100    if (scanner)
    1101         scanner->StartPassiveScan(dvbc, dvbsiparser);
     1101    {
     1102        uint ignore = gContext->GetNumSetting("EITIgnoresSource", 0);
     1103        scanner->StartPassiveScan(dvbc, dvbsiparser, (ignore ? true : false));
     1104    }
    11021105#endif // USING_DVB_EIT
    11031106
    11041107#endif // USING_DVB
     
    13261329            else
    13271330            {
    13281331                uint ttMin = gContext->GetNumSetting("EITTransportTimeout", 5);
    1329                 scanner->StartActiveScan(this, ttMin * 60);
     1332                uint ignore = gContext->GetNumSetting("EITIgnoresSource", 0);
     1333                scanner->StartActiveScan(this, ttMin * 60, (ignore ? true : false));
    13301334                SetFlags(kFlagEITScannerRunning);
    13311335                eitScanStartTime = QDateTime::currentDateTime().addYears(1);
    13321336            }
  • libs/libmythtv/eitscanner.cpp

     
    8282            uint sourceid = channel->GetCurrentSourceID();
    8383            if (sourceid && parser && eitHelper->GetListSize())
    8484            {
    85                 eitCount += eitHelper->ProcessEvents(sourceid);
     85                eitCount += eitHelper->ProcessEvents(sourceid, ignore_source);
    8686                t.start();
    8787            }
    8888        }
     
    155155 *  \brief Start inserting Event Information Tables from the multiplex
    156156 *         we happen to be tuned to into the database.
    157157 */
    158 void EITScanner::StartPassiveScan(DVBChannel *_channel, DVBSIParser *_parser)
     158void EITScanner::StartPassiveScan(DVBChannel *_channel, DVBSIParser *_parser,
     159                                  bool _ignore_source)
    159160{
    160161    eitHelper->ClearList();
    161     parser  = _parser;
    162     channel = _channel;
     162    parser        = _parser;
     163    channel       = _channel;
     164    ignore_source = _ignore_source;
     165
     166    if (ignore_source)
     167        VERBOSE(VB_EIT, LOC + "EIT scan ignoring sourceid..");
     168
    163169    QObject::connect(parser,    SIGNAL(EventsReady(QMap_Events*)),
    164170                     eitHelper, SLOT(HandleEITs(QMap_Events*)));
    165171}
     
    176182    parser  = NULL;
    177183}
    178184
    179 void EITScanner::StartActiveScan(TVRec *_rec, uint max_seconds_per_source)
     185void EITScanner::StartActiveScan(TVRec *_rec, uint max_seconds_per_source,
     186                                 bool _ignore_source)
    180187{
    181     rec = _rec;
     188    rec           = _rec;
     189    ignore_source = _ignore_source;
    182190
    183191    if (!activeScanChannels.size())
    184192    {
  • setup/backendsettings.cpp

     
    238238    return gc;
    239239};
    240240
     241static GlobalCheckBox *EITIgnoresSource()
     242{
     243    GlobalCheckBox *gc = new GlobalCheckBox("EITIgnoresSource");
     244    gc->setLabel(QObject::tr("DVB EIT Scan not Limited to Source Input"));
     245    gc->setValue(false);
     246    gc->setHelpText(QObject::tr("If set, DVB EIT scan will not be limited to "
     247                                "channels which are on the same input "
     248                                "source as the channel being viewed. "
     249                                "If your provider delivers EIT for "
     250                                "multiple orbital locations on a single "
     251                                "transport, enable this."));
     252    return gc;
     253};
     254
     255
    241256static GlobalSpinBox *WOLbackendReconnectWaitTime()
    242257{
    243258    GlobalSpinBox *gc = new GlobalSpinBox("WOLbackendReconnectWaitTime", 0, 1200, 5);
     
    647662    group2->addChild(VbiFormat());
    648663    group2->addChild(FreqTable());
    649664    group2->addChild(TimeOffset());
    650     group2->addChild(EITTransportTimeout());
    651665    group2->addChild(MasterBackendOverride());
    652666    group2->addChild(DeletesFollowLinks());
    653667    addChild(group2);
    654668
     669    VerticalConfigurationGroup* group2a1 = new VerticalConfigurationGroup(false);
     670    group2a1->setLabel(QObject::tr("EIT Scanner Options"));               
     671    group2a1->addChild(EITTransportTimeout());
     672    group2a1->addChild(EITIgnoresSource());
     673    addChild(group2a1);
     674
    655675    VerticalConfigurationGroup* group3 = new VerticalConfigurationGroup(false);
    656676    group3->setLabel(QObject::tr("Shutdown/Wakeup Options"));
    657677    group3->addChild(startupCommand());