Re: [vdr] [feature request] recording length computation and storage

2011-08-21 Thread Klaus Schmidinger

On 19.08.2011 23:56, Steffen Barszus wrote:

On Fri, 19 Aug 2011 22:18:03 +0200
Udo Richterudo_rich...@gmx.de  wrote:


Am 19.08.2011 15:30, schrieb Steffen Barszus:

On 08/19/11 11:46, Steffen Barszus wrote:

i would like to request, that
vdr is storing the length of a recording and make it accessible
to the plug-ins.


Where it gets stored is not my point, that it can be served from in
meory data read by ScanVideoDir is my point.

- readcompute by the core
- dont access harddisk for known recordings
- dont do it multiple times, if more then one part of vdr wants to
know it.

If its only in memory and read by the scanner its fine with me.

for medium to large recording base we speak about minutes not
milliseconds for reading that data.



Maybe some kind of caching mechanism, but please don't calculate the
length every time while doing the scan of the video directory. The
directory scanner is already slow enough, no need to add these minutes
to it.


It's slow since it needs to iterate through all recordings
and check file size of the index file (thats what i understand from
Klaus comment), so divide that by number of frames of the recording and
thats it. the directory scanner is anyway doing the same (iterating
the video directory and pick up necessary information). So it wouldn't
add anything substantially.


Would the attached patch work for you?
Line numbers may be off a little.

Klaus
--- recording.h	2011/08/21 11:34:03	2.24
+++ recording.h	2011/08/21 13:10:39
@@ -89,6 +89,7 @@
   mutable char *fileName;
   mutable char *name;
   mutable int fileSizeMB;
+  mutable int numFrames;
   int channel;
   int instanceId;
   bool isPesRecording;
@@ -123,6 +124,11 @@
   int HierarchyLevels(void) const;
   void ResetResume(void) const;
   double FramesPerSecond(void) const { return framesPerSecond; }
+  int NumFrames(void) const;
+   /// Returns the number of frames in this recording.
+   /// If the number of frames is unknown, -1 will be returned.
+  int LengthInSeconds(void) const;
+   /// Returns the length (in seconds) of this recording, or -1 in case of error.
   bool IsNew(void) const { return GetResume() = 0; }
   bool IsEdited(void) const;
   bool IsPesRecording(void) const { return isPesRecording; }
--- recording.c	2011/08/21 11:19:55	2.35
+++ recording.c	2011/08/21 13:43:03
@@ -60,6 +60,7 @@
 #define DISKCHECKDELTA100 // seconds between checks for free disk space
 #define REMOVELATENCY  10 // seconds to wait until next check after removing a file
 #define MARKSUPDATEDELTA   10 // seconds between checks for updating editing marks
+#define MININDEXAGE  3600 // seconds before an index file is considered no longer to be written
 
 #define MAX_SUBTITLE_LENGTH  40
 
@@ -617,6 +618,7 @@
   instanceId = InstanceId;
   isPesRecording = false;
   framesPerSecond = DEFAULTFRAMESPERSECOND;
+  numFrames = -1;
   deleted = 0;
   // set up the actual name:
   const char *Title = Event ? Event-Title() : NULL;
@@ -676,6 +678,7 @@
   lifetime = MAXLIFETIME;
   isPesRecording = false;
   framesPerSecond = DEFAULTFRAMESPERSECOND;
+  numFrames = -1;
   deleted = 0;
   titleBuffer = NULL;
   sortBuffer = NULL;
@@ -1031,6 +1034,25 @@
   resume = RESUME_NOT_INITIALIZED;
 }
 
+int cRecording::NumFrames(void) const
+{
+  if (numFrames  0) {
+ int nf = cIndexFile::GetLength(FileName(), IsPesRecording());
+ if (time(NULL) - LastModifiedTime(FileName())  MININDEXAGE)
+return nf; // check again later for ongoing recordings
+ numFrames = nf;
+ }
+  return numFrames;
+}
+
+int cRecording::LengthInSeconds(void) const
+{
+  int nf = NumFrames();
+  if (nf = 0)
+ return int((nf / FramesPerSecond() + 30) / 60) * 60;
+  return -1;
+}
+
 // --- cRecordings ---
 
 cRecordings Recordings;
