From d4237739aa06ca4c79bdd1daf14d04c5167d7a82 Mon Sep 17 00:00:00 2001 From: Klaas de Waal Date: Fri, 19 Jul 2024 18:39:02 +0200 Subject: [PATCH] Fix MPTS channel creation MPTS channel creation can be selected at the channel scan; if selected then one additional channel is created per transport stream which can be used to make recordings of the complete transport stream. An MPTS channel is created as a copy of an existing channel in the same transport stream. It did however happen that during the post processing the MPTS channel was discarded because of the "Logical Channel Numbers Required" or the "Complete Scan Data Required" options when the existing channel did not meet these criteria. This is now fixed by selecting an existing channel that has "Complete Scan Data", i.e. it does appear in PAT and PMT, and by setting a value for the logical channel number. --- .../libmythtv/channelscan/channelscan_sm.cpp | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp b/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp index 2a174bf9e72..c7413ba06fd 100644 --- a/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp +++ b/mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp @@ -548,12 +548,7 @@ void ChannelScanSM::HandleBAT(const BouquetAssociationTable *bat) ServiceListDescriptor services(serv_list); if (!authority.IsValid() || !services.IsValid()) continue; -#if 0 - LOG(VB_CHANSCAN, LOG_DEBUG, LOC + - QString("Found default authority '%1' in BAT for services in nid %2 tid %3") - .arg(authority.DefaultAuthority()) - .arg(netid).arg(tsid)); -#endif + for (uint j = 0; j < services.ServiceCount(); ++j) { // If the default authority is given in the SDT this @@ -575,12 +570,12 @@ void ChannelScanSM::HandleBAT(const BouquetAssociationTable *bat) void ChannelScanSM::HandleSDTo(uint tsid, const ServiceDescriptionTable *sdt) { QMutexLocker locker(&m_lock); - - LOG(VB_CHANSCAN, LOG_INFO, LOC + +#if 0 + LOG(VB_CHANSCAN, LOG_DEBUG, LOC + QString("Got a Service Description Table (other) for Transport ID %1 section %2/%3") .arg(tsid).arg(sdt->Section()).arg(sdt->LastSection())); LogLines(sdt->toString()); - +#endif m_otherTableTime = std::chrono::milliseconds(m_timer.elapsed()) + m_otherTableTimeout; uint netid = sdt->OriginalNetworkID(); @@ -1832,17 +1827,35 @@ ScanDTVTransportList ChannelScanSM::GetChannelList(bool addFullTS) const if (!item.m_channels.empty()) { + // Add a MPTS channel which can be used to record the entire transport + // stream multiplex. These recordings can be used in stream analyzer software. if (addFullTS) { - /* If addFullTS, then add a 'MPTS' channel - which can be used to record the entire MPTS from - the transport. */ - dbchan_it = pnum_to_dbchan.begin(); - ChannelInsertInfo info = *dbchan_it; - - // Use transport stream ID as (fake) service ID - // to use in callsign and as channel number + // Find the first channel that is present in PAT/PMT and use that as + // template for the new MPTS channel. + ChannelInsertInfo info {}; + for (auto & channel : pnum_to_dbchan) + { + if (channel.m_inPat && channel.m_inPmt) + { + info = channel; + break; + } + } + + // If we cannot find a valid channel then use the first channel in + // the list as template for the new MPTS channel. + if (info.m_serviceId == 0) + { + dbchan_it = pnum_to_dbchan.begin(); + info = *dbchan_it; + } + + // Use transport stream ID as (fake) service ID to use in callsign + // and as channel number. info.m_serviceId = info.m_sdtTsId ? info.m_sdtTsId : info.m_patTsId; + info.m_chanNum = QString("%1").arg(info.m_serviceId); + info.m_logicalChannel = info.m_serviceId; if (tuner_type == DTVTunerType::kTunerTypeASI) {