]> git.vomp.tv Git - vompclient.git/commitdiff
Display channel name, duration, resume point and size on recording info screen
authorChris Tallon <chris@vomp.tv>
Fri, 4 Oct 2019 15:47:19 +0000 (16:47 +0100)
committerChris Tallon <chris@vomp.tv>
Fri, 4 Oct 2019 15:47:19 +0000 (16:47 +0100)
Move framesToHMSF to RecInfo class
Bump VDR protocol version requirement

12 files changed:
recinfo.cc
recinfo.h
recording.cc
recording.h
vdr.cc
vdrcommand.h
video.cc
video.h
vradiorec.cc
vrecording.cc
vvideorec.cc
vvideorec.h

index 66ff677761b22f34b45e486fb00249c062a7aa31..1b7e2384f2e864f472711e70b4231e7bda422e46 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright 2006 Chris Tallon
+    Copyright 2019 Chris Tallon
 
     This file is part of VOMP.
 
     along with VOMP; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
+//portions from vdr by Klaus Schmiding HSMF code
+
+#include <math.h>
 
-#include "recinfo.h"
 #include "log.h"
+#include "i18n.h"
+
+#include "recinfo.h"
 
 RecInfo::RecInfo()
 {
@@ -35,6 +40,14 @@ RecInfo::RecInfo()
   descriptions = NULL;
 
   title = NULL;
+
+  channelName = NULL;
+  duration = 0;
+  fileSize = 0;
+  priority = 0;
+  lifetime = 0;
+
+  summaryWithDetails = NULL;
 }
 
 RecInfo::~RecInfo()
@@ -72,6 +85,18 @@ RecInfo::~RecInfo()
   types = NULL;
   languages = NULL;
   descriptions = NULL;
+
+  // TODO: Investigate why this is clearing instance vars
+
+  if (channelName) delete[] channelName;
+  channelName = NULL;
+  duration = 0;
+  fileSize = 0;
+  priority = 0;
+  lifetime = 0;
+
+  if (summaryWithDetails) delete[] summaryWithDetails;
+  summaryWithDetails = NULL;
 }
 
 void RecInfo::setNumComponents(ULONG tnumComponents)
@@ -109,6 +134,13 @@ void RecInfo::print()
     logger->log("RecInfo", Log::DEBUG, "languages[%lu]: %s", i, languages[i]);
     logger->log("RecInfo", Log::DEBUG, "descriptions[%lu]: %s", i, descriptions[i]);
   }
+
+  logger->log("RecInfo", Log::DEBUG, "Title: %s", title);
+  logger->log("RecInfo", Log::DEBUG, "Channel: %s", channelName);
+  logger->log("RecInfo", Log::DEBUG, "Duration: %lu", duration);
+  logger->log("RecInfo", Log::DEBUG, "Filesize: %lu", fileSize);
+  logger->log("RecInfo", Log::DEBUG, "Priority: %lu", priority);
+  logger->log("RecInfo", Log::DEBUG, "Lifetime: %lu", lifetime);
 }
 
 bool RecInfo::hasNoVideo()
@@ -123,3 +155,61 @@ bool RecInfo::hasNoVideo()
 
   return true;
 }
