From 3141fe63e54e23d60e9770d10c2b304dc6ba8c90 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 4 Oct 2019 16:47:19 +0100 Subject: [PATCH] Display channel name, duration, resume point and size on recording info screen Move framesToHMSF to RecInfo class Bump VDR protocol version requirement --- recinfo.cc | 94 +++++++++++++++++++++++++++++++++++++++++++++++++-- recinfo.h | 21 ++++++++++-- recording.cc | 4 +-- recording.h | 6 ++-- vdr.cc | 10 ++++-- vdrcommand.h | 3 +- video.cc | 1 - video.h | 16 ++------- vradiorec.cc | 32 +----------------- vrecording.cc | 4 +-- vvideorec.cc | 29 ++++------------ vvideorec.h | 4 +-- 12 files changed, 138 insertions(+), 86 deletions(-) diff --git a/recinfo.cc b/recinfo.cc index 66ff677..1b7e238 100644 --- a/recinfo.cc +++ b/recinfo.cc @@ -1,5 +1,5 @@ /* - Copyright 2006 Chris Tallon + Copyright 2019 Chris Tallon This file is part of VOMP. @@ -17,9 +17,14 @@ 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 -#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; +} diff --git a/recinfo.h b/recinfo.h index 27844d4..7180203 100644 --- 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 @@ -25,6 +26,14 @@ #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 diff --git a/recording.cc b/recording.cc index c50aed2..6921c33 100644 --- a/recording.cc +++ b/recording.cc @@ -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; diff --git a/recording.h b/recording.h index ba6d1a8..674061b 100644 --- a/recording.h +++ b/recording.h @@ -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 a9bb49b..e8da606 100644 --- a/vdr.cc +++ b/vdr.cc @@ -45,7 +45,7 @@ #include "tvmedia.h" #include -#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(); diff --git a/vdrcommand.h b/vdrcommand.h index b7208ae..d5dd585 100644 --- a/vdrcommand.h +++ b/vdrcommand.h @@ -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; diff --git a/video.cc b/video.cc index 8f8d5f6..e094954 100644 --- 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 3dcc0ce..8056ea6 100644 --- 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. @@ -26,14 +26,6 @@ #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; diff --git a/vradiorec.cc b/vradiorec.cc index 81840d7..7837587 100644 --- a/vradiorec.cc +++ b/vradiorec.cc @@ -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]; diff --git a/vrecording.cc b/vrecording.cc index 837478c..48d78fb 100644 --- a/vrecording.cc +++ b/vrecording.cc @@ -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")); diff --git a/vvideorec.cc b/vvideorec.cc index 7e2b3cc..0fbe3c6 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -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 -#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) diff --git a/vvideorec.h b/vvideorec.h index 66d0121..99bebb3 100644 --- a/vvideorec.h +++ b/vvideorec.h @@ -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; -- 2.39.2