From 81115c723520e1e728c8f86aa7e411b69d8abbc0 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Sun, 13 May 2012 16:08:21 +0400 Subject: [PATCH 1/5] zapit/src/frontend.cpp: add missed slave checks in sendToneBurst and sendEN50494TuningCommand --- src/zapit/src/frontend.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/zapit/src/frontend.cpp b/src/zapit/src/frontend.cpp index e8dc95d10..08195d7cf 100644 --- a/src/zapit/src/frontend.cpp +++ b/src/zapit/src/frontend.cpp @@ -860,7 +860,7 @@ void CFrontend::sendDiseqcCommand(const struct dvb_diseqc_master_cmd *cmd, const for (int i = 0; i < cmd->msg_len; i++) printf("0x%X ", cmd->msg[i]); printf("\n"); - if(slave) + if (slave || info.type != FE_QPSK) return; if (fop(ioctl, FE_DISEQC_SEND_MASTER_CMD, cmd) == 0) usleep(1000 * ms); @@ -873,6 +873,8 @@ uint32_t CFrontend::getDiseqcReply(const int /*timeout_ms*/) const void CFrontend::sendToneBurst(const fe_sec_mini_cmd_t burst, const uint32_t ms) { + if (slave || info.type != FE_QPSK) + return; if (fop(ioctl, FE_DISEQC_SEND_BURST, burst) == 0) usleep(1000 * ms); } @@ -1052,6 +1054,8 @@ void CFrontend::setInput(t_satellite_position satellitePosition, uint32_t freque uint32_t CFrontend::sendEN50494TuningCommand(const uint32_t frequency, const int high_band, const int horizontal, const int bank) { + if (slave || info.type != FE_QPSK) + return; uint32_t uni_qrgs[] = { 1284, 1400, 1516, 1632, 1748, 1864, 1980, 2096 }; uint32_t bpf; if (config.uni_qrg == 0) From 11d2b24f48e87dce002226d71a39f26c4a695303 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Mon, 14 May 2012 15:06:09 +0400 Subject: [PATCH 2/5] zapit/src/frontend.cpp: fix slave flag in CFrontend::sendEN50494TuningCommand --- src/zapit/src/frontend.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/zapit/src/frontend.cpp b/src/zapit/src/frontend.cpp index 08195d7cf..b1f65bec8 100644 --- a/src/zapit/src/frontend.cpp +++ b/src/zapit/src/frontend.cpp @@ -1054,8 +1054,6 @@ void CFrontend::setInput(t_satellite_position satellitePosition, uint32_t freque uint32_t CFrontend::sendEN50494TuningCommand(const uint32_t frequency, const int high_band, const int horizontal, const int bank) { - if (slave || info.type != FE_QPSK) - return; uint32_t uni_qrgs[] = { 1284, 1400, 1516, 1632, 1748, 1864, 1980, 2096 }; uint32_t bpf; if (config.uni_qrg == 0) @@ -1069,17 +1067,19 @@ uint32_t CFrontend::sendEN50494TuningCommand(const uint32_t frequency, const int unsigned int t = (frequency / 1000 + bpf + 2) / 4 - 350; if (t < 1024 && config.uni_scr >= 0 && config.uni_scr < 8) { - fprintf(stderr, "VOLT18=%d TONE_ON=%d, freq=%d bpf=%d ret=%d\n", currentVoltage == SEC_VOLTAGE_18, currentToneMode == SEC_TONE_ON, frequency, bpf, (t + 350) * 4000 - frequency); - cmd.msg[3] = (t >> 8) | /* highest 3 bits of t */ - (config.uni_scr << 5) | /* adress */ - (bank << 4) | /* not implemented yet */ - (horizontal << 3) | /* horizontal == 0x08 */ - (high_band) << 2; /* high_band == 0x04 */ - cmd.msg[4] = t & 0xFF; - fop(ioctl, FE_SET_VOLTAGE, SEC_VOLTAGE_18); - usleep(15 * 1000); /* en50494 says: >4ms and < 22 ms */ - sendDiseqcCommand(&cmd, 50); /* en50494 says: >2ms and < 60 ms */ - fop(ioctl, FE_SET_VOLTAGE, SEC_VOLTAGE_13); + INFO("VOLT18=%d TONE_ON=%d, freq=%d bpf=%d ret=%d", currentVoltage == SEC_VOLTAGE_18, currentToneMode == SEC_TONE_ON, frequency, bpf, (t + 350) * 4000 - frequency); + if (!slave && info.type == FE_QPSK) { + cmd.msg[3] = (t >> 8) | /* highest 3 bits of t */ + (config.uni_scr << 5) | /* adress */ + (bank << 4) | /* not implemented yet */ + (horizontal << 3) | /* horizontal == 0x08 */ + (high_band) << 2; /* high_band == 0x04 */ + cmd.msg[4] = t & 0xFF; + fop(ioctl, FE_SET_VOLTAGE, SEC_VOLTAGE_18); + usleep(15 * 1000); /* en50494 says: >4ms and < 22 ms */ + sendDiseqcCommand(&cmd, 50); /* en50494 says: >2ms and < 60 ms */ + fop(ioctl, FE_SET_VOLTAGE, SEC_VOLTAGE_13); + } return (t + 350) * 4000 - frequency; } WARN("ooops. t > 1024? (%d) or uni_scr out of range? (%d)", t, config.uni_scr); From 7afa758c43d7423c6932fcf6ea9238faf68b4b38 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Mon, 14 May 2012 15:23:00 +0400 Subject: [PATCH 3/5] zapit/src/scannit.cpp: add HD_SIMULCAST_LOGICAL_CHANNEL_DESCRIPTOR --- src/zapit/include/zapit/scannit.h | 4 +++- src/zapit/src/scannit.cpp | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/zapit/include/zapit/scannit.h b/src/zapit/include/zapit/scannit.h index 3dadda3ab..39e70ee37 100644 --- a/src/zapit/include/zapit/scannit.h +++ b/src/zapit/include/zapit/scannit.h @@ -45,6 +45,7 @@ class CNit : public OpenThreads::Thread freq_id_t freq_id; unsigned short nid; channel_number_map_t logical_map; + channel_number_map_t hd_logical_map; std::string networkName; NetworkInformationSectionList sections; @@ -54,7 +55,7 @@ class CNit : public OpenThreads::Thread bool ParseSatelliteDescriptor(SatelliteDeliverySystemDescriptor * sd, TransportStreamInfo * ts); bool ParseCableDescriptor(CableDeliverySystemDescriptor * sd, TransportStreamInfo * ts); bool ParseServiceList(ServiceListDescriptor * sd, TransportStreamInfo * ts); - bool ParseLogicalChannels(LogicalChannelDescriptor * ld, TransportStreamInfo * ts); + bool ParseLogicalChannels(LogicalChannelDescriptor * ld, TransportStreamInfo * ts, bool hd = false); public: CNit(t_satellite_position spos, freq_id_t frq, unsigned short pnid, int dnum = 0); @@ -63,6 +64,7 @@ class CNit : public OpenThreads::Thread bool Stop(); bool Parse(); channel_number_map_t & getLogicalMap() { return logical_map; }; + channel_number_map_t & getHDLogicalMap() { return hd_logical_map; }; std::string GetNetworkName() { return networkName; } }; diff --git a/src/zapit/src/scannit.cpp b/src/zapit/src/scannit.cpp index 072d0a1eb..6cd1986fa 100644 --- a/src/zapit/src/scannit.cpp +++ b/src/zapit/src/scannit.cpp @@ -259,6 +259,10 @@ bool CNit::Parse() if(pdsd == 0x00000028) ParseLogicalChannels((LogicalChannelDescriptor *) d, tsinfo); break; + case HD_SIMULCAST_LOGICAL_CHANNEL_DESCRIPTOR: + if(pdsd == 0x00000028) + ParseLogicalChannels((LogicalChannelDescriptor *) d, tsinfo, true); + break; default: { #ifdef DEBUG_NIT_UNUSED @@ -359,7 +363,7 @@ bool CNit::ParseServiceList(ServiceListDescriptor * sd, TransportStreamInfo * ts return true; } -bool CNit::ParseLogicalChannels(LogicalChannelDescriptor * ld, TransportStreamInfo * tsinfo) +bool CNit::ParseLogicalChannels(LogicalChannelDescriptor * ld, TransportStreamInfo * tsinfo, bool hd) { t_transport_stream_id transport_stream_id = tsinfo->getTransportStreamId(); t_original_network_id original_network_id = tsinfo->getOriginalNetworkId(); @@ -373,10 +377,14 @@ bool CNit::ParseLogicalChannels(LogicalChannelDescriptor * ld, TransportStreamIn transport_stream_id, original_network_id, service_id); int visible = (*it)->getVisibleServiceFlag(); #ifdef DEBUG_LCN - printf("NIT: logical channel tsid %04x onid %04x %012llx -> %d (%d)\n", transport_stream_id, original_network_id, channel_id, lcn, visible); + printf("NIT: logical channel tsid %04x onid %04x %012llx -> %d (%s, %d)\n", transport_stream_id, original_network_id, channel_id, lcn, hd ? "hd", : "sd", visible); #endif - if (visible && lcn) - logical_map[channel_id] = lcn; + if (visible && lcn) { + if(hd) + hd_logical_map[channel_id] = lcn; + else + logical_map[channel_id] = lcn; + } } return true; } From 630d9892e5ff6980290d70e831f2c64862d06f91 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Mon, 14 May 2012 15:24:01 +0400 Subject: [PATCH 4/5] zapit/src/scan.cpp: prefer logical numbers from hd descriptors --- src/zapit/src/scan.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/zapit/src/scan.cpp b/src/zapit/src/scan.cpp index d081ff859..bc4084eb8 100644 --- a/src/zapit/src/scan.cpp +++ b/src/zapit/src/scan.cpp @@ -220,6 +220,7 @@ bool CServiceScan::ReadNitSdt(t_satellite_position satellitePosition) #endif std::string networkName; channel_number_map_t nit_logical_map; + channel_number_map_t nit_hd_logical_map; _repeat: found_transponders += scantransponders.size(); CZapit::getInstance()->SendEvent ( CZapitClient::EVT_SCAN_NUM_TRANSPONDERS, @@ -286,6 +287,8 @@ _repeat: networkName = nit.GetNetworkName(); channel_number_map_t &lcn = nit.getLogicalMap(); nit_logical_map.insert(lcn.begin(), lcn.end()); + channel_number_map_t &hdlcn = nit.getHDLogicalMap(); + nit_hd_logical_map.insert(hdlcn.begin(), hdlcn.end()); } #ifdef USE_BAT @@ -320,7 +323,8 @@ _repeat: if (flags & (SCAN_NIT/*|SCAN_LOGICAL_NUMBERS*/) && !nit_logical_map.empty()) { std::string pname = networkName; - INFO("network [%s] %d logical channels\n", pname.c_str(), nit_logical_map.size()); + INFO("network [%s] %d logical channels (%d hd)\n", pname.c_str(), nit_logical_map.size(), nit_hd_logical_map.size()); + CServiceManager::getInstance()->ResetChannelNumbers(true, true); g_bouquetManager->loadBouquets(true); CZapitBouquet* bouquet; int bouquetId = g_bouquetManager->existsUBouquet(pname.c_str()); @@ -329,11 +333,21 @@ _repeat: else bouquet = g_bouquetManager->Bouquets[bouquetId]; + for(channel_number_map_t::iterator cit = nit_hd_logical_map.begin(); cit != nit_hd_logical_map.end(); ++cit) { + //nit_logical_map.erase(cit->first); + CZapitChannel * channel = CServiceManager::getInstance()->FindChannel48(cit->first); + if (channel) { + channel->number = cit->second; + if (!bouquet->getChannelByChannelID(channel->getChannelID())) + bouquet->addService(channel); + } + } for(channel_number_map_t::iterator cit = nit_logical_map.begin(); cit != nit_logical_map.end(); ++cit) { CZapitChannel * channel = CServiceManager::getInstance()->FindChannel48(cit->first); - if(channel && !bouquet->getChannelByChannelID(channel->getChannelID())) { + if (channel && !channel->number) { channel->number = cit->second; - bouquet->addService(channel); + if (!bouquet->getChannelByChannelID(channel->getChannelID())) + bouquet->addService(channel); } } bouquet->sortBouquetByNumber(); From c8b4d271f9b7be65db75d2228c590b95583bfc7a Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Mon, 14 May 2012 18:30:55 +0400 Subject: [PATCH 5/5] lib/xmltree/xmlparse.cpp: fix (workaround?) for crash while parsing invalid saved xml --- lib/xmltree/xmlparse.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/xmltree/xmlparse.cpp b/lib/xmltree/xmlparse.cpp index 95643c609..d0a531824 100644 --- a/lib/xmltree/xmlparse.cpp +++ b/lib/xmltree/xmlparse.cpp @@ -392,7 +392,8 @@ long XML_Parser::GetCurrentByteIndex() int XML_Parser::GetCurrentLineNumber() { - if (eventPtr) + /* at EOF positionPtr point to input, while eventPtr not updated -- focus */ + if (eventPtr && (positionPtr < eventPtr)) { XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); positionPtr=eventPtr;