Allow instant recording to record only present event

Message ID 50548962.5020509@tvdr.de
State New
Headers

Commit Message

Klaus Schmidinger Sept. 15, 2012, 1:57 p.m. UTC
  On 20.05.2012 13:55, Matti Lehtimäki wrote:
> On 05/20/2012 02:45 PM, Klaus Schmidinger wrote:
>> On 20.05.2012 13:41, Matti Lehtimäki wrote:
>>> On 05/20/2012 02:15 PM, Klaus Schmidinger wrote:
>>>> One more thing comes to mind: you also need to make sure that
>>>> the 'day' is set to the day of the EPG event. Just in case it
>>>> is past midnight already and the event started "yesterday" ;-)
>>>
>>> Indeed that was missing. I think setting the day is relevant only if
>>> VPS is used since in otherwise the start time is the current time not
>>> the start time of the event. Or should the start time be set to that
>>> of the event if VPS is not used?
>>
>> Well, that's a matter of taste.
>> For VPS it is relevant, otherwise it's up to you.
>
> Attached is a new version of the patch with correct day always set when VPS is used. Could this patch be included in next version of VDR?

While adopting this patch I found that we need to set the timer's 'event'
pointer to the actual event here, and that the start time should always be
set to the event's start time (even if VPS is not used) in order to keep
the event from getting reassigned to a different one later on.

I have attached a revised version of your patch (against VDR 1.7.30).
Please take a look and let me know whether it is still OK for you.

Klaus
  

Comments

Matti Lehtimäki Sept. 15, 2012, 3:18 p.m. UTC | #1
On 09/15/2012 04:57 PM, Klaus Schmidinger wrote:
> While adopting this patch I found that we need to set the timer's 'event'
> pointer to the actual event here, and that the start time should always be
> set to the event's start time (even if VPS is not used) in order to keep
> the event from getting reassigned to a different one later on.
>
> I have attached a revised version of your patch (against VDR 1.7.30).
> Please take a look and let me know whether it is still OK for you.

The revised version of the patch works the way I want so it's OK for me. 
Thanks.
  

Patch

--- ./MANUAL	2012/09/09 12:28:27	2.20
+++ ./MANUAL	2012/09/15 13:50:06
@@ -837,6 +837,11 @@ 
                          Default is 180 minutes (3 hours). The stop time of an
                          instant recording can be modified at any time by editing
                          the respective timer in the "Timers" menu.
+                         If this parameter is set to 0 ("present event"), only the
+                         currently running event will be recorded, using the stop
+                         margin and VPS setting as configured.
+                         Note that this parameter is also used when pausing live
+                         video!
 
   Max. video file size = 2000
                          The maximum size of a single recorded video file in MB.
--- ./config.c	2012/09/09 12:58:23	2.27
+++ ./config.c	2012/09/15 11:52:03
@@ -383,7 +383,7 @@ 
   MenuKeyCloses = 0;
   MarkInstantRecord = 1;
   strcpy(NameInstantRecord, "TITLE EPISODE");
-  InstantRecordTime = 180;
+  InstantRecordTime = DEFINSTRECTIME;
   LnbSLOF    = 11700;
   LnbFrequLo =  9750;
   LnbFrequHi = 10600;
--- ./config.h	2012/09/13 11:12:07	2.52
+++ ./config.h	2012/09/15 11:51:54
@@ -42,6 +42,7 @@ 
 #define TRANSFERPRIORITY  (LIVEPRIORITY - 1) // priority used for actual local Transfer Mode
 #define IDLEPRIORITY      (MINPRIORITY - 1)  // priority of an idle device
 #define MAXLIFETIME       99
+#define DEFINSTRECTIME    180 // default instant recording time (minutes)
 
 #define MINOSDWIDTH   480
 #define MAXOSDWIDTH  1920
--- ./menu.c	2012/09/09 12:23:00	2.60
+++ ./menu.c	2012/09/15 11:45:28
@@ -3118,7 +3118,7 @@ 
   Add(new cMenuEditIntItem( tr("Setup.Recording$VPS margin (s)"),            &data.VpsMargin, 0));
   Add(new cMenuEditBoolItem(tr("Setup.Recording$Mark instant recording"),    &data.MarkInstantRecord));
   Add(new cMenuEditStrItem( tr("Setup.Recording$Name instant recording"),     data.NameInstantRecord, sizeof(data.NameInstantRecord)));
-  Add(new cMenuEditIntItem( tr("Setup.Recording$Instant rec. time (min)"),   &data.InstantRecordTime, 1, MAXINSTANTRECTIME));
+  Add(new cMenuEditIntItem( tr("Setup.Recording$Instant rec. time (min)"),   &data.InstantRecordTime, 0, MAXINSTANTRECTIME, tr("Setup.Recording$present event")));
   Add(new cMenuEditIntItem( tr("Setup.Recording$Max. video file size (MB)"), &data.MaxVideoFileSize, MINVIDEOFILESIZE, MAXVIDEOFILESIZETS));
   Add(new cMenuEditBoolItem(tr("Setup.Recording$Split edited files"),        &data.SplitEditedFiles));
   Add(new cMenuEditStraItem(tr("Setup.Recording$Delete timeshift recording"),&data.DelTimeshiftRec, 3, delTimeshiftRecTexts));
