X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/bbfcb7ea1f040d030277e2b6f2efa9ea0967bf2b..1f852a117325a59bd044a825fe302ecfc8e13f67:/lib/dvb/scan.cpp diff --git a/lib/dvb/scan.cpp b/lib/dvb/scan.cpp index 76c71011..19c10868 100644 --- a/lib/dvb/scan.cpp +++ b/lib/dvb/scan.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,8 @@ int eDVBScan::isValidONIDTSID(int orbital_position, eOriginalNetworkID onid, eTr return orbital_position == 192; case 0x00B1: return tsid != 0x00B0; + case 0x00eb: + return tsid != 0x4321; case 0x0002: return abs(orbital_position-282) < 6; default: @@ -137,7 +140,7 @@ RESULT eDVBScan::nextChannel() RESULT eDVBScan::startFilter() { bool startSDT=true; - assert(m_demux); + ASSERT(m_demux); /* only start required filters filter */ @@ -163,7 +166,7 @@ RESULT eDVBScan::startFilter() { std::vector::const_iterator i = m_PAT->getSections().begin(); - assert(i != m_PAT->getSections().end()); + ASSERT(i != m_PAT->getSections().end()); tsid = (*i)->getTableIdExtension(); // in PAT this is the transport stream id m_pat_tsid = eTransportStreamID(tsid); for (; i != m_PAT->getSections().end(); ++i) @@ -279,6 +282,7 @@ void eDVBScan::PMTready(int err) bool have_video = false; unsigned short pcrpid = 0xFFFF; std::vector::const_iterator i; + for (i = m_PMT->getSections().begin(); i != m_PMT->getSections().end(); ++i) { const ProgramMapSection &pmt = **i; @@ -289,64 +293,82 @@ void eDVBScan::PMTready(int err) ElementaryStreamInfoConstIterator es; for (es = pmt.getEsInfo()->begin(); es != pmt.getEsInfo()->end(); ++es) { - int isaudio = 0, isvideo = 0, is_scrambled = 0; + int isaudio = 0, isvideo = 0, is_scrambled = 0, forced_audio = 0, forced_video = 0; switch ((*es)->getType()) { case 0x1b: // AVC Video Stream (MPEG4 H264) + case 0x10: // MPEG 4 Part 2 case 0x01: // MPEG 1 video case 0x02: // MPEG 2 video isvideo = 1; + forced_video = 1; //break; fall through !!! case 0x03: // MPEG 1 audio - case 0x04: // MPEG 2 audio: - if (!isvideo) + case 0x04: // MPEG 2 audio + case 0x0f: // MPEG 2 AAC + case 0x11: // MPEG 4 AAC + if (!isvideo) + { + forced_audio = 1; isaudio = 1; - //break; fall through !!! + } case 0x06: // PES Private case 0x81: // user private - /* PES private can contain AC-3, DTS or lots of other stuff. - check descriptors to get the exact type. */ + case 0xEA: // TS_PSI_ST_SMPTE_VC1 for (DescriptorConstIterator desc = (*es)->getDescriptors()->begin(); desc != (*es)->getDescriptors()->end(); ++desc) { uint8_t tag = (*desc)->getTag(); - if (!isaudio && !isvideo) + /* PES private can contain AC-3, DTS or lots of other stuff. + check descriptors to get the exakt type. */ + if (!forced_video && !forced_audio) { switch (tag) { - case DTS_DESCRIPTOR: + case 0x1C: // TS_PSI_DT_MPEG4_Audio + case 0x2B: // TS_PSI_DT_MPEG2_AAC case AAC_DESCRIPTOR: case AC3_DESCRIPTOR: + case DTS_DESCRIPTOR: + case AUDIO_STREAM_DESCRIPTOR: isaudio = 1; break; + case 0x28: // TS_PSI_DT_AVC + case 0x1B: // TS_PSI_DT_MPEG4_Video + case VIDEO_STREAM_DESCRIPTOR: + isvideo = 1; + 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) + RegistrationDescriptor *d = (RegistrationDescriptor*)(*desc); + switch (d->getFormatIdentifier()) { - case 0x41432d33: + case 0x44545331 ... 0x44545333: // DTS1/DTS2/DTS3 + case 0x41432d33: // == 'AC-3' + case 0x42535344: // == 'BSSD' (LPCM) isaudio = 1; + break; + case 0x56432d31: // == 'VC-1' + isvideo = 1; + break; default: break; } - break; } + default: + break; } } if (tag == CA_DESCRIPTOR) is_scrambled = 1; } + default: break; } - if (isaudio) - have_audio = true; - else if (isvideo) + if (isvideo) have_video = true; + else if (isaudio) + have_audio = true; else continue; if (is_scrambled) @@ -740,11 +762,20 @@ void eDVBScan::channelDone() } case iDVBFrontend::feTerrestrial: { + ePtr fe; eDVBFrontendParametersTerrestrial parm; m_ch_current->getDVBT(parm); snprintf(sname, 255, "%d SID 0x%02x", parm.frequency/1000, m_pmt_in_progress->first); + if (!m_channel->getFrontend(fe)) + { + ePyObject tp_dict = PyDict_New(); + fe->getTransponderData(tp_dict, false); + m_corrected_frequencys[m_chid_current] = + PyInt_AsLong(PyDict_GetItemString(tp_dict, "frequency")); + Py_DECREF(tp_dict); + } break; } case iDVBFrontend::feCable: @@ -765,7 +796,8 @@ void eDVBScan::channelDone() if (!(m_flags & scanOnlyFree) || !m_pmt_in_progress->second.scrambled) { SCAN_eDebug("add not scrambled!"); - std::pair >::iterator, bool> i = m_new_services.insert(std::pair >(ref, service)); + std::pair >::iterator, bool> i = + m_new_services.insert(std::pair >(ref, service)); if (i.second) { m_last_service = i.first; @@ -922,6 +954,24 @@ void eDVBScan::insertInto(iDVBChannelList *db, bool dontRemoveOldFlags) for (std::map >::const_iterator ch(m_new_channels.begin()); ch != m_new_channels.end(); ++ch) { + int system; + ch->second->getSystem(system); + if (system == iDVBFrontend::feTerrestrial) + { + std::map::iterator it = m_corrected_frequencys.find(ch->first); + if (it != m_corrected_frequencys.end()) + { + eDVBFrontendParameters *p = (eDVBFrontendParameters*)&(*ch->second); + eDVBFrontendParametersTerrestrial parm; + p->getDVBT(parm); + eDebug("corrected freq for tsid %04x, onid %04x, ns %08x is %d, old was %d", + ch->first.transport_stream_id.get(), ch->first.original_network_id.get(), + ch->first.dvbnamespace.get(), it->second, parm.frequency); + parm.frequency = it->second; + p->setDVBT(parm); + m_corrected_frequencys.erase(it); + } + } if (m_flags & scanOnlyFree) { eDVBFrontendParameters *ptr = (eDVBFrontendParameters*)&(*ch->second); @@ -1036,7 +1086,8 @@ RESULT eDVBScan::processSDT(eDVBNamespace dvbnamespace, const ServiceDescription } } - std::pair >::iterator, bool> i = m_new_services.insert(std::pair >(ref, service)); + std::pair >::iterator, bool> i = + m_new_services.insert(std::pair >(ref, service)); if (i.second) {