Hi,

This is the padding patch I mentioned a few days earlier. I realised I'd
over looked a few things so had to make some changes. 

At the moment this code introduces nothing new functionality wise, but
paves the way for being able to set custom padding.

When the prog class is initiated it pad_start and pad_end are given
values of -1. When the Prog object reaches the scheduleRecording in
recordserver.py it checks to see if those two pad settings are still -1.
If they are then it will set them to the default value specified in the
config file. This of course will be a problem if people actually want to
set a negative padding, personally I wouldn't expect anyone to want to
but if they do then we could change the -1 to -99 (thoughts?).

I would like to suggest turning the TV_RECORD_PADDING setting into two
settings, one for start and one for end. I've never had a problem with
programs starting early, but they start late all the time. When you're
using a dvb card like me and just capturing mpeg2 transport streams then
a minute can be quite a few meg.

If this patch is acceptable then my next step is to produce pages that
will allow you to alter the Padding when setting up a recording.

All feedback appreciated

Cheers,

Alex
(Muttley on #freevo)
? Freevo.e3p
? freevo.e3p
? pyos
? src/www/htdocs/help/wiki
Index: src/helpers/recordserver.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/helpers/recordserver.py,v
retrieving revision 1.59.2.3
diff -u -r1.59.2.3 recordserver.py
--- src/helpers/recordserver.py	29 Oct 2004 18:22:05 -0000	1.59.2.3
+++ src/helpers/recordserver.py	10 Nov 2004 19:45:59 -0000
@@ -251,6 +251,12 @@
                 _debug_('scheduleRecording: prog.channel_id="%s" chan.id="%s" chan.tunerid="%s"' % (String(prog.channel_id), String(chan.id), String(chan.tunerid)))
                 prog.tunerid = chan.tunerid
     
+        # If padding still set to -1 then use the default value
+        if prog.pad_start == -1:
+            prog.pad_start = config.TV_RECORD_PADDING
+        if prog.pad_end == -1:   
+            prog.pad_end   = config.TV_RECORD_PADDING
+    
         scheduledRecordings = self.getScheduledRecordings()
         scheduledRecordings.addProgram(prog, tv_util.getKey(prog))
         self.saveScheduledRecordings(scheduledRecordings)
@@ -415,14 +421,14 @@
             except:
                 recording = FALSE
 
-            if (prog.start - config.TV_RECORD_PADDING) <= now \
-                   and (prog.stop + config.TV_RECORD_PADDING) >= now \
+            if (prog.start - prog.pad_start) <= now \
+                   and (prog.stop + prog.pad_end) >= now \
                    and recording == FALSE:
                 # just add to the 'we want to record this' list
                 # then end the loop, and figure out which has priority,
                 # remember to take into account the full length of the shows
                 # and how much they overlap, or chop one short
-                duration = int((prog.stop + config.TV_RECORD_PADDING ) - now - 10)
+                duration = int((prog.stop + prog.pad_end ) - now - 10)
                 if duration < 10:
                     return 
 
@@ -435,7 +441,7 @@
                         # has a higher priority.
                         if self.isProgAFavorite(prog)[0] and \
                            not self.isProgAFavorite(currently_recording)[0] and \
-                           prog.stop + config.TV_RECORD_PADDING > now:
+                           prog.stop + prog.pad_end > now:
                             _debug_('ignore %s' % String(prog))
                             continue
                         sr.removeProgram(currently_recording, 
@@ -451,9 +457,9 @@
                             # Therefore we have overlapping paddings but not
                             # real stop / start times.
                             overlap = (currently_recording.stop + \
-                                       config.TV_RECORD_PADDING) - \
-                                      (prog.start - config.TV_RECORD_PADDING)
-                            if overlap <= (config.TV_RECORD_PADDING/2):
+                                       currently_recording.pad_end) - \
+                                      (prog.start - prog.pad_start)
+                            if overlap <= ((currently_recording.pad_end + prog.pad_start)/2):
                                 sr.removeProgram(currently_recording, 
                                                  tv_util.getKey(currently_recording))
                                 plugin.getbyname('RECORD').Stop()
@@ -477,7 +483,7 @@
 
         for prog in progs.values():
             # If the program is over remove the entry.
-            if ( prog.stop + config.TV_RECORD_PADDING) < now:
+            if ( prog.stop + prog.pad_end) < now:
                 _debug_('found a program to clean')
                 cleaned = TRUE
                 del progs[tv_util.getKey(prog)]
Index: src/tv/epg_types.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/tv/Attic/epg_types.py,v
retrieving revision 1.21
diff -u -r1.21 epg_types.py
--- src/tv/epg_types.py	19 Jul 2004 16:24:47 -0000	1.21
+++ src/tv/epg_types.py	10 Nov 2004 19:45:59 -0000
@@ -82,6 +82,8 @@
     categories = None
     date       = None
     scheduled  = None
+    pad_start  = None
+    pad_end    = None
 
 
     def __init__(self):
@@ -99,6 +101,10 @@
         # Due to problems with Twisted's marmalade this should not be changed
         # to a boolean type. 
         self.scheduled  = 0
+        
+        # Set Padding 
+        self.pad_start = -1
+        self.pad_end   = -1
 
 
     def __str__(self):

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to