summaryrefslogtreecommitdiff
path: root/displayreplay.c
blob: 6b585aa4e1182901ce02e3dcf426757082395681 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "displayreplay.h"

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);
}

cSDDisplayReplay::~cSDDisplayReplay() {
    view->Close();
}

void cSDDisplayReplay::SetRecording(const cRecording *Recording) {
    if (ok) {
        view->SetRecording(Recording);
        if (init) {
            view->SetRecordingLength(Recording->LengthInSeconds());
            SetTimeShiftValues(Recording);
            init = false;
        }
    }
}

void cSDDisplayReplay::SetTitle(const char *Title) {
    view->SetTitle(Title);
}

void cSDDisplayReplay::SetMode(bool Play, bool Forward, int Speed) {
    if (!ok)
        return;
    if (!Play && Speed < 0) {
        cControl *control = cControl::Control();
        if (control) {
            const cRecording *recording = control->GetRecording();
            if (recording && recording->FileName()) {
                view->StartOnPause(recording->FileName());
            }
        }
    } else {
        view->ClearOnPause();
    }

    view->SetControlIcons(Play, Forward, Speed);
}

void cSDDisplayReplay::SetProgress(int Current, int Total) {
    if (ok) {
        view->SetProgressbar(Current, Total);
        view->SetMarks(marks, Current, Total);
        view->SetEndTime(Current, Total);
    }
}

void cSDDisplayReplay::SetCurrent(const char *Current) {
    if (ok)
        view->SetCurrent(Current);
}

void cSDDisplayReplay::SetTotal(const char *Total) {
    if (ok)
        view->SetTotal(Total);
}

void cSDDisplayReplay::SetJump(const char *Jump) {
    if (ok)
        view->SetJump(Jump);
}

void cSDDisplayReplay::SetMessage(eMessageType Type, const char *Text) {
    if (ok)
        view->SetMessage(Type, Text);
}

void cSDDisplayReplay::Flush(void) {
    if (!ok)
        return;
    view->Flush();
}

void cSDDisplayReplay::SetTimeShiftValues(const cRecording *recording) {
    bool isTimeShift = false;
#if APIVERSNUM >= 20101
    int usage = recording->IsInUse();
    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;
    view->SetTimeShift(framesTotal, recLength);
}