From a2eb4cb31c5df65b943b68a9aa0a376655631143 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Thu, 1 Jun 2006 22:47:52 +0000 Subject: [PATCH] the scan should now work for scanning dish network .. they use the SDT OTHER --- lib/components/scan.cpp | 4 +- lib/dvb/pmt.cpp | 2 +- lib/dvb/scan.cpp | 95 +++++++++++++++++++++++++++-------------- lib/dvb/scan.h | 16 ++++--- lib/dvb/specs.h | 17 ++++++++ 5 files changed, 94 insertions(+), 40 deletions(-) diff --git a/lib/components/scan.cpp b/lib/components/scan.cpp index 5355208f..2870388a 100644 --- a/lib/components/scan.cpp +++ b/lib/components/scan.cpp @@ -106,8 +106,8 @@ int eComponentScan::start(int feid, int flags) } std::list > list; - - m_scan = new eDVBScan(channel, true); + + m_scan = new eDVBScan(channel); m_scan->connectEvent(slot(*this, &eComponentScan::scanEvent), m_scan_event_connection); m_scan->start(m_initial, flags); diff --git a/lib/dvb/pmt.cpp b/lib/dvb/pmt.cpp index 5301df9b..3b7a376f 100644 --- a/lib/dvb/pmt.cpp +++ b/lib/dvb/pmt.cpp @@ -501,7 +501,7 @@ int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux, if (ref.path.empty()) { delete m_dvb_scan; - m_dvb_scan = new eDVBScan(m_channel, false); + m_dvb_scan = new eDVBScan(m_channel, false, false); m_dvb_scan->connectEvent(slot(*this, &eDVBServicePMTHandler::SDTScanEvent), m_scan_event_connection); } } else diff --git a/lib/dvb/scan.cpp b/lib/dvb/scan.cpp index 89c4735a..f9d7547e 100644 --- a/lib/dvb/scan.cpp +++ b/lib/dvb/scan.cpp @@ -1,7 +1,4 @@ #include -#include -#include -#include #include #include #include @@ -22,9 +19,10 @@ static bool scan_debug; DEFINE_REF(eDVBScan); -eDVBScan::eDVBScan(iDVBChannel *channel, bool debug) +eDVBScan::eDVBScan(iDVBChannel *channel, bool usePAT, bool debug) :m_channel(channel), m_channel_state(iDVBChannel::state_idle) - ,m_ready(0), m_ready_all(readySDT), m_flags(0) + ,m_ready(0), m_ready_all(usePAT ? (readySDT|readyPAT) : readySDT) + ,m_flags(0), m_usePAT(usePAT) { scan_debug=debug; if (m_channel->getDemux(m_demux)) @@ -89,7 +87,7 @@ RESULT eDVBScan::nextChannel() m_SDT = 0; m_BAT = 0; m_NIT = 0; m_ready = 0; - + /* check what we need */ m_ready_all = readySDT; @@ -98,7 +96,10 @@ RESULT eDVBScan::nextChannel() if (m_flags & scanSearchBAT) m_ready_all |= readyBAT; - + + if (m_usePAT) + m_ready_all |= readyPAT; + if (m_ch_toScan.empty()) { SCAN_eDebug("no channels left to scan."); @@ -144,38 +145,62 @@ RESULT eDVBScan::nextChannel() RESULT eDVBScan::startFilter() { + bool startSDT=true; assert(m_demux); - + /* only start required filters filter */ - - m_SDT = 0; - if (m_ready_all & readySDT) + if (m_ready_all & readyPAT) + startSDT = m_ready & readyPAT; + + m_SDT = 0; + if (startSDT && (m_ready_all & readySDT)) { m_SDT = new eTable(); - if (m_SDT->start(m_demux, eDVBSDTSpec())) + if (m_ready & readyPAT) + { + std::vector::const_iterator i = + m_PAT->getSections().begin(); + assert(i != m_PAT->getSections().end()); + int tsid = (*i)->getTableIdExtension(); // in PAT this is the transport stream id + if (m_SDT->start(m_demux, eDVBSDTSpec(tsid, true))) + return -1; + } + else if (m_SDT->start(m_demux, eDVBSDTSpec())) return -1; CONNECT(m_SDT->tableReady, eDVBScan::SDTready); } - m_NIT = 0; - if (m_ready_all & readyNIT) + if (!(m_ready & readyPAT)) { - m_NIT = new eTable(); - if (m_NIT->start(m_demux, eDVBNITSpec())) - return -1; - CONNECT(m_NIT->tableReady, eDVBScan::NITready); - } + m_PAT = 0; + if (m_ready_all & readyPAT) + { + m_PAT = new eTable(); + if (m_PAT->start(m_demux, eDVBPATSpec())) + return -1; + CONNECT(m_PAT->tableReady, eDVBScan::PATready); + } - m_BAT = 0; - if (m_ready_all & readyBAT) - { - m_BAT = new eTable(); - if (m_BAT->start(m_demux, eDVBBATSpec())) - return -1; - CONNECT(m_BAT->tableReady, eDVBScan::BATready); + m_NIT = 0; + if (m_ready_all & readyNIT) + { + m_NIT = new eTable(); + if (m_NIT->start(m_demux, eDVBNITSpec())) + return -1; + CONNECT(m_NIT->tableReady, eDVBScan::NITready); + } + + m_BAT = 0; + if (m_ready_all & readyBAT) + { + m_BAT = new eTable(); + if (m_BAT->start(m_demux, eDVBBATSpec())) + return -1; + CONNECT(m_BAT->tableReady, eDVBScan::BATready); + } } - + return 0; } @@ -206,6 +231,15 @@ void eDVBScan::BATready(int err) channelDone(); } +void eDVBScan::PATready(int err) +{ + SCAN_eDebug("got pat"); + m_ready |= readyPAT; + if (!err) + m_ready |= validPAT; + startFilter(); // for starting the SDT filter +} + void eDVBScan::addKnownGoodChannel(const eDVBChannelID &chid, iDVBFrontendParameters *feparm) { /* add it to the list of known channels. */ @@ -548,10 +582,9 @@ RESULT eDVBScan::processSDT(eDVBNamespace dvbnamespace, const ServiceDescription SCAN_eDebug("ONID: %04x", sdt.getOriginalNetworkId()); eDVBChannelID chid(dvbnamespace, sdt.getTransportStreamId(), sdt.getOriginalNetworkId()); - /* save correct CHID for this channel if this is an ACTUAL_SDT */ - if (sdt.getTableId() == TID_SDT_ACTUAL) - m_chid_current = chid; - + /* save correct CHID for this channel */ + m_chid_current = chid; + for (ServiceDescriptionConstIterator s(services.begin()); s != services.end(); ++s) { SCAN_eDebugNoNewLine("SID %04x: ", (*s)->getServiceId()); diff --git a/lib/dvb/scan.h b/lib/dvb/scan.h index fe5e0686..0f32d678 100644 --- a/lib/dvb/scan.h +++ b/lib/dvb/scan.h @@ -1,9 +1,10 @@ #ifndef __lib_dvb_scan_h #define __lib_dvb_scan_h -#include #include +#include #include +#include #include #include #include @@ -31,8 +32,8 @@ private: RESULT nextChannel(); RESULT startFilter(); - enum { readySDT=1, readyNIT=2, readyBAT=4, - validSDT=8, validNIT=16, validBAT=32}; + enum { readyPAT=1, readySDT=2, readyNIT=4, readyBAT=8, + validPAT=16, validSDT=32, validNIT=64, validBAT=128}; /* scan state variables */ int m_channel_state; @@ -49,11 +50,13 @@ private: ePtr > m_SDT; ePtr > m_NIT; ePtr > m_BAT; - + ePtr > m_PAT; + void SDTready(int err); void NITready(int err); void BATready(int err); - + void PATready(int err); + void addKnownGoodChannel(const eDVBChannelID &chid, iDVBFrontendParameters *feparm); void addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameters *feparm); int sameChannel(iDVBFrontendParameters *ch1, iDVBFrontendParameters *ch2) const; @@ -64,8 +67,9 @@ private: RESULT processSDT(eDVBNamespace dvbnamespace, const ServiceDescriptionSection &sdt); int m_flags; + bool m_usePAT; public: - eDVBScan(iDVBChannel *channel, bool debug=false); + eDVBScan(iDVBChannel *channel, bool usePAT=true, bool debug=true ); ~eDVBScan(); enum { scanNetworkSearch = 1, scanSearchBAT = 2, scanRemoveServices = 4, scanDontRemoveFeeds=8 }; diff --git a/lib/dvb/specs.h b/lib/dvb/specs.h index afd5cef8..6f30c7b2 100644 --- a/lib/dvb/specs.h +++ b/lib/dvb/specs.h @@ -43,6 +43,23 @@ public: eDVBTableSpec::tfHaveTID | eDVBTableSpec::tfCheckCRC | eDVBTableSpec::tfHaveTimeout; } + eDVBSDTSpec(int tsid, bool other=false) + { + m_spec.pid = ServiceDescriptionSection::PID; + m_spec.tid = ServiceDescriptionSection::TID; + m_spec.tidext = tsid; + m_spec.timeout = 20000; // ServiceDescriptionSection::TIMEOUT; + m_spec.flags = eDVBTableSpec::tfAnyVersion | + eDVBTableSpec::tfHaveTID | eDVBTableSpec::tfCheckCRC | + eDVBTableSpec::tfHaveTIDExt | eDVBTableSpec::tfHaveTimeout; + if (other) + { + // SDT other transport stream have TID 0x46 (current is 0x42) + // so we mask out the third bit in table id mask.. + m_spec.flags |= eDVBTableSpec::tfHaveTIDMask; + m_spec.tid_mask = 0xFB; + } + } operator eDVBTableSpec &() { return m_spec; -- 2.30.2