#include <lib/base/estring.h>
#include <errno.h>
-static bool scan_debug;
-#define SCAN_eDebug(x...) do { if (scan_debug) eDebug(x); } while(0)
-#define SCAN_eDebugNoNewLine(x...) do { if (scan_debug) eDebugNoNewLine(x); } while(0)
+#define SCAN_eDebug(x...) do { if (m_scan_debug) eDebug(x); } while(0)
+#define SCAN_eDebugNoNewLine(x...) do { if (m_scan_debug) eDebugNoNewLine(x); } while(0)
DEFINE_REF(eDVBScan);
eDVBScan::eDVBScan(iDVBChannel *channel, bool usePAT, bool debug)
:m_channel(channel), m_channel_state(iDVBChannel::state_idle)
,m_ready(0), m_ready_all(usePAT ? (readySDT|readyPAT) : readySDT)
- ,m_pmt_running(false), m_abort_current_pmt(false), m_flags(0), m_usePAT(usePAT)
+ ,m_pmt_running(false), m_abort_current_pmt(false), m_flags(0)
+ ,m_usePAT(usePAT), m_scan_debug(debug)
{
- scan_debug=debug;
if (m_channel->getDemux(m_demux))
SCAN_eDebug("scan: failed to allocate demux!");
m_channel->connectStateChange(slot(*this, &eDVBScan::stateChange), m_stateChanged_connection);
if (m_ready_all & readyPAT)
startSDT = m_ready & readyPAT;
+ // m_ch_current is not set, when eDVBScan is just used for a SDT update
+ if (!m_ch_current)
+ {
+ unsigned int channelFlags;
+ m_channel->getCurrentFrontendParameters(m_ch_current);
+ m_ch_current->getFlags(channelFlags);
+ if (channelFlags & iDVBFrontendParameters::flagOnlyFree)
+ m_flags |= scanOnlyFree;
+ }
+
m_SDT = 0;
if (startSDT && (m_ready_all & readySDT))
{
- m_SDT = new eTable<ServiceDescriptionSection>();
+ m_SDT = new eTable<ServiceDescriptionSection>(m_scan_debug);
int tsid=-1;
if (m_ready & readyPAT && m_ready & validPAT)
{
for (; program != pat.getPrograms()->end(); ++program)
m_pmts_to_read.insert(std::pair<unsigned short, service>((*program)->getProgramNumber(), service((*program)->getProgramMapPid())));
}
- m_PMT = new eTable<ProgramMapSection>();
+ m_PMT = new eTable<ProgramMapSection>(m_scan_debug);
CONNECT(m_PMT->tableReady, eDVBScan::PMTready);
- PMTready(-1);
-
+ PMTready(-2);
// KabelBW HACK ... on 618Mhz and 626Mhz the transport stream id in PAT and SDT is different
+
{
int type;
m_ch_current->getSystem(type);
m_PAT = 0;
if (m_ready_all & readyPAT)
{
- m_PAT = new eTable<ProgramAssociationSection>();
+ m_PAT = new eTable<ProgramAssociationSection>(m_scan_debug);
if (m_PAT->start(m_demux, eDVBPATSpec()))
return -1;
CONNECT(m_PAT->tableReady, eDVBScan::PATready);
m_NIT = 0;
if (m_ready_all & readyNIT)
{
- m_NIT = new eTable<NetworkInformationSection>();
+ m_NIT = new eTable<NetworkInformationSection>(m_scan_debug);
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<BouquetAssociationSection>();
+ m_BAT = new eTable<BouquetAssociationSection>(m_scan_debug);
if (m_BAT->start(m_demux, eDVBBATSpec()))
return -1;
CONNECT(m_BAT->tableReady, eDVBScan::BATready);
}
}
-
return 0;
}
for (DescriptorConstIterator desc = (*es)->getDescriptors()->begin();
desc != (*es)->getDescriptors()->end(); ++desc)
{
- switch ((*desc)->getTag())
- {
- case DTS_DESCRIPTOR:
- case AAC_DESCRIPTOR:
- isaudio = 1;
- case AC3_DESCRIPTOR:
- isaudio = 1;
- break;
- case CA_DESCRIPTOR:
- is_scrambled = 1;
- break;
- case REGISTRATION_DESCRIPTOR: /* some services don't have a separate AC3 descriptor */
+ uint8_t tag = (*desc)->getTag();
+ if (!isaudio && !isvideo)
{
- /* libdvbsi++ doesn't yet support this descriptor type, so work around. */
- if ((*desc)->getLength() != 4)
- break;
- unsigned char descr[6];
- (*desc)->writeToBuffer(descr);
- int format_identifier = (descr[2] << 24) | (descr[3] << 16) | (descr[4] << 8) | (descr[5]);
- switch (format_identifier)
+ switch (tag)
{
- case 0x41432d33:
+ case DTS_DESCRIPTOR:
+ case AAC_DESCRIPTOR:
+ case AC3_DESCRIPTOR:
isaudio = 1;
- default:
+ break;
+ case REGISTRATION_DESCRIPTOR: /* some services don't have a separate AC3 descriptor */
+ {
+ /* libdvbsi++ doesn't yet support this descriptor type, so work around. */
+ if ((*desc)->getLength() != 4)
+ break;
+ unsigned char descr[6];
+ (*desc)->writeToBuffer(descr);
+ int format_identifier = (descr[2] << 24) | (descr[3] << 16) | (descr[4] << 8) | (descr[5]);
+ switch (format_identifier)
+ {
+ case 0x41432d33:
+ isaudio = 1;
+ default:
+ break;
+ }
break;
}
- break;
- }
+ }
}
+ if (tag == CA_DESCRIPTOR)
+ is_scrambled = 1;
}
break;
}
else
m_pmt_in_progress->second.serviceType = 100;
}
- if (err == -2) // aborted in sdt progress
+ if (err == -1) // timeout or removed by sdt
m_pmts_to_read.erase(m_pmt_in_progress++);
else if (m_pmt_running)
++m_pmt_in_progress;
m_PMT->start(m_demux, eDVBPMTSpec(m_pmt_in_progress->second.pmtPid, m_pmt_in_progress->first));
else
{
+ m_PMT = 0;
m_pmt_running = false;
channelDone();
}
{
unsigned long hash = 0;
- // m_ch_current is not set, when eDVBScan is just used for a SDT update
- if (!m_ch_current)
- {
- unsigned int channelFlags;
- m_channel->getCurrentFrontendParameters(m_ch_current);
- m_ch_current->getFlags(channelFlags);
- if (channelFlags & iDVBFrontendParameters::flagOnlyFree)
- m_flags |= scanOnlyFree;
- }
-
m_ch_current->getHash(hash);
eDVBNamespace dvbnamespace = buildNamespace(
if (m_abort_current_pmt)
{
m_abort_current_pmt = false;
- PMTready(-2);
+ PMTready(-1);
}
return;
}
{
unsigned long hash = 0;
- // m_ch_current is not set, when eDVBScan is just used for a SDT update
- if (!m_ch_current)
- {
- unsigned int channelFlags;
- m_channel->getCurrentFrontendParameters(m_ch_current);
- m_ch_current->getFlags(channelFlags);
- if (channelFlags & iDVBFrontendParameters::flagOnlyFree)
- m_flags |= scanOnlyFree;
- }
-
m_ch_current->getHash(hash);
m_chid_current = eDVBChannelID(
service->m_provider_name = pname;
}
- std::pair<std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator, bool> i = m_new_services.insert(std::pair<eServiceReferenceDVB, ePtr<eDVBService> >(ref, service));
-
- if (i.second)
- {
- m_last_service = i.first;
- m_event(evtNewService);
+ if (!(m_flags & scanOnlyFree) || !m_pmt_in_progress->second.scrambled) {
+ SCAN_eDebug("add not scrambled!");
+ std::pair<std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator, bool> i = m_new_services.insert(std::pair<eServiceReferenceDVB, ePtr<eDVBService> >(ref, service));
+ if (i.second)
+ {
+ m_last_service = i.first;
+ m_event(evtNewService);
+ }
}
+ else
+ SCAN_eDebug("dont add... is scrambled!");
m_pmts_to_read.erase(m_pmt_in_progress++);
}
SCAN_eDebug("is scrambled!");
add = false;
}
+ else
+ SCAN_eDebug("is free");
}
- else
+ else {
SCAN_eDebug("not found in PAT.. so we assume it is scrambled!!");
+ add = false;
+ }
}
if (add)