1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

VPS timers now record only events that have exactly the given start time

This commit is contained in:
Klaus Schmidinger 2006-04-01 13:27:14 +02:00
parent 6b968a6b27
commit 24b3579d14
3 changed files with 39 additions and 40 deletions

View File

@ -4468,3 +4468,6 @@ Video Disk Recorder Revision History
- Fixed learning keys when VDR is already running (thanks to Jurij Retzlaff). - Fixed learning keys when VDR is already running (thanks to Jurij Retzlaff).
- Fixed handling the system time transponder setting in the Setup/EPG menu, which - Fixed handling the system time transponder setting in the Setup/EPG menu, which
was broken by the min/max fix in cMenuEditIntItem. was broken by the min/max fix in cMenuEditIntItem.
- VPS timers now record only events that have exactly the given start time.
This fix also implements recording several subsequent events that have the
same VPS time (like a sports event with intermittent news breaks).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: timers.c 1.55 2006/03/26 14:38:46 kls Exp $ * $Id: timers.c 1.56 2006/04/01 13:27:14 kls Exp $
*/ */
#include "timers.h" #include "timers.h"
@ -401,7 +401,9 @@ int cTimer::Matches(const cEvent *Event, int *Overlap) const
startTime = stopTime = 0; startTime = stopTime = 0;
if (Overlap) if (Overlap)
*Overlap = overlap; *Overlap = overlap;
return overlap >= 1000 ? tmFull : overlap > 0 ? tmPartial : tmNone; if (UseVps)
return overlap > FULLMATCH ? tmFull : tmNone;
return overlap >= FULLMATCH ? tmFull : overlap > 0 ? tmPartial : tmNone;
} }
return tmNone; return tmNone;
} }
@ -435,8 +437,6 @@ time_t cTimer::StopTime(void) const
#define EPGLIMITBEFORE (1 * 3600) // Time in seconds before a timer's start time and #define EPGLIMITBEFORE (1 * 3600) // Time in seconds before a timer's start time and
#define EPGLIMITAFTER (1 * 3600) // after its stop time within which EPG events will be taken into consideration. #define EPGLIMITAFTER (1 * 3600) // after its stop time within which EPG events will be taken into consideration.
#define VPSLIMITBEFORE (2 * 3600) // Same for VPS timers, which need to
#define VPSLIMITAFTER (24 * 3600) // look further into the future to catch shifted broadcasts.
void cTimer::SetEventFromSchedule(const cSchedules *Schedules) void cTimer::SetEventFromSchedule(const cSchedules *Schedules)
{ {
@ -447,49 +447,45 @@ void cTimer::SetEventFromSchedule(const cSchedules *Schedules)
return; return;
} }
const cSchedule *Schedule = Schedules->GetSchedule(Channel()); const cSchedule *Schedule = Schedules->GetSchedule(Channel());
if (Schedule) { if (Schedule && Schedule->Events()->First()) {
time_t now = time(NULL); time_t now = time(NULL);
if (!lastSetEvent || Schedule->Modified() >= lastSetEvent) { if (!lastSetEvent || Schedule->Modified() >= lastSetEvent) {
const cEvent *Event = NULL; const cEvent *Event = NULL;
int Overlap = 0; if (HasFlags(tfVps) && Schedule->Events()->First()->Vps()) {
int Distance = INT_MIN; // VPS timers only match if their start time exactly matches the event's VPS time:
bool UseVps = HasFlags(tfVps); for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e)) {
const cEvent *PresentEvent = UseVps ? Schedule->GetPresentEvent() : NULL; if (e->RunningStatus() == SI::RunningStatusNotRunning)
const cEvent *FollowingEvent = UseVps ? Schedule->GetFollowingEvent() : NULL; continue; // skip events that have already stopped
// Set up the time frame within which to check events: int overlap = 0;
Matches(0, true); Matches(e, &overlap);
time_t TimeFrameBegin = StartTime() - (UseVps ? VPSLIMITBEFORE : EPGLIMITBEFORE); if (overlap > FULLMATCH) {
time_t TimeFrameEnd = StopTime() + (UseVps ? VPSLIMITAFTER : EPGLIMITAFTER); Event = e;
for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e)) { break; // take the first matching event
if (!UseVps || e != event && e != PresentEvent && e != FollowingEvent) { // always check these if this is a VPS timer }
}
}
else {
// Normal timers match the event they have the most overlap with:
int Overlap = 0;
// Set up the time frame within which to check events:
Matches(0, true);
time_t TimeFrameBegin = StartTime() - EPGLIMITBEFORE;
time_t TimeFrameEnd = StopTime() + EPGLIMITAFTER;
for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e)) {
if (e->EndTime() < TimeFrameBegin) if (e->EndTime() < TimeFrameBegin)
continue; // skip events way before the timer starts continue; // skip events way before the timer starts
if (e->StartTime() > TimeFrameEnd) if (e->StartTime() > TimeFrameEnd)
break; // the rest is way after the timer ends break; // the rest is way after the timer ends
} int overlap = 0;
int overlap = 0; Matches(e, &overlap);
Matches(e, &overlap); if (overlap && overlap >= Overlap) {
if (overlap && overlap >= Overlap) { if (Event && overlap == Overlap && e->Duration() <= Event->Duration())
int distance = 0;
if (now < e->StartTime())
distance = e->StartTime() - now;
else if (now > e->EndTime())
distance = e->EndTime() - now;
if (Event && overlap == Overlap) {
if (Overlap > FULLMATCH) { // this means VPS
if (abs(Distance) < abs(distance))
break; // we've already found the closest VPS event
}
else if (e->Duration() <= Event->Duration())
continue; // if overlap is the same, we take the longer event continue; // if overlap is the same, we take the longer event
Overlap = overlap;
Event = e;
} }
Overlap = overlap;
Distance = distance;
Event = e;
} }
} }
if (Event && Event->EndTime() < now - EXPIRELATENCY && Overlap > FULLMATCH && !Event->IsRunning())
Event = NULL;
SetEvent(Event); SetEvent(Event);
lastSetEvent = now; lastSetEvent = now;
} }

6
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/vdr * The project's page is at http://www.cadsoft.de/vdr
* *
* $Id: vdr.c 1.251 2006/03/26 09:16:53 kls Exp $ * $Id: vdr.c 1.252 2006/04/01 12:55:33 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -736,8 +736,6 @@ int main(int argc, char *argv[])
PreviousChannel[PreviousChannelIndex ^= 1] = LastChannel; PreviousChannel[PreviousChannelIndex ^= 1] = LastChannel;
// Timers and Recordings: // Timers and Recordings:
if (!Timers.BeingEdited()) { if (!Timers.BeingEdited()) {
// Delete expired timers:
Timers.DeleteExpired();
// Assign events to timers: // Assign events to timers:
Timers.SetEvents(); Timers.SetEvents();
// Must do all following calls with the exact same time! // Must do all following calls with the exact same time!
@ -768,6 +766,8 @@ int main(int argc, char *argv[])
if (Timer->InVpsMargin()) if (Timer->InVpsMargin())
TimerInVpsMargin = true; TimerInVpsMargin = true;
} }
// Delete expired timers:
Timers.DeleteExpired();
} }
if (!Menu && Recordings.NeedsUpdate()) { if (!Menu && Recordings.NeedsUpdate()) {
Recordings.Update(); Recordings.Update();