Ticket #5562: t5562_populate_default_authority.diff

File t5562_populate_default_authority.diff, 20.2 KB (added by Janne Grunau, 15 years ago)

untested

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

    diff --git a/mythtv/libs/libmythtv/channelscan/channelimporter.cpp b/mythtv/libs/libmythtv/channelscan/channelimporter.cpp
    index 9931128..65d9f3e 100644
    a b ScanDTVTransportList ChannelImporter::InsertChannels( 
    359359                        chan.atsc_minor_channel,
    360360                        chan.use_on_air_guide,
    361361                        chan.hidden, chan.hidden_in_guide,
    362                         chan.freqid);
     362                        chan.freqid,
     363                        QString::null,
     364                        QString::null,
     365                        QString::null,
     366                        chan.default_authority);
    363367                }
    364368            }
    365369
    ScanDTVTransportList ChannelImporter::UpdateChannels( 
    485489                    chan.atsc_minor_channel,
    486490                    chan.use_on_air_guide,
    487491                    chan.hidden, chan.hidden_in_guide,
    488                     chan.freqid);
     492                    chan.freqid,
     493                    QString::null,
     494                    QString::null,
     495                    QString::null,
     496                    chan.default_authority);
    489497            }
    490498
    491499            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 6328f0e..a81e7dc 100644
    a b  
    6565/// 10 seconds, so lets wait at least 30 seconds, in
    6666/// case of bad transmitter or lost packets.
    6767const uint ChannelScanSM::kDVBTableTimeout  = 30 * 1000;
     68/// The whole BAT & SDTo group comes round in 10s, so wait additional
     69/// 12 seconds to kDVBTableTimeout
     70const uint ChannelScanSM::kDVBoTableTimeout = ChannelScanSM::kDVBTableTimeout +
     71                                              12 * 1000;
    6872/// No logic here, lets just wait at least 10 seconds.
    6973const uint ChannelScanSM::kATSCTableTimeout = 10 * 1000;
    7074/// No logic here, lets just wait at least 15 seconds.
    ChannelScanSM::ChannelScanSM( 
    148152      wait_for_mpeg(false),
    149153      wait_for_atsc(false),
    150154      wait_for_dvb(false),
     155      wait_for_dvbo(false),
    151156      // Transports List
    152157      transportsScanned(0),
    153158      currentTestingDecryption(false),
    ChannelScanSM::ChannelScanSM( 
    183188        data->AddMPEGListener(this);
    184189        data->AddATSCMainListener(this);
    185190        data->AddDVBMainListener(this);
     191        data->AddDVBOtherListener(this);
    186192    }
    187193}
    188194
    void ChannelScanSM::HandleMGT(const MasterGuideTable *mgt) 
    371377    UpdateChannelInfo(true);
    372378}
    373379
    374 void ChannelScanSM::HandleSDT(uint, const ServiceDescriptionTable *sdt)
     380void ChannelScanSM::HandleSDT(uint tsid, const ServiceDescriptionTable *sdt)
    375381{
    376382    VERBOSE(VB_CHANSCAN, LOC +
    377383            QString("Got a Service Description Table for %1")
    void ChannelScanSM::HandleNIT(const NetworkInformationTable *nit) 
    395401            QString("Got a Network Information Table for %1")
    396402            .arg((*current).FriendlyName) + "\n" + nit->toString());
    397403
     404    uint netid = nit->NetworkID();
     405
     406    // If this is Astra 28.2 add start listening for Freesat BAT and SDTo
     407    if (!wait_for_dvbo && (netid == 2 || netid == 59))
     408    {
     409        GetDTVSignalMonitor()->GetScanStreamData()->SetFreesatAdditionalSI(true);
     410        wait_for_dvbo = true;
     411    }
     412
    398413    wait_for_dvb = true;
    399414    UpdateChannelInfo(true);
    400415}
    401416
     417void ChannelScanSM::HandleBAT(const BouquetAssociationTable *bat)
     418{
     419    VERBOSE(VB_CHANSCAN, LOC + "Got a Bouquet Association Table\n" +
     420            bat->toString());
     421
     422    for (uint i = 0; i < bat->TransportStreamCount(); i++)
     423    {
     424        uint tsid = bat->TSID(i);
     425        uint netid = bat->OriginalNetworkID(i);
     426        desc_list_t parsed =
     427            MPEGDescriptor::Parse(bat->TransportDescriptors(i),
     428                                  bat->TransportDescriptorsLength(i));
     429        // Look for default authority
     430        const unsigned char *def_auth =
     431            MPEGDescriptor::Find(parsed, DescriptorID::default_authority);
     432        const unsigned char *serv_list =
     433            MPEGDescriptor::Find(parsed, DescriptorID::service_list);
     434
     435        if (def_auth && serv_list)
     436        {
     437            DefaultAuthorityDescriptor authority(def_auth);
     438            ServiceListDescriptor services(serv_list);
     439
     440            for (uint j = 0; j < services.ServiceCount(); j++)
     441            {
     442               // If the default authority is given in the SDT this
     443               // overrides any definition in the BAT (or in the NIT)
     444               uint64_t index =
     445                   ((uint64_t)netid << 32) | (tsid << 16) | services.ServiceID(j);
     446               if (! defAuthorities.contains(index))
     447                   defAuthorities[index] = authority.DefaultAuthority();
     448            }
     449        }
     450    }
     451    UpdateChannelInfo(true);
     452}
     453
     454void ChannelScanSM::HandleSDTo(uint tsid, const ServiceDescriptionTable *sdt)
     455{
     456    VERBOSE(VB_CHANSCAN, LOC + "Got a Service Description Table (other)\n" +
     457            sdt->toString());
     458
     459    uint netid = sdt->OriginalNetworkID();
     460
     461    for (uint i = 0; i < sdt->ServiceCount(); i++)
     462    {
     463        uint serviceId = sdt->ServiceID(i);
     464        desc_list_t parsed =
     465            MPEGDescriptor::Parse(sdt->ServiceDescriptors(i),
     466                                  sdt->ServiceDescriptorsLength(i));
     467        // Look for default authority
     468        const unsigned char *def_auth =
     469            MPEGDescriptor::Find(parsed, DescriptorID::default_authority);
     470        if (def_auth)
     471        {
     472            DefaultAuthorityDescriptor authority(def_auth);
     473            defAuthorities[((uint64_t)netid << 32) | (tsid << 16) | serviceId] =
     474                authority.DefaultAuthority();
     475        }
     476    }
     477    UpdateChannelInfo(true);
     478}
     479
    402480void ChannelScanSM::HandleEncryptionStatus(uint pnum, bool encrypted)
    403481{
    404482    currentEncryptionStatus[pnum] = encrypted ? kEncEncrypted : kEncDecrypted;
    bool ChannelScanSM::UpdateChannelInfo(bool wait_until_complete) 
    783861        currentEncryptionStatus.clear();
    784862        currentEncryptionStatusChecked.clear();
    785863
    786         wait_for_mpeg = wait_for_atsc = wait_for_dvb = false;
     864        wait_for_mpeg = wait_for_atsc = wait_for_dvb = wait_for_dvbo = false;
    787865
    788866        if (scanning)
    789867        {
    static void update_info(ChannelInsertInfo &info, 
    848926}
    849927
    850928static void update_info(ChannelInsertInfo &info,
    851                         const ServiceDescriptionTable *sdt, uint i)
     929                        const ServiceDescriptionTable *sdt, uint i,
     930                        const QMap<uint64_t, QString> &defAuthorities)
    852931{
    853932    // HACK beg -- special exception for this network
    854933    //             (dbver == "1067")
    static void update_info(ChannelInsertInfo &info, 
    887966        (desc && !desc->IsDTV() && !desc->IsDigitalAudio());
    888967    info.is_audio_service = (desc && desc->IsDigitalAudio());
    889968
     969    info.service_id = sdt->ServiceID(i);
    890970    info.sdt_tsid   = sdt->TSID();
    891971    info.orig_netid = sdt->OriginalNetworkID();
    892972    info.in_sdt     = true;
     973
     974    desc_list_t parsed =
     975        MPEGDescriptor::Parse(sdt->ServiceDescriptors(i),
     976                                sdt->ServiceDescriptorsLength(i));
     977    // Look for default authority
     978    const unsigned char *def_auth =
     979        MPEGDescriptor::Find(parsed, DescriptorID::default_authority);
     980    if (def_auth)
     981    {
     982        DefaultAuthorityDescriptor authority(def_auth);
     983        info.default_authority = authority.DefaultAuthority();
     984    }
     985    else
     986    {
     987        uint64_t index = (uint64_t)info.orig_netid << 32 |
     988                         info.sdt_tsid << 16 | info.service_id;
     989        if (defAuthorities.contains(index))
     990            info.default_authority = defAuthorities[index];
     991    }
    893992}
    894993
    895994uint ChannelScanSM::GetCurrentTransportInfo(
    ChannelScanSM::GetChannelList(transport_scan_items_it_t trans_info, 
    10401139            {
    10411140                uint pnum = (*sdt_it)->ServiceID(i);
    10421141                PCM_INFO_INIT("dvb");
    1043                 update_info(info, *sdt_it, i);
     1142                update_info(info, *sdt_it, i, defAuthorities);
    10441143            }
    10451144        }
    10461145    }
    bool ChannelScanSM::HasTimedOut(void) 
    12951394        if (wait_for_dvb  && !sd->HasCachedAllNIT() && !sd->HasCachedAllSDTs())
    12961395            max_timeout = max(max_timeout, (int) kDVBTableTimeout);
    12971396
     1397        if (wait_for_dvbo)
     1398            max_timeout = max(max_timeout, (int) kDVBoTableTimeout);
     1399
    12981400        if (wait_for_atsc && !sd->HasCachedMGT()    && !sd->HasCachedAllVCTs())
    12991401            max_timeout = max(max_timeout, (int) kATSCTableTimeout);
    13001402
  • 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 5946546..d7e8087 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, 
    213220    bool              wait_for_mpeg;
    214221    bool              wait_for_atsc;
    215222    bool              wait_for_dvb;
     223    bool              wait_for_dvbo;
    216224
    217225    // Transports List
    218226    int                         transportsScanned;
    class ChannelScanSM : public MPEGStreamListener, 
    223231    bool                        currentTestingDecryption;
    224232    QMap<uint, uint>            currentEncryptionStatus;
    225233    QMap<uint, bool>            currentEncryptionStatusChecked;
     234    QMap<uint64_t, QString>     defAuthorities;
    226235
    227236    /// Found Channel Info
    228237    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 ebe3be3..d28896b 100644
    a b bool ScanDTVTransport::FillFromDB(DTVTunerType type, uint mplexid) 
    425425        "       c.serviceid,     c.atsc_major_chan, c.atsc_minor_chan, "
    426426        "       c.useonairguide, c.visible,         c.freqid,          "
    427427        "       c.icon,          c.tvformat,        c.xmltvid,         "
    428         "       d.transportid,   d.networkid                          "
     428        "       d.transportid,   d.networkid,       c.default_authority "
    429429        "FROM channel AS c, dtv_multiplex AS d "
    430430        "WHERE c.mplexid = :MPLEXID AND"
    431431        "      c.mplexid = d.mplexid");
    bool ScanDTVTransport::FillFromDB(DTVTunerType type, uint mplexid) 
    455455            QString::null,
    456456            false, false, false, false,
    457457            false, false, false, false,
    458             false, false, false, 0);
     458            false, false, false, 0,
     459            query.value(18).toString() /* default_authority */);
    459460
    460461        channels.push_back(chan);
    461462    }
  • mythtv/libs/libmythtv/mpeg/mpegtables.h

    diff --git a/mythtv/libs/libmythtv/mpeg/mpegtables.h b/mythtv/libs/libmythtv/mpeg/mpegtables.h
    index 678acc0..7aa5c27 100644
    a b enum 
    197197    PREMIERE_EIT_SPORT_PID  = 0x0b12,
    198198
    199199    ATSC_PSIP_PID = 0x1ffb,
     200
     201    // UK Freesat PIDs: SDTo/BAT, longterm EIT, shortterm EIT
     202    FREESAT_SI_PID     = 0x0f01,
     203    FREESAT_EIT_PID    = 0x0f02,
     204    FREESAT_ST_EIT_PID = 0x0f03,
    200205};
    201206
    202207/** \class TableID
  • mythtv/libs/libmythtv/mpeg/scanstreamdata.cpp

    diff --git a/mythtv/libs/libmythtv/mpeg/scanstreamdata.cpp b/mythtv/libs/libmythtv/mpeg/scanstreamdata.cpp
    index af48f3b..56c49d4 100644
    a b  
    77ScanStreamData::ScanStreamData()
    88    : MPEGStreamData(-1, true),
    99      ATSCStreamData(-1,-1, true),
    10       DVBStreamData(0, 0, -1, true)
     10      DVBStreamData(0, 0, -1, true),
     11      dvb_uk_freesat_si(false)
    1112{
    1213}
    1314
    ScanStreamData::~ScanStreamData() { ; } 
    1819 */
    1920bool ScanStreamData::IsRedundant(uint pid, const PSIPTable &psip) const
    2021{
     22    // Treat BAT and SDTo as redundant unless they are on the FREESAT_SI_PID
     23    if (dvb_uk_freesat_si &&
     24        (psip.TableID() == TableID::BAT || psip.TableID() == TableID::SDTo))
     25        return pid != FREESAT_SI_PID;
     26
    2127    return (ATSCStreamData::IsRedundant(pid,psip) ||
    2228            DVBStreamData::IsRedundant(pid,psip));
    2329}
    void ScanStreamData::Reset(void) 
    4248    AddListeningPID(ATSC_PSIP_PID);
    4349    AddListeningPID(DVB_NIT_PID);
    4450    AddListeningPID(DVB_SDT_PID);
     51    if (dvb_uk_freesat_si)
     52        AddListeningPID(FREESAT_SI_PID);
    4553}
    4654
    4755QString ScanStreamData::GetSIStandard(QString guess) const
  • mythtv/libs/libmythtv/mpeg/scanstreamdata.h

    diff --git a/mythtv/libs/libmythtv/mpeg/scanstreamdata.h b/mythtv/libs/libmythtv/mpeg/scanstreamdata.h
    index e9ab448..17cad5b 100644
    a b class ScanStreamData : 
    2828
    2929    QString GetSIStandard(QString guess = "mpeg") const;
    3030
     31    void SetFreesatAdditionalSI(bool freesat_si);
     32
    3133  private:
    3234    virtual bool DeleteCachedTable(PSIPTable *psip) const; 
     35    /// listen for addiotional Freesat service information
     36    int dvb_uk_freesat_si;
    3337};
    3438
     39inline void ScanStreamData::SetFreesatAdditionalSI(bool freesat_si)
     40{
     41    QMutexLocker locker(&_listener_lock);
     42    dvb_uk_freesat_si = freesat_si;
     43}
     44
    3545#endif // SCANSTREAMDATA_H_