summaryrefslogtreecommitdiff
path: root/coreengine/viewdisplayreplay.c
diff options
context:
space:
mode:
authorkamel5 <vdr.kamel5 (at) gmx (dot) net>2021-02-12 15:20:34 +0100
committerkamel5 <vdr.kamel5 (at) gmx (dot) net>2021-02-15 14:00:35 +0100
commitafa9cb77a3534dd253ec7e6b4ea63305e410097d (patch)
tree5d3e2cb556a88eb55e24ebe0982ee401bb2d424c /coreengine/viewdisplayreplay.c
parent1fc5379e2eed0ecd7eb2227564077a62bc0b1e12 (diff)
downloadvdr-plugin-skindesigner-afa9cb77a3534dd253ec7e6b4ea63305e410097d.tar.gz
vdr-plugin-skindesigner-afa9cb77a3534dd253ec7e6b4ea63305e410097d.tar.bz2
Add element timeShiftTimes to displayreplay
In displayreplay the tokens recstart, playbacktime and timeshiftrest added to display start time, actual playback time and the rest of the actual recording in timeshiftmode.
Diffstat (limited to 'coreengine/viewdisplayreplay.c')
-rw-r--r--coreengine/viewdisplayreplay.c49
1 files changed, 39 insertions, 10 deletions
diff --git a/coreengine/viewdisplayreplay.c b/coreengine/viewdisplayreplay.c
index 30b7c36..c3aeb00 100644
--- a/coreengine/viewdisplayreplay.c
+++ b/coreengine/viewdisplayreplay.c
@@ -6,6 +6,7 @@
cViewReplay::cViewReplay(void) {
veCustomTokens = NULL;
+ veTimeshiftTimes = NULL;
veEndTime = NULL;
veMessage = NULL;
veScraperContent = NULL;
@@ -45,6 +46,7 @@ void cViewReplay::SetViewElements(void) {
viewElementNames.insert(pair<string, int>("rectitle", (int)eVeDisplayReplay::rectitle));
viewElementNames.insert(pair<string, int>("recinfo", (int)eVeDisplayReplay::recinfo));
viewElementNames.insert(pair<string, int>("currenttime", (int)eVeDisplayReplay::currenttime));
+ viewElementNames.insert(pair<string, int>("timeshifttimes", (int)eVeDisplayReplay::timeshifttimes));
viewElementNames.insert(pair<string, int>("endtime", (int)eVeDisplayReplay::endtime));
viewElementNames.insert(pair<string, int>("totaltime", (int)eVeDisplayReplay::totaltime));
viewElementNames.insert(pair<string, int>("progressbar", (int)eVeDisplayReplay::progressbar));
@@ -92,6 +94,10 @@ void cViewReplay::SetViewElementObjects(void) {
{
veTotalTime = dynamic_cast<cVeDrTotalTime*>(viewElements[i]);
}
+ else if (dynamic_cast<cVeDrTimeshiftTimes*>(viewElements[i]))
+ {
+ veTimeshiftTimes = dynamic_cast<cVeDrTimeshiftTimes*>(viewElements[i]);
+ }
else if (dynamic_cast<cVeDrEndTime*>(viewElements[i]))
{
veEndTime = dynamic_cast<cVeDrEndTime*>(viewElements[i]);
@@ -153,8 +159,11 @@ void cViewReplay::ClearVariables(void) {
timeShiftFramesTotal = -1;
timeShiftLength = -1;
timeShiftDuration = "";
+ timeshiftrest = "";
if (veCustomTokens)
veCustomTokens->Reset();
+ if (veTimeshiftTimes)
+ veTimeshiftTimes->Set(cString(""), cString(""), cString(""));
if (veEndTime)
veEndTime->Set(cString(""));
if (veCutMarks)
@@ -200,17 +209,20 @@ void cViewReplay::SetTimeShiftValues(int current, int total) {
if (!Schedule)
return;
// Get event at actual recording position
- const cEvent *eventEnde = Schedule->GetEventAround(time(NULL));
+ const cEvent *eventEnde = Schedule->GetEventAround(time(0));
if (!eventEnde)
return;
- double fps = recording->FramesPerSecond();
+ // End of live program
time_t liveEventStop = eventEnde->EndTime();
+ // Begin of timeshift recording
time_t recordingStart = time(0) - recording->LengthInSeconds();
- timeShiftFramesTotal = (liveEventStop - recordingStart) * fps;
+ // actual timeshiftlength
timeShiftLength = liveEventStop - recordingStart;
- // Get event at actual replay position
- int secondsafter = (int)(recording->LengthInSeconds() * (1.0 - (double)current / (double)total));
- const cEvent *eventReplay = Schedule->GetEventAround(time(NULL) - secondsafter);
+ // timeshiftlength until end of live program
+ timeShiftFramesTotal = total * ((double)timeShiftLength / (double)recording->LengthInSeconds());
+ // Get event at actual replay position (add 30sec for a better match)
+ int timeShiftSecondsAfter = (int)(recording->LengthInSeconds() * (1.0 - (double)current / (double)total)) + 30;
+ const cEvent *eventReplay = Schedule->GetEventAround(time(0) - timeShiftSecondsAfter);
// Display title at replay position
if (eventReplay && eventReplay != lastEvent && veRecTitle) {
veRecTitle->Set(recording, eventReplay, true);
@@ -220,6 +232,9 @@ void cViewReplay::SetTimeShiftValues(int current, int total) {
int mins = (timeShiftLength / 60) % 60;
int hours = (timeShiftLength / 3600) % 24;
timeShiftDuration = cString::sprintf("%d:%02d", hours, mins);
+ mins = (timeShiftSecondsAfter / 60) % 60;
+ hours = (timeShiftSecondsAfter / 3600) % 24;
+ timeshiftrest = cString::sprintf("%d:%02d", hours, mins);
}
void cViewReplay::SetRecording(const cRecording *recording) {
@@ -249,16 +264,30 @@ void cViewReplay::SetTitle(const char *title) {
void cViewReplay::SetCurrent(const char *current) {
if (veCurrentTime)
- veCurrentTime->Set(current);
+ veCurrentTime->Set(current, timeShiftActive);
Render((int)eVeDisplayReplay::currenttime);
}
void cViewReplay::SetTotal(const char *total) {
if (veTotalTime)
- veTotalTime->Set(total, timeShiftActive, *timeShiftDuration);
+ veTotalTime->Set(total, *timeShiftDuration, timeShiftActive);
Render((int)eVeDisplayReplay::totaltime);
}
+void cViewReplay::SetTimeshiftTimes(int current, int total) {
+ if (!veTimeshiftTimes || reclength == 0)
+ return;
+ time_t recordingStart = 0;
+ time_t playbackTime = 0;
+ if (timeShiftActive) {
+ recordingStart = time(0) - recording->LengthInSeconds();
+ playbackTime = time(0) - (int)(recording->LengthInSeconds() * (1.0 - (double)current / (double)total));
+ } else
+ recordingStart = recording->Start();
+ veTimeshiftTimes->Set(TimeString(recordingStart), TimeString(playbackTime), timeshiftrest, timeShiftActive);
+ Render((int)eVeDisplayReplay::timeshifttimes);
+}
+
void cViewReplay::SetEndTime(int current, int total) {
if (!veEndTime || reclength == 0)
return;
@@ -270,12 +299,12 @@ void cViewReplay::SetEndTime(int current, int total) {
}
double rest = (double)(totalLength - current) / (double)totalLength;
time_t end = time(0) + rest * recordingLength;
- veEndTime->Set(TimeString(end));
+ veEndTime->Set(TimeString(end), timeShiftActive);
Render((int)eVeDisplayReplay::endtime);
}
void cViewReplay::SetProgressbar(int current, int total) {
- SetTimeShiftValues(current, total);
+// SetTimeShiftValues(current, total);
if (veProgressbar)
veProgressbar->Set(current, total, timeShiftActive, timeShiftFramesTotal);
Render((int)eVeDisplayReplay::progressbar);