Skip to content

Commit

Permalink
Number of transports in mythtv-setup log output
Browse files Browse the repository at this point in the history
The number of transports in the summary of the log output
is now always the number of transports found in the scan.
In the processing of the scan results, at some point all
transports of channels in the database that are not found in the scan,
called the off-air channels, are added to the list of transports.
This caused an incorrect number of transports to be presented.
This is now fixed.
Also added a summary of the scan parameters in the log output.
Also added, when option -v chanscan is given, a separate
listing of all transports found, in order of ascending frequency.

Refs #13472
  • Loading branch information
kmdewaal committed Sep 6, 2019
1 parent d63aa66 commit 6ab6329
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 4 deletions.
69 changes: 65 additions & 4 deletions mythtv/libs/libmythtv/channelscan/channelimporter.cpp
Expand Up @@ -65,6 +65,18 @@ void ChannelImporter::Process(const ScanDTVTransportList &_transports,

ScanDTVTransportList transports = _transports;

// Print some scan parameters
{
cout << endl << "Scan parameters:" << endl;
bool require_av = (m_service_requirements & kRequireAV) == kRequireAV;
bool require_a = (m_service_requirements & kRequireAudio) != 0;
cout << "Desired Services : " << (require_av ? "tv" : require_a ? "radio" : "all") << endl;
cout << "Unencrypted Only : " << (m_fta_only ? "yes" : "no") << endl;
cout << "Logical Channel Numbers : " << (m_lcn_only ? "yes" : "no") << endl;
cout << "Complete scan data required : " << (m_complete_only ? "yes" : "no") << endl;
cout << "Full search for old channels: " << (m_full_channel_search ? "yes" : "no") << endl;
}

// Print out each channel
if (VERBOSE_LEVEL_CHECK(VB_CHANSCAN, LOG_ANY))
{
Expand All @@ -83,14 +95,23 @@ void ChannelImporter::Process(const ScanDTVTransportList &_transports,

FilterServices(transports);

// Pull in DB info
// Print out each transport
uint transports_scanned_size = transports.size();
if (VERBOSE_LEVEL_CHECK(VB_CHANSCAN, LOG_ANY))
{
cout << endl;
cout << "Transport list (" << transports_scanned_size << "):" << endl;
cout << FormatTransports(transports).toLatin1().constData() << endl;
}

// Pull in DB info in transports
// Channels not found in scan but only in DB are returned in db_trans
sourceid = transports[0].m_channels[0].m_source_id;
ScanDTVTransportList db_trans = GetDBTransports(sourceid, transports);

// Make sure "Open Cable" channels are marked that way.
FixUpOpenCable(transports);


// All channels in the scan after comparing with the database
if (VERBOSE_LEVEL_CHECK(VB_CHANSCAN, LOG_ANY))
{
Expand All @@ -101,7 +122,8 @@ void ChannelImporter::Process(const ScanDTVTransportList &_transports,
cout << endl;
}

// If scan was not aborted prematurely..
// Add channels from the DB to the channels from the scan
// and possibly delete one or more of the off-air channels
if (m_do_delete)
{
ScanDTVTransportList trans = transports;
Expand All @@ -125,7 +147,7 @@ void ChannelImporter::Process(const ScanDTVTransportList &_transports,
cout << FormatChannels(transports, &info).toLatin1().constData() << endl;

// Create summary
QString msg = GetSummary(transports.size(), info, stats);
QString msg = GetSummary(transports_scanned_size, info, stats);
cout << msg.toLatin1().constData() << endl << endl;

if (m_do_insert)
Expand Down Expand Up @@ -158,6 +180,8 @@ QString ChannelImporter::toString(ChannelType type)
return "Unknown";
}

// Ask user what to do with the off-air channels
//
uint ChannelImporter::DeleteChannels(
ScanDTVTransportList &transports)
{
Expand Down Expand Up @@ -977,6 +1001,9 @@ void ChannelImporter::FilterServices(ScanDTVTransportList &transports) const
/** \fn ChannelImporter::GetDBTransports(uint,ScanDTVTransportList&) const
* \brief Adds found channel info to transports list,
* returns channels in DB which were not found in scan
* in another transport list. This can be the same transport
* if e.g. one channel is in the DB but not in the scan, but
* it can also contain transports that are not found in the scan.
*/
ScanDTVTransportList ChannelImporter::GetDBTransports(
uint sourceid, ScanDTVTransportList &transports) const
Expand Down Expand Up @@ -1364,6 +1391,40 @@ QString ChannelImporter::FormatChannels(
return msg;
}

QString ChannelImporter::FormatTransport(
const ScanDTVTransport &transport)
{
QString msg;
QTextStream ssMsg(&msg);

ssMsg << transport.m_modulation.toString().toLatin1().constData() << ":";
ssMsg << transport.m_frequency;

return msg;
}

QString ChannelImporter::FormatTransports(
const ScanDTVTransportList &transports_in)
{
// Sort transports in order of increasing frequency
struct less_than_key
{
inline bool operator() (const ScanDTVTransport &t1, const ScanDTVTransport &t2)
{
return t1.m_frequency < t2.m_frequency;
}
};
ScanDTVTransportList transports(transports_in);
std::sort(transports.begin(), transports.end(), less_than_key());

QString msg;

for (size_t i = 0; i < transports.size(); ++i)
msg += FormatTransport(transports[i]) + "\n";

return msg;
}

QString ChannelImporter::GetSummary(
uint transport_count,
const ChannelImporterBasicStats &info,
Expand Down
6 changes: 6 additions & 0 deletions mythtv/libs/libmythtv/channelscan/channelimporter.h
Expand Up @@ -219,6 +219,12 @@ class MTV_PUBLIC ChannelImporter
const ScanDTVTransport &transport,
const ChannelInsertInfo &chan);

static QString FormatTransport(
const ScanDTVTransport &transport);

static QString FormatTransports(
const ScanDTVTransportList &transports_in);

static QString GetSummary(
uint transport_count,
const ChannelImporterBasicStats &info,
Expand Down

0 comments on commit 6ab6329

Please sign in to comment.