+
+char* RecInfo::buildSummaryWithDetails()
+{
+  if (!summaryWithDetails)
+  {
+    Log* logger = Log::getInstance();
+
+    int swdLength = strlen(summary) +
+                    strlen(tr("Channel: ")) + strlen(channelName) +
+                    strlen(tr("Duration: ")) + 5 + /* 'hh:mm' */
+                    strlen(tr("Resume at: ")) + 5 + /* 'hh:mm' */
+                    strlen(tr("Size: ")) + 8 + /* '12345 MB' */
+                    6 + /* line endings */
+                    40 /* just in case (translation of New?) */ ;
+
+    int mins = duration / 60;
+    int hours = mins / 60;
+    mins = mins % 60;
+
+
+    char resumePointText[30];
+    if (resumePoint == 0)
+    {
+      strncpy(resumePointText, tr("New"), 30);
+      resumePointText[29] = '\0';
+    }
+    else
+    {
+      hmsf resumeHMSF = framesToHMSF(resumePoint);
+      SNPRINTF(resumePointText, 30, "%01u:%02u", resumeHMSF.hours, resumeHMSF.minutes);
+    }
+
+    summaryWithDetails = new char[swdLength];
+    SNPRINTF(summaryWithDetails, swdLength, "%s\n\n%s%s\n%s%01i:%02i\n%s%s\n%s%lu MB", summary,
+             tr("Channel: "), channelName,
+             tr("Duration: "), hours, mins,
+             tr("Resume at: "), resumePointText,
+             tr("Size: "), fileSize
+            );
+
+    logger->log("RecInfo", Log::DEBUG, "Build summary with details C: %i, A: %i", swdLength, strlen(summaryWithDetails));
+  }
+  return summaryWithDetails;
+}
+
+hmsf RecInfo::framesToHMSF(ULONG frames)
+{
+  hmsf ret;
+  /* from vdr */
+  double Seconds;
+  ret.frames = int(modf((frames + 0.5) / fps, &Seconds) * fps + 1);
+  int s = int(Seconds);
+  ret.seconds = s % 60;
+  ret.minutes = s / 60 % 60;
+  ret.hours = s / 3600;
+
+  return ret;
+}
index 27844d478c336072be46743507b480fff8dc2a81..7180203468799dc3eb5e2e23d0de7a6c335b732c 100644 (file)
--- a/recinfo.h
+++ b/recinfo.h
@@ -1,5 +1,5 @@
 /*
-    Copyright 2006 Chris Tallon
+    Copyright 2019 Chris Tallon
 
     This file is part of VOMP.
 
@@ -17,6 +17,7 @@
     along with VOMP; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
+//portions from vdr by Klaus Schmiding HSMF code
 
 #ifndef RECINFO_H
 #define RECINFO_H
 
 #include "defines.h"
 
+typedef struct _hmsf
+{
+  UINT hours;
+  UINT minutes;
+  UINT seconds;
+  UINT frames;
+} hmsf;
+
 class RecInfo
 {
   public:
@@ -46,16 +55,24 @@ class RecInfo
 
     char *title;
 
+    char* channelName;
+    ULONG duration;
+    ULONG fileSize;
+    ULONG priority;
+    ULONG lifetime;
+
     void setNumComponents(ULONG);
     void addComponent(ULONG componentNum, UCHAR tstream, UCHAR ttype, char* tlanguage, char* tdescription);
     // addComponent accepts a pointer to a buffer that RecInfo will free, not the caller
+    char* buildSummaryWithDetails();
 
     void print();
 
+    hmsf framesToHMSF(ULONG frames);
     bool hasNoVideo();
 
   private:
-
+    char* summaryWithDetails;
 };
 
 #endif
index c50aed2b8978da28e8ba4895f4c1397c9a743ba9..6921c33f465c8223173336b60d67f4e24fc985fb 100644 (file)
@@ -18,8 +18,6 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
-#include "recording.h"
-
 #include "recinfo.h"
 #include "mark.h"
 #include "log.h"
@@ -29,6 +27,8 @@
 #include "seriesinfo.h"
 #include "movieinfo.h"
 
+#include "recording.h"
+
 Recording* Recording::recInfoFor = NULL;
 RecInfo* Recording::recInfo = NULL;
 MovieInfo* Recording::movieInfo = NULL;
index ba6d1a897691293633e351fd658543d22b1e8449..674061bd1dfc4562a4819e58f6d7ea8869068d8f 100644 (file)
@@ -59,9 +59,9 @@ class Recording
     bool hasMarks();
     MarkList* getMarkList();
 
-   int movieID;
-   int seriesID;
-   int episodeID;
+    int movieID;
+    int seriesID;
+    int episodeID;
 
     static RecInfo* recInfo;
     static MovieInfo* movieInfo;
diff --git a/vdr.cc b/vdr.cc
index a9bb49b2544924e17fa4f3f36889b5d12a074449..e8da6067d325ab9b1e82a0943ea870747c9927d9 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -45,7 +45,7 @@
 #include "tvmedia.h"
 #include <climits>
 
-#define VOMP_PROTOCOLL_VERSION 0x00000401
+#define VOMP_PROTOCOLL_VERSION 0x00000402
 
 VDR* VDR::instance = NULL;
 #ifdef VOMP_MEDIAPLAYER
@@ -1230,7 +1230,7 @@ ULONG VDR::setEventTimer(char* timerString)
 RecInfo* VDR::getRecInfo(char* fileName)
 {
   VDR_RequestPacket vrp;
-  if (!vrp.init(VDR_GETRECINFO, true, strlen(fileName) + 1)) return NULL;
+  if (!vrp.init(VDR_GETRECINFO2, true, strlen(fileName) + 1)) return NULL;
   if (!vrp.addString(fileName)) return NULL;
   VDR_ResponsePacket* vresp = RequestResponse(&vrp);
 
@@ -1265,6 +1265,12 @@ RecInfo* VDR::getRecInfo(char* fileName)
   recInfo->fps=vresp->extractdouble();
   recInfo->title=vresp->extractString();
   
+  // New stuff
+  recInfo->channelName = vresp->extractString();
+  recInfo->duration = vresp->extractULONG();
+  recInfo->fileSize = vresp->extractULONG();
+  recInfo->priority = vresp->extractULONG();
+  recInfo->lifetime = vresp->extractULONG();
 
   recInfo->print();
 
index b7208aef1f4939e7cabf9573f7dbfb67e918f002..d5dd585ed9e07ef5a5d4092283ddf028704eddfe 100644 (file)
@@ -58,7 +58,8 @@ const static ULONG VDR_POSFROMFRAME        = 16;
 const static ULONG VDR_FRAMEFROMPOS        = 17;
 const static ULONG VDR_MOVERECORDING       = 18;
 const static ULONG VDR_GETNEXTIFRAME       = 19;
-const static ULONG VDR_GETRECINFO          = 20;
+// const static ULONG VDR_GETRECINFO          = 20;
+const static ULONG VDR_GETRECINFO2         = 24;
 const static ULONG VDR_GETMARKS            = 21;
 const static ULONG VDR_GETCHANNELPIDS      = 22;
 const static ULONG VDR_DELETETIMER         = 23;
index 8f8d5f61a8ea8b6db42e8bc68170a5060833c508..e094954e0cbe8f802b0bf85c8e29575813b6dee4 100644 (file)
--- a/video.cc
+++ b/video.cc
@@ -17,7 +17,6 @@
     along with VOMP; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
-//portions from vdr by Klaus Schmiding HSMF code
 
 #include "video.h"
 
diff --git a/video.h b/video.h
index 3dcc0cef0cffac1cecd89b6efda3b2ea19024b43..8056ea6a28e44bf48b6bcf7bb9c52a53abcb5b1e 100644 (file)
--- a/video.h
+++ b/video.h
@@ -1,5 +1,5 @@
 /*
-    Copyright 2004-2005 Chris Tallon
+    Copyright 2004-2019 Chris Tallon
 
     This file is part of VOMP.
 
 #include "draintarget.h"
 #include "abstractoption.h"
 
-typedef struct _hmsf
-{
-  UINT hours;
-  UINT minutes;
-  UINT seconds;
-  UINT frames;
-} hmsf;
-
 enum VideoMode {
        None,
        Fullscreen,
@@ -126,11 +118,7 @@ class Video: public DrainTarget, public AbstractOption
 
     virtual bool setVideoDisplay(VideoDisplay display);
 
-
-
-
-    //hmsf framesToHMSF(ULONG frames,double fps);
-   // UINT getFPS(); //removed
+    // UINT getFPS(); //removed
 
     // Video formats - AV_SET_VID_DISP_FMT
     const static UCHAR NTSC = 0;
index 81840d7191e06eabcb05ee7307eecb407e60bf5c..78375872bb086af4cdff93f28e00d27424cc9455 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright 2004-2006 Chris Tallon
+    Copyright 2004-2019 Chris Tallon
 
     This file is part of VOMP.
 
@@ -438,36 +438,6 @@ void VRadioRec::drawBarClocks()
 
   rectangle(clocksRegion, barBlue);
 
-/*
-  ULONG currentFrameNum = player->getCurrentFrameNum();
-  ULONG lengthFrames;
-  if (myRec->recInfo->timerEnd > time(NULL))
-  {
-    // chasing playback
-    // Work out an approximate length in frames (good to 1s...)
-    lengthFrames = (myRec->recInfo->timerEnd - myRec->recInfo->timerStart) * video->getFPS();
-  }
-  else
-  {
-//    lengthFrames = player->getLengthFrames();
-    lengthFrames = 0;
-  }
-
-  hmsf currentFrameHMSF = video->framesToHMSF(currentFrameNum);
-  hmsf lengthHMSF = video->framesToHMSF(lengthFrames);
-
-  char buffer[100];
-  if (currentFrameNum >= lengthFrames)
-  {
-    strcpy(buffer, "-:--:-- / -:--:--");
-  }
-  else
-  {
-    SNPRINTF(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", currentFrameHMSF.hours, currentFrameHMSF.minutes, currentFrameHMSF.seconds, lengthHMSF.hours, lengthHMSF.minutes, lengthHMSF.seconds);
-    logger->log("VRadioRec", Log::DEBUG, buffer);
-  }
-*/
-
   ULONG currentSeconds = player->getCurrentSeconds();
   ULONG lengthSeconds = player->getLengthSeconds();
   char buffer[100];
