Permalink
Browse files

Fix Channel Tuning Broken with DVB-C (Ziggo), closes #7486

Credits Christian Güdel, Dibblah and Klaas de Waal
  • Loading branch information...
1 parent 65913e7 commit 121944723e49bc81cbc31f7db932b97c612726d6 @bas-t committed Jul 6, 2012
@@ -177,6 +177,23 @@ ChannelScanSM::ChannelScanSM(
{
LOG(VB_CHANSCAN, LOG_INFO, LOC + "Connecting up DTVSignalMonitor");
ScanStreamData *data = new ScanStreamData();
+
+ MSqlQuery query(MSqlQuery::InitCon());
+ query.prepare(
+ "SELECT dvb_nit_id "
+ "FROM videosource "
+ "WHERE videosource.sourceid = :SOURCEID");
+ query.bindValue(":SOURCEID", _sourceID);
+ if (!query.exec() || !query.isActive())
+ {
+ MythDB::DBError("ChannelScanSM", query);
+ }
+ else if (query.next())
+ {
+ uint nitid = query.value(0).toInt();
+ data->SetRealNetworkID(nitid);
+ LOG(VB_CHANSCAN, LOG_INFO, LOC + QString("Setting NIT-ID to %1").arg(nitid));
+ }
dtvSigMon->SetStreamData(data);
dtvSigMon->AddFlags(SignalMonitor::kDTVSigMon_WaitForMGT |
@@ -234,6 +234,19 @@ bool DVBStreamData::HandleTables(uint pid, const PSIPTable &psip)
{
case TableID::NIT:
{
+ if (_dvb_real_network_id >= 0 && psip.TableIDExtension() != (uint)_dvb_real_network_id)
+ {
+ NetworkInformationTable *nit = new NetworkInformationTable(psip);
+ if (!nit->Mutate())
+ {
+ delete nit;
+ return true;
+ }
+ bool retval = HandleTables(pid, *nit);
+ delete nit;
+ return retval;
+ }
+
SetVersionNIT(psip.Version(), psip.LastSection());
SetNITSectionSeen(psip.Section());
@@ -291,6 +304,19 @@ bool DVBStreamData::HandleTables(uint pid, const PSIPTable &psip)
}
case TableID::NITo:
{
+ if (_dvb_real_network_id >= 0 && psip.TableIDExtension() == (uint)_dvb_real_network_id)
+ {
+ NetworkInformationTable *nit = new NetworkInformationTable(psip);
+ if (!nit->Mutate())
+ {
+ delete nit;
+ return true;
+ }
+ bool retval = HandleTables(pid, *nit);
+ delete nit;
+ return retval;
+ }
+
SetVersionNITo(psip.Version(), psip.LastSection());
SetNIToSectionSeen(psip.Section());
NetworkInformationTable nit(psip);
@@ -41,6 +41,9 @@ class MTV_PUBLIC DVBStreamData : virtual public MPEGStreamData
bool IsRedundant(uint pid, const PSIPTable&) const;
void ProcessSDT(uint tsid, const ServiceDescriptionTable*);
+ // NIT for broken providers
+ inline void SetRealNetworkID(int);
+
// EIT info/processing
inline void SetDishNetEIT(bool);
inline bool HasAnyEIT(void) const;
@@ -213,6 +216,9 @@ class MTV_PUBLIC DVBStreamData : virtual public MPEGStreamData
uint _desired_netid;
uint _desired_tsid;
+ // Real network ID for broken providers
+ int _dvb_real_network_id;
+
/// Decode DishNet's long-term DVB EIT
bool _dvb_eit_dishnet_long;
/// Tell us if the DVB service has EIT
@@ -252,6 +258,12 @@ inline void DVBStreamData::SetDishNetEIT(bool use_dishnet_eit)
_dvb_eit_dishnet_long = use_dishnet_eit;
}
+inline void DVBStreamData::SetRealNetworkID(int real_network_id)
+{
+ QMutexLocker locker(&_listener_lock);
+ _dvb_real_network_id = real_network_id;
+}
+
inline bool DVBStreamData::HasAnyEIT(void) const
{
QMutexLocker locker(&_listener_lock);
@@ -78,6 +78,17 @@ QString NetworkInformationTable::NetworkName() const
return _cached_network_name;
}
+bool NetworkInformationTable::Mutate(void)
+{
+ if (VerifyCRC())
+ {
+ SetTableID((TableID() == TableID::NITo) ? TableID::NIT : TableID::NITo);
+ SetCRC(CalcCRC());
+ return true;
+ }
+ else
+ return false;
+}
void ServiceDescriptionTable::Parse(void) const
{
@@ -81,6 +81,9 @@ class MTV_PUBLIC NetworkInformationTable : public PSIPTable
{ return _ptrs[i]+6; }
// }
+ /// mutates a NITo into a NITa (vice versa) and recalculates the CRC
+ bool Mutate(void);
+
void Parse(void) const;
QString toString(void) const;
QString NetworkName(void) const;
@@ -156,7 +159,7 @@ class MTV_PUBLIC ServiceDescriptionTable : public PSIPTable
// }
ServiceDescriptor *GetServiceDescriptor(uint i) const;
- /// mutates a SDTo into a SDTa and recalculates the CRC
+ /// mutates a SDTo into a SDTa (vice versa) and recalculates the CRC
bool Mutate(void);
void Parse(void) const;
@@ -200,6 +200,20 @@ class XMLTVGrabber : public ComboBoxSetting, public VideoSourceDBStorage
};
};
+class DVBNetID : public SpinBoxSetting, public VideoSourceDBStorage
+{
+ public:
+ DVBNetID(const VideoSource &parent, uint value, signed int min_val) :
+ SpinBoxSetting(this, min_val, 100000, 1),
+ VideoSourceDBStorage(this, parent, "dvb_nit_id")
+ {
+ setLabel(QObject::tr("Network ID"));
+ setHelpText(QObject::tr("Set this to the actual network ID at your "
+ "location, if you have a provider that broadcasts a broken "
+ "NIT. Leave at -1 if everything works out of the box."));
+ };
+};
+
FreqTableSelector::FreqTableSelector(const VideoSource &parent) :
ComboBoxSetting(this), VideoSourceDBStorage(this, parent, "freqtable")
{
@@ -660,6 +674,7 @@ VideoSource::VideoSource()
group->addChild(name = new Name(*this));
group->addChild(xmltv = new XMLTVConfig(*this));
group->addChild(new FreqTableSelector(*this));
+ group->addChild(new DVBNetID(*this, -1, -1));
addChild(group);
}

0 comments on commit 1219447

Please sign in to comment.