mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-01 01:41:23 +02:00
zapit/src/scanbat.cpp: api to get BAT bouquets
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#define BAT_SECTION_SIZE 4098
|
#define BAT_SECTION_SIZE 4098
|
||||||
|
|
||||||
typedef std::map <t_channel_id, int> channel_number_map_t;
|
typedef std::map <t_channel_id, int> channel_number_map_t;
|
||||||
|
typedef std::map <std::string, std::set<t_channel_id> > bouquet_map_t;
|
||||||
|
|
||||||
class CBat : public OpenThreads::Thread
|
class CBat : public OpenThreads::Thread
|
||||||
{
|
{
|
||||||
@@ -42,6 +43,8 @@ class CBat : public OpenThreads::Thread
|
|||||||
t_satellite_position satellitePosition;
|
t_satellite_position satellitePosition;
|
||||||
freq_id_t freq_id;
|
freq_id_t freq_id;
|
||||||
channel_number_map_t logical_map;
|
channel_number_map_t logical_map;
|
||||||
|
bouquet_map_t bouquet_map;
|
||||||
|
std::string bouquetName;
|
||||||
|
|
||||||
BouquetAssociationSectionList sections;
|
BouquetAssociationSectionList sections;
|
||||||
|
|
||||||
@@ -56,7 +59,8 @@ class CBat : public OpenThreads::Thread
|
|||||||
bool Start();
|
bool Start();
|
||||||
bool Stop();
|
bool Stop();
|
||||||
bool Parse();
|
bool Parse();
|
||||||
channel_number_map_t & getLogicalMap() { return logical_map; };
|
channel_number_map_t & getLogicalMap() { return logical_map; }
|
||||||
|
bouquet_map_t & getBouquets() { return bouquet_map; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -34,6 +34,11 @@
|
|||||||
#define DEBUG_BAT_UNUSED
|
#define DEBUG_BAT_UNUSED
|
||||||
#define DEBUG_LCN
|
#define DEBUG_LCN
|
||||||
|
|
||||||
|
static bool compare_section_num(BouquetAssociationSection * first, BouquetAssociationSection * second)
|
||||||
|
{
|
||||||
|
return first->getSectionNumber() < second->getSectionNumber();
|
||||||
|
}
|
||||||
|
|
||||||
CBat::CBat(t_satellite_position spos, freq_id_t frq, int dnum)
|
CBat::CBat(t_satellite_position spos, freq_id_t frq, int dnum)
|
||||||
{
|
{
|
||||||
satellitePosition = spos;
|
satellitePosition = spos;
|
||||||
@@ -141,6 +146,7 @@ bool CBat::Parse()
|
|||||||
if(!Read())
|
if(!Read())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
sections.sort(compare_section_num);
|
||||||
BouquetAssociationSectionConstIterator sit;
|
BouquetAssociationSectionConstIterator sit;
|
||||||
for (sit = sections.begin(); sit != sections.end(); ++sit) {
|
for (sit = sections.begin(); sit != sections.end(); ++sit) {
|
||||||
BouquetAssociationSection * bat = *sit;
|
BouquetAssociationSection * bat = *sit;
|
||||||
@@ -162,7 +168,7 @@ bool CBat::Parse()
|
|||||||
case BOUQUET_NAME_DESCRIPTOR:
|
case BOUQUET_NAME_DESCRIPTOR:
|
||||||
{
|
{
|
||||||
BouquetNameDescriptor * nd = (BouquetNameDescriptor *) d;
|
BouquetNameDescriptor * nd = (BouquetNameDescriptor *) d;
|
||||||
std::string bouquetName = stringDVBUTF8(nd->getBouquetName());
|
/*std::string*/ bouquetName = stringDVBUTF8(nd->getBouquetName());
|
||||||
printf("BAT: bouquet name [%s]\n", bouquetName.c_str());
|
printf("BAT: bouquet name [%s]\n", bouquetName.c_str());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -267,15 +273,16 @@ bool CBat::ParseServiceList(ServiceListDescriptor * sd, BouquetAssociation * b)
|
|||||||
ServiceListItemConstIterator it;
|
ServiceListItemConstIterator it;
|
||||||
for (it = slist->begin(); it != slist->end(); ++it) {
|
for (it = slist->begin(); it != slist->end(); ++it) {
|
||||||
ServiceListItem * s = *it;
|
ServiceListItem * s = *it;
|
||||||
#if 0
|
#if 1
|
||||||
t_channel_id channel_id = CZapitChannel::makeChannelId(satellitePosition,
|
t_channel_id channel_id = CZapitChannel::makeChannelId(0 /*satellitePosition*/,
|
||||||
freq_id, b->getTransportStreamId(), b->getOriginalNetworkId(), s->getServiceId());
|
0 /*freq_id*/, b->getTransportStreamId(), b->getOriginalNetworkId(), s->getServiceId());
|
||||||
CServiceScan::getInstance()->AddServiceType(channel_id, s->getServiceType());
|
CServiceScan::getInstance()->AddServiceType(channel_id, s->getServiceType());
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEBUG_BAT
|
#ifdef DEBUG_BAT
|
||||||
printf("BAT: service tsid %04x onid %04x sid %04x type %02x\n",
|
printf("BAT: service tsid %04x onid %04x sid %04x type %02x\n",
|
||||||
b->getTransportStreamId(), b->getOriginalNetworkId(), s->getServiceId(), s->getServiceType());
|
b->getTransportStreamId(), b->getOriginalNetworkId(), s->getServiceId(), s->getServiceType());
|
||||||
#endif
|
#endif
|
||||||
|
bouquet_map[bouquetName].insert(channel_id);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -288,8 +295,11 @@ bool CBat::ParseLogicalChannels(LogicalChannelDescriptor * ld, BouquetAssociatio
|
|||||||
const LogicalChannelList &clist = *ld->getChannelList();
|
const LogicalChannelList &clist = *ld->getChannelList();
|
||||||
LogicalChannelListConstIterator it;
|
LogicalChannelListConstIterator it;
|
||||||
for (it = clist.begin(); it != clist.end(); ++it) {
|
for (it = clist.begin(); it != clist.end(); ++it) {
|
||||||
t_service_id service_id = (*it)->getServiceId();
|
|
||||||
int lcn = (*it)->getLogicalChannelNumber();
|
int lcn = (*it)->getLogicalChannelNumber();
|
||||||
|
if(lcn == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
t_service_id service_id = (*it)->getServiceId();
|
||||||
t_channel_id channel_id = CZapitChannel::makeChannelId(0, 0,
|
t_channel_id channel_id = CZapitChannel::makeChannelId(0, 0,
|
||||||
transport_stream_id, original_network_id, service_id);
|
transport_stream_id, original_network_id, service_id);
|
||||||
/* (*it)->getVisibleServiceFlag(); */
|
/* (*it)->getVisibleServiceFlag(); */
|
||||||
@@ -299,7 +309,7 @@ bool CBat::ParseLogicalChannels(LogicalChannelDescriptor * ld, BouquetAssociatio
|
|||||||
CZapitChannel * chan = CServiceManager::getInstance()->FindChannel48(channel_id);
|
CZapitChannel * chan = CServiceManager::getInstance()->FindChannel48(channel_id);
|
||||||
if(chan)
|
if(chan)
|
||||||
name = chan->getName();
|
name = chan->getName();
|
||||||
printf("BAT: logical channel %05d: tsid %04x onid %04x %016llx [%s]\n", lcn, transport_stream_id, original_network_id, channel_id, name.c_str());
|
printf("BAT: logical channel %05d: tsid %04x onid %04x %016llx [%s] visible %d\n", lcn, transport_stream_id, original_network_id, channel_id, name.c_str(), (*it)->getVisibleServiceFlag());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user