}
}
-RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, const eventData *&result )
+RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, const eventData *&result, int direction)
// if t == -1 we search the current event...
{
singleLock s(cache_lock);
{
if (t==-1)
t = time(0)+eDVBLocalTimeHandler::getInstance()->difference();
- timeMap::iterator i = It->second.second.lower_bound(t); // find > or equal
+ timeMap::iterator i = direction <= 0 ? It->second.second.lower_bound(t) : // find > or equal
+ It->second.second.upper_bound(t); // just >
if ( i != It->second.second.end() )
{
- if ( i->second->getStartTime() != t )
+ if ( direction < 0 || (direction == 0 && i->second->getStartTime() > t) )
{
timeMap::iterator x = i;
--x;
if ( x != It->second.second.end() )
{
time_t start_time = x->second->getStartTime();
- if (t < start_time)
- return -1;
- if (t > (start_time+x->second->getDuration()))
- return -1;
+ if (direction >= 0)
+ {
+ if (t < start_time)
+ return -1;
+ if (t > (start_time+x->second->getDuration()))
+ return -1;
+ }
i = x;
}
else
return -1;
}
-RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, const eit_event_struct *&result )
+RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, const eit_event_struct *&result, int direction)
{
singleLock s(cache_lock);
const eventData *data=0;
- RESULT ret = lookupEventTime(service, t, data);
+ RESULT ret = lookupEventTime(service, t, data, direction);
if ( !ret && data )
result = data->get();
return ret;
}
-RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, Event *& result )
+RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, Event *& result, int direction)
{
singleLock s(cache_lock);
const eventData *data=0;
- RESULT ret = lookupEventTime(service, t, data);
+ RESULT ret = lookupEventTime(service, t, data, direction);
if ( !ret && data )
result = new Event((uint8_t*)data->get());
return ret;
}
-RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, ePtr<eServiceEvent> &result )
+RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, ePtr<eServiceEvent> &result, int direction)
{
singleLock s(cache_lock);
const eventData *data=0;
- RESULT ret = lookupEventTime(service, t, data);
+ RESULT ret = lookupEventTime(service, t, data, direction);
if ( !ret && data )
{
Event ev((uint8_t*)data->get());
}
case 1:
type=PyInt_AsLong(entry);
- if (type < 0 || type > 1)
+ if (type < -1 || type > 2)
{
eDebug("unknown type %d", type);
continue;
ePtr<eServiceEvent> ptr;
if (stime)
{
- if (type == 0)
- lookupEventTime(ref, stime, ptr);
- else // type == 1
+ if (type == 2)
lookupEventId(ref, event_id, ptr);
+ else
+ lookupEventTime(ref, stime, ptr, type);
}
PyObject *ret = handleEvent(ptr, dest_list, argstring, argcount, service, nowTime, service_name, convertFunc, convertFuncArgs);
if (ret)
// eventData's are plain entrys out of the cache.. it's not safe to use them after cache unlock
// but its faster in use... its not allowed to delete this pointers via delete or free..
SWIG_VOID(RESULT) lookupEventId(const eServiceReference &service, int event_id, const eventData *&SWIG_OUTPUT);
- SWIG_VOID(RESULT) lookupEventTime(const eServiceReference &service, time_t, const eventData *&SWIG_OUTPUT);
+ SWIG_VOID(RESULT) lookupEventTime(const eServiceReference &service, time_t, const eventData *&SWIG_OUTPUT, int direction=0);
SWIG_VOID(RESULT) getNextTimeEntry(const eventData *&SWIG_OUTPUT);
// eit_event_struct's are plain dvb eit_events .. it's not safe to use them after cache unlock
// its not allowed to delete this pointers via delete or free..
RESULT lookupEventId(const eServiceReference &service, int event_id, const eit_event_struct *&);
- RESULT lookupEventTime(const eServiceReference &service, time_t , const eit_event_struct *&);
+ RESULT lookupEventTime(const eServiceReference &service, time_t , const eit_event_struct *&, int direction=0);
RESULT getNextTimeEntry(const eit_event_struct *&);
// Event's are parsed epg events.. it's safe to use them after cache unlock
// after use this Events must be deleted (memleaks)
RESULT lookupEventId(const eServiceReference &service, int event_id, Event* &);
- RESULT lookupEventTime(const eServiceReference &service, time_t, Event* &);
+ RESULT lookupEventTime(const eServiceReference &service, time_t, Event* &, int direction=0);
RESULT getNextTimeEntry(Event *&);
#endif
PyObject *lookupEvent(PyObject *list, PyObject *convertFunc=NULL);
// eServiceEvent are parsed epg events.. it's safe to use them after cache unlock
// for use from python ( members: m_start_time, m_duration, m_short_description, m_extended_description )
SWIG_VOID(RESULT) lookupEventId(const eServiceReference &service, int event_id, ePtr<eServiceEvent> &SWIG_OUTPUT);
- SWIG_VOID(RESULT) lookupEventTime(const eServiceReference &service, time_t, ePtr<eServiceEvent> &SWIG_OUTPUT);
+ SWIG_VOID(RESULT) lookupEventTime(const eServiceReference &service, time_t, ePtr<eServiceEvent> &SWIG_OUTPUT, int direction=0);
SWIG_VOID(RESULT) getNextTimeEntry(ePtr<eServiceEvent> &SWIG_OUTPUT);
};