eitd: comment most of unused code

Origin commit data
------------------
Branch: ni/coolstream
Commit: 551cce893a
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2012-02-08 (Wed, 08 Feb 2012)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2012-02-08 21:01:50 +04:00
parent d68f9d7d9a
commit e50494a908
4 changed files with 482 additions and 466 deletions

View File

@@ -52,6 +52,7 @@
const std::string languangeOFF = "OFF"; const std::string languangeOFF = "OFF";
#if 0
SIevent::SIevent(const struct eit_event *e) SIevent::SIevent(const struct eit_event *e)
{ {
eventID = (e->event_id_hi << 8) | e->event_id_lo; eventID = (e->event_id_hi << 8) | e->event_id_lo;
@@ -75,6 +76,7 @@ SIevent::SIevent(const struct eit_event *e)
original_network_id = 0; original_network_id = 0;
transport_stream_id = 0; transport_stream_id = 0;
} }
#endif
SIevent::SIevent(const t_original_network_id _original_network_id, const t_transport_stream_id _transport_stream_id, const t_service_id _service_id, SIevent::SIevent(const t_original_network_id _original_network_id, const t_transport_stream_id _transport_stream_id, const t_service_id _service_id,
const unsigned short _event_id) const unsigned short _event_id)
@@ -177,6 +179,7 @@ void SIevent::parse(Event &event)
} }
} }
#if 0
// Std-Copy // Std-Copy
SIevent::SIevent(const SIevent &e) SIevent::SIevent(const SIevent &e)
{ {
@@ -202,20 +205,7 @@ SIevent::SIevent(const SIevent &e)
table_id = e.table_id; table_id = e.table_id;
version = e.version; version = e.version;
} }
#endif
int SIevent::saveXML(FILE *file, const char *serviceName) const
{
if(saveXML0(file))
return 1;
if(serviceName) {
if(fprintf(file, " <service_name>")<0)
return 2;
saveStringToXMLfile(file, serviceName);
if(fprintf(file, "</service_name>\n")<0)
return 3;
}
return saveXML2(file);
}
char SIevent::getFSK() const char SIevent::getFSK() const
{ {
@@ -240,65 +230,6 @@ char SIevent::getFSK() const
return 0x00; // 0x00 undefined return 0x00; // 0x00 undefined
} }
int SIevent::saveXML0(FILE *file) const
{
if(fprintf(file, "\t\t<event id=\"%04x\">\n", eventID)<0)
return 1;
return 0;
}
int SIevent::saveXML2(FILE *file) const
{
for (std::map<std::string, std::string>::const_iterator
i = langName.begin() ;
i != langName.end() ;
i++) {
if (i->second.length()) {
fprintf(file, "\t\t\t<name lang=\"%s\" string=\"", i->first.c_str());
saveStringToXMLfile(file, i->second.c_str());
fprintf(file, "\"/>\n");
}
}
for (std::map<std::string, std::string>::const_iterator
i = langText.begin() ;
i != langText.end() ;
i++) {
if (i->second.length()) {
fprintf(file, "\t\t\t<text lang=\"%s\" string=\"", i->first.c_str());
saveStringToXMLfile(file, i->second.c_str());
fprintf(file, "\"/>\n");
}
}
if(item.length()) {
fprintf(file, "\t\t\t<item string=\"");
saveStringToXMLfile(file, item.c_str());
fprintf(file, "\"/>\n");
}
if(itemDescription.length()) {
fprintf(file, "\t\t\t<item_description string=\"");
saveStringToXMLfile(file, itemDescription.c_str());
fprintf(file, "\"/>\n");
}
for (std::map<std::string, std::string>::const_iterator
i = langExtendedText.begin() ;
i != langExtendedText.end() ;
i++) {
if (i->second.length()) {
fprintf(file, "\t\t\t<extended_text lang=\"%s\" string=\"", i->first.c_str());
saveStringToXMLfile(file, i->second.c_str());
fprintf(file, "\"/>\n");
}
}
for_each(times.begin(), times.end(), saveSItimeXML(file));
for(unsigned i=0; i<contentClassification.length(); i++)
fprintf(file, "\t\t\t<content class=\"%02x\" user=\"%02x\"/>\n", contentClassification[i], userClassification[i]);
for_each(components.begin(), components.end(), saveSIcomponentXML(file));
for_each(ratings.begin(), ratings.end(), saveSIparentalRatingXML(file));
for_each(linkage_descs.begin(), linkage_descs.end(), saveSIlinkageXML(file));
fprintf(file, "\t\t</event>\n");
return 0;
}
std::string SIevent::getName() const std::string SIevent::getName() const
{ {
if (CSectionsdClient::LANGUAGE_MODE_OFF == SIlanguage::getMode()) { if (CSectionsdClient::LANGUAGE_MODE_OFF == SIlanguage::getMode()) {
@@ -379,6 +310,79 @@ void SIevent::setExtendedText(const std::string &lang, const std::string &text)
} }
} }
int SIevent::saveXML(FILE *file, const char *serviceName) const
{
if(saveXML0(file))
return 1;
if(serviceName) {
if(fprintf(file, " <service_name>")<0)
return 2;
saveStringToXMLfile(file, serviceName);
if(fprintf(file, "</service_name>\n")<0)
return 3;
}
return saveXML2(file);
}
int SIevent::saveXML0(FILE *file) const
{
if(fprintf(file, "\t\t<event id=\"%04x\">\n", eventID)<0)
return 1;
return 0;
}
int SIevent::saveXML2(FILE *file) const
{
for (std::map<std::string, std::string>::const_iterator
i = langName.begin() ;
i != langName.end() ;
i++) {
if (i->second.length()) {
fprintf(file, "\t\t\t<name lang=\"%s\" string=\"", i->first.c_str());
saveStringToXMLfile(file, i->second.c_str());
fprintf(file, "\"/>\n");
}
}
for (std::map<std::string, std::string>::const_iterator
i = langText.begin() ;
i != langText.end() ;
i++) {
if (i->second.length()) {
fprintf(file, "\t\t\t<text lang=\"%s\" string=\"", i->first.c_str());
saveStringToXMLfile(file, i->second.c_str());
fprintf(file, "\"/>\n");
}
}
if(item.length()) {
fprintf(file, "\t\t\t<item string=\"");
saveStringToXMLfile(file, item.c_str());
fprintf(file, "\"/>\n");
}
if(itemDescription.length()) {
fprintf(file, "\t\t\t<item_description string=\"");
saveStringToXMLfile(file, itemDescription.c_str());
fprintf(file, "\"/>\n");
}
for (std::map<std::string, std::string>::const_iterator
i = langExtendedText.begin() ;
i != langExtendedText.end() ;
i++) {
if (i->second.length()) {
fprintf(file, "\t\t\t<extended_text lang=\"%s\" string=\"", i->first.c_str());
saveStringToXMLfile(file, i->second.c_str());
fprintf(file, "\"/>\n");
}
}
for_each(times.begin(), times.end(), saveSItimeXML(file));
for(unsigned i=0; i<contentClassification.length(); i++)
fprintf(file, "\t\t\t<content class=\"%02x\" user=\"%02x\"/>\n", contentClassification[i], userClassification[i]);
for_each(components.begin(), components.end(), saveSIcomponentXML(file));
for_each(ratings.begin(), ratings.end(), saveSIparentalRatingXML(file));
for_each(linkage_descs.begin(), linkage_descs.end(), saveSIlinkageXML(file));
fprintf(file, "\t\t</event>\n");
return 0;
}
void SIevent::dump(void) const void SIevent::dump(void) const
{ {
printf("Unique key: %llx\n", uniqueKey()); printf("Unique key: %llx\n", uniqueKey());
@@ -414,12 +418,7 @@ void SIevent::dump(void) const
printf(" 0x%02hhx", userClassification[i]); printf(" 0x%02hhx", userClassification[i]);
printf("\n"); printf("\n");
} }
/*
if(startzeit)
printf("Startzeit: %s", ctime(&startzeit));
if(dauer)
printf("Dauer: %02u:%02u:%02u (%umin, %us)\n", dauer/3600, (dauer%3600)/60, dauer%60, dauer/60, dauer);
*/
for_each(times.begin(), times.end(), printSItime()); for_each(times.begin(), times.end(), printSItime());
for_each(components.begin(), components.end(), printSIcomponent()); for_each(components.begin(), components.end(), printSIcomponent());
for_each(ratings.begin(), ratings.end(), printSIparentalRating()); for_each(ratings.begin(), ratings.end(), printSIparentalRating());
@@ -437,12 +436,7 @@ void SIevent::dumpSmall(void) const
for (std::map<std::string, std::string>::const_iterator it = langExtendedText.begin() ; for (std::map<std::string, std::string>::const_iterator it = langExtendedText.begin() ;
it != langExtendedText.end() ; ++it) it != langExtendedText.end() ; ++it)
printf("Extended-Text (%s): %s\n", it->first.c_str(), it->second.c_str()); printf("Extended-Text (%s): %s\n", it->first.c_str(), it->second.c_str());
/*
if(startzeit)
printf("Startzeit: %s", ctime(&startzeit));
if(dauer)
printf("Dauer: %02u:%02u:%02u (%umin, %us)\n", dauer/3600, (dauer%3600)/60, dauer%60, dauer/60, dauer);
*/
for_each(times.begin(), times.end(), printSItime()); for_each(times.begin(), times.end(), printSItime());
for_each(ratings.begin(), ratings.end(), printSIparentalRating()); for_each(ratings.begin(), ratings.end(), printSIparentalRating());
for_each(linkage_descs.begin(), linkage_descs.end(), printSIlinkage()); for_each(linkage_descs.begin(), linkage_descs.end(), printSIlinkage());

View File

@@ -38,6 +38,7 @@ class SIservice;
class SIservices; class SIservices;
class SIbouquets; class SIbouquets;
#if 0
struct eit_event { struct eit_event {
unsigned event_id_hi : 8; unsigned event_id_hi : 8;
unsigned event_id_lo : 8; unsigned event_id_lo : 8;
@@ -61,6 +62,7 @@ struct eit_event {
unsigned descriptors_loop_length_lo : 8; unsigned descriptors_loop_length_lo : 8;
} __attribute__ ((packed)) ; } __attribute__ ((packed)) ;
#endif
struct descr_component_header { struct descr_component_header {
unsigned descriptor_tag : 8; unsigned descriptor_tag : 8;
@@ -79,6 +81,7 @@ struct descr_component_header {
unsigned iso_639_2_language_code_lo : 8; unsigned iso_639_2_language_code_lo : 8;
} __attribute__ ((packed)) ; } __attribute__ ((packed)) ;
#if 0
struct descr_linkage_header { struct descr_linkage_header {
unsigned descriptor_tag : 8; unsigned descriptor_tag : 8;
unsigned descriptor_length : 8; unsigned descriptor_length : 8;
@@ -90,6 +93,7 @@ struct descr_linkage_header {
unsigned service_id_lo : 8; unsigned service_id_lo : 8;
unsigned linkage_type : 8; unsigned linkage_type : 8;
} __attribute__ ((packed)) ; } __attribute__ ((packed)) ;
#endif
struct descr_pdc_header { struct descr_pdc_header {
unsigned descriptor_tag : 8; unsigned descriptor_tag : 8;
@@ -101,6 +105,7 @@ struct descr_pdc_header {
class SIlinkage { class SIlinkage {
public: public:
#if 0
SIlinkage(const struct descr_linkage_header *link) { SIlinkage(const struct descr_linkage_header *link) {
linkageType = link->linkage_type; linkageType = link->linkage_type;
transportStreamId = (link->transport_stream_id_hi << 8) | link->transport_stream_id_lo; transportStreamId = (link->transport_stream_id_hi << 8) | link->transport_stream_id_lo;
@@ -110,7 +115,6 @@ public:
//name = std::string(((const char *)link) + sizeof(struct descr_linkage_header), link->descriptor_length - (sizeof(struct descr_linkage_header) - 2)); //name = std::string(((const char *)link) + sizeof(struct descr_linkage_header), link->descriptor_length - (sizeof(struct descr_linkage_header) - 2));
name = convertDVBUTF8(((const char *)link)+sizeof(struct descr_linkage_header), link->descriptor_length-(sizeof(struct descr_linkage_header)-2), 0, 0); name = convertDVBUTF8(((const char *)link)+sizeof(struct descr_linkage_header), link->descriptor_length-(sizeof(struct descr_linkage_header)-2), 0, 0);
} }
// Std-copy // Std-copy
SIlinkage(const SIlinkage &l) { SIlinkage(const SIlinkage &l) {
linkageType = l.linkageType; linkageType = l.linkageType;
@@ -119,6 +123,7 @@ public:
serviceId = l.serviceId; serviceId = l.serviceId;
name = l.name; name = l.name;
} }
#endif
// default // default
SIlinkage(void) { SIlinkage(void) {
@@ -176,150 +181,145 @@ struct saveSIlinkageXML : public std::unary_function<class SIlinkage, void>
//typedef std::multiset <SIlinkage, std::less<SIlinkage> > SIlinkage_descs; //typedef std::multiset <SIlinkage, std::less<SIlinkage> > SIlinkage_descs;
typedef std::vector<class SIlinkage> SIlinkage_descs; typedef std::vector<class SIlinkage> SIlinkage_descs;
class SIcomponent { class SIcomponent
public: {
SIcomponent(const struct descr_component_header *comp) { public:
streamContent=comp->stream_content; std::string component; // Text aus dem Component Descriptor
componentType=comp->component_type; unsigned char componentType; // Component Descriptor
componentTag=comp->component_tag; unsigned char componentTag; // Component Descriptor
if(comp->descriptor_length>sizeof(struct descr_component_header)-2) unsigned char streamContent; // Component Descriptor
//component=std::string(((const char *)comp)+sizeof(struct descr_component_header), comp->descriptor_length-(sizeof(struct descr_component_header)-2)); #if 0
component=convertDVBUTF8(((const char *)comp)+sizeof(struct descr_component_header), comp->descriptor_length-(sizeof(struct descr_component_header)-2), 0, 0); SIcomponent(const struct descr_component_header *comp) {
} streamContent=comp->stream_content;
// Std-copy componentType=comp->component_type;
SIcomponent(const SIcomponent &c) { componentTag=comp->component_tag;
streamContent=c.streamContent; if(comp->descriptor_length>sizeof(struct descr_component_header)-2)
componentType=c.componentType; //component=std::string(((const char *)comp)+sizeof(struct descr_component_header), comp->descriptor_length-(sizeof(struct descr_component_header)-2));
componentTag=c.componentTag; component=convertDVBUTF8(((const char *)comp)+sizeof(struct descr_component_header), comp->descriptor_length-(sizeof(struct descr_component_header)-2), 0, 0);
component=c.component; }
} // Std-copy
SIcomponent(const SIcomponent &c) {
SIcomponent(void) { streamContent=c.streamContent;
streamContent=0; componentType=c.componentType;
componentType=0; componentTag=c.componentTag;
componentTag=0; component=c.component;
} }
// Der Operator zum sortieren #endif
bool operator < (const SIcomponent& c) const { SIcomponent(void) {
return streamContent < c.streamContent; streamContent=0;
// return component < c.component; componentType=0;
} componentTag=0;
void dump(void) const { }
if(component.length()) // Der Operator zum sortieren
printf("Component: %s\n", component.c_str()); bool operator < (const SIcomponent& c) const {
printf("Stream Content: 0x%02hhx\n", streamContent); return streamContent < c.streamContent;
printf("Component type: 0x%02hhx\n", componentType); }
printf("Component tag: 0x%02hhx\n", componentTag); void dump(void) const {
} if(component.length())
int saveXML(FILE *file) const { printf("Component: %s\n", component.c_str());
fprintf(file, "\t\t\t<component tag=\"%02x\" type=\"%02x\" stream_content=\"%02x\" text=\"", componentTag, componentType, streamContent); printf("Stream Content: 0x%02hhx\n", streamContent);
saveStringToXMLfile(file,component.c_str()); printf("Component type: 0x%02hhx\n", componentType);
fprintf(file, "\"/>\n"); printf("Component tag: 0x%02hhx\n", componentTag);
// %s }
// return 1; int saveXML(FILE *file) const {
// saveStringToXMLfile(file, component.c_str()); fprintf(file, "\t\t\t<component tag=\"%02x\" type=\"%02x\" stream_content=\"%02x\" text=\"", componentTag, componentType, streamContent);
// fprintf(file, "\"/>\n"); saveStringToXMLfile(file,component.c_str());
return 0; fprintf(file, "\"/>\n");
} return 0;
std::string component; // Text aus dem Component Descriptor }
unsigned char componentType; // Component Descriptor
unsigned char componentTag; // Component Descriptor
unsigned char streamContent; // Component Descriptor
}; };
typedef std::multiset <SIcomponent, std::less<SIcomponent> > SIcomponents;
// Fuer for_each // Fuer for_each
struct printSIcomponent : public std::unary_function<class SIcomponent, void> struct printSIcomponent : public std::unary_function<class SIcomponent, void>
{ {
void operator() (const SIcomponent &c) { c.dump();} void operator() (const SIcomponent &c) { c.dump();}
}; };
// Fuer for_each // Fuer for_each
struct saveSIcomponentXML : public std::unary_function<class SIcomponent, void> struct saveSIcomponentXML : public std::unary_function<class SIcomponent, void>
{ {
FILE *f; FILE *f;
saveSIcomponentXML(FILE *fi) { f=fi;} saveSIcomponentXML(FILE *fi) { f=fi;}
void operator() (const SIcomponent &c) { c.saveXML(f);} void operator() (const SIcomponent &c) { c.saveXML(f);}
}; };
typedef std::multiset <SIcomponent, std::less<SIcomponent> > SIcomponents; class SIparentalRating
{
public:
std::string countryCode;
unsigned char rating; // Bei 1-16 -> Minumim Alter = rating +3
class SIparentalRating { SIparentalRating(const std::string &cc, unsigned char rate) {
public: rating=rate;
SIparentalRating(const std::string &cc, unsigned char rate) { countryCode=cc;
rating=rate; }
countryCode=cc; #if 0
} // Std-Copy
// Std-Copy SIparentalRating(const SIparentalRating &r) {
SIparentalRating(const SIparentalRating &r) { rating=r.rating;
rating=r.rating; countryCode=r.countryCode;
countryCode=r.countryCode; }
} #endif
// Der Operator zum sortieren // Der Operator zum sortieren
bool operator < (const SIparentalRating& c) const { bool operator < (const SIparentalRating& c) const {
return countryCode < c.countryCode; return countryCode < c.countryCode;
} }
void dump(void) const { void dump(void) const {
printf("Rating: %s %hhu (+3)\n", countryCode.c_str(), rating); printf("Rating: %s %hhu (+3)\n", countryCode.c_str(), rating);
} }
int saveXML(FILE *file) const { int saveXML(FILE *file) const {
if(fprintf(file, "\t\t\t<parental_rating country=\"%s\" rating=\"%hhu\"/>\n", countryCode.c_str(), rating)<0) if(fprintf(file, "\t\t\t<parental_rating country=\"%s\" rating=\"%hhu\"/>\n", countryCode.c_str(), rating)<0)
return 1; return 1;
return 0; return 0;
} }
std::string countryCode;
unsigned char rating; // Bei 1-16 -> Minumim Alter = rating +3
}; };
// Fuer for_each // Fuer for_each
struct printSIparentalRating : public std::unary_function<SIparentalRating, void> struct printSIparentalRating : public std::unary_function<SIparentalRating, void>
{ {
void operator() (const SIparentalRating &r) { r.dump();} void operator() (const SIparentalRating &r) { r.dump();}
}; };
// Fuer for_each // Fuer for_each
struct saveSIparentalRatingXML : public std::unary_function<SIparentalRating, void> struct saveSIparentalRatingXML : public std::unary_function<SIparentalRating, void>
{ {
FILE *f; FILE *f;
saveSIparentalRatingXML(FILE *fi) { f=fi;} saveSIparentalRatingXML(FILE *fi) { f=fi;}
void operator() (const SIparentalRating &r) { r.saveXML(f);} void operator() (const SIparentalRating &r) { r.saveXML(f);}
}; };
typedef std::set <SIparentalRating, std::less<SIparentalRating> > SIparentalRatings; typedef std::set <SIparentalRating, std::less<SIparentalRating> > SIparentalRatings;
class SItime { class SItime {
public: public:
SItime(time_t s, unsigned d) { time_t startzeit; // lokale Zeit, 0 -> time shifted (cinedoms)
startzeit=s; unsigned dauer; // in Sekunden, 0 -> time shifted (cinedoms)
dauer=d; // in Sekunden, 0 -> time shifted (cinedoms)
} SItime(time_t s, unsigned d) {
// Std-Copy startzeit=s;
SItime(const SItime &t) { dauer=d; // in Sekunden, 0 -> time shifted (cinedoms)
startzeit=t.startzeit; }
dauer=t.dauer; #if 0
} // Std-Copy
// Der Operator zum sortieren SItime(const SItime &t) {
bool operator < (const SItime& t) const { startzeit=t.startzeit;
return startzeit < t.startzeit; dauer=t.dauer;
} }
void dump(void) const { #endif
printf("Startzeit: %s", ctime(&startzeit)); // Der Operator zum sortieren
printf("Dauer: %02u:%02u:%02u (%umin, %us)\n", dauer/3600, (dauer%3600)/60, dauer%60, dauer/60, dauer); bool operator < (const SItime& t) const {
} return startzeit < t.startzeit;
int saveXML(FILE *file) const { // saves the time }
// Ist so noch nicht in Ordnung, das sollte untergliedert werden, void dump(void) const {
// da sonst evtl. time,date,duration,time,date,... auftritt printf("Startzeit: %s", ctime(&startzeit));
// und eine rein sequentielle Ordnung finde ich nicht ok. printf("Dauer: %02u:%02u:%02u (%umin, %us)\n", dauer/3600, (dauer%3600)/60, dauer%60, dauer/60, dauer);
/* }
struct tm *zeit=localtime(&startzeit); int saveXML(FILE *file) const { // saves the time
fprintf(file, "\t\t\t\t\t<time>%02d:%02d:%02d</time>\n", zeit->tm_hour, zeit->tm_min, zeit->tm_sec); fprintf(file, "\t\t\t<time start_time=\"%u\" duration=\"%u\"/>\n", (unsigned int) startzeit, dauer);
fprintf(file, "\t\t\t\t\t<date>%02d.%02d.%04d</date>\n", zeit->tm_mday, zeit->tm_mon+1, zeit->tm_year+1900); return 0;
fprintf(file, "\t\t\t\t\t<duration>%u</duration>\n", dauer); }
*/
fprintf(file, "\t\t\t<time start_time=\"%u\" duration=\"%u\"/>\n", (unsigned int) startzeit, dauer);
return 0;
}
time_t startzeit; // lokale Zeit, 0 -> time shifted (cinedoms)
unsigned dauer; // in Sekunden, 0 -> time shifted (cinedoms)
}; };
typedef std::set <SItime, std::less<SItime> > SItimes; typedef std::set <SItime, std::less<SItime> > SItimes;
@@ -327,109 +327,119 @@ typedef std::set <SItime, std::less<SItime> > SItimes;
// Fuer for_each // Fuer for_each
struct printSItime : public std::unary_function<SItime, void> struct printSItime : public std::unary_function<SItime, void>
{ {
void operator() (const SItime &t) { t.dump();} void operator() (const SItime &t) { t.dump();}
}; };
// Fuer for_each // Fuer for_each
struct saveSItimeXML : public std::unary_function<SItime, void> struct saveSItimeXML : public std::unary_function<SItime, void>
{ {
FILE *f; FILE *f;
saveSItimeXML(FILE *fi) { f=fi;} saveSItimeXML(FILE *fi) { f=fi;}
void operator() (const SItime &t) { t.saveXML(f);} void operator() (const SItime &t) { t.saveXML(f);}
}; };
class SIevent { class SIevent
public: {
t_service_id service_id; private:
t_original_network_id original_network_id; std::map<std::string, std::string> langName;
t_transport_stream_id transport_stream_id; std::map<std::string, std::string> langText;
std::map<std::string, std::string> langExtendedText;
SIevent(const struct eit_event *); int running;
void parse(Event &event);
// Std-Copy
SIevent(const SIevent &);
SIevent(const t_original_network_id, const t_transport_stream_id, const t_service_id, const unsigned short);
SIevent(void) {
service_id = 0;
original_network_id = 0;
transport_stream_id = 0;
eventID = 0;
vps = 0;
table_id = 0xFF; /* 0xFF means "not set" */
version = 0xFF;
}
unsigned short eventID;
// Name aus dem Short-Event-Descriptor
std::string getName() const;
void setName(const std::string &lang, const std::string &name);
// Text aus dem Short-Event-Descriptor protected:
std::string getText() const; int saveXML0(FILE *f) const;
void setText(const std::string &lang, const std::string &text); int saveXML2(FILE *f) const;
std::string itemDescription; // Aus dem Extended Descriptor public:
std::string item; // Aus dem Extended Descriptor t_service_id service_id;
t_original_network_id original_network_id;
t_transport_stream_id transport_stream_id;
unsigned short eventID;
time_t vps;
unsigned char table_id;
unsigned char version;
// Aus dem Extended Descriptor SIcomponents components;
std::string getExtendedText() const; SIparentalRatings ratings;
void appendExtendedText(const std::string &lang, const std::string &text); SIlinkage_descs linkage_descs;
void setExtendedText(const std::string &lang, const std::string &text); SItimes times;
std::string contentClassification; // Aus dem Content Descriptor, als String, da mehrere vorkommen koennen std::string itemDescription; // Aus dem Extended Descriptor
std::string userClassification; // Aus dem Content Descriptor, als String, da mehrere vorkommen koennen std::string item; // Aus dem Extended Descriptor
std::string contentClassification; // Aus dem Content Descriptor, als String, da mehrere vorkommen koennen
t_channel_id get_channel_id(void) const { std::string userClassification; // Aus dem Content Descriptor, als String, da mehrere vorkommen koennen
return CREATE_CHANNEL_ID; #if 0
} SIevent(const struct eit_event *);
// Std-Copy
SIevent(const SIevent &);
#endif
SIevent(const t_original_network_id, const t_transport_stream_id, const t_service_id, const unsigned short);
SIevent(void) {
service_id = 0;
original_network_id = 0;
transport_stream_id = 0;
eventID = 0;
vps = 0;
table_id = 0xFF; /* 0xFF means "not set" */
version = 0xFF;
}
void parse(Event &event);
event_id_t uniqueKey(void) const { // Name aus dem Short-Event-Descriptor
return CREATE_EVENT_ID(CREATE_CHANNEL_ID, eventID); std::string getName() const;
} void setName(const std::string &lang, const std::string &name);
int runningStatus(void) const {
return running; // Text aus dem Short-Event-Descriptor
} std::string getText() const;
SIcomponents components; void setText(const std::string &lang, const std::string &text);
SIparentalRatings ratings;
SIlinkage_descs linkage_descs;
SItimes times; // Aus dem Extended Descriptor
time_t vps; std::string getExtendedText() const;
unsigned char table_id; void appendExtendedText(const std::string &lang, const std::string &text);
unsigned char version; void setExtendedText(const std::string &lang, const std::string &text);
// Der Operator zum sortieren
bool operator < (const SIevent& e) const { t_channel_id get_channel_id(void) const {
return uniqueKey()<e.uniqueKey(); return CREATE_CHANNEL_ID;
} }
int saveXML(FILE *file) const { // saves the event
return saveXML0(file) || saveXML2(file); event_id_t uniqueKey(void) const {
} return CREATE_EVENT_ID(CREATE_CHANNEL_ID, eventID);
int saveXML(FILE *file, const char *serviceName) const; // saves the event }
void dump(void) const; // dumps the event to stdout int runningStatus(void) const {
void dumpSmall(void) const; // dumps the event to stdout (not all information) return running;
char getFSK() const; }
protected: // Der Operator zum sortieren
int saveXML0(FILE *f) const; bool operator < (const SIevent& e) const {
int saveXML2(FILE *f) const; return uniqueKey()<e.uniqueKey();
private: }
std::map<std::string, std::string> langName; int saveXML(FILE *file) const { // saves the event
std::map<std::string, std::string> langText; return saveXML0(file) || saveXML2(file);
std::map<std::string, std::string> langExtendedText; }
int running; int saveXML(FILE *file, const char *serviceName) const; // saves the event
char getFSK() const;
void dump(void) const; // dumps the event to stdout
void dumpSmall(void) const; // dumps the event to stdout (not all information)
}; };
typedef std::set <SIevent, std::less<SIevent> > SIevents;
// Fuer for_each // Fuer for_each
struct printSIevent : public std::unary_function<SIevent, void> struct printSIevent : public std::unary_function<SIevent, void>
{ {
void operator() (const SIevent &e) { e.dump();} void operator() (const SIevent &e) { e.dump();}
}; };
// Fuer for_each // Fuer for_each
struct saveSIeventXML : public std::unary_function<SIevent, void> struct saveSIeventXML : public std::unary_function<SIevent, void>
{ {
FILE *f; FILE *f;
saveSIeventXML(FILE *fi) { f=fi;} saveSIeventXML(FILE *fi) { f=fi;}
void operator() (const SIevent &e) { e.saveXML(f);} void operator() (const SIevent &e) { e.saveXML(f);}
}; };
#if 0
// Fuer for_each // Fuer for_each
struct saveSIeventXMLwithServiceName : public std::unary_function<SIevent, void> struct saveSIeventXMLwithServiceName : public std::unary_function<SIevent, void>
{ {
@@ -446,7 +456,9 @@ struct saveSIeventXMLwithServiceName : public std::unary_function<SIevent, void>
e.saveXML(f); e.saveXML(f);
} }
}; };
#endif
#if 0
// Fuer for_each // Fuer for_each
struct printSIeventWithService : public std::unary_function<SIevent, void> struct printSIeventWithService : public std::unary_function<SIevent, void>
{ {
@@ -477,5 +489,6 @@ class SIevents : public std::set <SIevent, std::less<SIevent> >
// Loescht alte Events (aufgrund aktueller Zeit - seconds und Zeit im Event) // Loescht alte Events (aufgrund aktueller Zeit - seconds und Zeit im Event)
void removeOldEvents(long seconds); void removeOldEvents(long seconds);
}; };
#endif
#endif // SIEVENTS_HPP #endif // SIEVENTS_HPP

View File

@@ -50,6 +50,7 @@ struct descr_generic_header {
unsigned descriptor_length : 8; unsigned descriptor_length : 8;
} __attribute__ ((packed)) ; } __attribute__ ((packed)) ;
#if 0
struct descr_short_event_header { struct descr_short_event_header {
unsigned descriptor_tag : 8; unsigned descriptor_tag : 8;
unsigned descriptor_length : 8; unsigned descriptor_length : 8;
@@ -58,6 +59,7 @@ struct descr_short_event_header {
unsigned language_code_lo : 8; unsigned language_code_lo : 8;
unsigned event_name_length : 8; unsigned event_name_length : 8;
} __attribute__ ((packed)) ; } __attribute__ ((packed)) ;
#endif
struct descr_service_header { struct descr_service_header {
unsigned descriptor_tag : 8; unsigned descriptor_tag : 8;
@@ -66,6 +68,7 @@ struct descr_service_header {
unsigned service_provider_name_length : 8; unsigned service_provider_name_length : 8;
} __attribute__ ((packed)) ; } __attribute__ ((packed)) ;
#if 0
struct descr_extended_event_header { struct descr_extended_event_header {
unsigned descriptor_tag : 8; unsigned descriptor_tag : 8;
unsigned descriptor_length : 8; unsigned descriptor_length : 8;
@@ -76,6 +79,7 @@ struct descr_extended_event_header {
unsigned iso_639_2_language_code_lo : 8; unsigned iso_639_2_language_code_lo : 8;
unsigned length_of_items : 8; unsigned length_of_items : 8;
} __attribute__ ((packed)) ; } __attribute__ ((packed)) ;
#endif
struct service_list_entry { struct service_list_entry {
unsigned service_id_hi : 8; unsigned service_id_hi : 8;
@@ -95,6 +99,68 @@ inline unsigned min(unsigned a, unsigned b)
return b < a ? b : a; return b < a ? b : a;
} }
void SIsectionEIT::parse(void)
{
#if 0
if (!buffer || parsed)
return;
const uint8_t *actPos;
const uint8_t *bufEnd;
struct eit_event *evt;
unsigned short descriptors_loop_length;
if (bufferLength < sizeof(SI_section_EIT_header) + sizeof(struct eit_event)) {
bufferLength=0;
return;
}
unsigned char table_id = header()->table_id;
unsigned char version_number = header()->version_number;
actPos = buffer + sizeof(SI_section_EIT_header);
bufEnd = buffer + bufferLength;
while (actPos < bufEnd - sizeof(struct eit_event)) {
evt = (struct eit_event *) actPos;
SIevent e(evt);
e.service_id = service_id();
e.original_network_id = original_network_id();
e.transport_stream_id = transport_stream_id();
e.table_id = table_id;
e.version = version_number;
descriptors_loop_length = sizeof(struct eit_event) + ((evt->descriptors_loop_length_hi << 8) | evt->descriptors_loop_length_lo);
parseDescriptors(actPos, min((unsigned)(bufEnd - actPos), descriptors_loop_length), e);
evts.insert(e);
actPos += descriptors_loop_length;
}
#endif
#if 1
const EventList &elist = *getEvents();
if(elist.empty())
return;
t_service_id sid = getTableIdExtension();
t_original_network_id onid = getOriginalNetworkId();
t_transport_stream_id tsid = getTransportStreamId();
unsigned char tid = getTableId();
unsigned char version = getVersionNumber();
for (EventConstIterator eit = elist.begin(); eit != elist.end(); ++eit) {
Event &event = (**eit);
SIevent e(onid, tsid, sid, event.getEventId());
e.table_id = tid;
e.version = version;
e.parse(event);
evts.insert(e);
}
#endif
parsed = 1;
}
#if 0
static int get_table(unsigned char hi, unsigned char mid, unsigned char lo) static int get_table(unsigned char hi, unsigned char mid, unsigned char lo)
{ {
char lang[4]; char lang[4];
@@ -117,15 +183,6 @@ static int get_table(unsigned char hi, unsigned char mid, unsigned char lo)
return 0; return 0;
} }
bool check_blacklisted(const t_original_network_id onid, const t_transport_stream_id tsid)
{
if ( (onid == 0x0001) &&
((tsid == 0x03F0) || (tsid == 0x0408) || (tsid == 0x040E) || (tsid == 0x0412) || (tsid == 0x0416) || (tsid == 0x041E) ||
(tsid == 0x0420) || (tsid == 0x0422) || (tsid == 0x0424) || (tsid == 0x0444) ))
return true;
else
return false;
}
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Da es vorkommen kann das defekte Packete empfangen werden // Da es vorkommen kann das defekte Packete empfangen werden
// sollte hier alles ueberprueft werden. // sollte hier alles ueberprueft werden.
@@ -240,113 +297,6 @@ void SIsectionEIT::parseExtendedEventDescriptor(const char *buf, SIevent &e, uns
} }
} }
#ifdef ENABLE_FREESATEPG
std::string SIsectionEIT::freesatHuffmanDecode(std::string input)
{
const char *src = input.c_str();
uint size = input.length();
if (src[1] == 1 || src[1] == 2)
{
std::string uncompressed(size * 3, ' ');
uint p = 0;
struct hufftab *table;
unsigned table_length;
if (src[1] == 1)
{
table = fsat_huffman1;
table_length = sizeof(fsat_huffman1) / sizeof(fsat_huffman1[0]);
}
else
{
table = fsat_huffman2;
table_length = sizeof(fsat_huffman2) / sizeof(fsat_huffman2[0]);
}
unsigned value = 0, byte = 2, bit = 0;
while (byte < 6 && byte < size)
{
value |= src[byte] << ((5-byte) * 8);
byte++;
}
char lastch = START;
do
{
bool found = false;
unsigned bitShift = 0;
if (lastch == ESCAPE)
{
found = true;
// Encoded in the next 8 bits.
// Terminated by the first ASCII character.
char nextCh = (value >> 24) & 0xff;
bitShift = 8;
if ((nextCh & 0x80) == 0)
lastch = nextCh;
if (p >= uncompressed.length())
uncompressed.resize(p+10);
uncompressed[p++] = nextCh;
}
else
{
for (unsigned j = 0; j < table_length; j++)
{
if (table[j].last == lastch)
{
unsigned mask = 0, maskbit = 0x80000000;
for (short kk = 0; kk < table[j].bits; kk++)
{
mask |= maskbit;
maskbit >>= 1;
}
if ((value & mask) == table[j].value)
{
char nextCh = table[j].next;
bitShift = table[j].bits;
if (nextCh != STOP && nextCh != ESCAPE)
{
if (p >= uncompressed.length())
uncompressed.resize(p+10);
uncompressed[p++] = nextCh;
}
found = true;
lastch = nextCh;
break;
}
}
}
}
if (found)
{
// Shift up by the number of bits.
for (unsigned b = 0; b < bitShift; b++)
{
value = (value << 1) & 0xfffffffe;
if (byte < size)
value |= (src[byte] >> (7-bit)) & 1;
if (bit == 7)
{
bit = 0;
byte++;
}
else bit++;
}
}
else
{
// Entry missing in table.
uncompressed.resize(p);
uncompressed.append("...");
return uncompressed;
}
} while (lastch != STOP && value != 0);
uncompressed.resize(p);
return uncompressed;
}
else return input;
}
#endif
void SIsectionEIT::parseShortEventDescriptor(const char *buf, SIevent &e, unsigned maxlen) void SIsectionEIT::parseShortEventDescriptor(const char *buf, SIevent &e, unsigned maxlen)
{ {
@@ -414,70 +364,19 @@ void SIsectionEIT::parseDescriptors(const uint8_t *des, unsigned len, SIevent &e
des+=desc->descriptor_length+2; des+=desc->descriptor_length+2;
} }
} }
// Die infos aus dem Puffer holen
void SIsectionEIT::parse(void)
{
if (!buffer || parsed)
return;
#if 0
const uint8_t *actPos;
const uint8_t *bufEnd;
struct eit_event *evt;
unsigned short descriptors_loop_length;
if (bufferLength < sizeof(SI_section_EIT_header) + sizeof(struct eit_event)) {
bufferLength=0;
return;
}
unsigned char table_id = header()->table_id;
unsigned char version_number = header()->version_number;
actPos = buffer + sizeof(SI_section_EIT_header);
bufEnd = buffer + bufferLength;
while (actPos < bufEnd - sizeof(struct eit_event)) {
evt = (struct eit_event *) actPos;
SIevent e(evt);
e.service_id = service_id();
e.original_network_id = original_network_id();
e.transport_stream_id = transport_stream_id();
e.table_id = table_id;
e.version = version_number;
descriptors_loop_length = sizeof(struct eit_event) + ((evt->descriptors_loop_length_hi << 8) | evt->descriptors_loop_length_lo);
parseDescriptors(actPos, min((unsigned)(bufEnd - actPos), descriptors_loop_length), e);
evts.insert(e);
actPos += descriptors_loop_length;
}
#endif #endif
#if 1
const EventList &elist = *getEvents();
if(elist.empty())
return;
t_service_id sid = getTableIdExtension();
t_original_network_id onid = getOriginalNetworkId();
t_transport_stream_id tsid = getTransportStreamId();
unsigned char tid = getTableId();
unsigned char version = getVersionNumber();
for (EventConstIterator eit = elist.begin(); eit != elist.end(); ++eit) {
Event &event = (**eit);
SIevent e(onid, tsid, sid, event.getEventId());
e.table_id = tid;
e.version = version;
e.parse(event);
evts.insert(e);
}
#endif
parsed = 1;
}
/********************/ /********************/
bool check_blacklisted(const t_original_network_id onid, const t_transport_stream_id tsid)
{
if ( (onid == 0x0001) &&
((tsid == 0x03F0) || (tsid == 0x0408) || (tsid == 0x040E) || (tsid == 0x0412) || (tsid == 0x0416) || (tsid == 0x041E) ||
(tsid == 0x0420) || (tsid == 0x0422) || (tsid == 0x0424) || (tsid == 0x0444) ))
return true;
else
return false;
}
void SIsectionSDT::parseNVODreferenceDescriptor(const char *buf, SIservice &s) void SIsectionSDT::parseNVODreferenceDescriptor(const char *buf, SIservice &s)
{ {
struct descr_generic_header *hdr=(struct descr_generic_header *)buf; struct descr_generic_header *hdr=(struct descr_generic_header *)buf;
@@ -589,3 +488,111 @@ void SIsectionSDT::parse(void)
parsed = 1; parsed = 1;
} }
#ifdef ENABLE_FREESATEPG
std::string SIsectionEIT::freesatHuffmanDecode(std::string input)
{
const char *src = input.c_str();
uint size = input.length();
if (src[1] == 1 || src[1] == 2)
{
std::string uncompressed(size * 3, ' ');
uint p = 0;
struct hufftab *table;
unsigned table_length;
if (src[1] == 1)
{
table = fsat_huffman1;
table_length = sizeof(fsat_huffman1) / sizeof(fsat_huffman1[0]);
}
else
{
table = fsat_huffman2;
table_length = sizeof(fsat_huffman2) / sizeof(fsat_huffman2[0]);
}
unsigned value = 0, byte = 2, bit = 0;
while (byte < 6 && byte < size)
{
value |= src[byte] << ((5-byte) * 8);
byte++;
}
char lastch = START;
do
{
bool found = false;
unsigned bitShift = 0;
if (lastch == ESCAPE)
{
found = true;
// Encoded in the next 8 bits.
// Terminated by the first ASCII character.
char nextCh = (value >> 24) & 0xff;
bitShift = 8;
if ((nextCh & 0x80) == 0)
lastch = nextCh;
if (p >= uncompressed.length())
uncompressed.resize(p+10);
uncompressed[p++] = nextCh;
}
else
{
for (unsigned j = 0; j < table_length; j++)
{
if (table[j].last == lastch)
{
unsigned mask = 0, maskbit = 0x80000000;
for (short kk = 0; kk < table[j].bits; kk++)
{
mask |= maskbit;
maskbit >>= 1;
}
if ((value & mask) == table[j].value)
{
char nextCh = table[j].next;
bitShift = table[j].bits;
if (nextCh != STOP && nextCh != ESCAPE)
{
if (p >= uncompressed.length())
uncompressed.resize(p+10);
uncompressed[p++] = nextCh;
}
found = true;
lastch = nextCh;
break;
}
}
}
}
if (found)
{
// Shift up by the number of bits.
for (unsigned b = 0; b < bitShift; b++)
{
value = (value << 1) & 0xfffffffe;
if (byte < size)
value |= (src[byte] >> (7-bit)) & 1;
if (bit == 7)
{
bit = 0;
byte++;
}
else bit++;
}
}
else
{
// Entry missing in table.
uncompressed.resize(p);
uncompressed.append("...");
return uncompressed;
}
} while (lastch != STOP && value != 0);
uncompressed.resize(p);
return uncompressed;
}
else return input;
}
#endif

View File

@@ -60,6 +60,7 @@ struct SI_section_SDT_header {
unsigned reserved_future_use2 : 8; unsigned reserved_future_use2 : 8;
} __attribute__ ((packed)) ; // 11 bytes } __attribute__ ((packed)) ; // 11 bytes
#if 0
struct SI_section_EIT_header { struct SI_section_EIT_header {
unsigned table_id : 8; unsigned table_id : 8;
#if __BYTE_ORDER == __BIG_ENDIAN #if __BYTE_ORDER == __BIG_ENDIAN
@@ -94,7 +95,7 @@ struct SI_section_EIT_header {
unsigned segment_last_section_number : 8; unsigned segment_last_section_number : 8;
unsigned last_table_id : 8; unsigned last_table_id : 8;
} __attribute__ ((packed)) ; // 14 bytes } __attribute__ ((packed)) ; // 14 bytes
#endif
// Muss evtl. angepasst werden falls damit RST, TDT und TOT gelesen werden sollen // Muss evtl. angepasst werden falls damit RST, TDT und TOT gelesen werden sollen
// ^^^ // ^^^
// RST usw. haben section_syntax_indicator == 0, andere == 1 (obi) // RST usw. haben section_syntax_indicator == 0, andere == 1 (obi)
@@ -155,15 +156,15 @@ protected:
unsigned bufferLength; unsigned bufferLength;
}; };
class SIsectionEIT : public SIsection, public EventInformationSection class SIsectionEIT : /*public SIsection,*/ public EventInformationSection
{ {
public: public:
SIsectionEIT(uint8_t *buf) : SIsection(buf), EventInformationSection(buf) SIsectionEIT(uint8_t *buf) : /*SIsection(buf),*/ EventInformationSection(buf)
{ {
parsed = 0; parsed = 0;
parse(); parse();
} }
#if 0
t_service_id service_id(void) const { t_service_id service_id(void) const {
return buffer ? ((((struct SI_section_EIT_header *)buffer)->service_id_hi << 8) | return buffer ? ((((struct SI_section_EIT_header *)buffer)->service_id_hi << 8) |
((struct SI_section_EIT_header *)buffer)->service_id_lo): 0; ((struct SI_section_EIT_header *)buffer)->service_id_lo): 0;
@@ -178,14 +179,12 @@ public:
return buffer ? ((((struct SI_section_EIT_header *)buffer)->transport_stream_id_hi << 8) | return buffer ? ((((struct SI_section_EIT_header *)buffer)->transport_stream_id_hi << 8) |
((struct SI_section_EIT_header *)buffer)->transport_stream_id_lo) : 0; ((struct SI_section_EIT_header *)buffer)->transport_stream_id_lo) : 0;
} }
struct SI_section_EIT_header const *header(void) const { struct SI_section_EIT_header const *header(void) const {
return (struct SI_section_EIT_header *)buffer; return (struct SI_section_EIT_header *)buffer;
} }
#endif
const SIevents &events(void) const { const SIevents &events(void) const {
//if(!parsed)
// parse(); -> nicht const
return evts; return evts;
} }
@@ -197,6 +196,7 @@ protected:
SIevents evts; SIevents evts;
int parsed; int parsed;
void parse(void); void parse(void);
#if 0
void parseDescriptors(const uint8_t *desc, unsigned len, SIevent &e); void parseDescriptors(const uint8_t *desc, unsigned len, SIevent &e);
void parseShortEventDescriptor(const char *buf, SIevent &e, unsigned maxlen); void parseShortEventDescriptor(const char *buf, SIevent &e, unsigned maxlen);
void parseExtendedEventDescriptor(const char *buf, SIevent &e, unsigned maxlen); void parseExtendedEventDescriptor(const char *buf, SIevent &e, unsigned maxlen);
@@ -205,6 +205,7 @@ protected:
void parseParentalRatingDescriptor(const char *buf, SIevent &e, unsigned maxlen); void parseParentalRatingDescriptor(const char *buf, SIevent &e, unsigned maxlen);
void parseLinkageDescriptor(const char *buf, SIevent &e, unsigned maxlen); void parseLinkageDescriptor(const char *buf, SIevent &e, unsigned maxlen);
void parsePDCDescriptor(const char *buf, SIevent &e, unsigned maxlen); void parsePDCDescriptor(const char *buf, SIevent &e, unsigned maxlen);
#endif
#ifdef ENABLE_FREESATEPG #ifdef ENABLE_FREESATEPG
std::string freesatHuffmanDecode(std::string input); std::string freesatHuffmanDecode(std::string input);
#endif #endif
@@ -219,12 +220,13 @@ public:
parse(); parse();
} }
#if 0
// Std-Copy // Std-Copy
SIsectionSDT(const SIsectionSDT &s) : SIsection(s) { SIsectionSDT(const SIsectionSDT &s) : SIsection(s) {
svs = s.svs; svs = s.svs;
parsed = s.parsed; parsed = s.parsed;
} }
#endif
// Benutzt den uebergebenen Puffer (sollte mit new char[n] allokiert sein) // Benutzt den uebergebenen Puffer (sollte mit new char[n] allokiert sein)
SIsectionSDT(uint8_t *buf) : SIsection(buf) { SIsectionSDT(uint8_t *buf) : SIsection(buf) {
parsed = 0; parsed = 0;