summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--eepg.c599
-rw-r--r--epghandler.c126
-rw-r--r--epghandler.h41
-rw-r--r--log.h77
-rw-r--r--setupeepg.c36
-rw-r--r--setupeepg.h35
7 files changed, 578 insertions, 338 deletions
diff --git a/Makefile b/Makefile
index 19c0684..a2d413e 100644
--- a/Makefile
+++ b/Makefile
@@ -65,7 +65,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
### The object files (add further files here):
-OBJS = $(PLUGIN).o dish.o
+OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o
ifdef DBG
CXXFLAGS += -g
diff --git a/eepg.c b/eepg.c
index a1fb5e4..1b7c0a2 100644
--- a/eepg.c
+++ b/eepg.c
@@ -38,14 +38,16 @@
#include <libsi/si.h>
#include "eepg.h"
#include "dish.h"
+#if APIVERSNUM > 10725
+#include "epghandler.h"
+#endif
+#include "log.h"
+#include "setupeepg.h"
#include <map>
#include <string>
#include <stdarg.h>
-#define VERBOSE 1
-/* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */
-/* all is logged into /var/log/syslog */
#if APIVERSNUM < 10401
#error You need at least VDR API version 1.4.1 for this plugin
@@ -84,8 +86,6 @@ template <class T> T REALLOC(T Var, size_t Size)
using namespace std;
-// --- cSetupEEPG -------------------------------------------------------
-
const char *optPats[] = {
"%s",
"%s (Option %d)",
@@ -110,45 +110,15 @@ char *cs_hexdump (int m, const uchar * buf, int n)
return (dump);
}
-class cSetupEEPG
-{
-public:
- int OptPat;
- int OrderInfo;
- int RatingInfo;
- int FixEpg;
- int DisplayMessage;
- int ProcessEIT;
-#ifdef DEBUG
- int LogLevel;
-#endif
-
-public:
- cSetupEEPG (void);
-};
+cSetupEEPG* SetupPE = cSetupEEPG::getInstance();
-cSetupEEPG SetupPE;
-
-cSetupEEPG::cSetupEEPG (void)
-{
- OptPat = 1;
- OrderInfo = 1;
- RatingInfo = 1;
- FixEpg = 0;
- DisplayMessage = 1;
- ProcessEIT = 0;
-#ifdef DEBUG
- LogLevel = 0;
-#endif
-
-}
// --- cMenuSetupPremiereEpg ------------------------------------------------------------
class cMenuSetupPremiereEpg:public cMenuSetupPage
{
private:
- cSetupEEPG data;
+ cSetupEEPG* data;
const char *optDisp[NUM_PATS];
char buff[NUM_PATS][32];
protected:
@@ -159,94 +129,38 @@ public:
cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void)
{
- data = SetupPE;
+ data = cSetupEEPG::getInstance();
SetSection (tr ("PremiereEPG"));
optDisp[0] = tr ("off");
for (unsigned int i = 1; i < NUM_PATS; i++) {
snprintf (buff[i], sizeof (buff[i]), optPats[i], "Event", 1);
optDisp[i] = buff[i];
}
- Add (new cMenuEditStraItem (tr ("Tag option events"), &data.OptPat, NUM_PATS, optDisp));
- Add (new cMenuEditBoolItem (tr ("Show order information"), &data.OrderInfo));
- Add (new cMenuEditBoolItem (tr ("Show rating information"), &data.RatingInfo));
- Add (new cMenuEditBoolItem (tr ("Fix EPG data"), &data.FixEpg));
- Add (new cMenuEditBoolItem (tr ("Display summary message"), &data.DisplayMessage));
+ Add (new cMenuEditStraItem (tr ("Tag option events"), &data->OptPat, NUM_PATS, optDisp));
+ Add (new cMenuEditBoolItem (tr ("Show order information"), &data->OrderInfo));
+ Add (new cMenuEditBoolItem (tr ("Show rating information"), &data->RatingInfo));
+ Add (new cMenuEditBoolItem (tr ("Fix EPG data"), &data->FixEpg));
+ Add (new cMenuEditBoolItem (tr ("Display summary message"), &data->DisplayMessage));
#ifdef DEBUG
- Add (new cMenuEditIntItem (tr ("Level of logging verbosity"), &data.LogLevel, 0, 5));
- Add (new cMenuEditBoolItem (tr ("Process EIT info with EEPG"), &data.ProcessEIT));
+ Add (new cMenuEditIntItem (tr ("Level of logging verbosity"), &data->LogLevel, 0, 5));
+ Add (new cMenuEditBoolItem (tr ("Process EIT info with EEPG"), &data->ProcessEIT));
#endif
}
void cMenuSetupPremiereEpg::Store (void)
{
- SetupPE = data;
- SetupStore ("OptionPattern", SetupPE.OptPat);
- SetupStore ("OrderInfo", SetupPE.OrderInfo);
- SetupStore ("RatingInfo", SetupPE.RatingInfo);
- SetupStore ("FixEpg", SetupPE.FixEpg);
- SetupStore ("DisplayMessage", SetupPE.DisplayMessage);
+ //SetupPE = data;
+ SetupStore ("OptionPattern", SetupPE->OptPat);
+ SetupStore ("OrderInfo", SetupPE->OrderInfo);
+ SetupStore ("RatingInfo", SetupPE->RatingInfo);
+ SetupStore ("FixEpg", SetupPE->FixEpg);
+ SetupStore ("DisplayMessage", SetupPE->DisplayMessage);
#ifdef DEBUG
- SetupStore ("LogLevel", SetupPE.LogLevel);
- SetupStore ("ProcessEIT", SetupPE.ProcessEIT);
+ SetupStore ("LogLevel", SetupPE->LogLevel);
+ SetupStore ("ProcessEIT", SetupPE->ProcessEIT);
#endif
}
-bool CheckLevel(int level)
-{
-#ifdef DEBUG
- if (SetupPE.LogLevel >= level)
-#else
- if (VERBOSE >= level)
-#endif
- {
- return true;
- }
- return false;
-}
-
-const char* PrepareLog(string message)
-{
- message = "EEPG: " + message;
- return message.c_str();
-}
-
-#define MAXSYSLOGBUF 256
-
-//void LogVsyslog(int errLevel, const char * message, ...)
-void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...)
-{
- va_list ap;
- char fmt[MAXSYSLOGBUF];
- if (errLevel == LOG_DEBUG) {
- snprintf(fmt, sizeof(fmt), "[%d] %s:%d %s", cThread::ThreadId(), function, lineNum, message);
- } else {
- snprintf(fmt, sizeof(fmt), "[%d] %s", cThread::ThreadId(), message);
- }
- va_start(ap,message);
- vsyslog ( errLevel, fmt, ap );
- va_end(ap);
-}
-
-#define LogI(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_INFO, __LINE__, __FUNCTION__, b ) : void() )
-#define LogE(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_ERR, __LINE__, __FUNCTION__, b ) : void() )
-#define LogD(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_DEBUG, __LINE__, __FUNCTION__, b ) : void() )
-//#define LogE(a, b...) void( CheckLevel(a) ? esyslog ( b ) : void() )
-//#define LogD(a, b...) void( CheckLevel(a) ? dsyslog ( b ) : void() )
-#define prep(s) PrepareLog(s)
-#define prep2(s) s
-
-//void LogF(int level, const char * message, ...) __attribute__ ((format (printf,2,3)));
-
-//void LogF(int level, const char * message, ...)
-//{
-// if (CheckLevel(level)) {
-// va_list ap;
-// va_start(ap,message);
-// vsyslog (LOG_ERR, PrepareLog(message), ap );
-// va_end(ap);
-// }
-//}
-
#define Asprintf(a, b, c...) void( asprintf(a, b, c) < 0 ? esyslog("memory allocation error - %s", b) : void() )
// --- CRC16 -------------------------------------------------------------------
@@ -322,7 +236,7 @@ private:
unsigned char InitialSummary[64];
void NextPmt (void);
- void ProccessContinuous(u_short Pid, u_char Tid, int Length, const u_char *Data);
+ void ProccessContinuous(u_short Pid, u_char Tid, int Length, const u_char *Data);
protected:
virtual void Process (u_short Pid, u_char Tid, const u_char * Data, int Length);
virtual void AddFilter (u_short Pid, u_char Tid);
@@ -350,9 +264,9 @@ protected:
virtual void PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]); //gets a channel and returns an array of schedules that WriteToSchedule can write to. Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1
virtual void FinishWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]);
virtual void WriteToSchedule (cSchedule * ps[MAX_EQUIVALENCES], unsigned short int NumberOfEquivalences,
- unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text,
- char *SummText, unsigned short int ThemeId, unsigned short int TableId,
- unsigned short int Version, char Rating = 0x00);
+ unsigned int EventId, unsigned int StartTime, unsigned int Duration, char *Text,
+ char *SummText, unsigned short int ThemeId, unsigned short int TableId,
+ unsigned short int Version, char Rating = 0x00);
virtual void LoadIntoSchedule (void);
virtual void LoadEquivalentChannels (void);
@@ -579,7 +493,7 @@ static bool load_sky_file (const char *filename)
memset (string1, 0, sizeof (string1));
memset (string2, 0, sizeof (string2));
if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2
- || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) {
+ || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) {
nH = sky_tables[tableId];
LenPrefix = strlen (string2);
for (i = 0; i < LenPrefix; i++) {
@@ -598,7 +512,7 @@ static bool load_sky_file (const char *filename)
nH = nH->P0;
if (nH->Value != NULL || (LenPrefix - 1) == i) {
LogE (0 ,prep("Error, huffman prefix code already exists for \"%s\"=%s with '%s'"), string1,
- string2, nH->Value);
+ string2, nH->Value);
}
}
break;
@@ -616,7 +530,7 @@ static bool load_sky_file (const char *filename)
nH = nH->P1;
if (nH->Value != NULL || (LenPrefix - 1) == i) {
LogE (0, prep("Error, huffman prefix code already exists for \"%s\"=%s with '%s'"), string1,
- string2, nH->Value);
+ string2, nH->Value);
}
}
break;
@@ -642,7 +556,7 @@ static bool load_sky_file (const char *filename)
memset (string1, 0, sizeof (string1));
memset (string2, 0, sizeof (string2));
if (sscanf (Line, "%c=%[^\n]\n", string1, string2) == 2
- || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) {
+ || (sscanf (Line, "%[^=]=%[^\n]\n", string1, string2) == 2)) {
nH = sky_tables[tableId];
LenPrefix = strlen (string2);
for (i = 0; i < LenPrefix; i++) {
@@ -961,20 +875,20 @@ void CleanString (unsigned char *String)
cChannel *GetChannelByID(tChannelID & channelID, bool searchOtherPos)
{
- cChannel *VC = Channels.GetByChannelID(channelID, true);
- if(!VC && searchOtherPos){
- //look on other satpositions
- for(int i = 0;i < NumberOfAvailableSources;i++){
- channelID = tChannelID(AvailableSources[i], channelID.Nid(), channelID.Tid(), channelID.Sid());
- VC = Channels.GetByChannelID(channelID, true);
- if(VC){
- //found this actually on satellite nextdoor...
- break;
- }
- }
+ cChannel *VC = Channels.GetByChannelID(channelID, true);
+ if(!VC && searchOtherPos){
+ //look on other satpositions
+ for(int i = 0;i < NumberOfAvailableSources;i++){
+ channelID = tChannelID(AvailableSources[i], channelID.Nid(), channelID.Tid(), channelID.Sid());
+ VC = Channels.GetByChannelID(channelID, true);
+ if(VC){
+ //found this actually on satellite nextdoor...
+ break;
+ }
}
+ }
- return VC;
+ return VC;
}
bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB stream?
@@ -1050,7 +964,7 @@ bool cFilterEEPG::InitDictionary (void)
LogD (4, prep("EEPGDebug: loading freesat.dict"));
FileName += "/freesat.t1";
if (!load_freesat_file (1, FileName.c_str()))
- return false;
+ return false;
FileName = ConfDir;
FileName += "/freesat.t2";
return load_freesat_file (2, FileName.c_str());
@@ -1098,7 +1012,7 @@ void loadEquivalentChannelMap (void)
//TODO DPE add code to reload if file is changed
if (equiChanMap.size() > 0)
- return;
+ return;
File = fopen (FileName.c_str(), "r");
@@ -1128,37 +1042,37 @@ void loadEquivalentChannelMap (void)
tChannelID OriginalChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid);
bool found = false;
//int i = 0;
- cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false);
- if (!OriginalChannel) {
- LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing?
- continue;
+ cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false);
+ if (!OriginalChannel) {
+ LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing?
+ continue;
+ }
+ if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) {
+ if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid)
+ != 5) {
+ rid = 0;
}
- if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) {
- if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid)
- != 5) {
- rid = 0;
+ tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid);
+ cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function?
+ if (EquivChannel) {
+ ret = equiChanMap.equal_range(*OriginalChID.ToString());
+ for (it=ret.first; it!=ret.second; ++it)
+ if ((*it).second == *OriginalChID.ToString()) {
+ found = true;
+ break;
+ }
+
+ if (!found) {
+ string origCh(*OriginalChID.ToString());
+ string equiCh(*EquivChID.ToString());
+ equiChanMap.insert(pair<string,string>(origCh.c_str(),equiCh.c_str()));
+ LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str());
+ for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ )
+ LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str());
}
- tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid);
- cChannel *EquivChannel = Channels.GetByChannelID (EquivChID, false); //TODO use valid function?
- if (EquivChannel) {
- ret = equiChanMap.equal_range(*OriginalChID.ToString());
- for (it=ret.first; it!=ret.second; ++it)
- if ((*it).second == *OriginalChID.ToString()) {
- found = true;
- break;
- }
-
- if (!found) {
- string origCh(*OriginalChID.ToString());
- string equiCh(*EquivChID.ToString());
- equiChanMap.insert(pair<string,string>(origCh.c_str(),equiCh.c_str()));
- LogD(4, prep("Found %s equivalent to %s. origCh %s"), *EquivChID.ToString(), *OriginalChID.ToString(), origCh.c_str());
- for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ )
- LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str());
- }
- } else
- LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID);
- }
+ } else
+ LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID);
+ }
} //if scanf string1
} //if string1
} //if scanf
@@ -1167,7 +1081,7 @@ void loadEquivalentChannelMap (void)
fclose (File);
LogD(3, prep("Loaded %i equivalents."), equiChanMap.size());
for ( it2=equiChanMap.begin() ; it2 != equiChanMap.end(); it2++ )
- LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str());
+ LogD(3, prep("Original ID %s <-> Equivalent ID %s"), (*it2).first.c_str(), it2->second.c_str());
} //if file
}
void cFilterEEPG::LoadEquivalentChannels (void)
@@ -1208,21 +1122,21 @@ void cFilterEEPG::LoadEquivalentChannels (void)
while (i < nChannels && (!found)) {
C = &sChannels[i];
if (C->Src[0] == (unsigned int)cSource::FromString (source) && C->Nid[0] == nid
- && C->Tid[0] == tid && C->Sid[0] == sid)
+ && C->Tid[0] == tid && C->Sid[0] == sid)
found = true;
else
i++;
}
if (!found) {
LogI(2, prep("Warning: in equivalence file, cannot find original channel %s. Perhaps you are tuned to another transponder right now."),
- origChanID);
+ origChanID);
} else {
cChannel *OriginalChannel = Channels.GetByChannelID (OriginalChID, false);
if (!OriginalChannel)
- LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalency is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing?
+ LogI(2, prep("Warning, not found epg channel \'%s\' in channels.conf. Equivalence is assumed to be valid, but perhaps you should check the entry in the equivalents file"), origChanID); //TODO: skip this ing?
if (sscanf (equiChanID, "%[^-]-%i -%i -%i ", source, &nid, &tid, &sid) == 4) {
if (sscanf (equiChanID, "%[^-]-%i -%i -%i -%i ", source, &nid, &tid, &sid, &rid)
- != 5) {
+ != 5) {
rid = 0;
}
tChannelID EquivChID = tChannelID (cSource::FromString (source), nid, tid, sid, rid);
@@ -1241,7 +1155,7 @@ void cFilterEEPG::LoadEquivalentChannels (void)
C->Sid[C->NumberOfEquivalences - 1], i);
} else
LogE(0, prep("Error, channel with id %i has more than %i equivalences. Increase MAX_EQUIVALENCES."),
- i, MAX_EQUIVALENCES);
+ i, MAX_EQUIVALENCES);
} else
LogI(0, prep("Warning, not found equivalent channel \'%s\' in channels.conf"), equiChanID);
}
@@ -1326,7 +1240,7 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW)
cChannel *VC = GetChannelByID(channelID, true);
bool IsFound = (VC);
if(IsFound) {
- C->Src[0] = VC->Source();
+ C->Src[0] = VC->Source();
}
CleanString (C->Name);
@@ -1339,10 +1253,10 @@ int cFilterEEPG::GetChannelsMHW (const u_char * Data, int Length, int MHW)
} //else nChannels > MAX_CHANNELS
LoadEquivalentChannels ();
GetLocalTimeOffset (); //reread timing variables, only used for MHW
- return 2; //obviously, when you get here, channels are read succesfully, but since all channels are sent at once, you can stop now
+ return 2; //obviously, when you get here, channels are read successfully, but since all channels are sent at once, you can stop now
} //if nChannels == 0
LogE (0, prep("Warning: Trying to read Channels more than once!"));
-//you will only get here when GetChannelsMHW is called, and nChannels !=0, e.g. when multiple citpids cause channels to be read multiple times. Second time, do nothing, give error so that the rest of the chain is not restarted also.
+ //you will only get here when GetChannelsMHW is called, and nChannels !=0, e.g. when multiple citpids cause channels to be read multiple times. Second time, do nothing, give error so that the rest of the chain is not restarted also.
return 0;
}
@@ -1472,7 +1386,7 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse
if (TitleEventId != HILO32 (SD->EventId)) {
LogI(0, prep("ERROR, Title has EventId %08x and points to Summary with EventId %08x."), TitleEventId,
- HILO32 (SD->EventId));
+ HILO32 (SD->EventId));
return 0; //return empty string
}
@@ -1513,7 +1427,7 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse
("EEPGDEBUG: EventId %08x NumberOfBlocks %02x BlockId %08x SummTxtOffset %08x *p2: %02x Unkn1:%02x, Unkn2:%02x.",
HILO32 (SD->EventId), SD->NumberOfBlocks, HILO32 (SD->BlockId), HILO32 (SD->SummTxtOffset), *p2, SD->Unknown1,
SD->Unknown2);
- */
+ */
unsigned char *Text = NULL; //makes first realloc work like malloc
int TotLength = 0; //and also makes empty summaries if *p2 != 0x4e
if (SD->NumberOfBlocks > 1) {
@@ -1575,8 +1489,8 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse
break;
default:
LogE(0, prep("ERROR *p2 has strange value: EventId %08x NumberOfBlocks %02x BlockId %08x SummTxtOffset %08x *p2: %02x Unkn1:%02x, Unkn2:%02x."),
- HILO32 (SD->EventId), SD->NumberOfBlocks, HILO32 (SD->BlockId), HILO32 (SD->SummTxtOffset), *p2,
- SD->Unknown1, SD->Unknown2);
+ HILO32 (SD->EventId), SD->NumberOfBlocks, HILO32 (SD->BlockId), HILO32 (SD->SummTxtOffset), *p2,
+ SD->Unknown1, SD->Unknown2);
break;
} //end of switch
} //NrOfBlocks > 1
@@ -1586,15 +1500,25 @@ char *cFilterEEPG::GetSummaryTextNagra (const u_char * DataStart, long int Offse
p += 29; //skip fixed part of block
if (SD->NumberOfBlocks == 1)
- p -= 4; //in this case there is NO summarytext AND no GBR??!!
+ p -= 4; //in this case there is NO summary text AND no GBR??!!
for (int i = 1; i < (SD->NumberOfBlocks - 1); i++) {
- LogD(3, prep("DEBUG: Extra Blockinfo: %02x %02x %02x %02x."), *p, *(p + 1), *(p + 2), *(p + 3));
- p += 4; //skip this extra blockinfo
+ LogD(3, prep("DEBUG: Extra Block info: %02x %02x %02x %02x."), *p, *(p + 1), *(p + 2), *(p + 3));
+ p += 4; //skip this extra block info
}
return (char *) Text;
}
-void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES]) //gets a channel and returns an array of schedules that WriteToSchedule can write to. Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1
+/**
+ * \brief Prepare to Write to Schedule
+ *
+ * gets a channel and returns an array of schedules that WriteToSchedule can write to.
+ * Call this routine before a batch of titles with the same ChannelId will be WriteToScheduled; batchsize can be 1
+ *
+ * \param C channel to prepare
+ * \param s VDR epg schedules
+ * \param ps pointer to the schedules that WriteToSchedule can write to
+ */
+void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSchedule * ps[MAX_EQUIVALENCES])
{
for (int eq = 0; eq < C->NumberOfEquivalences; eq++) {
tChannelID channelID = tChannelID (C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]);
@@ -1606,7 +1530,7 @@ void cFilterEEPG::PrepareToWriteToSchedule (sChannel * C, cSchedules * s, cSched
ps[eq] = s->AddSchedule (channelID); //open a a schedule for each equivalent channel
else {
ps[eq] = NULL;
- LogE(5, prep("ERROR: Titleblock has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."),
+ LogE(5, prep("ERROR: Title block has invalid (equivalent) channel ID: Equivalence: %i, Source:%x, C->Nid:%x,C->Tid:%x,C->Sid:%x."),
eq, C->Src[eq], C->Nid[eq], C->Tid[eq], C->Sid[eq]);
}
}
@@ -1730,13 +1654,13 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor
LogD(3, prep("DEBUG: ChannelId %04x, Blocklength %04x, NumberOfTitles %lu."), ChannelId, Blocklength,
NumberOfTitles);
- p += 4; //skip ChannelId and Blocklength
+ p += 4; //skip ChannelId and Block length
next_p = p + Blocklength;
if (next_p > DataEnd) { //only process if block is complete
LogE(0, prep("ERROR, Block exceeds end of Data. p:%p, Blocklength:%x,DataEnd:%p."), p, Blocklength, DataEnd);
return; //fatal error, this should never happen
}
- p += 4; //skip Titlenumber
+ p += 4; //skip Title number
sChannel *C = &sChannels[ChannelSeq[ChannelId]]; //find channel
cSchedule *ps[MAX_EQUIVALENCES];
@@ -1755,7 +1679,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor
tmCurrent->tm_mon = CurrentMonth;
tmCurrent->tm_mday = MonthdayTitles;
tmCurrent->tm_hour = 0;
- tmCurrent->tm_min = StartTime; //if starttime is bigger than 1 hour, mktime will correct this!
+ tmCurrent->tm_min = StartTime; //if start time is bigger than 1 hour, mktime will correct this!
tmCurrent->tm_sec = 0;
tmCurrent->tm_isdst = -1; //now correct with daylight savings
if (MonthdayTitles < CurrentMonthday - 7) //the titles that are older than one week are not from the past, but from next month!
@@ -1769,7 +1693,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor
//u_char *t2 = (u_char *) Data + HILO32 (Title->OffsetToText2);
if (t >= DataEnd)
LogE(0, prep("ERROR, Title Text out of range: t:%p, DataEnd:%p, Data:%p, Length:%i."), t, DataEnd, Data,
- Length);
+ Length);
else {
Asprintf (&Text, "%.*s", *t, t + 1);
//asprintf (&Text, "%.*s %.*s", *t, t + 1, *t2, t2 + 1); //FIXME second text string is not processed right now
@@ -1783,7 +1707,7 @@ void cFilterEEPG::GetTitlesNagra (const u_char * Data, int Length, unsigned shor
else
SummText = GetSummaryTextNagra (DataStartSummaries, HILO32 (Title->SumDataOffset), EventId);
- LogD(3, prep("DEBUG: Eventid: %08x ChannelId:%x, Starttime %02i:%02i, Duration %i, OffsetToText:%08x, OffsetToText2:%08x, SumDataOffset:%08x ThemeId:%x Title:%s \n SummaryText:%s"),
+ LogD(3, prep("DEBUG: Eventid: %08x ChannelId:%x, Start time %02i:%02i, Duration %i, OffsetToText:%08x, OffsetToText2:%08x, SumDataOffset:%08x ThemeId:%x Title:%s \n SummaryText:%s"),
EventId, ChannelId, Hours, Minutes, Title->Duration,
HILO32 (Title->OffsetToText), HILO32 (Title->OffsetToText2),
HILO32 (Title->SumDataOffset), Title->ThemeId, Text, SummText);
@@ -1869,7 +1793,7 @@ int cFilterEEPG::GetThemesNagra (const u_char * Data, int Length, unsigned short
u_char *NewThemeId = DataStartTitles + HILO32 (TT->TitleOffset) + 28;
if (NewThemeId >= DataEndTitles)
LogE(0, prep("ERROR, ThemeId out of range: NewThemeId:%p, DataEndTitles:%p, DataStartTitles:%p."), NewThemeId,
- DataEndTitles, DataStartTitles);
+ DataEndTitles, DataStartTitles);
else {
//esyslog("EEPGDEBUG: NewThemeId:%02x, Text:%s.",*NewThemeId, Text);
if (Themes[*NewThemeId][0] != 0x00) { //theme is already filled, break off
@@ -1881,7 +1805,7 @@ int cFilterEEPG::GetThemesNagra (const u_char * Data, int Length, unsigned short
else if (ThemeId != *NewThemeId) { //different theme ids in block
if ((ThemeId & 0xf0) != (*NewThemeId & 0xf0)) { //major nible of themeid does not correspond
LogE(3, prep("ERROR, Theme has multiple indices which differ in major nibble, old index = %x, new index = %x. Ignoring both indices."),
- ThemeId, *NewThemeId);
+ ThemeId, *NewThemeId);
AnyDoubt = true;
break;
} else if ((ThemeId & 0x0f) != 0) //ThemeId is like 1a, 2a, not like 10,20. So it is minor in tree-structure, and it should be labeled in major part of tree
@@ -1903,7 +1827,7 @@ int cFilterEEPG::GetThemesNagra (const u_char * Data, int Length, unsigned short
Textlength = 63; //leave room for trailing NULL
if (Themes[ThemeId][0] != 0) {
LogE(0, prep("Trying to add new theme, but Id already exists. ThemeId = %x, Old theme with this Id:%s, new theme: %s."),
- ThemeId, Themes[ThemeId], Text);
+ ThemeId, Themes[ThemeId], Text);
continue;
}
memcpy (&Themes[ThemeId], Text, Textlength);
@@ -1943,7 +1867,7 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length)
sChannelsNagraGuide *Channel = (sChannelsNagraGuide *) p;
sChannel *C = &sChannels[j];
C->ChannelId = j + 1; //Nagra starts numbering at 1
- ChannelSeq[C->ChannelId] = j; //fill lookup table to go from channel-id to sequence nr in table; lookuptable starts with 0
+ ChannelSeq[C->ChannelId] = j; //fill lookup table to go from channel-id to sequence nr in table; lookup table starts with 0
C->SkyNumber = 0;
C->NumberOfEquivalences = 1; //there is always an original channel. every equivalence adds 1
C->Src[0] = Source(); //assume all EPG channels are on same satellite, if not, manage this via equivalents!!!
@@ -1954,9 +1878,9 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length)
cChannel *VC = GetChannelByID(channelID, true);
bool IsFound = (VC);
if(IsFound) {
- strncpy((char*)(C->Name), VC->Name (), 64);
- C->Src[0] = VC->Source();
- CleanString (C->Name);
+ strncpy((char*)(C->Name), VC->Name (), 64);
+ C->Src[0] = VC->Source();
+ CleanString (C->Name);
}
else
C->Name[0] = '\0'; //empty string
@@ -2008,7 +1932,7 @@ int cFilterEEPG::GetChannelsNagra (const u_char * Data, int Length)
isyslog ("EEPGDEBUG: Always0x81 is NOT 0x81:%x.", Channel->Always0x81);
if (Channel->Always0x44 != 0x44)
isyslog ("EEPGDEBUG: Always0x44 is NOT 0x44:%x.", Channel->Always0x44);
- */
+ */
}
if (p != DataEnd)
@@ -2037,7 +1961,7 @@ int cFilterEEPG::GetNagra (const u_char * Data, int Length)
u_char *p = (u_char *) Data + 8;
if (*p != 0x01) {
LogE(0, prep("Error, Nagra first byte in table_id_extension 0x00 is not 0x01 but %02x. Format unknown, exiting."),
- *p);
+ *p);
return 0; //fatal error
}
p++; //skip 0x01 byte
@@ -2086,7 +2010,7 @@ int cFilterEEPG::GetNagra (const u_char * Data, int Length)
(0x0810) bouquet info; references to channels within a package, day 1 of the month
(0x0820) same day 2 of the month
(0x09f0) same day 31 of the month
- */
+ */
if (!(TBH->TableIdExtensionHigh >= 0x02 && TBH->TableIdExtensionHigh <= 0x07)) //here we regulate which tables we are testing
return (1);
@@ -2134,11 +2058,11 @@ void cFilterEEPG::ProcessNagra ()
NumberOfTables--;
}
- for (int i = 0; i < NagraCounter; i++) { //first prcoess all themes, since they all use the same codes
+ for (int i = 0; i < NagraCounter; i++) { //first process all themes, since they all use the same codes
unsigned short int TableIdExtension = NagraTIE[i];
int TIE = TableIdExtension - 0x0200; //from 0x0400 to 0x0200 -> titles
LogI(0, prep("Processing TableIdExtension:%04x"), TableIdExtension);
- GetTitlesNagra (buffer[TIE] + 4, bufsize[TIE] - 4, TableIdExtension); //assume title-reading is completed //TODO Language code terminatd by 0 is ignored
+ GetTitlesNagra (buffer[TIE] + 4, bufsize[TIE] - 4, TableIdExtension); //assume title-reading is completed //TODO Language code terminated by 0 is ignored
free (buffer[TIE]);
buffer[TIE] = NULL;
NumberOfTables--;
@@ -2149,7 +2073,7 @@ void cFilterEEPG::ProcessNagra ()
}
if (NumberOfTables != 0)
LogE(0, prep("ERROR, Not all tables processed and stream is already repeating. NumberOfTables = %i."),
- NumberOfTables);
+ NumberOfTables);
}
/**
@@ -2163,7 +2087,7 @@ int cFilterEEPG::GetTitlesMHW1 (const u_char * Data, int Length)
sTitleMHW1 *Title = (sTitleMHW1 *) Data;
if (Title->ChannelId == 0xff) { //FF is separator packet
if (memcmp (InitialTitle, Data, 46) == 0) { //data is the same as initial title //TODO use easier notation
- LogD(2, prep("End procesing titles"));
+ LogD(2, prep("End processing titles"));
return 2;
}
if (nTitles == 0)
@@ -2399,7 +2323,7 @@ int cFilterEEPG::GetSummariesMHW1 (const u_char * Data, int Length)
} //numreplays <10
else {
LogE(0, prep("Warning, number of replays %d > 10, cannot process."),
- Summary->NumReplays);
+ Summary->NumReplays);
return 1; //nonfatal error
}
} //length >11
@@ -2761,7 +2685,7 @@ void cFilterEEPG::FreeSummaries (void)
S = Summaries[i];
if (i < nSummaries - 1) {
S2 = Summaries[i + 1]; //look at next summary
- if (S->Text != S2->Text && S->Text != 0x00) //this is the last summary that points to this textblock; needed in case NumReplays > 1, multiple pointers to same textblock
+ if (S->Text != S2->Text && S->Text != 0x00) //this is the last summary that points to this text block; needed in case NumReplays > 1, multiple pointers to same textblock
free (S->Text);
} else if (S->Text != 0x00)
free (S->Text);
@@ -2794,7 +2718,7 @@ void cFilterEEPG::LoadIntoSchedule (void)
Title_t *T;
Summary_t *S;
int remembersummary;
-//keep statistics
+ //keep statistics
int SummariesNotFound = 0;
int NoSummary = 0;
int NotMatching = 0;
@@ -2824,7 +2748,7 @@ void cFilterEEPG::LoadIntoSchedule (void)
if (!foundtitle) //no more titles with summaries
break;
if ((T->EventId == S->EventId) && (T->MjdTime == S->Replays[0].MjdTime)
- && ((T->ChannelId == S->Replays[0].ChannelId) || ((Format != SKY_IT) && (Format != SKY_UK)))) { //should always be true, titles and summaries are broadcasted in order...
+ && ((T->ChannelId == S->Replays[0].ChannelId) || ((Format != SKY_IT) && (Format != SKY_UK)))) { //should always be true, titles and summaries are broadcasted in order...
LogD(3, prep("T->EventId == S->EventId"));
//MjdTime = 0 for all but SKY
//S->ChannelId must be equal to T->ChannelId only for SKY; in MHW1 S->ChannelId overrides T->ChannelId when NumReplays > 1
@@ -2872,8 +2796,8 @@ void cFilterEEPG::LoadIntoSchedule (void)
} //while
while (index < S->NumReplays);
-//TODO: why load events that have already past, and then run Cleanup
-//end of putting title and summary in schedule
+ //TODO: why load events that have already past, and then run Cleanup
+ //end of putting title and summary in schedule
i++; //move to next title
} //if T->EventId == S->EventId
else {
@@ -2889,7 +2813,7 @@ void cFilterEEPG::LoadIntoSchedule (void)
//esyslog ("EEPG Error: could not find summary for summary-available Title %d.", i);
esyslog
("EEPG: Error, summary not found for EventId %08x Titlenr %d:SummAv:%x,Unknown1:%x,Unknown2:%x,Un3:%x,Name:%s.",
- T->EventId, i, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text);
+ T->EventId, i, T->SummaryAvailable, T->Unknown1, T->Unknown2, T->Unknown3, T->Text);
/* write Title info to schedule */
sChannel *C = &sChannels[ChannelSeq[T->ChannelId]]; //find channel
@@ -2929,7 +2853,7 @@ void cFilterEEPG::LoadIntoSchedule (void)
esyslog ("EEPG: %i summaries not found", SummariesNotFound);
if (NotMatching > nSummaries)
LogI (0, prep("Warning: lost sync %i times, summary did not match %i times."),
- LostSync, NotMatching);
+ LostSync, NotMatching);
FreeSummaries (); //do NOT free channels, themes and bouquets here because they will be reused in SKY!
FreeTitles ();
@@ -2963,7 +2887,7 @@ namespace SI
DishSeriesDescriptorTag = 0x96,
};
- // typedef InheritEnum< DescriptorTagExt, SI::DescriptorTag > ExtendedDescriptorTag;
+// typedef InheritEnum< DescriptorTagExt, SI::DescriptorTag > ExtendedDescriptorTag;
/*extern const char *getCharacterTable(const unsigned char *&buffer, int &length, bool *isSingleByte = NULL);
extern bool convertCharacterTable(const char *from, size_t fromLength, char *to, size_t toLength, const char *fromCode);
@@ -3004,13 +2928,13 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven
newEvent->SetStartTime (pEvent->StartTime());
newEvent->SetDuration (pEvent->Duration());
newEvent->SetVersion (pEvent->Version());
- // newEvent->SetContents(pEvent->Contents());
+// newEvent->SetContents(pEvent->Contents());
newEvent->SetParentalRating(pEvent->ParentalRating());
newEvent->SetVps (pEvent->Vps());
newEvent->SetTitle (pEvent->Title ());
newEvent->SetShortText (pEvent->ShortText ());
newEvent->SetDescription (pEvent->Description ());
- // newEvent->SetComponents (pEvent->Components());
+// newEvent->SetComponents (pEvent->Components());
newEvent->FixEpgBugs ();
pSchedule->AddEvent(newEvent);
@@ -3025,13 +2949,13 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven
newEvent->SetStartTime (pEvent->StartTime());
newEvent->SetDuration (pEvent->Duration());
newEvent->SetVersion (pEvent->Version());
-// newEvent->SetContents(pEvent->Contents());
+// newEvent->SetContents(pEvent->Contents());
newEvent->SetParentalRating(pEvent->ParentalRating());
newEvent->SetVps (pEvent->Vps());
newEvent->SetTitle (pEvent->Title ());
newEvent->SetShortText (pEvent->ShortText ());
newEvent->SetDescription (pEvent->Description ());
-// newEvent->SetComponents (pEvent->Components());
+// newEvent->SetComponents (pEvent->Components());
newEvent->FixEpgBugs ();
pSchedule->AddEvent(newEvent);
@@ -3042,10 +2966,10 @@ void cEIT2::updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEven
}
cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, bool isEITPid, bool OnlyRunningStatus)
- : SI::EIT (Data, false)
+: SI::EIT (Data, false)
{
//LogD(2, prep("cEIT2::cEIT2"));
- if (Tid > 0 && (Format == DISH_BEV || (SetupPE.ProcessEIT && isEITPid))) Tid--;
+ if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--;
if (!CheckCRCAndParse ()) {
LogD(2, prep("!CheckCRCAndParse ()"));
@@ -3102,13 +3026,11 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
pEvent = newEvent = new cEvent (SiEitEvent.getEventId ());
if (!pEvent)
continue;
- //updateEquivalent(Schedules, channel->GetChannelID(), pEvent);
} else {
//LogD(3, prep("existing event channelID: %s Title: %s TableID 0x%02X new TID 0x%02X Version %i, new version %i"), *channel->GetChannelID().ToString(), pEvent->Title(), pEvent->TableID(), Tid, pEvent->Version(), versionNumber);
// We have found an existing event, either through its event ID or its start time.
pEvent->SetSeen ();
- //updateEquivalent(Schedules, channel->GetChannelID(), pEvent);
// If the existing event has a zero table ID it was defined externally and shall
// not be overwritten.
if (pEvent->TableID () == 0x00) {
@@ -3132,7 +3054,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
int LanguagePreferenceShort = -1;
SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d;
if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort)
- || !ShortEventDescriptor) {
+ || !ShortEventDescriptor) {
delete ShortEventDescriptor;
ShortEventDescriptor = sed;
d = NULL; // so that it is not deleted
@@ -3142,7 +3064,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
bool UseExtendedEventDescriptor = false;
SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d;
if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt)
- || !ExtendedEventDescriptors) {
+ || !ExtendedEventDescriptors) {
delete ExtendedEventDescriptors;
ExtendedEventDescriptors = new SI::ExtendedEventDescriptors;
UseExtendedEventDescriptor = true;
@@ -3248,7 +3170,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
case SI::ExtendedEventDescriptorTag: {
SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d;
if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt)
- || !ExtendedEventDescriptors) {
+ || !ExtendedEventDescriptors) {
delete ExtendedEventDescriptors;
ExtendedEventDescriptors = new SI::ExtendedEventDescriptors;
UseExtendedEventDescriptor = true;
@@ -3264,7 +3186,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
case SI::ShortEventDescriptorTag: {
SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d;
if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort)
- || !ShortEventDescriptor) {
+ || !ShortEventDescriptor) {
delete ShortEventDescriptor;
ShortEventDescriptor = sed;
d = NULL; // so that it is not deleted
@@ -3301,7 +3223,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
if (I18nIsPreferredLanguage(Setup.EPGLanguages, Rating.languageCode, LanguagePreferenceRating)) {
int ParentalRating = (Rating.getRating() & 0xFF);
switch (ParentalRating) {
- // values defined by the DVB standard (minimum age = rating + 3 years):
+ // values defined by the DVB standard (minimum age = rating + 3 years):
case 0x01 ... 0x0F:
ParentalRating += 3;
break;
@@ -3364,7 +3286,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
if (ld->getLinkageType () == 0xB0) { // Premiere World
time_t now = time (NULL);
bool hit = SiEitEvent.getStartTime () <= now
- && now < SiEitEvent.getStartTime () + SiEitEvent.getDuration ();
+ && now < SiEitEvent.getStartTime () + SiEitEvent.getDuration ();
if (hit) {
char linkName[ld->privateData.getLength () + 1];
strn0cpy (linkName, (const char *) ld->privateData.getData (), sizeof (linkName));
@@ -3381,7 +3303,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
transponder = Channels.GetByTransponderID (linkID);
link =
Channels.NewChannel (transponder, linkName, "", "", ld->getOriginalNetworkId (),
- ld->getTransportStreamId (), ld->getServiceId ());
+ ld->getTransportStreamId (), ld->getServiceId ());
}
if (link) {
if (!LinkChannels)
@@ -3404,15 +3326,15 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
Components = new cComponents;
char buffer[Utf8BufSize (256)];
Components->SetComponent (Components->NumComponents (), Stream, Type,
- I18nNormalizeLanguageCode (cd->languageCode),
- cd->description.getText (buffer, sizeof (buffer)));
+ I18nNormalizeLanguageCode (cd->languageCode),
+ cd->description.getText (buffer, sizeof (buffer)));
}
}
break;
case SI::DishExtendedEventDescriptorTag: {
SI::UnimplementedDescriptor *deed = (SI::UnimplementedDescriptor *)d;
if (!DishEventDescriptor) {
- DishEventDescriptor = new SI::DishDescriptor();
+ DishEventDescriptor = new SI::DishDescriptor();
}
DishEventDescriptor->setExtendedtData(Tid+1, deed->getData());
HasExternalData = true;
@@ -3421,7 +3343,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
case SI::DishShortEventDescriptorTag: {
SI::UnimplementedDescriptor *dsed = (SI::UnimplementedDescriptor *)d;
if (!DishEventDescriptor) {
- DishEventDescriptor = new SI::DishDescriptor();
+ DishEventDescriptor = new SI::DishDescriptor();
}
DishEventDescriptor->setShortData(Tid+1, dsed->getData());
HasExternalData = true;
@@ -3436,7 +3358,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
DishEventDescriptor->setRating(rating);
}
}
- break;
+ break;
case SI::DishSeriesDescriptorTag: {
if (d->getLength() == 10) {
//LogD(2, prep("DishSeriesDescriptorTag: %s)"), (const char*) d->getData().getData());
@@ -3449,7 +3371,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
// LogD(2, prep("DishSeriesDescriptorTag length: %d)"), d->getLength());
// }
}
- break;
+ break;
default:
break;
}
@@ -3468,7 +3390,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
pEvent->SetTitle (buffer);
LogD(3, prep("channelID: %s Title: %s"), *channel->GetChannelID().ToString(), pEvent->Title());
l = ShortEventDescriptor->text.getLength();
- if (l > 0) { //Set the Short Text only if ther is data so that we do not overwrite valid data
+ if (l > 0) { //Set the Short Text only if there is data so that we do not overwrite valid data
f = (unsigned char *) ShortEventDescriptor->text.getData().getData();
decodeText2 (f, l, buffer, sizeof (buffer));
//ShortEventDescriptor->text.getText(buffer, sizeof(buffer));
@@ -3489,59 +3411,59 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
pEvent->SetDescription (NULL);
if (DishEventDescriptor) {
- if (DishEventDescriptor->getName())
- pEvent->SetTitle(DishEventDescriptor->getName());
- //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishShortEventDescriptor->getText());
-// pEvent->SetDescription(DishExtendedEventDescriptor->getText());
- char *tmp;
- string fmt;
- fmt = "%s";
- if (0 != strcmp(DishEventDescriptor->getShortText(),"") && DishEventDescriptor->hasTheme()) {
- fmt += " - ";
- }
- fmt += "%s";
- if (DishEventDescriptor->hasTheme() && DishEventDescriptor->hasCategory()) {
- fmt += " ~ ";
- }
- fmt += "%s";
-
- Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getShortText()
- , DishEventDescriptor->getTheme()
- , DishEventDescriptor->getCategory());
- pEvent->SetShortText(tmp);
- //LogD(2, prep("EEPGDEBUG:DishTheme:%x-DishCategory:%x)"), DishTheme, DishCategory);
- free(tmp);
-
- fmt = "%s";
- if (0 != strcmp(DishEventDescriptor->getDescription(),"")
- && (0 != strcmp(DishEventDescriptor->getRating(),"")
- || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) {
- fmt += "\n\nRating: ";
- }
- fmt += "%s %s";
- if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) {
- fmt += "\n\nProgram ID: ";
- }
- fmt += "%s %s%s";
- time_t orgAirDate = DishEventDescriptor->getOriginalAirDate();
- char datestr [80];
- bool dateok = false;
- if (orgAirDate == 0) {
- dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0;
- }
-
- Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getDescription()
- , DishEventDescriptor->getRating()
- , DishEventDescriptor->getStarRating()
- , DishEventDescriptor->getProgramId()
- , DishEventDescriptor->getSeriesId()
- , orgAirDate == 0 || !dateok ? "" : datestr);
- pEvent->SetDescription(tmp);
- free(tmp);
-
-
- //LogD(2, prep("DishDescription: %s"), DishExtendedEventDescriptor->getText());
- //LogD(2, prep("DishShortText: %s"), DishExtendedEventDescriptor->getShortText());
+ if (DishEventDescriptor->getName())
+ pEvent->SetTitle(DishEventDescriptor->getName());
+ //LogD(2, prep("channelID: %s DishTitle: %s"), *channel->GetChannelID().ToString(), DishShortEventDescriptor->getText());
+ // pEvent->SetDescription(DishExtendedEventDescriptor->getText());
+ char *tmp;
+ string fmt;
+ fmt = "%s";
+ if (0 != strcmp(DishEventDescriptor->getShortText(),"") && DishEventDescriptor->hasTheme()) {
+ fmt += " - ";
+ }
+ fmt += "%s";
+ if (DishEventDescriptor->hasTheme() && DishEventDescriptor->hasCategory()) {
+ fmt += " ~ ";
+ }
+ fmt += "%s";
+
+ Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getShortText()
+ , DishEventDescriptor->getTheme()
+ , DishEventDescriptor->getCategory());
+ pEvent->SetShortText(tmp);
+ //LogD(2, prep("EEPGDEBUG:DishTheme:%x-DishCategory:%x)"), DishTheme, DishCategory);
+ free(tmp);
+
+ fmt = "%s";
+ if (0 != strcmp(DishEventDescriptor->getDescription(),"")
+ && (0 != strcmp(DishEventDescriptor->getRating(),"")
+ || 0 != strcmp(DishEventDescriptor->getStarRating(),""))) {
+ fmt += "\n\nRating: ";
+ }
+ fmt += "%s %s";
+ if (0 != strcmp(DishEventDescriptor->getProgramId(),"")) {
+ fmt += "\n\nProgram ID: ";
+ }
+ fmt += "%s %s%s";
+ time_t orgAirDate = DishEventDescriptor->getOriginalAirDate();
+ char datestr [80];
+ bool dateok = false;
+ if (orgAirDate == 0) {
+ dateok = strftime (datestr,80," Original Air Date: %a %b %d %Y",gmtime(&orgAirDate)) > 0;
+ }
+
+ Asprintf (&tmp, fmt.c_str(), DishEventDescriptor->getDescription()
+ , DishEventDescriptor->getRating()
+ , DishEventDescriptor->getStarRating()
+ , DishEventDescriptor->getProgramId()
+ , DishEventDescriptor->getSeriesId()
+ , orgAirDate == 0 || !dateok ? "" : datestr);
+ pEvent->SetDescription(tmp);
+ free(tmp);
+
+
+ //LogD(2, prep("DishDescription: %s"), DishExtendedEventDescriptor->getText());
+ //LogD(2, prep("DishShortText: %s"), DishExtendedEventDescriptor->getShortText());
}
}
@@ -3605,7 +3527,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
if (pPreviousEvent->Description ())
len_title_extern =
snprintf (buffer_title_extern, sizeof (buffer_title_extern) - 1, "%s",
- pPreviousEvent->Description ());
+ pPreviousEvent->Description ());
if (len_title_intern > 0) {
if (len_title_extern < 1)
pPreviousEvent->SetDescription (buffer_title_intern);
@@ -3622,7 +3544,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
}
}
#endif /* DDEPGENTRY */
- updateEquivalent(Schedules, channel->GetChannelID(), pEvent);
+ updateEquivalent(Schedules, channel->GetChannelID(), pEvent);
}
if (Empty && Tid == 0x4E && getSectionNumber () == 0)
// ETR 211: an empty entry in section 0 of table 0x4E means there is currently no event running
@@ -3661,7 +3583,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false)
isyslog ("EEPG: written %i summaries", SummaryCounter);
isyslog ("EEPG: rejected %i titles/summaries because of higher TableId", RejectTableId);
//Send message when finished
- if (SetupPE.DisplayMessage) {
+ if (SetupPE->DisplayMessage) {
char *mesg;
Asprintf(&mesg, "EEPG: written %i summaries", SummaryCounter);
Skins.QueueMessage(mtInfo, mesg, 2);
@@ -3691,10 +3613,10 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false)
FreeSummaries ();
// Enable EIT scan for all except DISH_BEV since it is already enabled
- if (SetupPE.ProcessEIT && !UnprocessedFormat[EIT]
- && !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) {
- UnprocessedFormat[EIT] = EIT_PID;
- loadEquivalentChannelMap();
+ if (SetupPE->ProcessEIT && !UnprocessedFormat[EIT]
+ && !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) {
+ UnprocessedFormat[EIT] = EIT_PID;
+ loadEquivalentChannelMap();
}
//now start looking for next format to process
@@ -3728,8 +3650,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false)
EndThemes = false;
switch (Format) {
case PREMIERE:
- if (!Matches (pid, 0xA0))
- Add (pid, 0xA0);
+ AddFilter (pid, 0xA0);
break;
case MHW1:
AddFilter (0xd3, 0x92); //ThemesMHW1//TODO: all filters are serialized, strictly speaking Themes is non-fatal...
@@ -3753,7 +3674,9 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false)
AddFilter (pid, 0xb0); //perhaps TID is equal to first data byte?
break;
case DISH_BEV:
+#if APIVERSNUM < 10726
AddFilter (EIT_PID, 0, 0); // event info, actual(0x4e)/other(0x4f) TS, present/following
+#endif
AddFilter (0x0300, 0, 0); // Dish Network EEPG event info, actual(0x4e)/other(0x4f) TS, present/following
AddFilter (0x0441, 0, 0); // Dish Network EEPG event info, actual(0x4e)/other(0x4f) TS, present/following
// AddFilter (0x0441, 0x50, 0xf0); // Bell ExpressVU EEPG
@@ -3771,27 +3694,27 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false)
void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const u_char *Data)
{
- //0x39 Viasat, 0x0300 Dish Network EEPG, 0x0441 Bell ExpressVU EEPG
- LogD(4, prep("Pid: 0x%02x Tid: %d Length: %d"), Pid, Tid, Length);
- cSchedulesLock SchedulesLock(true, 10);
+ //0x39 Viasat, 0x0300 Dish Network EEPG, 0x0441 Bell ExpressVU EEPG
+ LogD(4, prep("Pid: 0x%02x Tid: %d Length: %d"), Pid, Tid, Length);
+ cSchedulesLock SchedulesLock(true, 10);
+ cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock));
+ //Look for other satelite positions only if Dish/Bell ExpressVU for the moment hardcoded pid check
+ if(Schedules)
+ SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID);
+
+ else//cEIT EIT (Schedules, Source (), Tid, Data);
+ {
+ // If we don't get a write lock, let's at least get a read lock, so
+ // that we can set the running status and 'seen' timestamp (well, actually
+ // with a read lock we shouldn't be doing that, but it's only integers that
+ // get changed, so it should be ok)
+ cSchedulesLock SchedulesLock;
cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock));
- //Look for other satelite positions only if Dish/Bell ExpressVU for the moment hardcoded pid check
if(Schedules)
- SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID);
+ SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID, true);
- else//cEIT EIT (Schedules, Source (), Tid, Data);
- {
- // If we don't get a write lock, let's at least get a read lock, so
- // that we can set the running status and 'seen' timestamp (well, actually
- // with a read lock we shouldn't be doing that, but it's only integers that
- // get changed, so it should be ok)
- cSchedulesLock SchedulesLock;
- cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock));
- if(Schedules)
- SI::cEIT2 EIT(Schedules, Source(), Tid, Data, Pid == EIT_PID, true);
-
- //cEIT EIT (Schedules, Source (), Tid, Data, true);
- }
+ //cEIT EIT (Schedules, Source (), Tid, Data, true);
+ }
}
void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Length)
@@ -3854,7 +3777,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len
}
//Format = 0; // 0 = premiere, 1 = MHW1, 2 = MHW2, 3 = Sky Italy (OpenTV), 4 = Sky UK (OpenTV), 5 = Freesat (Freeview), 6 = Nagraguide
SI::Descriptor * d;
- unsigned char nDescriptorTag;
+ unsigned char nDescriptorTag;
for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext (it));) {
LogD(4, prep("EEPGDEBUG:d->getDescriptorTAG():%x,SI::PrivateTag:%x\n"), d->getDescriptorTag (), SI::PrivateDataSpecifierDescriptorTag);
nDescriptorTag = d->getDescriptorTag ();
@@ -3931,7 +3854,7 @@ void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Len
if (((Source() == cSource::FromString("S119.0W")
&& Transponder() == cChannel::Transponder(12472,'H'))
|| (Source() == cSource::FromString("S91.0W")
- && Transponder() == cChannel::Transponder(12224,'R')))
+ && Transponder() == cChannel::Transponder(12224,'R')))
&& !UnprocessedFormat[DISH_BEV]) {
UnprocessedFormat[DISH_BEV] = stream.getPid ();
}
@@ -4212,7 +4135,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
{
time_t firstTime = 0;
SI::Descriptor * d;
- unsigned char nDescriptorTag;
+ unsigned char nDescriptorTag;
bool UseExtendedEventDescriptor = false;
int LanguagePreferenceShort = -1;
int LanguagePreferenceExt = -1;
@@ -4220,7 +4143,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
nDescriptorTag = d->getDescriptorTag ();
switch (nDescriptorTag) {
case 0xF0: // order information
- if (SetupPE.OrderInfo) {
+ if (SetupPE->OrderInfo) {
static const char *text[] = {
trNOOP ("Ordernumber"),
trNOOP ("Price"),
@@ -4242,7 +4165,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
}
break;
case 0xF1: // parental rating
- if (SetupPE.RatingInfo) {
+ if (SetupPE->RatingInfo) {
char buff[512];
int p = 0;
const unsigned char *data = d->getData ().getData () + 2;
@@ -4278,7 +4201,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
case SI::ExtendedEventDescriptorTag: {
SI::ExtendedEventDescriptor * eed = (SI::ExtendedEventDescriptor *) d;
if (I18nIsPreferredLanguage (Setup.EPGLanguages, eed->languageCode, LanguagePreferenceExt)
- || !ExtendedEventDescriptors) {
+ || !ExtendedEventDescriptors) {
delete ExtendedEventDescriptors;
ExtendedEventDescriptors = new SI::ExtendedEventDescriptors;
UseExtendedEventDescriptor = true;
@@ -4294,7 +4217,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
case SI::ShortEventDescriptorTag: {
SI::ShortEventDescriptor * sed = (SI::ShortEventDescriptor *) d;
if (I18nIsPreferredLanguage (Setup.EPGLanguages, sed->languageCode, LanguagePreferenceShort)
- || !ShortEventDescriptor) {
+ || !ShortEventDescriptor) {
delete ShortEventDescriptor;
ShortEventDescriptor = sed;
d = NULL; // so that it is not deleted
@@ -4315,14 +4238,14 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
crc[0] = cit.getContentId ();
SI::PremiereContentTransmissionDescriptor * pct;
for (SI::Loop::Iterator it;
- (pct =
- (SI::PremiereContentTransmissionDescriptor *) cit.eventDescriptors.getNext (it,
- SI::
- PremiereContentTransmissionDescriptorTag));) {
+ (pct =
+ (SI::PremiereContentTransmissionDescriptor *) cit.eventDescriptors.getNext (it,
+ SI::
+ PremiereContentTransmissionDescriptorTag));) {
int nid = pct->getOriginalNetworkId ();
int tid = pct->getTransportStreamId ();
int sid = pct->getServiceId ();
- if (SetupPE.FixEpg) {
+ if (SetupPE->FixEpg) {
if (nid == 133) {
if (tid == 0x03 && sid == 0xf0) {
tid = 0x02;
@@ -4368,12 +4291,10 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
for (SI::Loop::Iterator it2; sd.startTimeLoop.getNext (st, it2);) {
time_t StartTime = st.getStartTime (mjd);
time_t EndTime = StartTime + cit.getDuration ();
- int runningStatus = (StartTime < now
- && now < EndTime) ? SI::RunningStatusRunning : ((StartTime - 30 < now
- && now <
- StartTime) ? SI::
- RunningStatusStartsInAFewSeconds
- : SI::RunningStatusNotRunning);
+ int runningStatus =
+ (StartTime < now && now < EndTime) ? SI::RunningStatusRunning :
+ ((StartTime - 30 < now && now < StartTime) ?
+ SI::RunningStatusStartsInAFewSeconds : SI::RunningStatusNotRunning);
bool isOpt = false;
if (index++ == 0 && nCount > 1)
isOpt = true;
@@ -4416,7 +4337,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
ShortEventDescriptor->name.getText (buffer, sizeof (buffer));
if (isOpt) {
char buffer2[sizeof (buffer) + 32];
- snprintf (buffer2, sizeof (buffer2), optPats[SetupPE.OptPat], buffer, optCount);
+ snprintf (buffer2, sizeof (buffer2), optPats[SetupPE->OptPat], buffer, optCount);
pEvent->SetTitle (buffer2);
} else
pEvent->SetTitle (buffer);
@@ -4429,7 +4350,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
}
if (order || rating) {
int len = (pEvent->Description ()? strlen (pEvent->Description ()) : 0) +
- (order ? strlen (order) : 0) + (rating ? strlen (rating) : 0);
+ (order ? strlen (order) : 0) + (rating ? strlen (rating) : 0);
char buffer[len + 32];
buffer[0] = 0;
if (pEvent->Description ())
@@ -4578,6 +4499,10 @@ bool cPluginEEPG::Start (void)
for (int i = 0; i < NumberOfAvailableSources; i++)
isyslog ("EEPG: Available sources:%s.", *cSource::ToString (AvailableSources[i]));
+#if APIVERSNUM > 10725
+ new cEEpgHandler();
+#endif
+
closedir(ConfigDir);
return true;
}
@@ -4598,10 +4523,10 @@ void cPluginEEPG::Stop (void)
free (ConfDir);
}
if (sky_tables[0]) {
- free(sky_tables[0]);
+ free(sky_tables[0]);
}
if (sky_tables[1]) {
- free(sky_tables[1]);
+ free(sky_tables[1]);
}
}
@@ -4625,20 +4550,20 @@ bool cPluginEEPG::SetupParse (const char *Name, const char *Value)
if (!strcasecmp (Name, "OptionPattern"))
- SetupPE.OptPat = atoi (Value);
+ SetupPE->OptPat = atoi (Value);
else if (!strcasecmp (Name, "OrderInfo"))
- SetupPE.OrderInfo = atoi (Value);
+ SetupPE->OrderInfo = atoi (Value);
else if (!strcasecmp (Name, "RatingInfo"))
- SetupPE.RatingInfo = atoi (Value);
+ SetupPE->RatingInfo = atoi (Value);
else if (!strcasecmp (Name, "FixEpg"))
- SetupPE.FixEpg = atoi (Value);
+ SetupPE->FixEpg = atoi (Value);
else if (!strcasecmp (Name, "DisplayMessage"))
- SetupPE.DisplayMessage = atoi (Value);
+ SetupPE->DisplayMessage = atoi (Value);
#ifdef DEBUG
else if (!strcasecmp (Name, "LogLevel"))
- SetupPE.LogLevel = atoi (Value);
+ SetupPE->LogLevel = atoi (Value);
else if (!strcasecmp (Name, "ProcessEIT"))
- SetupPE.ProcessEIT = atoi (Value);
+ SetupPE->ProcessEIT = atoi (Value);
#endif
else
return false;
diff --git a/epghandler.c b/epghandler.c
new file mode 100644
index 0000000..29f092b
--- /dev/null
+++ b/epghandler.c
@@ -0,0 +1,126 @@
+/*
+ * cEEpgHandler.c
+ *
+ * Created on: 11.3.2012
+ * Author: d.petrovski
+ */
+
+#include "epghandler.h"
+#if APIVERSNUM > 10725
+#include "log.h"
+
+cEEpgHandler::cEEpgHandler() {
+ // TODO Auto-generated constructor stub
+ LogD(4, prep("cEEpgHandler()"));
+
+}
+
+cEEpgHandler::~cEEpgHandler() {
+ // TODO Auto-generated destructor stub
+}
+
+bool cEEpgHandler::HandleEitEvent(cSchedule* Schedule,
+ const SI::EIT::Event* EitEvent, uchar TableID, uchar Version) {
+ //LogD(1, prep("HandleEitEvent"));
+ return false;
+ // return true;
+}
+
+bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) {
+ Event->SetEventID(EventID);
+ return true;
+}
+
+bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) {
+ LogD(3, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title);
+
+ if (!Event->Title() || Title && (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title))))
+ Event->SetTitle(Title);
+ return true;
+}
+
+bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) {
+ LogD(3, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText);
+
+ if (Event->ShortText() && strcmp(Event->ShortText(),"") != 0) {
+ origShortText = std::string(Event->ShortText());
+ }
+ else {
+ origShortText.clear();
+ }
+
+ //if (!Event->ShortText() || ShortText && (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText))))
+ Event->SetShortText(ShortText);
+ return true;
+}
+
+bool cEEpgHandler::SetDescription(cEvent* Event, const char* Description) {
+ LogD(3, prep("Event id:%d Description:%s new Description:%s"), Event->EventID(), Event->Description(), Description);
+
+ if (Event->Description() && strcmp(Event->Description(),"") != 0)
+ origDescription = Event->Description();
+ else
+ origDescription.clear();
+
+ //if (!Event->Description() || Description && (!strcmp(Event->Description(),"") || (strcmp(Description,"") && strcmp(Event->Description(),Description))))
+ Event->SetDescription(Description);
+ return true;
+}
+
+bool cEEpgHandler::SetContents(cEvent* Event, uchar* Contents) {
+ Event->SetContents(Contents);
+ return true;
+}
+
+bool cEEpgHandler::SetParentalRating(cEvent* Event, int ParentalRating) {
+ Event->SetParentalRating(ParentalRating);
+ return true;
+}
+
+bool cEEpgHandler::SetStartTime(cEvent* Event, time_t StartTime) {
+ Event->SetStartTime(StartTime);
+ return true;
+}
+
+bool cEEpgHandler::SetDuration(cEvent* Event, int Duration) {
+ Event->SetDuration(Duration);
+ return true;
+}
+
+bool cEEpgHandler::SetVps(cEvent* Event, time_t Vps) {
+ Event->SetVps(Vps);
+ return true;
+}
+
+bool cEEpgHandler::HandleEvent(cEvent* Event) {
+
+ LogD(3, prep("HandleEvent st:%s ost:%s desc:%s odesc:%s"),Event->ShortText(),origShortText.c_str(),Event->Description(),origDescription.c_str());
+
+ //After FixEpgBugs of cEvent set the original Short Text if empty
+ if (!Event->ShortText() || !strcmp(Event->ShortText(),""))
+ Event->SetShortText(origShortText.c_str());
+
+ if (!Event->Description() && !origDescription.empty()) {
+ Event->SetDescription(origDescription.c_str());
+ }
+ //TODO just to see the difference
+ //else if (!origDescription.empty() && !origDescription.compare(Event->Description())) {
+ // origDescription.append(" | EIT: ");
+ // origDescription.append(Event->Description());
+ // Event->SetDescription(origDescription.c_str());
+ // }
+
+ return true;
+}
+
+bool cEEpgHandler::SortSchedule(cSchedule* Schedule) {
+ Schedule->Sort();
+ return true;
+}
+
+bool cEEpgHandler::DropOutdated(cSchedule* Schedule, time_t SegmentStart,
+ time_t SegmentEnd, uchar TableID, uchar Version) {
+ return false;
+}
+
+#endif
diff --git a/epghandler.h b/epghandler.h
new file mode 100644
index 0000000..61f295b
--- /dev/null
+++ b/epghandler.h
@@ -0,0 +1,41 @@
+/*
+ * cEEpgHandler.h
+ *
+ * Created on: 11.3.2012
+ * Author: d.petrovski
+ */
+
+#ifndef CEEPGHANDLER_H_
+#define CEEPGHANDLER_H_
+#include <vdr/config.h>
+#if APIVERSNUM > 10725
+#include <vdr/epg.h>
+#include <string>
+
+class cEEpgHandler : public cEpgHandler {
+public:
+ cEEpgHandler();
+ virtual ~cEEpgHandler();
+ virtual bool IgnoreChannel(const cChannel *Channel) { return false; }
+ virtual bool HandleEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version);
+ virtual bool SetEventID(cEvent *Event, tEventID EventID);
+ virtual bool SetTitle(cEvent *Event, const char *Title);
+ virtual bool SetShortText(cEvent *Event, const char *ShortText);
+ virtual bool SetDescription(cEvent *Event, const char *Description);
+ virtual bool SetContents(cEvent *Event, uchar *Contents);
+ virtual bool SetParentalRating(cEvent *Event, int ParentalRating);
+ virtual bool SetStartTime(cEvent *Event, time_t StartTime);
+ virtual bool SetDuration(cEvent *Event, int Duration);
+ virtual bool SetVps(cEvent *Event, time_t Vps);
+ virtual bool FixEpgBugs(cEvent *Event) { return false; }
+ virtual bool HandleEvent(cEvent *Event);
+ virtual bool SortSchedule(cSchedule *Schedule);
+ virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version);
+
+private:
+ std::string origShortText;
+ std::string origDescription;
+};
+
+#endif /*APIVERSNUM > 10725*/
+#endif /* CEEPGHANDLER_H_ */
diff --git a/log.h b/log.h
new file mode 100644
index 0000000..35942d3
--- /dev/null
+++ b/log.h
@@ -0,0 +1,77 @@
+/*
+ * log.h
+ *
+ * Created on: 08.5.2012
+ * Author: d.petrovski
+ */
+
+#ifndef LOG_H_
+#define LOG_H_
+
+#include <string>
+#include <stdarg.h>
+#include "setupeepg.h"
+
+#define VERBOSE 1
+/* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */
+/* all is logged into /var/log/syslog */
+
+
+inline bool CheckLevel(int level)
+{
+#ifdef DEBUG
+ if (cSetupEEPG::getInstance()->LogLevel >= level)
+#else
+ if (VERBOSE >= level)
+#endif
+ {
+ return true;
+ }
+ return false;
+}
+
+inline const char* PrepareLog(std::string message)
+{
+ message = "EEPG: " + message;
+ return message.c_str();
+}
+
+#define MAXSYSLOGBUF 256
+
+//void LogVsyslog(int errLevel, const char * message, ...)
+inline void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...)
+{
+ va_list ap;
+ char fmt[MAXSYSLOGBUF];
+ if (errLevel == LOG_DEBUG) {
+ snprintf(fmt, sizeof(fmt), "[%d] %s:%d %s", cThread::ThreadId(), function, lineNum, message);
+ } else {
+ snprintf(fmt, sizeof(fmt), "[%d] %s", cThread::ThreadId(), message);
+ }
+ va_start(ap,message);
+ vsyslog ( errLevel, fmt, ap );
+ va_end(ap);
+}
+
+#define LogI(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_INFO, __LINE__, __FUNCTION__, b ) : void() )
+#define LogE(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_ERR, __LINE__, __FUNCTION__, b ) : void() )
+#define LogD(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_DEBUG, __LINE__, __FUNCTION__, b ) : void() )
+//#define LogE(a, b...) void( CheckLevel(a) ? esyslog ( b ) : void() )
+//#define LogD(a, b...) void( CheckLevel(a) ? dsyslog ( b ) : void() )
+#define prep(s) PrepareLog(s)
+#define prep2(s) s
+
+
+//void LogF(int level, const char * message, ...) __attribute__ ((format (printf,2,3)));
+
+//void LogF(int level, const char * message, ...)
+//{
+// if (CheckLevel(level)) {
+// va_list ap;
+// va_start(ap,message);
+// vsyslog (LOG_ERR, PrepareLog(message), ap );
+// va_end(ap);
+// }
+//}
+
+#endif /* LOG_H_ */
diff --git a/setupeepg.c b/setupeepg.c
new file mode 100644
index 0000000..3738227
--- /dev/null
+++ b/setupeepg.c
@@ -0,0 +1,36 @@
+/*
+ * setupeepg.c
+ *
+ * Created on: 08.5.2012
+ * Author: d.petrovski
+ */
+
+#include <stddef.h>
+#include "setupeepg.h"
+
+// --- cSetupEEPG -------------------------------------------------------
+
+cSetupEEPG* cSetupEEPG::_setupEEPG = NULL;
+
+cSetupEEPG::cSetupEEPG (void)
+{
+ OptPat = 1;
+ OrderInfo = 1;
+ RatingInfo = 1;
+ FixEpg = 0;
+ DisplayMessage = 1;
+ ProcessEIT = 0;
+#ifdef DEBUG
+ LogLevel = 0;
+#endif
+
+}
+
+cSetupEEPG* cSetupEEPG::getInstance()
+{
+ if (!_setupEEPG)
+ _setupEEPG = new cSetupEEPG();
+
+ return _setupEEPG;
+}
+
diff --git a/setupeepg.h b/setupeepg.h
new file mode 100644
index 0000000..f5e342a
--- /dev/null
+++ b/setupeepg.h
@@ -0,0 +1,35 @@
+/*
+ * setupeepg.h
+ *
+ * Created on: 08.5.2012
+ * Author: d.petrovski
+ */
+
+#ifndef SETUPEEPG_H_
+#define SETUPEEPG_H_
+
+class cSetupEEPG
+{
+public:
+ int OptPat;
+ int OrderInfo;
+ int RatingInfo;
+ int FixEpg;
+ int DisplayMessage;
+ int ProcessEIT;
+#ifdef DEBUG
+ int LogLevel;
+#endif
+
+public:
+ static cSetupEEPG* getInstance();
+
+private:
+ cSetupEEPG (void);
+ cSetupEEPG(cSetupEEPG const&); // copy constructor is private
+ cSetupEEPG& operator=(cSetupEEPG const&); // assignment operator is private
+ static cSetupEEPG* _setupEEPG;
+
+};
+
+#endif /* SETUPEEPG_H_ */