eitd: remove all code inder #ifdef UPDATE_NETWORKS

This commit is contained in:
[CST] Focus
2012-02-01 21:00:45 +04:00
parent de2140ec78
commit db26589266
4 changed files with 5 additions and 3007 deletions

View File

@@ -40,10 +40,6 @@
#include "SIutils.hpp"
#include "SIservices.hpp"
#include "SIevents.hpp"
#ifdef UPDATE_NETWORKS
#include "SIbouquets.hpp"
#include "SInetworks.hpp"
#endif
#include "SIsections.hpp"
#include <dmxapi.h>

View File

@@ -37,23 +37,13 @@
#include "SIutils.hpp"
#include "SIservices.hpp"
#include "SIevents.hpp"
#ifdef UPDATE_NETWORKS
#include "SIbouquets.hpp"
#include "SInetworks.hpp"
#endif
#include "SIsections.hpp"
#include <dmxapi.h>
#include <zapit/dvbstring.h>
#include <edvbstring.h>
#ifdef ENABLE_FREESATEPG
#include "FreesatTables.hpp"
#endif
#define NOVA 0x3ffe
#define CANALDIGITAAL 0x3fff
//#define DEBUG
struct descr_generic_header {
unsigned descriptor_tag : 8;
unsigned descriptor_length : 8;
@@ -869,401 +859,3 @@ void SIsectionSDT::parse(void)
parsed = 1;
}
#ifdef UPDATE_NETWORKS
/************************************/
/*
//Within the Service List all Channels of a bouquet are specified
int SIsectionBAT::parseServiceListDescriptor(const char *buf, SIbouquet &s, int section_no, int count)
{
struct descr_generic_header *sv=(struct descr_generic_header *)buf;
buf+=sizeof(struct descr_generic_header);
unsigned short len = sv->descriptor_length;
while(len >= sizeof(struct service_list_entry)) {
struct service_list_entry *sl=(struct service_list_entry *)buf;
buf+=sizeof(struct service_list_entry);
SIbouquet bs(s);
bs.service_id=(sl->service_id_hi << 8) | sl->service_id_lo;
bs.serviceTyp=sl->service_type;
bs.position = (uint16_t) (((section_no & 0x1f) << 11) + (count & 0x7ff));
// printf("Section Number: %d Count: %d position: %04x\n", section_no, count, bs.position);
bsv.insert(bs);
len -= sizeof(struct service_list_entry);
count++;
}
return count;
}
void SIsectionBAT::parseBouquetNameDescriptor(const char *buf, SIbouquet &s)
{
struct descr_generic_header *sv=(struct descr_generic_header *)buf;
buf+=sizeof(struct descr_generic_header);
if(sv->descriptor_length) {
// if(*buf < 0x06) // other code table
// s.bouquetName=std::string(buf+1, sv->descriptor_length-1);
//else
//s.bouquetName=std::string(buf, sv->descriptor_length);
s.bouquetName = CDVBString((const char *)(buf), sv->descriptor_length).getContent();
}
//printf("Bouquet-Name: %s\n", s.bouquetName.c_str());
}
int SIsectionBAT::parseDescriptors(const char *des, unsigned len, SIbouquet &s, int section_no, int count, const char *bouquetName)
{
struct descr_generic_header *desc;
while(len>=sizeof(struct descr_generic_header)) {
desc=(struct descr_generic_header *)des;
// printf("Type: %s\n", decode_descr(desc->descriptor_tag));
// printf("Length: %hhu\n", desc->descriptor_length);
if(desc->descriptor_tag==0x41) {
// printf("Found service list descriptor\n");
count = parseServiceListDescriptor((const char *)desc, s, section_no, count);
}
// else if(desc->descriptor_tag==0x47) {
// printf("Found bouquet name descriptor\n");
// parseBouquetNameDescriptor((const char *)desc, s);
// }
len-=desc->descriptor_length+2;
des+=desc->descriptor_length+2;
}
return count;
}
*/
// Die infos aus dem Puffer holen
void SIsectionBAT::parse(void)
{
const char *actPos;
struct bat_service *sv;
// struct bouquet_ident bi;
struct SI_section_BAT_header *bh;
unsigned short descriptors_loop_length;
unsigned short descriptors_length;
uint32_t current_private_data_specifier;
struct loop_len *ll;
// std::string bouquetName = "";
if (!buffer || parsed)
return;
if (bufferLength < sizeof(SI_section_BAT_header) + sizeof(struct bat_service)) {
printf("BAT fix?\n"); //No Services possible - length too short
bufferLength=0;
return;
}
actPos = &buffer[0]; // We need Bouquet ID and bouquet descriptor length from header
bh = (struct SI_section_BAT_header *)actPos; // Header
t_bouquet_id bouquet_id = (bh->bouquet_id_hi << 8) | bh->bouquet_id_lo;
// printf("hi: %hu lo: %hu\n", bh->bouquet_descriptors_length_hi, bh->bouquet_descriptors_length_lo);
descriptors_loop_length = (bh->bouquet_descriptors_length_hi << 8) | bh->bouquet_descriptors_length_lo;
// SIbouquet s((bh->bouquet_id_hi << 8) | bh->bouquet_id_lo); //Create a new Bouquet entry
// printf("ident: %hu actpos: %p buf+bl: %p desclen: %hu\n", bi.bouquet_id, actPos, buffer+bufferLength, descriptors_loop_length);
int count = 0;
//Fill out Bouquet Name
//count = parseDescriptors(((const char *)bh) + sizeof(SI_section_BAT_header), descriptors_loop_length, s, bh->section_number, count);
const char *des = ((const char *)bh) + sizeof(SI_section_BAT_header);
unsigned len = descriptors_loop_length;
struct descr_generic_header *desc;
struct descr_generic_header *privdesc = NULL;
std::string bouquetName = "";
current_private_data_specifier = 0;
while(len>=sizeof(struct descr_generic_header)) {
desc=(struct descr_generic_header *)des;
if(desc->descriptor_tag==0x47) {
// printf("Found bouquet name descriptor\n");
//parseBouquetNameDescriptor((const char *)desc, s);
const char *buf = (const char *) desc;
//struct descr_generic_header *sv=(struct descr_generic_header *)buf;
buf+=sizeof(struct descr_generic_header);
if(desc->descriptor_length) {
/*
if(*buf < 0x06) // other code table
s.bouquetName=std::string(buf+1, sv->descriptor_length-1);
else
s.bouquetName=std::string(buf, sv->descriptor_length);
*/
//Mega stupid providers do not reserve their own bouquet_id
//So we do it for them... f*ck that's stupid too, but what else can we do...
if (bouquet_id == 0x0001) {
if (!strncmp((const char *) buf, "NOVA", 4))
bouquet_id = NOVA;
if (!strncmp((const char *) buf, "CanalDigitaal", 13))
bouquet_id = CANALDIGITAAL;
}
bouquetName = CDVBString((const char *)(buf), desc->descriptor_length).getContent();
}
}
if (desc->descriptor_tag == 0x5f) {
const char *buf = (const char *) desc;
//struct descr_generic_header *sv=(struct descr_generic_header *)buf;
buf+=sizeof(struct descr_generic_header);
struct private_data_specifier *pds=(struct private_data_specifier *)buf;
buf+=sizeof(struct private_data_specifier);
current_private_data_specifier=(((pds->byte1 << 24) | (pds->byte2 << 16)) | (pds->byte3 << 8)) | pds->byte4;
//printf("Private Data Specifier: %08x\n", current_private_data_specifier);
}
len-=desc->descriptor_length+2;
des+=desc->descriptor_length+2;
}
//s.bouquetName = bouquetName;
actPos += sizeof(SI_section_BAT_header) + descriptors_loop_length;
ll = (struct loop_len *)actPos;
descriptors_loop_length = (ll->descriptors_loop_length_hi << 8) | ll->descriptors_loop_length_lo; //len is not used at the moment
// printf("desclen: %hu\n", descriptors_loop_length);
actPos += sizeof(loop_len);
if (bouquet_id != 0x0001) {
while (actPos <= &buffer[bufferLength - sizeof(struct bat_service)]) {
sv = (struct bat_service *)actPos;
//s.transport_stream_id = (sv->transport_stream_id_hi << 8) | sv->transport_stream_id_lo;
//s.original_network_id = (sv->original_network_id_hi << 8) | sv->original_network_id_lo;
// s.position = (uint16_t) (((bh->section_number & 0x1f) << 11) + (count & 0x7ff));
// printf("Section Number: %d Count: %d position: %04x\n", bh->section_number, count, s.position);
descriptors_length = (sv->descriptors_loop_length_hi << 8) | sv->descriptors_loop_length_lo;
// Transport Stream Loop
//count = parseDescriptors(((const char *)sv) + sizeof(struct bat_service), descriptors_length, s, bh->section_number, count,
//(const char *) bouquetName[0]);
bool found = false;
int loop_count = 1;
while (loop_count >= 0) {
const char *des_ = ((const char *)sv) + sizeof(struct bat_service);
len = descriptors_length;
while(len>=sizeof(struct descr_generic_header)) {
desc=(struct descr_generic_header *)des_;
// printf("Type: %s\n", decode_descr(desc->descriptor_tag));
// printf("Length: %hhu\n", desc->descriptor_length);
const char *buf = (const char *) desc;
buf+=sizeof(struct descr_generic_header);
unsigned short dlen = desc->descriptor_length;
if ((desc->descriptor_tag==0x41) && (loop_count == 0) && (current_private_data_specifier != 0x00000002)) {
// printf("Found service list descriptor\n");
//count = parseServiceListDescriptor((const char *)desc, s, section_no, count);
//struct descr_generic_header *sv=(struct descr_generic_header *)buf;
while(dlen >= sizeof(struct service_list_entry)) {
struct service_list_entry *sl=(struct service_list_entry *)buf;
buf+=sizeof(struct service_list_entry);
SIbouquet bs(bouquet_id);
bs.bouquetName = bouquetName;
bs.transport_stream_id = (sv->transport_stream_id_hi << 8) | sv->transport_stream_id_lo;
bs.original_network_id = (sv->original_network_id_hi << 8) | sv->original_network_id_lo;
bs.service_id=(sl->service_id_hi << 8) | sl->service_id_lo;
bs.serviceTyp=sl->service_type;
bs.position = (uint16_t) (((bh->section_number & 0x1f) << 11) + (count & 0x7ff));
if (found) {
const char *privbuf = (const char *) privdesc;
privbuf+=sizeof(struct descr_generic_header);
unsigned short privdlen = privdesc->descriptor_length;
bool found_posi = false;
int order_entry_size;
order_entry_size = sizeof(struct digplus_order_entry);
while ((privdlen >= order_entry_size) && (!found_posi)) {
struct digplus_order_entry *oe = (struct digplus_order_entry *)privbuf;
privbuf+=order_entry_size;
/*
printf("Search: %04x Service_id: %04x Posi:%04x\n",
(sl->service_id_hi << 8) | sl->service_id_lo,
(oe->service_id_hi << 8) | oe->service_id_lo,
(oe->channel_number_hi << 8) | oe->channel_number_lo);
*/
if ( ((sl->service_id_hi << 8) | sl->service_id_lo) ==
((oe->service_id_hi << 8) | oe->service_id_lo)) {
bs.position = (oe->channel_number_hi << 8) | oe->channel_number_lo;
/*
printf("Found Search: %04x Service_id: %04x Posi:%04x\n",
(sl->service_id_hi << 8) | sl->service_id_lo,
current_service_id,
current_channel_number);
*/
found_posi=true;
}
privdlen -= order_entry_size;
}
if (!found_posi)
bs.position = 0xffff;
}
// printf("Section Number: %d Count: %d position: %04x\n", section_no, count, bs.position);
//printf("Set Position: %04x\n",bs.position);
bsv.insert(bs);
dlen -= sizeof(struct service_list_entry);
count++;
}
}
if (desc->descriptor_tag == 0x5f) {
struct private_data_specifier *pds=(struct private_data_specifier *)buf;
buf+=sizeof(struct private_data_specifier);
if ((pds->byte1 != 0) || (pds->byte2 != 0) || (pds->byte3 != 0) || (pds->byte4 != 0))
current_private_data_specifier=(((pds->byte1 << 24) | (pds->byte2 << 16)) |
(pds->byte3 << 8)) | pds->byte4;
//printf("Private Data Specifier: %08x\n", current_private_data_specifier);
}
if (desc->descriptor_tag == 0x81) {
if (current_private_data_specifier == 0x55504300) {
//printf("UPC Bouquet ordering descriptor found!\n");
privdesc = (struct descr_generic_header *)desc;
found = true;
}
}
if (desc->descriptor_tag == 0x82) {
if ((current_private_data_specifier == 0x00000010) || (bouquet_id == 0x0021)) {
//printf("TPS Bouquet ordering descriptor found!\n");
privdesc = (struct descr_generic_header *)desc;
found = true;
}
}
if (desc->descriptor_tag == 0x83) {
if ((current_private_data_specifier == 0x000000c0) || (current_private_data_specifier == 0x0000003a)) {
//printf("Canal+ Bouquet ordering descriptor found!\n");
privdesc = (struct descr_generic_header *)desc;
found = true;
}
}
if (desc->descriptor_tag == 0x93) {
if ((current_private_data_specifier == 0x00362275) || (bouquet_id == CANALDIGITAAL)) {
//printf("Irdeto Bouquet ordering descriptor found!\n");
privdesc = (struct descr_generic_header *)desc;
found = true;
}
}
if ((desc->descriptor_tag == 0xb1) && (loop_count == 0)) {
if (current_private_data_specifier == 0x00000002) {
//printf("BSkyB Bouquet ordering descriptor found!\n");
const char *privbuf = (const char *) desc;
privbuf+=sizeof(struct descr_generic_header);
unsigned short privdlen = desc->descriptor_length - 2;
//Nirvana 27.4.06: first 2 bytes still unknown: always 0xffff on sky italia?
//check if resulting bouquets on 28.2E look more sensible...
struct bskyb_bid *bid = (struct bskyb_bid *)privbuf;
if ((bid->unknown1 == 0xff) && (bid->unknown2 == 0xff)) {
privbuf+=2; //first 2 bytes of each 0xb1 desc unknown
while (privdlen >= sizeof(struct bskyb_order_entry)) {
struct bskyb_order_entry *oe = (struct bskyb_order_entry *)privbuf;
privbuf+=sizeof(struct bskyb_order_entry);
SIbouquet bs(bouquet_id);
bs.bouquetName = bouquetName;
bs.transport_stream_id = (sv->transport_stream_id_hi << 8) |
sv->transport_stream_id_lo;
bs.original_network_id = (sv->original_network_id_hi << 8) |
sv->original_network_id_lo;
bs.service_id = (oe->service_id_hi << 8) | oe->service_id_lo;
bs.serviceTyp = oe->service_type;
bs.position = (oe->channel_number_hi << 8) | oe->channel_number_lo;
bsv.insert(bs);
privdlen -= sizeof(struct bskyb_order_entry);
}
}
}
}
len-=desc->descriptor_length+2;
des_+=desc->descriptor_length+2;
}
loop_count--;
}
actPos += sizeof(struct bat_service) + descriptors_length;
// count++;
}
}
parsed = 1;
}
void SIsectionNIT::copyDeliveryDescriptor(const char *buf, SInetwork &s)
{
//struct descr_generic_header *sv=(struct descr_generic_header *)buf;
buf+=sizeof(struct descr_generic_header);
memmove(s.delivery_descriptor, buf, sizeof(struct satellite_delivery_descriptor)); //same size as cable...
//printf("Bouquet-Name: %s\n", s.bouquetName.c_str());
}
void SIsectionNIT::parseDescriptors(const char *des, unsigned len, SInetwork &s)
{
// struct satellite_delivery_descriptor *sdd;
// const char *ddp;
// t_transport_stream_id tsid;
// t_original_network_id onid;
// unsigned short orbital_pos;
struct descr_generic_header *desc;
des += sizeof(struct nit_transponder);
len -= sizeof(struct nit_transponder);
while(len>=sizeof(struct descr_generic_header)) {
desc=(struct descr_generic_header *)des;
// printf("Type: %s\n", decode_descr(desc->descriptor_tag));
// printf("Length: %hhu\n", desc->descriptor_length);
if ( (desc->descriptor_tag==0x43) || (desc->descriptor_tag==0x44) ) {
s.delivery_type = desc->descriptor_tag;
// printf("Found satellite_delivery_system_descriptor\n");
copyDeliveryDescriptor((const char *)desc, s);
// ddp = &s.delivery_descriptor[0];
// sdd = (struct satellite_delivery_descriptor *)ddp;
// tsid = s.transport_stream_id;
// onid = s.original_network_id;
// orbital_pos = (sdd->orbital_pos_hi << 8) | sdd->orbital_pos_lo;
// printf("ONID: %04x TSID: %04x Orbital Position: %d\n", onid, tsid, orbital_pos);
}
len-=desc->descriptor_length+2;
des+=desc->descriptor_length+2;
}
}
// Die infos aus dem Puffer holen
void SIsectionNIT::parse(void)
{
const char *actPos;
const char *bufEnd;
struct nit_transponder *tp;
struct SI_section_NIT_header *nh;
unsigned short descriptors_loop_length;
unsigned short descriptors_length;
struct loop_len *ll;
//t_network_id network_id;
if (!buffer || parsed)
return;
if (bufferLength < sizeof(SI_section_NIT_header) + sizeof(struct nit_transponder)) {
printf("NIT fix?\n"); //No Services possible - length too short
bufferLength=0;
return;
}
actPos = buffer; // We need Bouquet ID and bouquet descriptor length from header
bufEnd = buffer + bufferLength;
nh = (struct SI_section_NIT_header *)actPos; // Header
// printf("hi: %hu lo: %hu\n", bh->bouquet_descriptors_length_hi, bh->bouquet_descriptors_length_lo);
descriptors_loop_length = (nh->network_descriptors_length_hi << 8) | nh->network_descriptors_length_lo;
// SIbouquet s((bh->bouquet_id_hi << 8) | bh->bouquet_id_lo); //Create a new Bouquet entry
// printf("ident: %hu actpos: %p buf+bl: %p desclen: %hu\n", bi.bouquet_id, actPos, buffer+bufferLength, descriptors_loop_length);
// parseDescriptors(((const char *)bh) + sizeof(SI_section_BAT_header), descriptors_loop_length, s); //Fill out Bouquet Name
actPos += sizeof(SI_section_NIT_header) + descriptors_loop_length;
ll = (struct loop_len *)actPos;
descriptors_loop_length = (ll->descriptors_loop_length_hi << 8) | ll->descriptors_loop_length_lo; //len is not used at the moment
// printf("desclen: %hu\n", descriptors_loop_length);
actPos += sizeof(loop_len);
while (actPos <= bufEnd - sizeof(struct nit_transponder)) {
tp = (struct nit_transponder *)actPos;
SInetwork s(tp);
s.network_id = (nh->network_id_hi << 8) | nh->network_id_lo;
s.transport_stream_id = (tp->transport_stream_id_hi << 8) | tp->transport_stream_id_lo;
s.original_network_id = (tp->original_network_id_hi << 8) | tp->original_network_id_lo;
descriptors_length = sizeof(struct nit_transponder) + ((tp->descriptors_loop_length_hi << 8) | tp->descriptors_loop_length_lo);
parseDescriptors(actPos, min((unsigned)(bufEnd - actPos), descriptors_length), s); // Transport Stream Loop
ntw.insert(s);
actPos += descriptors_length;
}
parsed = 1;
}
#endif

View File

@@ -26,10 +26,7 @@
//
#include <endian.h>
#ifdef UPDATE_NETWORKS
#include "SInetworks.hpp"
#include "SIbouquets.hpp"
#endif
struct SI_section_SDT_header {
unsigned table_id : 8;
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -681,129 +678,4 @@ private:
void parseNVODreferenceDescriptor(const char *buf, SIservice &s);
};
#ifdef UPDATE_NETWORKS
class SIsectionBAT : public SIsection
{
public:
SIsectionBAT(const SIsection &s) : SIsection(s) {
parsed = 0;
parse();
}
// Std-Copy
SIsectionBAT(const SIsectionBAT &s) : SIsection(s) {
bsv = s.bsv;
parsed = s.parsed;
}
// Benutzt den uebergebenen Puffer (sollte mit new char[n] allokiert sein)
SIsectionBAT(unsigned bufLength, char *buf) : SIsection(bufLength, buf) {
parsed = 0;
parse();
}
unsigned short bouquetID(void) const {
return buffer ? ((((struct SI_section_BAT_header *)buffer)->bouquet_id_hi << 8) |
((struct SI_section_BAT_header *)buffer)->bouquet_id_lo) : (unsigned short) -1;
}
struct SI_section_BAT_header const *header(void) const {
return (struct SI_section_BAT_header *)buffer;
}
static void dump(const struct SI_section_BAT_header *header) {
if (!header)
return;
SIsection::dump1((const struct SI_section_header *)header);
printf("bouquet_id: 0x%02x%02x\n", header->bouquet_id_hi, header->bouquet_id_lo);
SIsection::dump2((const struct SI_section_header *)header);
printf("bouquet_descriptors_length %hu\n",
(header->bouquet_descriptors_length_hi << 8) | header->bouquet_descriptors_length_lo);
}
static void dump(const SIsectionBAT &s) {
dump((struct SI_section_BAT_header *)s.buffer);
}
void dump(void) const {
dump((struct SI_section_BAT_header *)buffer);
}
const SIbouquets &bouquets(void) const {
//if(!parsed)
// parse(); -> nicht const
return bsv;
}
protected:
SIbouquets bsv;
int parsed;
void parse(void);
// int parseDescriptors(const char *desc, unsigned len, SIbouquet &s, int section_no, int count, const char *bouquetName);
// void parseBouquetNameDescriptor(const char *buf, SIbouquet &s);
// int parseServiceListDescriptor(const char *buf, SIbouquet &s, int section_no, int count);
};
class SIsectionNIT : public SIsection
{
public:
SIsectionNIT(const SIsection &s) : SIsection(s) {
parsed = 0;
parse();
}
// Std-Copy
SIsectionNIT(const SIsectionNIT &s) : SIsection(s) {
ntw = s.ntw;
parsed = s.parsed;
}
// Benutzt den uebergebenen Puffer (sollte mit new char[n] allokiert sein)
SIsectionNIT(unsigned bufLength, char *buf) : SIsection(bufLength, buf) {
parsed = 0;
parse();
}
unsigned short networkID(void) const {
return buffer ? ((((struct SI_section_NIT_header *)buffer)->network_id_hi << 8) |
((struct SI_section_NIT_header *)buffer)->network_id_lo) : (unsigned short) -1;
}
struct SI_section_NIT_header const *header(void) const {
return (struct SI_section_NIT_header *)buffer;
}
static void dump(const struct SI_section_NIT_header *header) {
if (!header)
return;
SIsection::dump1((const struct SI_section_header *)header);
printf("network_id: 0x%02x%02x\n", header->network_id_hi, header->network_id_lo);
SIsection::dump2((const struct SI_section_header *)header);
printf("network_descriptors_length %hu\n",
(header->network_descriptors_length_hi << 8) | header->network_descriptors_length_lo);
}
static void dump(const SIsectionNIT &s) {
dump((struct SI_section_NIT_header *)s.buffer);
}
void dump(void) const {
dump((struct SI_section_NIT_header *)buffer);
}
const SInetworks &networks(void) const {
//if(!parsed)
// parse(); -> nicht const
return ntw;
}
protected:
SInetworks ntw;
int parsed;
void parse(void);
void parseDescriptors(const char *desc, unsigned len, SInetwork &s);
void copyDeliveryDescriptor(const char *buf, SInetwork &s);
};
#endif
#endif // SISECTIONS_HPP

File diff suppressed because it is too large Load Diff