vdr-plugin-skindesigner/displayreplay.c

110 lines
2.8 KiB
C
Raw Normal View History

2014-09-27 09:25:14 +02:00
#include "displayreplay.h"
2016-01-26 18:32:38 +01:00
cSDDisplayReplay::cSDDisplayReplay(cViewReplay *replayView, bool ModeOnly) {
init = true;
view = replayView;
ok = view->Init();
if (!ok)
esyslog("skindesigner: Error initiating displayreplay view - aborting");
view->SetModeOnly(ModeOnly);
2014-09-27 09:25:14 +02:00
}
cSDDisplayReplay::~cSDDisplayReplay() {
2016-01-26 18:32:38 +01:00
view->Close();
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::SetRecording(const cRecording *Recording) {
2016-01-26 18:32:38 +01:00
if (ok) {
view->SetRecording(Recording);
if (init) {
view->SetRecordingLength(Recording->LengthInSeconds());
SetTimeShiftValues(Recording);
init = false;
}
}
2014-09-27 09:25:14 +02:00
}
2015-02-01 14:45:33 +01:00
void cSDDisplayReplay::SetTitle(const char *Title) {
2016-01-26 18:32:38 +01:00
view->SetTitle(Title);
2015-02-01 14:45:33 +01:00
}
2014-09-27 09:25:14 +02:00
void cSDDisplayReplay::SetMode(bool Play, bool Forward, int Speed) {
2016-01-26 18:32:38 +01:00
if (!ok)
2014-09-27 09:25:14 +02:00
return;
if (!Play && Speed < 0) {
cControl *control = cControl::Control();
if (control) {
const cRecording *recording = control->GetRecording();
2016-01-26 18:32:38 +01:00
if (recording && recording->FileName()) {
view->StartOnPause(recording->FileName());
}
}
} else {
2016-01-26 18:32:38 +01:00
view->ClearOnPause();
}
2016-01-26 18:32:38 +01:00
view->SetControlIcons(Play, Forward, Speed);
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::SetProgress(int Current, int Total) {
2016-01-26 18:32:38 +01:00
if (ok) {
view->SetProgressbar(Current, Total);
view->SetMarks(marks, Current, Total);
view->SetEndTime(Current, Total);
view->DelayOnPause();
2016-01-26 18:32:38 +01:00
}
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::SetCurrent(const char *Current) {
2016-01-26 18:32:38 +01:00
if (ok)
view->SetCurrent(Current);
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::SetTotal(const char *Total) {
2016-01-26 18:32:38 +01:00
if (ok)
view->SetTotal(Total);
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::SetJump(const char *Jump) {
2016-01-26 18:32:38 +01:00
if (ok)
view->SetJump(Jump);
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::SetMessage(eMessageType Type, const char *Text) {
2016-01-26 18:32:38 +01:00
if (ok)
view->SetMessage(Type, Text);
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::Flush(void) {
2016-01-26 18:32:38 +01:00
if (!ok)
2014-09-27 09:25:14 +02:00
return;
view->Flush(false);
2014-09-27 09:25:14 +02:00
}
void cSDDisplayReplay::SetTimeShiftValues(const cRecording *recording) {
//check for instant recording
const char *recName = recording->Name();
if (recName && *recName == '@')
return;
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;
2016-01-26 18:32:38 +01:00
view->SetTimeShift(framesTotal, recLength);
}