--- ./po/de_DE.po	2012/09/13 11:18:53	2.34
+++ ./po/de_DE.po	2012/09/15 12:04:42
@@ -1077,6 +1077,9 @@ 
 msgid "Setup.Recording$Instant rec. time (min)"
 msgstr "Dauer der Direktaufzeichnung (min)"
 
+msgid "Setup.Recording$present event"
+msgstr "laufende Sendung"
+
 msgid "Setup.Recording$Max. video file size (MB)"
 msgstr "Max. Videodateigröße (MB)"
 
--- ./po/fi_FI.po	2012/09/13 11:18:14	2.40
+++ ./po/fi_FI.po	2012/09/15 12:04:17
@@ -1080,6 +1080,9 @@ 
 msgid "Setup.Recording$Instant rec. time (min)"
 msgstr "Pikatallennuksen kesto (min)"
 
+msgid "Setup.Recording$present event"
+msgstr "nykyinen tapahtuma"
+
 msgid "Setup.Recording$Max. video file size (MB)"
 msgstr "Suurin tiedostokoko (Mt)"
 
--- ./timers.c	2012/06/09 14:37:24	2.11
+++ ./timers.c	2012/09/15 13:34:03
@@ -32,6 +32,9 @@ 
   deferred = 0;
   recording = pending = inVpsMargin = false;
   flags = tfNone;
+  *file = 0;
+  aux = NULL;
+  event = NULL;
   if (Instant)
      SetFlags(tfActive | tfInstant);
   channel = Channel ? Channel : Channels.GetByNumber(cDevice::CurrentChannel());
@@ -41,15 +44,40 @@ 
   day = SetTime(t, 0);
   weekdays = 0;
   start = now->tm_hour * 100 + now->tm_min;
-  stop = now->tm_hour * 60 + now->tm_min + Setup.InstantRecordTime;
-  stop = (stop / 60) * 100 + (stop % 60);
+  stop = 0;
+  if (!Setup.InstantRecordTime && channel) {
+     cSchedulesLock SchedulesLock;
+     if (const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock)) {
+        if (const cSchedule *Schedule = Schedules->GetSchedule(channel)) {
+           if (const cEvent *Event = Schedule->GetPresentEvent()) {
+              time_t tstart = Event->StartTime();
+              time_t tstop = Event->EndTime();
+              if (Event->Vps() && Setup.UseVps) {
+                 SetFlags(tfVps);
+                 tstart = Event->Vps();
+                 }
+              else {
+                 tstop  += Setup.MarginStop * 60;
+                 tstart -= Setup.MarginStart * 60;
+                 }
+              day = SetTime(tstart, 0);
+              struct tm *time = localtime_r(&tstart, &tm_r);
+              start = time->tm_hour * 100 + time->tm_min;
+              time = localtime_r(&tstop, &tm_r);
+              stop = time->tm_hour * 100 + time->tm_min;
+              SetEvent(Event);
+              }
+           }
+        }
+     }
+  if (!stop) {
+     stop = now->tm_hour * 60 + now->tm_min + (Setup.InstantRecordTime ? Setup.InstantRecordTime : DEFINSTRECTIME);
+     stop = (stop / 60) * 100 + (stop % 60);
+     }
   if (stop >= 2400)
      stop -= 2400;
   priority = Pause ? Setup.PausePriority : Setup.DefaultPriority;
   lifetime = Pause ? Setup.PauseLifetime : Setup.DefaultLifetime;
-  *file = 0;
-  aux = NULL;
-  event = NULL;
   if (Instant && channel)
      snprintf(file, sizeof(file), "%s%s", Setup.MarkInstantRecord ? "@" : "", *Setup.NameInstantRecord ? Setup.NameInstantRecord : channel->Name());
   if (VfatFileSystem && (Utf8StrLen(file) > VFAT_MAX_FILENAME)) {
@@ -66,6 +94,9 @@ 
   deferred = 0;
   recording = pending = inVpsMargin = false;
   flags = tfActive;
+  *file = 0;
+  aux = NULL;
+  event = NULL;
   if (Event->Vps() && Setup.UseVps)
      SetFlags(tfVps);
   channel = Channels.GetByChannelID(Event->ChannelID(), true);
@@ -86,7 +117,6 @@ 
      stop -= 2400;
   priority = Setup.DefaultPriority;
   lifetime = Setup.DefaultLifetime;
-  *file = 0;
   const char *Title = Event->Title();
   if (!isempty(Title))
      Utf8Strn0Cpy(file, Event->Title(), sizeof(file));
@@ -95,8 +125,7 @@ 
      file[Utf8SymChars(file, VFAT_MAX_FILENAME)] = 0;
      dsyslog("timer file name truncated to '%s'", file);
      }
-  aux = NULL;
-  event = NULL; // let SetEvent() be called to get a log message
+  SetEvent(Event);
 }
 
 cTimer::cTimer(const cTimer &Timer)