vdr-plugin-skindesigner/displayreplay.c

151 lines
4.2 KiB
C
Raw Normal View History

2014-09-27 09:25:14 +02:00
#define __STL_CONFIG_H
#include <vdr/player.h>
2014-09-27 09:25:14 +02:00
#include "displayreplay.h"
cSDDisplayReplay::cSDDisplayReplay(cTemplate *replayTemplate, bool ModeOnly) {
doOutput = true;
initial = true;
2015-05-10 12:55:23 +02:00
initialModeSet = false;
2014-09-27 09:25:14 +02:00
modeOnly = ModeOnly;
replayView = NULL;
2014-09-27 09:25:14 +02:00
if (!replayTemplate) {
doOutput = false;
esyslog("skindesigner: displayReplay no valid template - aborting");
return;
}
replayView = new cDisplayReplayView(replayTemplate->GetRootView());
if (!replayView->createOsd()) {
doOutput = false;
return;
}
replayView->DrawDebugGrid();
2014-09-27 09:25:14 +02:00
}
cSDDisplayReplay::~cSDDisplayReplay() {
if (replayView)
delete replayView;
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::SetRecording(const cRecording *Recording) {
2015-02-01 14:45:33 +01:00
if (!doOutput || !Recording)
2014-09-27 09:25:14 +02:00
return;
if (initial) {
replayView->SetRecordingLength(Recording->LengthInSeconds());
SetTimeShiftValues(Recording);
}
2014-09-27 09:25:14 +02:00
replayView->DrawTitle(Recording);
replayView->DrawRecordingInformation(Recording);
replayView->DrawScraperContent(Recording);
}
2015-02-01 14:45:33 +01:00
void cSDDisplayReplay::SetTitle(const char *Title) {
if (!doOutput || !Title)
return;
replayView->DrawTitle(Title);
}
2014-09-27 09:25:14 +02:00
void cSDDisplayReplay::SetMode(bool Play, bool Forward, int Speed) {
if (!doOutput)
return;
if (!Play && Speed < 0) {
string recFileName = "";
cControl *control = cControl::Control();
if (control) {
const cRecording *recording = control->GetRecording();
if (recording && recording->FileName())
recFileName = recording->FileName();
}
replayView->DrawOnPause(recFileName, modeOnly);
} else {
replayView->ClearOnPause();
}
2014-09-27 09:25:14 +02:00
replayView->DrawControlIcons(Play, Forward, Speed, modeOnly);
2015-05-10 12:55:23 +02:00
initialModeSet = true;
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::SetProgress(int Current, int Total) {
if (!doOutput)
return;
replayView->DelayOnPause();
2014-09-27 09:25:14 +02:00
replayView->DrawProgressBar(Current, Total);
2014-10-28 18:09:10 +01:00
replayView->DrawMarks(marks, Current, Total);
replayView->DrawEndTime(Current, Total);
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::SetCurrent(const char *Current) {
if (!doOutput)
return;
replayView->DrawCurrent(Current);
}
void cSDDisplayReplay::SetTotal(const char *Total) {
if (!doOutput)
return;
replayView->DrawTotal(Total);
}
void cSDDisplayReplay::SetJump(const char *Jump) {
if (!doOutput)
return;
replayView->DrawJump(Jump);
}
void cSDDisplayReplay::SetMessage(eMessageType Type, const char *Text) {
if (!doOutput)
return;
replayView->DrawMessage(Type, Text);
}
void cSDDisplayReplay::Flush(void) {
if (!doOutput)
return;
2015-01-06 06:07:48 +01:00
if (!modeOnly) {
replayView->DrawDate();
replayView->DrawTime();
}
if (modeOnly) {
cControl *control = cControl::Control();
if (control) {
double fps = control->FramesPerSecond();
int current = 0;
int total = 0;
if (control->GetIndex(current, total))
replayView->DrawProgressModeOnly(fps, current, total);
}
}
2015-05-10 12:55:23 +02:00
if (initial && initialModeSet) {
replayView->DrawBackground(modeOnly);
replayView->DrawCustomTokens();
2014-09-27 09:25:14 +02:00
replayView->DoFadeIn();
initial = false;
} else {
if (replayView->CustomTokenChange())
replayView->DrawCustomTokens();
2014-09-27 09:25:14 +02:00
replayView->Flush();
}
}
void cSDDisplayReplay::SetTimeShiftValues(const cRecording *recording) {
2015-05-16 11:02:09 +02:00
bool isTimeShift = false;
#if APIVERSNUM >= 20101
int usage = recording->IsInUse();
2015-05-16 11:02:09 +02:00
if (usage & ruTimer)
isTimeShift = true;
#endif
if (!isTimeShift)
return;
const cRecordingInfo *recInfo = recording->Info();
if (!recInfo)
return;
const cEvent *event = recInfo->GetEvent();
if (!event)
return;
double fps = recording->FramesPerSecond();
time_t liveEventStop = event->EndTime();
time_t recordingStart = time(0) - recording->LengthInSeconds();
int framesTotal = (liveEventStop - recordingStart)*fps;
int recLength = liveEventStop - recordingStart;
replayView->SetTimeShift(framesTotal, recLength);
}