mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-03 02:41:12 +02:00
eitd: remove code under DO_NOT_INCLUDE_STUFF_NOT_NEEDED_FOR_SECTIONSD ifdef
Origin commit data
------------------
Branch: ni/coolstream
Commit: f41acb304a
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2012-02-01 (Wed, 01 Feb 2012)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -358,236 +358,3 @@ void SIevent::dumpSmall(void) const
|
||||
for_each(ratings.begin(), ratings.end(), printSIparentalRating());
|
||||
for_each(linkage_descs.begin(), linkage_descs.end(), printSIlinkage());
|
||||
}
|
||||
/*
|
||||
// Liest n Bytes aus einem Socket per read
|
||||
inline int readNbytes(int fd, char *buf, int n)
|
||||
{
|
||||
int j;
|
||||
for(j=0; j<n;) {
|
||||
int r=read (fd, buf, n-j);
|
||||
if(r<=0) {
|
||||
perror ("read");
|
||||
return -1;
|
||||
}
|
||||
j+=r;
|
||||
buf+=r;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
*/
|
||||
|
||||
#ifndef DO_NOT_INCLUDE_STUFF_NOT_NEEDED_FOR_SECTIONSD
|
||||
// Liest n Bytes aus einem Socket per read
|
||||
// Liefert 0 bei timeout
|
||||
// und -1 bei Fehler
|
||||
// ansonsten die Anzahl gelesener Bytes
|
||||
inline int readNbytes(int fd, char *buf, int n, unsigned timeoutInSeconds)
|
||||
{
|
||||
int j;
|
||||
for(j=0; j<n;) {
|
||||
struct pollfd ufds;
|
||||
// memset(&ufds, 0, sizeof(ufds));
|
||||
ufds.fd=fd;
|
||||
ufds.events=POLLIN|POLLPRI;
|
||||
ufds.revents=0;
|
||||
int rc=poll(&ufds, 1, timeoutInSeconds*1000);
|
||||
if(!rc)
|
||||
return 0; // timeout
|
||||
else if(rc<0) {
|
||||
perror ("poll");
|
||||
return -1;
|
||||
}
|
||||
int r=read (fd, buf, n-j);
|
||||
if(r<=0) {
|
||||
perror ("read");
|
||||
return -1;
|
||||
}
|
||||
j+=r;
|
||||
buf+=r;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
SIevent SIevent::readActualEvent(t_service_id serviceID, unsigned timeoutInSeconds)
|
||||
{
|
||||
int fd;
|
||||
SIevent evt; // Std-Event das bei Fehler zurueckgeliefert wird
|
||||
struct SI_section_header header;
|
||||
char *buf;
|
||||
unsigned short section_length;
|
||||
|
||||
if ((fd = open(DEMUX_DEVICE, O_RDWR)) == -1) {
|
||||
perror(DEMUX_DEVICE);
|
||||
return evt;
|
||||
}
|
||||
|
||||
if (!setfilter(fd, 0x12, 0x4e, 0xff, DMX_IMMEDIATE_START | DMX_CHECK_CRC)) {
|
||||
close(fd);
|
||||
return evt;
|
||||
}
|
||||
|
||||
time_t szeit = time(NULL);
|
||||
|
||||
// Segment mit Event fuer sid suchen
|
||||
do {
|
||||
int rc = readNbytes(fd, (char *)&header, sizeof(header), timeoutInSeconds);
|
||||
|
||||
if(!rc)
|
||||
break; // timeout
|
||||
|
||||
else if(rc<0) {
|
||||
close(fd);
|
||||
perror ("read header");
|
||||
return evt;
|
||||
}
|
||||
|
||||
section_length = (header.section_length_hi << 8) | header.section_length_lo;
|
||||
|
||||
buf = new char[sizeof(header) + section_length - 5];
|
||||
|
||||
if (!buf) {
|
||||
close(fd);
|
||||
printf("Not enough memory!\n");
|
||||
return evt;
|
||||
}
|
||||
|
||||
// Den Header kopieren
|
||||
memmove(buf, &header, sizeof(header));
|
||||
rc = readNbytes(fd, &buf[sizeof(header)], section_length - 5, timeoutInSeconds);
|
||||
|
||||
if(!rc) {
|
||||
delete[] buf;
|
||||
break; // timeout
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
close(fd);
|
||||
delete[] buf;
|
||||
perror ("read section");
|
||||
return evt;
|
||||
}
|
||||
|
||||
if (header.current_next_indicator) {
|
||||
// Wir wollen nur aktuelle sections
|
||||
SIsectionEIT e(SIsection(sizeof(header) + section_length - 5, buf));
|
||||
time_t zeit = time(NULL);
|
||||
for (SIevents::iterator k = e.events().begin(); k != e.events().end(); ++k)
|
||||
if (k->service_id == serviceID)
|
||||
for (SItimes::iterator t = k->times.begin(); t != k->times.end(); ++t)
|
||||
if ((t->startzeit <= zeit) && (zeit <= (long)(t->startzeit+t->dauer))) {
|
||||
close(fd);
|
||||
return SIevent(*k);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
} while (time(NULL) < szeit + (long)timeoutInSeconds);
|
||||
|
||||
close(fd);
|
||||
return evt;
|
||||
}
|
||||
|
||||
void SIevents::removeOldEvents(long seconds)
|
||||
{
|
||||
time_t current_time = time(NULL);
|
||||
|
||||
for(SIevents::iterator it = begin(); it != end(); )
|
||||
{
|
||||
// "it->times.erase(kt);":
|
||||
// passing `const SItimes' as `this' argument of `void set<SItime,less<SItime>,allocator<SItime> >::erase(_Rb_tree_iterator<SItime,const SItime &,const SItime *>)' discards qualifiers
|
||||
|
||||
// hence we have to modify a copy
|
||||
|
||||
SIevent copy_of_event(*it);
|
||||
bool copy_has_changed = false;
|
||||
|
||||
for (SItimes::iterator jt = copy_of_event.times.begin(); jt != copy_of_event.times.end(); )
|
||||
{
|
||||
if ((jt->startzeit) + (int)(jt->dauer) < current_time - seconds)
|
||||
{
|
||||
copy_of_event.times.erase(jt++);
|
||||
copy_has_changed = true;
|
||||
}
|
||||
else
|
||||
++jt;
|
||||
}
|
||||
if (copy_has_changed)
|
||||
{
|
||||
erase(it++);
|
||||
|
||||
// Set has the important property that inserting a new element into a set does not
|
||||
// invalidate iterators that point to existing elements.
|
||||
if (copy_of_event.times.size() != 0)
|
||||
#ifdef DEBUG
|
||||
assert((++insert(it, copy_of_event)) == it);
|
||||
#else
|
||||
insert(it, copy_of_event); // it is the hint where to insert (I hope that doesn't invalidate it)
|
||||
// insert(copy_of_event); // alternative method without hint
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
// Entfernt anhand der Services alle time shifted events (ohne Text,
|
||||
// mit service-id welcher im nvod steht)
|
||||
// und sortiert deren Zeiten in die Events mit dem Text ein.
|
||||
void SIevents::mergeAndRemoveTimeShiftedEvents(const SIservices &services)
|
||||
{
|
||||
// Wir gehen alle services durch, suchen uns die services mit nvods raus
|
||||
// und fuegen dann die Zeiten der Events mit der service-id eines nvods
|
||||
// in das entsprechende Event mit der service-id das die nvods hat ein.
|
||||
// die 'nvod-events' werden auch geloescht
|
||||
|
||||
// SIevents eventsToDelete; // Hier rein kommen Events die geloescht werden sollen
|
||||
for(SIservices::iterator k=services.begin(); k!=services.end(); ++k)
|
||||
if(k->nvods.size()) {
|
||||
// NVOD-Referenzen gefunden
|
||||
// Zuerst mal das Event mit dem Text holen
|
||||
iterator e;
|
||||
for(e=begin(); e!=end(); ++e)
|
||||
if(e->service_id == k->service_id)
|
||||
break;
|
||||
if(e!=end()) {
|
||||
// *e == event mit dem Text
|
||||
SIevent newEvent(*e); // Kopie des Events
|
||||
// Jetzt die nvods druchgehen und deren Uhrzeiten in obiges Event einfuegen
|
||||
for(SInvodReferences::iterator n=k->nvods.begin(); n!=k->nvods.end(); ++n) {
|
||||
// Alle druchgehen und deren Events suchen
|
||||
for(iterator en=begin(); en!=end(); en++) {
|
||||
if(en->service_id==n->getServiceID()) {
|
||||
newEvent.times.insert(en->times.begin(), en->times.end());
|
||||
// newEvent.times.insert(SItime(en->startzeit, en->dauer));
|
||||
// eventsToDelete.insert(SIevent(*en));
|
||||
}
|
||||
}
|
||||
}
|
||||
erase(e); // Altes Event loeschen -> iterator (e) ung<6E>ltig
|
||||
insert(newEvent); // und das erweiterte Event wieder einfuegen
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// delete all events with serviceID that have a service type 0
|
||||
//
|
||||
for (iterator it = begin(); it != end(); )
|
||||
{
|
||||
SIservices::iterator s = services.find(SIservice(it->service_id, it->original_network_id, it->transport_stream_id));
|
||||
if ((s != services.end()) && (s->serviceTyp == 0))
|
||||
{
|
||||
// Set is a Sorted Associative Container
|
||||
// Erasing an element from a set also does not invalidate any iterators,
|
||||
// except, of course, for iterators that actually point to the element
|
||||
// that is being erased.
|
||||
erase(it++);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user