Ticket #5562: defaultauthority_patch2-0-22-fixes-r23473.patch

File defaultauthority_patch2-0-22-fixes-r23473.patch, 9.1 KB (added by Douglas Mackay <douglas.mackay@…>, 14 years ago)
  • mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp

    diff -aur a/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp b/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
    a b  
    146146      sourceID(_sourceID),
    147147      signalTimeout(signal_timeout),
    148148      channelTimeout(channel_timeout),
     149      otherTableTimeout(0),
     150      otherTableTime(0),
     151      setOtherTables(false),
    149152      inputname(_inputname),
    150153      m_test_decryption(test_decryption),
    151154      extend_scan_list(false),
     
    190193        data->AddMPEGListener(this);
    191194        data->AddATSCMainListener(this);
    192195        data->AddDVBMainListener(this);
     196        data->AddDVBOtherListener(this);
    193197    }
    194198}
    195199
     
    375379    UpdateChannelInfo(true);
    376380}
    377381
    378 void ChannelScanSM::HandleSDT(uint, const ServiceDescriptionTable *sdt)
     382void ChannelScanSM::HandleSDT(uint tsid, const ServiceDescriptionTable *sdt)
    379383{
    380384    VERBOSE(VB_CHANSCAN, LOC +
    381385            QString("Got a Service Description Table for %1")
    382386            .arg((*current).FriendlyName) + "\n" + sdt->toString());
    383387
     388    // If this is Astra 28.2 add start listening for Freesat BAT and SDTo
     389    if (!setOtherTables && (sdt->OriginalNetworkID() == 2 || sdt->OriginalNetworkID() == 59))
     390    {
     391        GetDTVSignalMonitor()->GetScanStreamData()->SetFreesatAdditionalSI(true);
     392        setOtherTables = true;
     393        otherTableTimeout = 10000; // The whole BAT & SDTo group comes round in 10s
     394        // Delay processing the SDT until we've seen BATs and SDTos
     395        otherTableTime = timer.elapsed() + otherTableTimeout;
     396
     397        VERBOSE(VB_CHANSCAN, LOC + QString("SDT has OriginalNetworkID %1, look for "
     398                                            "additional Freesat SI").arg(sdt->OriginalNetworkID()));
     399    }
     400
     401    if (timer.elapsed() < otherTableTime)
     402    {
     403        // Set the version for the SDT so we see it again.
     404        GetDTVSignalMonitor()->GetDVBStreamData()->SetVersionSDT(sdt->TSID(), -1, 0);
     405    }
     406
    384407    uint id = sdt->OriginalNetworkID() << 16 | sdt->TSID();
    385408    ts_scanned.insert(id);
    386409
     
    404427    UpdateChannelInfo(true);
    405428}
    406429
     430void ChannelScanSM::HandleBAT(const BouquetAssociationTable *bat)
     431{
     432    VERBOSE(VB_CHANSCAN, LOC + "Got a Bouquet Association Table\n" +
     433            bat->toString());
     434
     435    otherTableTime = timer.elapsed() + otherTableTimeout;
     436
     437    for (uint i = 0; i < bat->TransportStreamCount(); i++)
     438    {
     439        uint tsid = bat->TSID(i);
     440        uint netid = bat->OriginalNetworkID(i);
     441        desc_list_t parsed =
     442            MPEGDescriptor::Parse(bat->TransportDescriptors(i),
     443                                  bat->TransportDescriptorsLength(i));
     444        // Look for default authority
     445        const unsigned char *def_auth =
     446            MPEGDescriptor::Find(parsed, DescriptorID::default_authority);
     447        const unsigned char *serv_list =
     448            MPEGDescriptor::Find(parsed, DescriptorID::service_list);
     449
     450        if (def_auth && serv_list)
     451        {
     452            DefaultAuthorityDescriptor authority(def_auth);
     453            ServiceListDescriptor services(serv_list);
     454
     455            for (uint j = 0; j < services.ServiceCount(); j++)
     456            {
     457               // If the default authority is given in the SDT this
     458               // overrides any definition in the BAT (or in the NIT)
     459                VERBOSE(VB_CHANSCAN, LOC + QString("found default authority(BAT) "
     460                                                    "for service %1 %2 %3")
     461                        .arg(netid).arg(tsid).arg(services.ServiceID(j)));
     462               uint64_t index =
     463                   ((uint64_t)netid << 32) | (tsid << 16) | services.ServiceID(j);
     464               if (! defAuthorities.contains(index))
     465                   defAuthorities[index] = authority.DefaultAuthority();
     466            }
     467        }
     468    }
     469}
     470
     471void ChannelScanSM::HandleSDTo(uint tsid, const ServiceDescriptionTable *sdt)
     472{
     473    VERBOSE(VB_CHANSCAN, LOC + "Got a Service Description Table (other)\n" +
     474            sdt->toString());
     475
     476    otherTableTime = timer.elapsed() + otherTableTimeout;
     477
     478    uint netid = sdt->OriginalNetworkID();
     479
     480    for (uint i = 0; i < sdt->ServiceCount(); i++)
     481    {
     482        uint serviceId = sdt->ServiceID(i);
     483        desc_list_t parsed =
     484            MPEGDescriptor::Parse(sdt->ServiceDescriptors(i),
     485                                  sdt->ServiceDescriptorsLength(i));
     486        // Look for default authority
     487        const unsigned char *def_auth =
     488            MPEGDescriptor::Find(parsed, DescriptorID::default_authority);
     489        if (def_auth)
     490        {
     491            DefaultAuthorityDescriptor authority(def_auth);
     492            VERBOSE(VB_CHANSCAN, LOC + QString("found default authority(SDTo) "
     493                                                "for service %1 %2 %3")
     494                    .arg(netid).arg(tsid).arg(serviceId));
     495            defAuthorities[((uint64_t)netid << 32) | (tsid << 16) | serviceId] =
     496                authority.DefaultAuthority();
     497        }
     498    }
     499}
     500
    407501void ChannelScanSM::HandleEncryptionStatus(uint pnum, bool encrypted)
    408502{
    409503    currentEncryptionStatus[pnum] = encrypted ? kEncEncrypted : kEncDecrypted;
     
    660754    }
    661755
    662756    // DVB
    663     if ((!wait_until_complete || sd->HasCachedAllNIT()) && currentInfo->nits.empty())
     757    if ((!wait_until_complete || sd->HasCachedAllNIT()) && (currentInfo->nits.empty() ||
     758        timer.elapsed() > (int)otherTableTime))
     759    {
    664760        currentInfo->nits = sd->GetCachedNIT();
     761    }
    665762
    666763    sdt_vec_t sdttmp = sd->GetCachedSDTs();
    667764    tsid_checked.clear();
     
    823920        currentEncryptionStatus.clear();
    824921        currentEncryptionStatusChecked.clear();
    825922
     923        setOtherTables = false;
     924        otherTableTime = 0;
     925
    826926        if (scanning)
    827927        {
    828928            transportsScanned++;
     
    886986}
    887987
    888988static void update_info(ChannelInsertInfo &info,
    889                         const ServiceDescriptionTable *sdt, uint i)
     989                        const ServiceDescriptionTable *sdt, uint i,
     990                        const QMap<uint64_t, QString> &defAuthorities)
    890991{
    891992    // HACK beg -- special exception for this network
    892993    //             (dbver == "1067")
     
    9251026        (desc && !desc->IsDTV() && !desc->IsDigitalAudio());
    9261027    info.is_audio_service = (desc && desc->IsDigitalAudio());
    9271028
     1029    info.service_id = sdt->ServiceID(i);
    9281030    info.sdt_tsid   = sdt->TSID();
    9291031    info.orig_netid = sdt->OriginalNetworkID();
    9301032    info.in_sdt     = true;
     
    9381040    if (def_auth)
    9391041    {
    9401042        DefaultAuthorityDescriptor authority(def_auth);
     1043        VERBOSE(VB_CHANSCAN, QString("found default authority(SDT) "
     1044                                            "for service %1 %2 %3")
     1045                .arg(info.orig_netid).arg(info.sdt_tsid).arg(info.service_id));
    9411046        info.default_authority = authority.DefaultAuthority();
    9421047    }
     1048    else
     1049    {
     1050        uint64_t index = (uint64_t)info.orig_netid << 32 |
     1051                        info.sdt_tsid << 16 | info.service_id;
     1052        if (defAuthorities.contains(index))
     1053            info.default_authority = defAuthorities[index];
     1054    }
    9431055}
    9441056
    9451057uint ChannelScanSM::GetCurrentTransportInfo(
     
    10901202            {
    10911203                uint pnum = (*sdt_it)->ServiceID(i);
    10921204                PCM_INFO_INIT("dvb");
    1093                 update_info(info, *sdt_it, i);
     1205                update_info(info, *sdt_it, i, defAuthorities);
    10941206            }
    10951207        }
    10961208    }
  • mythtv/libs/libmythtv/channelscan/channelscan_sm.h

    diff -aur a/mythtv/libs/libmythtv/channelscan/channelscan_sm.h b/mythtv/libs/libmythtv/channelscan/channelscan_sm.h
    a b  
    8383
    8484class ChannelScanSM : public MPEGStreamListener,
    8585                      public ATSCMainStreamListener,
    86                       public DVBMainStreamListener
     86                      public DVBMainStreamListener,
     87                      public DVBOtherStreamListener
    8788{
    8889    friend class AnalogSignalHandler;
    8990
     
    146147    void HandleSDT(uint tsid, const ServiceDescriptionTable*);
    147148    void HandleTDT(const TimeDateTable*) {}
    148149
     150    // DVB Other
     151    void HandleNITo(const NetworkInformationTable*) {}
     152    void HandleSDTo(uint tsid, const ServiceDescriptionTable*);
     153    void HandleBAT(const BouquetAssociationTable*);
     154
    149155  private:
    150156    // some useful gets
    151157    DTVChannel       *GetDTVChannel(void);
     
    203209    int               sourceID;
    204210    uint              signalTimeout;
    205211    uint              channelTimeout;
     212    uint              otherTableTimeout;
     213    uint              otherTableTime;
     214    bool              setOtherTables;
    206215    QString           inputname;
    207216    bool              m_test_decryption;
    208217    bool              extend_scan_list;
     
    226235    bool                        currentTestingDecryption;
    227236    QMap<uint, uint>            currentEncryptionStatus;
    228237    QMap<uint, bool>            currentEncryptionStatusChecked;
     238    QMap<uint64_t, QString>     defAuthorities;
    229239
    230240    /// Found Channel Info
    231241    ChannelList       channelList;