added timeshift support in displayreplay

This commit is contained in:
louis
2015-05-16 07:57:14 +02:00
parent 727f20617c
commit 53547389a4
6 changed files with 75 additions and 7 deletions

View File

@@ -6,6 +6,10 @@
cDisplayReplayView::cDisplayReplayView(cTemplateView *tmplView) : cView(tmplView) {
length = 0;
timeShiftActive = false;
timeShiftFramesTotal = 0;
timeShiftLength = 1;
timeShiftDuration = "";
endLast = "";
onPauseView = NULL;
numMarksLast = 0;
@@ -32,6 +36,15 @@ bool cDisplayReplayView::createOsd(void) {
return ok;
}
void cDisplayReplayView::SetTimeShift(int framesTotal, int timeShiftLength) {
timeShiftActive = true;
timeShiftFramesTotal = framesTotal;
this->timeShiftLength = timeShiftLength;
int mins = (timeShiftLength / 60) % 60;
int hours = (timeShiftLength / 3600) % 24;
timeShiftDuration = *cString::sprintf("%d:%02d", hours, mins);
}
void cDisplayReplayView::DrawBackground(bool modeOnly) {
map < string, string > stringTokens;
map < string, int > intTokens;
@@ -218,7 +231,9 @@ void cDisplayReplayView::DrawCurrent(const char *current) {
void cDisplayReplayView::DrawTotal(const char *total) {
map < string, string > stringTokens;
map < string, int > intTokens;
intTokens.insert(pair<string,int>("timeshift", timeShiftActive));
stringTokens.insert(pair<string,string>("rectotal", total));
stringTokens.insert(pair<string,string>("timeshifttotal", timeShiftDuration));
ClearViewElement(veRecTotal);
DrawViewElement(veRecTotal, &stringTokens, &intTokens);
@@ -227,8 +242,14 @@ void cDisplayReplayView::DrawTotal(const char *total) {
void cDisplayReplayView::DrawEndTime(int current, int total) {
if (!current)
return;
double rest = (double)(total - current) / (double)total;
time_t end = time(0) + rest*length;
int totalLength = total;
int recordingLength = length;
if (timeShiftActive && timeShiftFramesTotal > 0) {
totalLength = timeShiftFramesTotal;
recordingLength = timeShiftLength;
}
double rest = (double)(totalLength - current) / (double)totalLength;
time_t end = time(0) + rest*recordingLength;
string endTime = *TimeString(end);
if (!endTime.compare(endLast)) {
return;
@@ -246,9 +267,15 @@ void cDisplayReplayView::DrawEndTime(int current, int total) {
void cDisplayReplayView::DrawProgressBar(int current, int total) {
map < string, string > stringTokens;
map < string, int > intTokens;
intTokens.insert(pair<string,int>("current", current));
intTokens.insert(pair<string,int>("total", total));
stringTokens.insert(pair<string,string>("dummy", ""));
intTokens.insert(pair<string,int>("timeshift", timeShiftActive));
if (timeShiftActive) {
intTokens.insert(pair<string,int>("timeshifttotal", timeShiftFramesTotal));
}
ClearViewElement(veRecProgressBar);
DrawViewElement(veRecProgressBar, &stringTokens, &intTokens);
}
@@ -264,7 +291,10 @@ void cDisplayReplayView::DrawMarks(const cMarks *marks, int current, int total)
map < string, vector< map< string, string > > > loopTokens;
vector< map< string, string > > markTokens;
stringstream tot;
tot << total;
if (!timeShiftActive)
tot << total;
else
tot << timeShiftFramesTotal;
bool isStartMark = true;
for (const cMark *m = marks->First(); m; m = marks->Next(m)) {

View File

@@ -8,6 +8,10 @@
class cDisplayReplayView : public cView, public cViewHelpers {
private:
int length;
bool timeShiftActive;
int timeShiftFramesTotal;
int timeShiftLength;
string timeShiftDuration;
string endLast;
cDisplayReplayOnPauseView *onPauseView;
int numMarksLast;
@@ -20,6 +24,7 @@ public:
virtual ~cDisplayReplayView();
bool createOsd(void);
void SetRecordingLength(int length) { this->length = length; };
void SetTimeShift(int framesTotal, int timeShiftLength);
void DrawBackground(bool modeOnly);
void DrawDate(void);
void DrawTime(void);