zapit/src/scannit.cpp: parse network name and logical numbers

This commit is contained in:
[CST] Focus
2012-03-17 16:25:38 +04:00
parent 25f1eb3532
commit 5ff235027f
2 changed files with 42 additions and 0 deletions

View File

@@ -29,9 +29,12 @@
#include <dvbsi++/satellite_delivery_system_descriptor.h>
#include <dvbsi++/cable_delivery_system_descriptor.h>
#include <dvbsi++/service_list_descriptor.h>
#include <dvbsi++/logical_channel_descriptor.h>
#define NIT_SECTION_SIZE 1024
typedef std::map <t_channel_id, int> channel_number_map_t;
class CNit : public OpenThreads::Thread
{
private:
@@ -41,6 +44,7 @@ class CNit : public OpenThreads::Thread
t_satellite_position satellitePosition;
freq_id_t freq_id;
unsigned short nid;
channel_number_map_t logical_map;
NetworkInformationSectionList sections;
@@ -49,6 +53,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);
public:
CNit(t_satellite_position spos, freq_id_t frq, unsigned short pnid, int dnum = 0);
@@ -56,6 +61,7 @@ class CNit : public OpenThreads::Thread
bool Start();
bool Stop();
bool Parse();
channel_number_map_t & getLogicalMap() { return logical_map; };
};
#endif

View File

@@ -24,10 +24,13 @@
#include <zapit/scannit.h>
#include <zapit/scan.h>
#include <dvbsi++/descriptor_tag.h>
#include <dvbsi++/network_name_descriptor.h>
#include <math.h>
#include <eitd/edvbstring.h>
#define DEBUG_NIT
//#define DEBUG_NIT_UNUSED
#define DEBUG_LCN
CNit::CNit(t_satellite_position spos, freq_id_t frq, unsigned short pnid, int dnum)
{
@@ -183,6 +186,17 @@ bool CNit::Parse()
ParseServiceList((ServiceListDescriptor *) d, tsinfo);
break;
case LOGICAL_CHANNEL_DESCRIPTOR:
ParseLogicalChannels((LogicalChannelDescriptor *) d, tsinfo);
break;
case NETWORK_NAME_DESCRIPTOR:
{
NetworkNameDescriptor * nd = (NetworkNameDescriptor *) d;
int tsidonid = (tsinfo->getTransportStreamId() << 16) | tsinfo->getOriginalNetworkId();
std::string networkName = stringDVBUTF8(nd->getNetworkName(), 0, tsidonid);
printf("NIT: network name [%s]\n", networkName.c_str());
}
break;
default:
{
#ifdef DEBUG_NIT_UNUSED
@@ -283,3 +297,25 @@ bool CNit::ParseServiceList(ServiceListDescriptor * sd, TransportStreamInfo * ts
}
return true;
}
bool CNit::ParseLogicalChannels(LogicalChannelDescriptor * ld, TransportStreamInfo * tsinfo)
{
t_transport_stream_id transport_stream_id = tsinfo->getTransportStreamId();
t_original_network_id original_network_id = tsinfo->getOriginalNetworkId();
const LogicalChannelList &clist = *ld->getChannelList();
LogicalChannelListConstIterator it;
for (it = clist.begin(); it != clist.end(); ++it) {
t_service_id service_id = (*it)->getServiceId();
int lcn = (*it)->getLogicalChannelNumber();
/* FIXME dont use freq_id / satellitePosition ? */
t_channel_id channel_id = CZapitChannel::makeChannelId(satellitePosition,
freq_id, transport_stream_id, original_network_id, service_id);
// (*it)->getVisibleServiceFlag();
logical_map[channel_id] = lcn;
#ifdef DEBUG_LCN
printf("NIT: lcn tsid %04x onid %04x %llx -> %d\n", transport_stream_id, original_network_id, channel_id, lcn);
#endif
}
return true;
}