2000-09-03 11:40:00 +02:00
/***************************************************************************
eit . h - description
- - - - - - - - - - - - - - - - - - -
begin : Fri Aug 25 2000
copyright : ( C ) 2000 by Robert Schneider
email : Robert . Schneider @ web . de
2001-08-15 13:56:11 +02:00
2001 - 08 - 15 : Adapted to ' libdtv ' by Rolf Hakenes < hakenes @ hippomi . de >
2000-09-03 11:40:00 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/***************************************************************************
* *
* This program is free software ; you can redistribute it and / or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation ; either version 2 of the License , or *
* ( at your option ) any later version . *
* *
2003-02-02 15:49:52 +01:00
* $ Id : eit . h 1.24 2003 / 02 / 02 14 : 07 : 39 kls Exp $
2000-09-03 11:40:00 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# ifndef __EIT_H
# define __EIT_H
2002-11-24 14:48:38 +01:00
# include "channels.h"
2000-10-29 13:17:22 +01:00
# include "thread.h"
# include "tools.h"
2000-09-03 11:40:00 +02:00
2002-01-13 16:18:40 +01:00
# define MAXEPGBUGFIXLEVEL 2
2000-10-29 13:17:22 +01:00
class cEventInfo : public cListObject {
friend class cSchedule ;
friend class cEIT ;
private :
2001-10-28 13:53:44 +01:00
unsigned char uTableID ; // Table ID this event came from
2002-11-24 14:48:38 +01:00
tChannelID channelID ; // Channel ID of program for that event
2000-10-29 13:17:22 +01:00
bool bIsFollowing ; // true if this is the next event on this channel
bool bIsPresent ; // true if this is the present event running
char * pExtendedDescription ; // Extended description of this event
char * pSubtitle ; // Subtitle of event
char * pTitle ; // Title of event
unsigned short uEventID ; // Event ID of this event
long lDuration ; // duration of event in seconds
time_t tTime ; // Start time
int nChannelNumber ; // the actual channel number from VDR's channel list (used in cMenuSchedule for sorting by channel number)
protected :
2001-10-28 13:53:44 +01:00
void SetTableID ( unsigned char tableid ) ;
2000-10-29 13:17:22 +01:00
void SetFollowing ( bool foll ) ;
void SetPresent ( bool pres ) ;
2001-09-22 13:07:43 +02:00
void SetTitle ( const char * string ) ;
2002-11-24 14:48:38 +01:00
void SetChannelID ( tChannelID channelid ) ;
2000-10-29 13:17:22 +01:00
void SetEventID ( unsigned short evid ) ;
void SetDuration ( long l ) ;
void SetTime ( time_t t ) ;
2001-09-22 13:07:43 +02:00
void SetExtendedDescription ( const char * string ) ;
void SetSubtitle ( const char * string ) ;
2002-11-24 14:48:38 +01:00
cEventInfo ( tChannelID channelid , unsigned short eventid ) ;
2001-03-31 15:04:37 +02:00
public :
2000-10-29 13:17:22 +01:00
~ cEventInfo ( ) ;
2001-10-28 13:53:44 +01:00
const unsigned char GetTableID ( void ) const ;
2000-10-29 13:17:22 +01:00
const char * GetTimeString ( void ) const ;
const char * GetEndTimeString ( void ) const ;
const char * GetDate ( void ) const ;
bool IsFollowing ( void ) const ;
bool IsPresent ( void ) const ;
const char * GetExtendedDescription ( void ) const ;
const char * GetSubtitle ( void ) const ;
const char * GetTitle ( void ) const ;
unsigned short GetEventID ( void ) const ;
long GetDuration ( void ) const ;
time_t GetTime ( void ) const ;
2002-11-24 14:48:38 +01:00
tChannelID GetChannelID ( void ) const ;
2000-10-29 13:17:22 +01:00
int GetChannelNumber ( void ) const { return nChannelNumber ; }
void SetChannelNumber ( int ChannelNumber ) const { ( ( cEventInfo * ) this ) - > nChannelNumber = ChannelNumber ; } // doesn't modify the EIT data, so it's ok to make it 'const'
2001-04-01 15:40:43 +02:00
void Dump ( FILE * f , const char * Prefix = " " ) const ;
2002-02-23 17:11:19 +01:00
static bool Read ( FILE * f , cSchedule * Schedule ) ;
2001-08-17 13:19:10 +02:00
void FixEpgBugs ( void ) ;
2000-10-29 13:17:22 +01:00
} ;
class cSchedule : public cListObject {
friend class cSchedules ;
friend class cEIT ;
private :
cEventInfo * pPresent ;
cEventInfo * pFollowing ;
2002-11-24 14:48:38 +01:00
tChannelID channelID ;
2000-10-29 13:17:22 +01:00
cList < cEventInfo > Events ;
protected :
2002-11-24 14:48:38 +01:00
void SetChannelID ( tChannelID channelid ) ;
2000-10-29 13:17:22 +01:00
bool SetFollowingEvent ( cEventInfo * pEvent ) ;
bool SetPresentEvent ( cEventInfo * pEvent ) ;
void Cleanup ( time_t tTime ) ;
void Cleanup ( void ) ;
2002-11-24 14:48:38 +01:00
cSchedule ( tChannelID channelid = tChannelID : : InvalidID ) ;
2001-03-31 15:04:37 +02:00
public :
2000-10-29 13:17:22 +01:00
~ cSchedule ( ) ;
2002-02-23 17:11:19 +01:00
cEventInfo * AddEvent ( cEventInfo * EventInfo ) ;
2000-10-29 13:17:22 +01:00
const cEventInfo * GetPresentEvent ( void ) const ;
const cEventInfo * GetFollowingEvent ( void ) const ;
2002-11-24 14:48:38 +01:00
tChannelID GetChannelID ( void ) const ;
2001-10-28 13:53:44 +01:00
const cEventInfo * GetEvent ( unsigned short uEventID , time_t tTime = 0 ) const ;
const cEventInfo * GetEventAround ( time_t tTime ) const ;
2000-10-29 13:17:22 +01:00
const cEventInfo * GetEventNumber ( int n ) const { return Events . Get ( n ) ; }
int NumEvents ( void ) const { return Events . Count ( ) ; }
2001-04-01 15:40:43 +02:00
void Dump ( FILE * f , const char * Prefix = " " ) const ;
2002-02-23 17:11:19 +01:00
static bool Read ( FILE * f , cSchedules * Schedules ) ;
2000-10-29 13:17:22 +01:00
} ;
2000-09-03 11:40:00 +02:00
2000-10-29 13:17:22 +01:00
class cSchedules : public cList < cSchedule > {
2002-02-23 17:11:19 +01:00
friend class cSchedule ;
2000-10-29 13:17:22 +01:00
friend class cSIProcessor ;
private :
const cSchedule * pCurrentSchedule ;
2002-11-24 14:48:38 +01:00
tChannelID currentChannelID ;
2000-10-29 13:17:22 +01:00
protected :
2002-11-24 14:48:38 +01:00
const cSchedule * AddChannelID ( tChannelID channelid ) ;
const cSchedule * SetCurrentChannelID ( tChannelID channelid ) ;
2000-10-29 13:17:22 +01:00
void Cleanup ( ) ;
2001-03-31 15:04:37 +02:00
public :
2000-10-29 13:17:22 +01:00
cSchedules ( void ) ;
~ cSchedules ( ) ;
2002-11-24 14:48:38 +01:00
const cSchedule * GetSchedule ( tChannelID channelid ) const ;
2000-10-29 13:17:22 +01:00
const cSchedule * GetSchedule ( void ) const ;
2001-04-01 15:40:43 +02:00
void Dump ( FILE * f , const char * Prefix = " " ) const ;
2002-02-23 17:11:19 +01:00
static bool Read ( FILE * f ) ;
2000-10-29 13:17:22 +01:00
} ;
2000-09-03 11:40:00 +02:00
2000-10-29 13:17:22 +01:00
typedef struct sip_filter {
2000-09-03 11:40:00 +02:00
2003-02-02 15:49:52 +01:00
unsigned short pid ;
2000-10-29 13:17:22 +01:00
u_char tid ;
int handle ;
bool inuse ;
2000-09-03 11:40:00 +02:00
2000-10-29 13:17:22 +01:00
} SIP_FILTER ;
2000-09-03 11:40:00 +02:00
2003-01-06 14:44:27 +01:00
class cCaDescriptor ;
class cCaDescriptors ;
2000-10-29 13:17:22 +01:00
class cSIProcessor : public cThread {
private :
2000-11-18 13:57:32 +01:00
static int numSIProcessors ;
static cSchedules * schedules ;
static cMutex schedulesMutex ;
2003-01-06 14:44:27 +01:00
static cCaDescriptors * caDescriptors ;
static cMutex caDescriptorsMutex ;
2001-08-11 09:38:12 +02:00
static const char * epgDataFileName ;
2002-10-13 09:34:47 +02:00
static time_t lastDump ;
2000-11-18 13:57:32 +01:00
bool masterSIProcessor ;
2002-11-10 15:50:21 +01:00
int currentSource ;
2002-03-10 12:45:58 +01:00
int currentTransponder ;
2003-01-06 14:44:27 +01:00
int pmtIndex ;
int pmtPid ;
2000-10-29 13:17:22 +01:00
SIP_FILTER * filters ;
2001-06-02 10:47:40 +02:00
char * fileName ;
2001-03-31 15:04:37 +02:00
bool active ;
2000-10-29 13:17:22 +01:00
void Action ( void ) ;
2003-02-02 15:49:52 +01:00
bool AddFilter ( unsigned short pid , u_char tid ) ;
bool DelFilter ( unsigned short pid , u_char tid ) ;
2001-06-02 10:47:40 +02:00
bool ShutDownFilters ( void ) ;
2001-03-31 15:04:37 +02:00
public :
2000-10-29 13:17:22 +01:00
cSIProcessor ( const char * FileName ) ;
~ cSIProcessor ( ) ;
2001-08-11 09:38:12 +02:00
static void SetEpgDataFileName ( const char * FileName ) ;
static const char * GetEpgDataFileName ( void ) ;
2002-02-23 13:55:57 +01:00
static const cSchedules * Schedules ( cMutexLock & MutexLock ) ;
// Caller must provide a cMutexLock which has to survive the entire
// time the returned cSchedules is accessed. Once the cSchedules is no
// longer used, the cMutexLock must be destroyed.
2003-01-06 14:44:27 +01:00
static int GetCaDescriptors ( int Source , int Transponder , int ServiceId , int BufSize , uchar * Data ) ;
///< Gets all CA descriptors for a given channel.
///< Copies all available CA descriptors for the given Source, Transponder and ServiceId
///< into the provided buffer at Data (at most BufSize bytes).
///< \return Returns the number of bytes copied into Data (0 if no CA descriptors are
///< available), or -1 if BufSize was too small to hold all CA descriptors.
2002-02-23 17:11:19 +01:00
static bool Read ( FILE * f = NULL ) ;
2002-08-25 10:49:02 +02:00
static void Clear ( void ) ;
2001-06-02 10:47:40 +02:00
void SetStatus ( bool On ) ;
2002-11-10 15:50:21 +01:00
void SetCurrentTransponder ( int CurrentSource , int CurrentTransponder ) ;
2002-11-24 14:48:38 +01:00
static bool SetCurrentChannelID ( tChannelID channelid ) ;
2002-10-13 09:34:47 +02:00
static void TriggerDump ( void ) ;
2000-10-29 13:17:22 +01:00
} ;
2000-09-03 11:40:00 +02:00
# endif