index 837478c8158f424fb2bb9f2b8e8606ddf9a812e3..48d78fb94c1d9f8004336bd9560503036e5f4a14 100644 (file)
@@ -82,8 +82,8 @@ VRecording::VRecording(RecMan* trecman, Recording* trec)
   WTextbox * summary=new WTextbox();
   summary->setParaMode(true);
 
-  if (rec->recInfo && strlen(rec->recInfo->summary))
-    summary->setText(rec->recInfo->summary);
+  if (rec->recInfo)
+    summary->setText(rec->recInfo->buildSummaryWithDetails());
   else
     summary->setText(tr("Summary unavailable"));
 
index 7e2b3cc80b80264fabc7356823b90caaa7a7229d..0fbe3c605d27d7184ef37ac19edb7098aa63f1b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright 2004-2005 Chris Tallon
+    Copyright 2004-2019 Chris Tallon
 
     This file is part of VOMP.
 
@@ -20,9 +20,6 @@
 
 #include <math.h>
 
-#include "vvideorec.h"
-#include "vteletextview.h"
-
 #include "command.h"
 #include "osd.h"
 #include "wsymbol.h"
@@ -42,7 +39,9 @@
 #include "recinfo.h"
 #include "log.h"
 #include "channel.h"
+#include "vteletextview.h"
+#include "vvideorec.h"
+
 VVideoRec::VVideoRec(Recording* rec, bool ish264)
 {
   boxstack = BoxStack::getInstance();
@@ -923,22 +922,6 @@ void VVideoRec::timercall(int clientReference)
   }
 }
 
