From a76a03c0d815680e3e8fc52f24f60a30177d3021 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 11 Jan 2004 18:00:00 +0100 Subject: Version 1.3.1 - Fixed a lockup in the EPG scanner when no non-primary device was available (thanks to Martin Holst for reporting this one). - Fixed a compiler warning about virtual cConfig::Load() functions (thanks to Lauri Tischler for reporting this one). - Fixed a warning about character comparison in libsi/si.c (thanks to Lauri Tischler for reporting this one). - The new parameter "Update channels" in the "Setup/DVB" menu can be used to control if and how channels will be automatically updated (see MANUAL). This has already been part of the 'autopid' patch by Andreas Schultz and has now been adopted. - Fixed a crash in case there is no DVB hardware present (thanks to Sascha Volkenandt for reporting this one). - Changed calculation of channel ids to make it work for tv stations that use the undefined NID value 0 (thanks to Teemu Rantanen for reporting this one). - Enhanced the SDT filter to handle multi part sections. - Added support for selecting preferred EPG languages (based upon a patch by Teemu Rantanen). - Fixed a 'const' in libsi/si.h (thanks to Marcel Wiesweg). - Fixed the 'su' call in 'runvdr' to make it work on systems that require the user name to appear before the command option (thanks to Robert Huitl). - Fixed testing for matching section filters in case they are turned off (thanks to Marcel Wiesweg). - In case of incomplete sections an error message is now logged only every 10 seconds. - Fixed a possible NULL pointer access in cEITScanner::Process() (thanks to Andreas Kool). - The actual transponder data is now taken from the NIT and existing channels are adjusted if necessary. If the NIT contains new transponders, they are scanned for channels during the next EPG scan. Note that only the satellite branches are tested, cable and terrestrial need to be tested by somebody who actually has such equipment. --- nit.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 nit.c (limited to 'nit.c') diff --git a/nit.c b/nit.c new file mode 100644 index 0000000..1ac731c --- /dev/null +++ b/nit.c @@ -0,0 +1,139 @@ +/* + * nit.c: NIT section filter + * + * See the main source file 'vdr.c' for copyright information and + * how to reach the author. + * + * $Id: nit.c 1.1 2004/01/11 15:42:51 kls Exp $ + */ + +#include "nit.h" +#include +#include "channels.h" +#include "eitscan.h" +#include "libsi/section.h" +#include "libsi/descriptor.h" +#include "tools.h" + +cNitFilter::cNitFilter(void) +{ + Set(0x10, 0x40); // NIT +} + +void cNitFilter::SetStatus(bool On) +{ + cFilter::SetStatus(On); + sectionSyncer.Reset(); +} + +void cNitFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length) +{ + SI::NIT nit(Data, false); + if (!nit.CheckCRCAndParse()) + return; + if (!sectionSyncer.Sync(nit.getVersionNumber(), nit.getSectionNumber(), nit.getLastSectionNumber())) + return; + if (!Channels.Lock(true, 10)) + return; + for (SI::Loop::Iterator it; nit.transportStreamLoop.hasNext(it); ) { + SI::NIT::TransportStream ts = nit.transportStreamLoop.getNext(it); + SI::Descriptor *d; + for (SI::Loop::Iterator it2; (d = ts.transportStreamDescriptors.getNext(it2)); ) { + switch (d->getDescriptorTag()) { + case SI::SatelliteDeliverySystemDescriptorTag: { + SI::SatelliteDeliverySystemDescriptor *sd = (SI::SatelliteDeliverySystemDescriptor *)d; + int Source = cSource::FromData(cSource::stSat, BCD2INT(sd->getOrbitalPosition()), sd->getWestEastFlag()); + int Frequency = BCD2INT(sd->getFrequency()) / 100; + static char Polarizations[] = { 'h', 'v', 'l', 'r' }; + char Polarization = Polarizations[sd->getPolarization()]; + static int CodeRates[] = { FEC_NONE, FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_7_8, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE }; + int CodeRate = CodeRates[sd->getFecInner()]; + int SymbolRate = BCD2INT(sd->getSymbolRate()) / 10; + bool found = false; + for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) { + if (!Channel->GroupSep() && Channel->Source() == Source && Channel->Nid() == ts.getOriginalNetworkId() && Channel->Tid() == ts.getTransportStreamId()) { + if (Setup.UpdateChannels >= 4) + Channel->SetSatTransponderData(Source, Frequency, Polarization, SymbolRate, CodeRate); + found = true; + } + } + if (!found && Setup.UpdateChannels >= 4) { + cChannel *Channel = new cChannel; + Channel->SetId(ts.getOriginalNetworkId(), ts.getTransportStreamId(), 0, 0, false); + if (Channel->SetSatTransponderData(Source, Frequency, Polarization, SymbolRate, CodeRate, false)) + EITScanner.AddTransponder(Channel); + else + delete Channel; + } + } + break; + case SI::CableDeliverySystemDescriptorTag: { + SI::CableDeliverySystemDescriptor *sd = (SI::CableDeliverySystemDescriptor *)d; + int Source = cSource::FromData(cSource::stCable); + int Frequency = BCD2INT(sd->getFrequency()) / 10; + //XXX FEC_outer??? + static int CodeRates[] = { FEC_NONE, FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_7_8, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE }; + int CodeRate = CodeRates[sd->getFecInner()]; + static int Modulations[] = { QPSK, QAM_16, QAM_32, QAM_64, QAM_128, QAM_256 }; + int Modulation = Modulations[sd->getModulation()]; + int SymbolRate = BCD2INT(sd->getSymbolRate()) / 10; + bool found = false; + for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) { + if (!Channel->GroupSep() && Channel->Source() == Source && Channel->Nid() == ts.getOriginalNetworkId() && Channel->Tid() == ts.getTransportStreamId()) { + if (Setup.UpdateChannels >= 4) + Channel->SetCableTransponderData(Source, Frequency, Modulation, SymbolRate, CodeRate); + found = true; + } + } + if (!found && Setup.UpdateChannels >= 4) { + cChannel *Channel = new cChannel; + Channel->SetId(ts.getOriginalNetworkId(), ts.getTransportStreamId(), 0, 0, false); + if (Channel->SetCableTransponderData(Source, Frequency, Modulation, SymbolRate, CodeRate, false)) + EITScanner.AddTransponder(Channel); + else + delete Channel; + } + } + break; + case SI::TerrestrialDeliverySystemDescriptorTag: { + SI::TerrestrialDeliverySystemDescriptor *sd = (SI::TerrestrialDeliverySystemDescriptor *)d; + int Source = cSource::FromData(cSource::stCable); + int Frequency = sd->getFrequency() * 10; + static int Bandwidths[] = { BANDWIDTH_6_MHZ, BANDWIDTH_7_MHZ, BANDWIDTH_8_MHZ, BANDWIDTH_AUTO, BANDWIDTH_AUTO, BANDWIDTH_AUTO, BANDWIDTH_AUTO, BANDWIDTH_AUTO }; + int Bandwidth = Bandwidths[sd->getBandwidth()]; + static int Constellations[] = { QPSK, QAM_16, QAM_64, QAM_AUTO }; + int Constellation = Constellations[sd->getConstellation()]; + static int Hierarchies[] = { HIERARCHY_NONE, HIERARCHY_1, HIERARCHY_2, HIERARCHY_4 }; + int Hierarchy = Hierarchies[sd->getHierarchy()]; + static int CodeRates[] = { FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_7_8, FEC_NONE, FEC_NONE, FEC_NONE }; + int CodeRateHP = CodeRates[sd->getCodeRateHP()]; + int CodeRateLP = CodeRates[sd->getCodeRateLP()]; + static int GuardIntervals[] = { GUARD_INTERVAL_1_4, GUARD_INTERVAL_1_8, GUARD_INTERVAL_1_16, GUARD_INTERVAL_1_32 }; + int GuardInterval = GuardIntervals[sd->getGuardInterval()]; + static int TransmissionModes[] = { TRANSMISSION_MODE_2K, TRANSMISSION_MODE_8K, TRANSMISSION_MODE_AUTO, TRANSMISSION_MODE_AUTO }; + int TransmissionMode = TransmissionModes[sd->getTransmissionMode()]; + bool found = false; + for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) { + if (!Channel->GroupSep() && Channel->Source() == Source && Channel->Nid() == ts.getOriginalNetworkId() && Channel->Tid() == ts.getTransportStreamId()) { + if (Setup.UpdateChannels >= 4) + Channel->SetTerrTransponderData(Source, Frequency, Bandwidth, Constellation, Hierarchy, CodeRateHP, CodeRateLP, GuardInterval, TransmissionMode); + found = true; + } + } + if (!found && Setup.UpdateChannels >= 4) { + cChannel *Channel = new cChannel; + Channel->SetId(ts.getOriginalNetworkId(), ts.getTransportStreamId(), 0, 0, false); + if (Channel->SetTerrTransponderData(Source, Frequency, Bandwidth, Constellation, Hierarchy, CodeRateHP, CodeRateLP, GuardInterval, TransmissionMode, false)) + EITScanner.AddTransponder(Channel); + else + delete Channel; + } + } + break; + default: ; + } + delete d; + } + } + Channels.Unlock(); +} -- cgit v1.2.3