Ticket #5562: t5562_default_authority_r21554.diff

File t5562_default_authority_r21554.diff, 19.6 KB (added by Janne Grunau, 15 years ago)

updated to r21554 and added verbose messages

  • mythtv/libs/libmythtv/channelscan/channelimporter.cpp

    diff --git a/mythtv/libs/libmythtv/channelscan/channelimporter.cpp b/mythtv/libs/libmythtv/channelscan/channelimporter.cpp
    index f84ec74..0f0e48c 100644
    a b ScanDTVTransportList ChannelImporter::InsertChannels( 
    358358                        chan.atsc_minor_channel,
    359359                        chan.use_on_air_guide,
    360360                        chan.hidden, chan.hidden_in_guide,
    361                         chan.freqid);
     361                        chan.freqid,
     362                        QString::null,
     363                        QString::null,
     364                        QString::null,
     365                        chan.default_authority);
    362366                }
    363367            }
    364368
    ScanDTVTransportList ChannelImporter::UpdateChannels( 
    484488                    chan.atsc_minor_channel,
    485489                    chan.use_on_air_guide,
    486490                    chan.hidden, chan.hidden_in_guide,
    487                     chan.freqid);
     491                    chan.freqid,
     492                    QString::null,
     493                    QString::null,
     494                    QString::null,
     495                    chan.default_authority);
    488496            }
    489497
    490498            if (filter)
  • mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp

    diff --git a/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp b/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
    index bcd986d..d41b301 100644
    a b  
    6363/// 10 seconds, so lets wait at least 30 seconds, in
    6464/// case of bad transmitter or lost packets.
    6565const uint ChannelScanSM::kDVBTableTimeout  = 30 * 1000;
     66/// The whole BAT & SDTo group comes round in 10s, so wait additional
     67/// 12 seconds to kDVBTableTimeout
     68const uint ChannelScanSM::kDVBoTableTimeout = ChannelScanSM::kDVBTableTimeout +
     69                                              12 * 1000;
    6670/// No logic here, lets just wait at least 10 seconds.
    6771const uint ChannelScanSM::kATSCTableTimeout = 10 * 1000;
    6872/// No logic here, lets just wait at least 15 seconds.
    ChannelScanSM::ChannelScanSM( 
    150154      scanning(false),
    151155      threadExit(false),
    152156      waitingForTables(false),
     157      wait_for_dvbo(false),
    153158      // Transports List
    154159      transportsScanned(0),
    155160      currentTestingDecryption(false),
    ChannelScanSM::ChannelScanSM( 
    185190        data->AddMPEGListener(this);
    186191        data->AddATSCMainListener(this);
    187192        data->AddDVBMainListener(this);
     193        data->AddDVBOtherListener(this);
    188194    }
    189195}
    190196
    void ChannelScanSM::HandleMGT(const MasterGuideTable *mgt) 
    370376    UpdateChannelInfo(true);
    371377}
    372378
    373 void ChannelScanSM::HandleSDT(uint, const ServiceDescriptionTable *sdt)
     379void ChannelScanSM::HandleSDT(uint tsid, const ServiceDescriptionTable *sdt)
    374380{
    375381    VERBOSE(VB_CHANSCAN, LOC +
    376382            QString("Got a Service Description Table for %1")
    void ChannelScanSM::HandleNIT(const NetworkInformationTable *nit) 
    396402            QString("Got a Network Information Table for %1")
    397403            .arg((*current).FriendlyName) + "\n" + nit->toString());
    398404
     405    uint netid = nit->NetworkID();
     406
     407    // If this is Astra 28.2 add start listening for Freesat BAT and SDTo
     408    if (!wait_for_dvbo && (netid == 2 || netid == 59))
     409    {
     410        VERBOSE(VB_IMPORTANT, LOC + QString("NIT has NetworkID %1, look for "
     411                                            "additional Freesat SI").arg(netid));
     412        GetDTVSignalMonitor()->GetScanStreamData()->SetFreesatAdditionalSI(true);
     413        wait_for_dvbo = true;
     414    }
     415
     416    UpdateChannelInfo(true);
     417}
     418
     419void ChannelScanSM::HandleBAT(const BouquetAssociationTable *bat)
     420{
     421    VERBOSE(VB_CHANSCAN, LOC + "Got a Bouquet Association Table\n" +
     422            bat->toString());
     423
     424    for (uint i = 0; i < bat->TransportStreamCount(); i++)
     425    {
     426        uint tsid = bat->TSID(i);
     427        uint netid = bat->OriginalNetworkID(i);
     428        desc_list_t parsed =
     429            MPEGDescriptor::Parse(bat->TransportDescriptors(i),
     430                                  bat->TransportDescriptorsLength(i));
     431        // Look for default authority
     432        const unsigned char *def_auth =
     433            MPEGDescriptor::Find(parsed, DescriptorID::default_authority);
     434        const unsigned char *serv_list =
     435            MPEGDescriptor::Find(parsed, DescriptorID::service_list);
     436
     437        if (def_auth && serv_list)
     438        {
     439            DefaultAuthorityDescriptor authority(def_auth);
     440            ServiceListDescriptor services(serv_list);
     441
     442            for (uint j = 0; j < services.ServiceCount(); j++)
     443            {
     444               // If the default authority is given in the SDT this
     445               // overrides any definition in the BAT (or in the NIT)
     446                VERBOSE(VB_IMPORTANT, LOC + QString("found default authority(BAT) "
     447                                                    "for service %1 %2 %3")
     448                        .arg(netid).arg(tsid).arg(services.ServiceID(j)));
     449               uint64_t index =
     450                   ((uint64_t)netid << 32) | (tsid << 16) | services.ServiceID(j);
     451               if (! defAuthorities.contains(index))
     452                   defAuthorities[index] = authority.DefaultAuthority();
     453            }
     454        }
     455    }
     456    wait_for_dvbo = false;
     457    UpdateChannelInfo(true);
     458}
     459
     460void ChannelScanSM::HandleSDTo(uint tsid, const ServiceDescriptionTable *sdt)
     461{
     462    VERBOSE(VB_CHANSCAN, LOC + "Got a Service Description Table (other)\n" +
     463            sdt->toString());
     464
     465    uint netid = sdt->OriginalNetworkID();
     466
     467    for (uint i = 0; i < sdt->ServiceCount(); i++)
     468    {
     469        uint serviceId = sdt->ServiceID(i);
     470        desc_list_t parsed =
     471            MPEGDescriptor::Parse(sdt->ServiceDescriptors(i),
     472                                  sdt->ServiceDescriptorsLength(i));
     473        // Look for default authority
     474        const unsigned char *def_auth =
     475            MPEGDescriptor::Find(parsed, DescriptorID::default_authority);
     476        if (def_auth)
     477        {
     478            DefaultAuthorityDescriptor authority(def_auth);
     479            VERBOSE(VB_IMPORTANT, LOC + QString("found default authority(SDTo) "
     480                                                "for service %1 %2 %3")
     481                    .arg(netid).arg(tsid).arg(serviceId));
     482            defAuthorities[((uint64_t)netid << 32) | (tsid << 16) | serviceId] =
     483                authority.DefaultAuthority();
     484        }
     485    }
    399486    UpdateChannelInfo(true);
    400487}
    401488
    bool ChannelScanSM::UpdateChannelInfo(bool wait_until_complete) 
    650737            transport_tune_complete &=
    651738                (!currentInfo->tvcts.empty() || !currentInfo->cvcts.empty());
    652739        }
    653         if (sd->HasCachedAnyNIT() || sd->HasCachedAnySDTs())
     740        if (sd->HasCachedAnyNIT() || sd->HasCachedAnySDTs() || wait_for_dvbo)
    654741        {
    655742            transport_tune_complete &= !currentInfo->nits.empty();
    656743            transport_tune_complete &= !currentInfo->sdts.empty();
     744            transport_tune_complete &= !wait_for_dvbo;
    657745        }
    658746        if (transport_tune_complete)
    659747        {
    bool ChannelScanSM::UpdateChannelInfo(bool wait_until_complete) 
    783871
    784872        currentEncryptionStatus.clear();
    785873        currentEncryptionStatusChecked.clear();
     874        wait_for_dvbo = false;
    786875
    787876        if (scanning)
    788877        {
    static void update_info(ChannelInsertInfo &info, 
    847936}
    848937
    849938static void update_info(ChannelInsertInfo &info,
    850                         const ServiceDescriptionTable *sdt, uint i)
     939                        const ServiceDescriptionTable *sdt, uint i,
     940                        const QMap<uint64_t, QString> &defAuthorities)
    851941{
    852942    // HACK beg -- special exception for this network
    853943    //             (dbver == "1067")
    static void update_info(ChannelInsertInfo &info, 
    886976        (desc && !desc->IsDTV() && !desc->IsDigitalAudio());
    887977    info.is_audio_service = (desc && desc->IsDigitalAudio());
    888978
     979    info.service_id = sdt->ServiceID(i);
    889980    info.sdt_tsid   = sdt->TSID();
    890981    info.orig_netid = sdt->OriginalNetworkID();
    891982    info.in_sdt     = true;
     983
     984    desc_list_t parsed =
     985        MPEGDescriptor::Parse(sdt->ServiceDescriptors(i),
     986                                sdt->ServiceDescriptorsLength(i));
     987    // Look for default authority
     988    const unsigned char *def_auth =
     989        MPEGDescriptor::Find(parsed, DescriptorID::default_authority);
     990    if (def_auth)
     991    {
     992        DefaultAuthorityDescriptor authority(def_auth);
     993        VERBOSE(VB_IMPORTANT, QString("found default authority(SDT) "
     994                                            "for service %1 %2 %3")
     995                .arg(info.orig_netid).arg(info.sdt_tsid).arg(info.service_id));
     996        info.default_authority = authority.DefaultAuthority();
     997    }
     998    else
     999    {
     1000        uint64_t index = (uint64_t)info.orig_netid << 32 |
     1001                         info.sdt_tsid << 16 | info.service_id;
     1002        if (defAuthorities.contains(index))
     1003            info.default_authority = defAuthorities[index];
     1004    }
    8921005}
    8931006
    8941007uint ChannelScanSM::GetCurrentTransportInfo(
    ChannelScanSM::GetChannelList(transport_scan_items_it_t trans_info, 
    10391152            {
    10401153                uint pnum = (*sdt_it)->ServiceID(i);
    10411154                PCM_INFO_INIT("dvb");
    1042                 update_info(info, *sdt_it, i);
     1155                update_info(info, *sdt_it, i, defAuthorities);
    10431156            }
    10441157        }
    10451158    }
    bool ChannelScanSM::HasTimedOut(void) 
    12931406            return timer.elapsed() > (int) kDVBTableTimeout;
    12941407        if (sd->HasCachedMGT() || sd->HasCachedAnyVCTs())
    12951408            return timer.elapsed() > (int) kATSCTableTimeout;
    1296         if (sd->HasCachedAnyPAT() || sd->HasCachedAnyPMTs())
     1409        if (sd->HasCachedAnyPAT() || sd->HasCachedAnyPMTs() || wait_for_dvbo)
    12971410            return timer.elapsed() > (int) kMPEGTableTimeout;
    12981411
    12991412        return true;
  • mythtv/libs/libmythtv/channelscan/channelscan_sm.h

    diff --git a/mythtv/libs/libmythtv/channelscan/channelscan_sm.h b/mythtv/libs/libmythtv/channelscan/channelscan_sm.h
    index 2d36bdc..8bf0427 100644
    a b class AnalogSignalHandler : public SignalMonitorListener 
    8282
    8383class ChannelScanSM : public MPEGStreamListener,
    8484                      public ATSCMainStreamListener,
    85                       public DVBMainStreamListener
     85                      public DVBMainStreamListener,
     86                      public DVBOtherStreamListener
    8687{
    8788    friend class AnalogSignalHandler;
    8889
    class ChannelScanSM : public MPEGStreamListener, 
    144145    void HandleSDT(uint tsid, const ServiceDescriptionTable*);
    145146    void HandleTDT(const TimeDateTable*) {}
    146147
     148    // DVB Other
     149    void HandleNITo(const NetworkInformationTable*) {}
     150    void HandleSDTo(uint tsid, const ServiceDescriptionTable*);
     151    void HandleBAT(const BouquetAssociationTable*);
     152
    147153  private:
    148154    // some useful gets
    149155    DTVChannel       *GetDTVChannel(void);
    class ChannelScanSM : public MPEGStreamListener, 
    188194    static QString loc(const ChannelScanSM*);
    189195
    190196    static const uint kDVBTableTimeout;
     197    static const uint kDVBoTableTimeout;
    191198    static const uint kATSCTableTimeout;
    192199    static const uint kMPEGTableTimeout;
    193200
    class ChannelScanSM : public MPEGStreamListener, 
    209216    bool              waitingForTables;
    210217    QTime             timer;
    211218
     219    bool              wait_for_dvbo;
    212220    // Transports List
    213221    int                         transportsScanned;
    214222    QSet<uint32_t>              ts_scanned;
    class ChannelScanSM : public MPEGStreamListener, 
    219227    bool                        currentTestingDecryption;
    220228    QMap<uint, uint>            currentEncryptionStatus;
    221229    QMap<uint, bool>            currentEncryptionStatusChecked;
     230    QMap<uint64_t, QString>     defAuthorities;
    222231
    223232    /// Found Channel Info
    224233    ChannelList       channelList;
  • mythtv/libs/libmythtv/channelscan/scaninfo.cpp

    diff --git a/mythtv/libs/libmythtv/channelscan/scaninfo.cpp b/mythtv/libs/libmythtv/channelscan/scaninfo.cpp
    index e01035e..bfa3829 100644
    a b ScanDTVTransportList LoadScan(uint scanid) 
    119119            "    in_pat,             in_pmt,             in_vct,             "
    120120            "    in_nit,             in_sdt,             is_encrypted,       "
    121121            "    is_data_service,    is_audio_service,   is_opencable,       "
    122             "    could_be_opencable, decryption_status "
     122            "    could_be_opencable, decryption_status,  default_authority  "
    123123            "FROM channelscan_channel "
    124124            "WHERE transportid = :TRANSPORTID");
    125125        query2.bindValue(":TRANSPORTID", query.value(15).toUInt());
    ScanDTVTransportList LoadScan(uint scanid) 
    178178                query2.value(31).toBool()/*is_audio_service*/,
    179179                query2.value(32).toBool()/*is_opencable*/,
    180180                query2.value(33).toBool()/*could_be_opencable*/,
    181                 query2.value(34).toInt()/*decryption_status*/);
     181                query2.value(34).toInt()/*decryption_status*/,
     182                query2.value(35).toString()/*default_authority*/);
    182183
    183184            mux.channels.push_back(chan);
    184185        }
  • mythtv/libs/libmythtv/dbchannelinfo.cpp

    diff --git a/mythtv/libs/libmythtv/dbchannelinfo.cpp b/mythtv/libs/libmythtv/dbchannelinfo.cpp
    index aa500e3..cf6f623 100644
    a b bool ChannelInsertInfo::SaveScan(uint scanid, uint transportid) const 
    170170        "    in_pat,             in_pmt,             in_vct,             "
    171171        "    in_nit,             in_sdt,             is_encrypted,       "
    172172        "    is_data_service,    is_audio_service,   is_opencable,       "
    173         "    could_be_opencable, decryption_status                       "
     173        "    could_be_opencable, decryption_status,  default_authority   "
    174174        " )  "
    175175        "VALUES "
    176176        " ( :SCANID,            :TRANSPORTID,                            "
    bool ChannelInsertInfo::SaveScan(uint scanid, uint transportid) const 
    185185        "   :IN_PAT,            :IN_PMT,            :IN_VCT,             "
    186186        "   :IN_NIT,            :IN_SDT,            :IS_ENCRYPTED,       "
    187187        "   :IS_DATA_SERVICE,   :IS_AUDIO_SERVICE,  :IS_OPEBCABLE,       "
    188         "   :COULD_BE_OPENCABLE,:DECRYPTION_STATUS                       "
     188        "   :COULD_BE_OPENCABLE,:DECRYPTION_STATUS, :DEFAULT_AUTHORITY   "
    189189        " );");
    190190
    191191    query.bindValue(":SCANID", scanid);
    bool ChannelInsertInfo::SaveScan(uint scanid, uint transportid) const 
    225225    query.bindValue(":IS_OPEBCABLE", is_opencable);
    226226    query.bindValue(":COULD_BE_OPENCABLE", could_be_opencable);
    227227    query.bindValue(":DECRYPTION_STATUS", decryption_status);
     228    query.bindValue(":DEFAULT_AUTHORITY", default_authority);
    228229
    229230    if (!query.exec())
    230231    {
    ChannelInsertInfo::ChannelInsertInfo( 
    254255    bool    _in_nit,             bool    _in_sdt,
    255256    bool    _is_encrypted,       bool    _is_data_service,
    256257    bool    _is_audio_service,   bool    _is_opencable,
    257     bool    _could_be_opencable, int     _decryption_status) :
     258    bool    _could_be_opencable, int     _decryption_status,
     259    QString _default_authority) :
    258260    db_mplexid(_db_mplexid),
    259261    source_id(_source_id),
    260262    channel_id(_channel_id),
    ChannelInsertInfo::ChannelInsertInfo( 
    271273    icon(_icon),
    272274    format(_format),
    273275    xmltvid(_xmltvid),
     276    default_authority(_default_authority),
    274277    pat_tsid(_pat_tsid),
    275278    vct_tsid(_vct_tsid),
    276279    vct_chan_tsid(_vct_chan_tsid),
    ChannelInsertInfo::ChannelInsertInfo( 
    298301    icon.detach();
    299302    format.detach();
    300303    xmltvid.detach();
     304    default_authority.detach();
    301305    si_standard.detach();
    302306}
    303307
    ChannelInsertInfo &ChannelInsertInfo::operator=( 
    320324    icon               = other.icon;        icon.detach();
    321325    format             = other.format;      format.detach();
    322326    xmltvid            = other.xmltvid;     xmltvid.detach();
     327    default_authority  = other.default_authority; default_authority.detach();
    323328
    324329    // non-DB info
    325330    pat_tsid           = other.pat_tsid;
    void ChannelInsertInfo::ImportExtraInfo(const ChannelInsertInfo &other) 
    391396    {
    392397        xmltvid            = other.xmltvid;     xmltvid.detach();
    393398    }
     399    if (!other.default_authority.isEmpty() && default_authority.isEmpty())
     400    {
     401        default_authority  = other.default_authority; default_authority.detach();
     402    }
    394403    // non-DB info
    395404    if (other.pat_tsid && !pat_tsid)
    396405        pat_tsid           = other.pat_tsid;
  • mythtv/libs/libmythtv/dbchannelinfo.h

    diff --git a/mythtv/libs/libmythtv/dbchannelinfo.h b/mythtv/libs/libmythtv/dbchannelinfo.h
    index 5d1dc14..b2f9135 100644
    a b class MPUBLIC ChannelInsertInfo 
    9090        hidden(false), hidden_in_guide(false),
    9191        freqid(QString::null), icon(QString::null),
    9292        format(QString::null), xmltvid(QString::null),
     93        default_authority(QString::null),
    9394        pat_tsid(0), vct_tsid(0), vct_chan_tsid(0), sdt_tsid(0),
    9495        orig_netid(0), netid(0),
    9596        si_standard(QString::null),
    class MPUBLIC ChannelInsertInfo 
    128129
    129130        bool    _is_encrypted,       bool    _is_data_service,
    130131        bool    _is_audio_service,   bool    _is_opencable,
    131         bool    _could_be_opencable, int     _decryption_status);
     132        bool    _could_be_opencable, int     _decryption_status,
     133        QString _default_authority);
    132134
    133135    ChannelInsertInfo(const ChannelInsertInfo &other) { (*this = other); }
    134136    ChannelInsertInfo &operator=(const ChannelInsertInfo &other);
    class MPUBLIC ChannelInsertInfo 
    156158    QString icon;
    157159    QString format;
    158160    QString xmltvid;
     161    QString default_authority;
    159162
    160163    // non-DB info
    161164    uint    pat_tsid;
  • mythtv/libs/libmythtv/dtvmultiplex.cpp

    diff --git a/mythtv/libs/libmythtv/dtvmultiplex.cpp b/mythtv/libs/libmythtv/dtvmultiplex.cpp
    index 9a42aff..5b5db3f 100644
    a b bool ScanDTVTransport::FillFromDB(DTVTunerType type, uint mplexid) 
    429429        "       c.serviceid,     c.atsc_major_chan, c.atsc_minor_chan, "
    430430        "       c.useonairguide, c.visible,         c.freqid,          "
    431431        "       c.icon,          c.tvformat,        c.xmltvid,         "
    432         "       d.transportid,   d.networkid                          "
     432        "       d.transportid,   d.networkid,       c.default_authority "
    433433        "FROM channel AS c, dtv_multiplex AS d "
    434434        "WHERE c.mplexid = :MPLEXID AND"
    435435        "      c.mplexid = d.mplexid");
    bool ScanDTVTransport::FillFromDB(DTVTunerType type, uint mplexid) 
    459459            QString::null,
    460460            false, false, false, false,
    461461            false, false, false, false,
    462             false, false, false, 0);
     462            false, false, false, 0,
     463            query.value(18).toString() /* default_authority */);
    463464
    464465        channels.push_back(chan);
    465466    }
  • mythtv/libs/libmythtv/dvbstreamhandler.cpp

    diff --git a/mythtv/libs/libmythtv/dvbstreamhandler.cpp b/mythtv/libs/libmythtv/dvbstreamhandler.cpp
    index d14a188..2a632b2 100644
    a b void DVBStreamHandler::RunSR(void) 
    462462
    463463bool DVBStreamHandler::AddPIDFilter(PIDInfo *info)
    464464{
    465 #ifdef DEBUG_PID_FILTERS
    466     VERBOSE(VB_RECORD, LOC + QString("AddPIDFilter(0x%1) priority %2")
     465//#ifdef DEBUG_PID_FILTERS
     466    VERBOSE(VB_IMPORTANT, LOC + QString("AddPIDFilter(0x%1) priority %2")
    467467            .arg(info->_pid, 0, 16).arg(GetPIDPriority(info->_pid)));
    468 #endif // DEBUG_PID_FILTERS
     468//#endif // DEBUG_PID_FILTERS
    469469
    470470    QMutexLocker writing_locker(&_pid_lock);
    471471    _pid_info[info->_pid] = info;