@@ -1102,6 +1124,7 @@
  if (endswith(buffer, deleted ? DELEXT : RECEXT)) {
 cRecording *r = new cRecording(buffer);
 if (r-Name()) {
+   r-NumFrames(); // initializes the numFrames member
Lock();
Add(r);
ChangeState();
@@ -1514,9 +1537,6 @@
 // The maximum time to wait before giving up while catching up on an index file:
 #define MAXINDEXCATCHUP   8 // seconds
 
-// The minimum age of an index file for considering it no longer to be written:
-#define MININDEXAGE3600 // seconds
-
 struct tIndexPes {
   uint32_t offset;
   uchar type;
___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


[vdr] [feature request] recording length computation and storage

2011-08-19 Thread Steffen Barszus
Hi !

After having seen that there are several plug-ins computing the
recording length on their own and that being a very expensive task (in
respect of io and cpu) and also the same implementation needs to be
copied over and over again, i would like to request, that vdr is
storing the length of a recording and make it accessible to the
plug-ins. I would imagine, that some logic to store it in the info file
after/while generating/writing the index would be a good way. 

Plug-ins which possibly could make use of that are:
* live
* extrecmenu
* restfulapi

I'm sure there are more of it. 

Has someone allready thought of this ? Are there any plans to have that
or someone allready using a patch for this ? 

Thanks !

Steffen

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [feature request] recording length computation and storage

2011-08-19 Thread André Weidemann

Hi Steffen,

On 19.08.2011 11:46, Steffen Barszus wrote:

Hi !

After having seen that there are several plug-ins computing the
recording length on their own and that being a very expensive task (in
respect of io and cpu) and also the same implementation needs to be
copied over and over again, i would like to request, that vdr is
storing the length of a recording and make it accessible to the
plug-ins. I would imagine, that some logic to store it in the info file
after/while generating/writing the index would be a good way.

Plug-ins which possibly could make use of that are:
* live
* extrecmenu
* restfulapi

I'm sure there are more of it.

Has someone allready thought of this ? Are there any plans to have that
or someone allready using a patch for this ?


Please correct me, if I am wrong, but I think vdr-1.7.20 has this 
feature. Take a look at recording.h:


static int GetLength(const char *FileName, bool IsPesRecording = false);
   /// Calculates the recording length (numer of frames) without 
actually reading the index file.

   /// Returns -1 in case of error.

Regards
 André

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [feature request] recording length computation and storage

2011-08-19 Thread Klaus Schmidinger

On 08/19/11 11:46, Steffen Barszus wrote:

Hi !

After having seen that there are several plug-ins computing the
recording length on their own and that being a very expensive task (in
respect of io and cpu) and also the same implementation needs to be
copied over and over again, i would like to request, that vdr is
storing the length of a recording and make it accessible to the
plug-ins. I would imagine, that some logic to store it in the info file
after/while generating/writing the index would be a good way.

Plug-ins which possibly could make use of that are:
* live
* extrecmenu
* restfulapi

I'm sure there are more of it.

Has someone allready thought of this ? Are there any plans to have that
or someone allready using a patch for this ?


How about cIndexFile::GetLength()?
This was newly added in version 1.7.20.

Klaus

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [feature request] recording length computation and storage

2011-08-19 Thread Steffen Barszus
On Fri, 19 Aug 2011 12:21:24 +0200
Klaus Schmidinger klaus.schmidin...@tvdr.de wrote:

 On 08/19/11 11:46, Steffen Barszus wrote:
  Hi !
 
  After having seen that there are several plug-ins computing the
  recording length on their own and that being a very expensive task
  (in respect of io and cpu) and also the same implementation needs
  to be copied over and over again, i would like to request, that vdr
  is storing the length of a recording and make it accessible to the
  plug-ins. I would imagine, that some logic to store it in the info
  file after/while generating/writing the index would be a good way.
 
 
 How about cIndexFile::GetLength()?
 This was newly added in version 1.7.20.

Not yet - its returning the number of frames - to have one calculation,
length in seconds would be required (Ok, its available as well).

Also it reads the index directly (if i'm not mistaken, i can barely
read C), which would then be read x-times , where x is the number of
plugins using it ( + vdr ? I'm not sure of it ). 

I would think that in recording.h as public member of class
cRecordingInfo would make sense. In my understanding the recordings
information are held in memory after reading it with
ScanVideoDir, this should be part of that information in
memory (not reading file from disk for this separately).



 

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [feature request] recording length computation and storage

2011-08-19 Thread Klaus Schmidinger

On 19.08.2011 14:39, Steffen Barszus wrote:

On Fri, 19 Aug 2011 12:21:24 +0200
Klaus Schmidingerklaus.schmidin...@tvdr.de  wrote:


On 08/19/11 11:46, Steffen Barszus wrote:

Hi !

After having seen that there are several plug-ins computing the
recording length on their own and that being a very expensive task
(in respect of io and cpu) and also the same implementation needs
to be copied over and over again, i would like to request, that vdr
is storing the length of a recording and make it accessible to the
plug-ins. I would imagine, that some logic to store it in the info
file after/while generating/writing the index would be a good way.



How about cIndexFile::GetLength()?
This was newly added in version 1.7.20.


Not yet - its returning the number of frames - to have one calculation,
length in seconds would be required (Ok, its available as well).

Also it reads the index directly (if i'm not mistaken, i can barely
read C), which would then be read x-times , where x is the number of
plugins using it ( + vdr ? I'm not sure of it ).

I would think that in recording.h as public member of class
cRecordingInfo would make sense. In my understanding the recordings
information are held in memory after reading it with
ScanVideoDir, this should be part of that information in
memory (not reading file from disk for this separately).


I don't want to make this part of the 'info' file.
Besides, it's only the directory entry that gets read, not
the file itself.

Klaus

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [feature request] recording length computation and storage

2011-08-19 Thread Steffen Barszus
On Fri, 19 Aug 2011 14:48:46 +0200
Klaus Schmidinger klaus.schmidin...@tvdr.de wrote:

 On 19.08.2011 14:39, Steffen Barszus wrote:
  On Fri, 19 Aug 2011 12:21:24 +0200
  Klaus Schmidingerklaus.schmidin...@tvdr.de  wrote:
 
  On 08/19/11 11:46, Steffen Barszus wrote:
  Hi !
 
  After having seen that there are several plug-ins computing the
  recording length on their own and that being a very expensive task
  (in respect of io and cpu) and also the same implementation needs
  to be copied over and over again, i would like to request, that
  vdr is storing the length of a recording and make it accessible
  to the plug-ins. I would imagine, that some logic to store it in
  the info file after/while generating/writing the index would be a
  good way.
 
 
  How about cIndexFile::GetLength()?
  This was newly added in version 1.7.20.
 
  Not yet - its returning the number of frames - to have one
  calculation, length in seconds would be required (Ok, its available
  as well).
 
  Also it reads the index directly (if i'm not mistaken, i can barely
  read C), which would then be read x-times , where x is the number of
  plugins using it ( + vdr ? I'm not sure of it ).
 
  I would think that in recording.h as public member of class
  cRecordingInfo would make sense. In my understanding the recordings
  information are held in memory after reading it with
  ScanVideoDir, this should be part of that information in
  memory (not reading file from disk for this separately).
 
 I don't want to make this part of the 'info' file.
 Besides, it's only the directory entry that gets read, not
 the file itself.

Where it gets stored is not my point, that it can be served from in
meory data read by ScanVideoDir is my point. 

- readcompute by the core
- dont access harddisk for known recordings
- dont do it multiple times, if more then one part of vdr wants to know
  it. 

If its only in memory and read by the scanner its fine with me. 

for medium to large recording base we speak about minutes not
milliseconds for reading that data. 




___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [feature request] recording length computation and storage

2011-08-19 Thread Udo Richter
Am 19.08.2011 15:30, schrieb Steffen Barszus:
 On 08/19/11 11:46, Steffen Barszus wrote:
 i would like to request, that
 vdr is storing the length of a recording and make it accessible
 to the plug-ins.

 Where it gets stored is not my point, that it can be served from in
 meory data read by ScanVideoDir is my point. 
 
 - readcompute by the core
 - dont access harddisk for known recordings
 - dont do it multiple times, if more then one part of vdr wants to know
   it. 
 
 If its only in memory and read by the scanner its fine with me. 
 
 for medium to large recording base we speak about minutes not
 milliseconds for reading that data. 


Maybe some kind of caching mechanism, but please don't calculate the
length every time while doing the scan of the video directory. The
directory scanner is already slow enough, no need to add these minutes
to it.

Cheers,

Udo

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr