From 54df4f849216084b7056e59f793c592e81c97e68 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Tue, 8 Apr 2008 19:38:41 +0200 Subject: display length of recordings (#451) --- css/styles.css | 4 ++++ pages/recordings.ecpp | 5 ++++- recman.cpp | 22 ++++++++++++++++++++++ recman.h | 3 +++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/css/styles.css b/css/styles.css index ae09f78..25b82ca 100644 --- a/css/styles.css +++ b/css/styles.css @@ -921,6 +921,10 @@ div.recording_item { width: 5.75em; } +.recording_item div.recording_duration { + width: 2.5em; +} + .recording_item div.recording_name { font-weight: bold; cursor: pointer; diff --git a/pages/recordings.ecpp b/pages/recordings.ecpp index 11b20a6..daa4427 100644 --- a/pages/recordings.ecpp +++ b/pages/recordings.ecpp @@ -131,11 +131,12 @@ for (iter = recordingsTree->begin(path); iter != end; ++iter) { if (!recItem->IsDir()) { string day(FormatDateTime("%a,", recItem->StartTime())); string dayLen(lexical_cast(day.length() - 1) + ".25em;"); + string duration(lexical_cast(recItem->Duration()) + "'"); string shortDescr(recItem->RecInfo()->ShortText() ? recItem->RecInfo()->ShortText() : ""); string hint(tr("Click to view details.")); if (!shortDescr.empty()) hint = shortDescr + "
" + hint;
  • - <& rec_item_file name=(recItem->Name()) level=(level) id=(recItem->Id()) day=(day) dayLen=(dayLen) startTime=(recItem->StartTime()) hint=(hint) shortDescr=(shortDescr) archived=(RecordingsManager::GetArchiveDescr(recItem->Recording())) &> + <& rec_item_file name=(recItem->Name()) level=(level) id=(recItem->Id()) day=(day) dayLen=(dayLen) startTime=(recItem->StartTime()) duration=(duration) hint=(hint) shortDescr=(shortDescr) archived=(RecordingsManager::GetArchiveDescr(recItem->Recording())) &>
  • <%cpp> } @@ -203,6 +204,7 @@ for (iter = recordingsTree->begin(path); iter != end; ++iter) { string day; string dayLen; time_t startTime; + string duration; string hint; string shortDescr; string archived; @@ -213,6 +215,7 @@ for (iter = recordingsTree->begin(path); iter != end; ++iter) {
    <$ day $>
    <$ FormatDateTime(tr("%b %d %y"), startTime) $>
    <$ FormatDateTime(tr("%I:%M %p"), startTime) $>
    +
    <$ duration $>
    diff --git a/recman.cpp b/recman.cpp index 26d78d9..ca7741a 100644 --- a/recman.cpp +++ b/recman.cpp @@ -12,6 +12,7 @@ #include "epg_events.h" #include "recman.h" +#define INDEXFILESUFFIX "/index.vdr" using namespace std::tr1; using namespace std; @@ -237,6 +238,27 @@ namespace vdrlive { return m_recording->start; } + long RecordingsItemRec::Duration() const + { + long RecLength = 0; + if (!m_recording->FileName()) return 0; + cString filename = cString::sprintf("%s%s", m_recording->FileName(), INDEXFILESUFFIX); + if (*filename) { + if (access(filename, R_OK) == 0) { + struct stat buf; + if (stat(filename, &buf) == 0) { + struct tIndex { int offset; uchar type; uchar number; short reserved; }; + int delta = buf.st_size % sizeof(tIndex); + if (delta) { + delta = sizeof(tIndex) - delta; + esyslog("ERROR: invalid file size (%ld) in '%s'", buf.st_size, *filename); + } + RecLength = (buf.st_size + delta) / sizeof(tIndex) / SecondsToFrames(60); + } + } + } + return RecLength; + } /** * Implementation of class RecordingsTree: diff --git a/recman.h b/recman.h index 45265b3..8044d38 100644 --- a/recman.h +++ b/recman.h @@ -121,6 +121,7 @@ namespace vdrlive { virtual time_t StartTime() const = 0; virtual bool IsDir() const = 0; + virtual long Duration() const = 0; virtual const std::string& Name() const { return m_name; } virtual const std::string Id() const = 0; @@ -149,6 +150,7 @@ namespace vdrlive { virtual ~RecordingsItemDir(); virtual time_t StartTime() const { return 0; } + virtual long Duration() const { return 0; } virtual bool IsDir() const { return true; } virtual std::string const Id() const { return ""; } @@ -170,6 +172,7 @@ namespace vdrlive { virtual ~RecordingsItemRec(); virtual time_t StartTime() const; + virtual long Duration() const; virtual bool IsDir() const { return false; } virtual const std::string Id() const { return m_id; } -- cgit v1.2.3