-hmsf VVideoRec::framesToHMSF(ULONG frames)
-{
-  hmsf ret;
-  /* from vdr */
-  double Seconds;
-  double fps=myRec->recInfo->fps;
-  ret.frames= int(modf((frames + 0.5) / fps, &Seconds) * fps + 1);
-  int s = int(Seconds);
-  ret.seconds=s % 60;
-  ret.minutes = s / 60 % 60;
-  ret.hours = s / 3600;
-
-
-  return ret;
-}
-
 void VVideoRec::drawBarClocks()
 {
   if (barScanHold)
@@ -991,8 +974,8 @@ void VVideoRec::drawBarClocks()
     lengthFrames = player->getLengthFrames();
   }
 
-  hmsf currentFrameHMSF = framesToHMSF(currentFrameNum);
-  hmsf lengthHMSF = framesToHMSF(lengthFrames);
+  hmsf currentFrameHMSF = myRec->recInfo->framesToHMSF(currentFrameNum);
+  hmsf lengthHMSF = myRec->recInfo->framesToHMSF(lengthFrames);
 
   char buffer[100];
   if (currentFrameNum >= lengthFrames)
index 66d01218fd7e80c28729640aaad5aa1fad5d7f4b..99bebb38977cabff29b6bc19d481c69bed1592c2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright 2004-2005 Chris Tallon
+    Copyright 2004-2019 Chris Tallon
 
     This file is part of VOMP.
 
@@ -68,8 +68,6 @@ class VVideoRec : public Boxx, public TimerReceiver, public OSDReceiver
 
     void doTeletext();
 
-       hmsf framesToHMSF(ULONG frames); //moved from video, this is a recording property, if needed elsewhere -> recording
-
   private:
     BoxStack* boxstack;
     VDR* vdr;