summaryrefslogtreecommitdiff
path: root/state.h
blob: 4c74ee3a21511dc021c9598b3563c67ced1f56e2 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/**
 *  GraphLCD plugin for the Video Disk Recorder
 *
 *  state.h  -  status monitor class
 *
 *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
 *  (c) 2010-2012 Wolfgang Astleitner <mrwastl AT users sourceforge net>
 **/

#ifndef _GRAPHLCD_STATE_H_
#define _GRAPHLCD_STATE_H_

#include <map>
#include <string>

#include <vdr/status.h>


struct tChannel
{
    tChannelID id;
    int number;
    std::string name;
    std::string shortName;
    std::string provider;
    std::string portal;
    std::string source;
    bool hasTeletext;
    bool hasMultiLanguage;
    bool hasDolby;
    bool isEncrypted;
    bool isRadio;
};

struct tEvent
{
    bool valid;
    time_t startTime;
    time_t vpsTime;
    int duration;
    std::string title;
    std::string shortText;
    std::string description;
};

enum eReplayMode
{
    eReplayNormal,
    eReplayMusic,
    eReplayDVD,
    eReplayFile,
    eReplayImage,
    eReplayAudioCD
};

struct tReplayState
{
    std::string name;
    std::string loopmode;
    cControl * control;
    eReplayMode mode;
    int current;
    int total;
    bool play;
    bool forward;
    int speed;
};

struct tRecording
{
    int deviceNumber;
    std::string name;
    std::string fileName;
};

struct tOsdState
{
    std::string currentItem;
    std::vector <std::string> items;
    std::string title;
    std::string redButton;
    std::string greenButton;
    std::string yellowButton;
    std::string blueButton;
    std::string textItem;
    std::string message;
    int currentItemIndex;
    int currentTextItemScroll;
    bool currentTextItemScrollReset;
};

struct tVolumeState
{
    int value;
    uint64_t lastChange;
};

struct tAudioState
{
    int currentTrack;
    std::vector <std::string> tracks;
    int currentChannel;
    uint64_t lastChange;
};

class cGraphLCDDisplay;

class cGraphLCDState : public cStatus
{
private:
    cGraphLCDDisplay * mDisplay;
    bool first;
    bool tickUsed;

    cMutex mutex;

    tChannel mChannel;
    tEvent mPresent;
    tEvent mFollowing;
    tReplayState mReplay;
    std::vector <tRecording> mRecordings;
    tOsdState mOsd;
    tVolumeState mVolume;
    tAudioState  mAudio;

    void SetChannel(int ChannelNumber);
    void UpdateChannelInfo(void);
    void UpdateEventInfo(void);
    void UpdateReplayInfo(void);
protected:
#if VDRVERSNUM >= 10726
    virtual void ChannelSwitch(const cDevice *Device, int ChannelNumber, bool LiveView);
#else  
    virtual void ChannelSwitch(const cDevice *Device, int ChannelNumber);
#endif
    virtual void Recording(const cDevice *Device, const char *Name, const char *FileName, bool On);
    virtual void Replaying(const cControl *Control, const char *Name, const char *FileName, bool On);
    virtual void SetVolume(int Volume, bool Absolute);
    virtual void SetAudioTrack(int Index, const char * const *Tracks);
    virtual void SetAudioChannel(int AudioChannel);
    virtual void OsdClear();
    virtual void OsdTitle(const char *Title);
    virtual void OsdStatusMessage(const char *Message);
    virtual void OsdHelpKeys(const char *Red, const char *Green, const char *Yellow, const char *Blue);
    virtual void OsdItem(const char *Text, int Index);
    virtual void OsdCurrentItem(const char *Text);
    virtual void OsdTextItem(const char *Text, bool Scroll);
    virtual void OsdChannel(const char *Text);
    virtual void OsdProgramme(time_t PresentTime, const char *PresentTitle, const char *PresentSubtitle, time_t FollowingTime, const char *FollowingTitle, const char *FollowingSubtitle);

public:
    cGraphLCDState(cGraphLCDDisplay * Display);
    virtual ~cGraphLCDState();

    void Update();
    void Tick();
    tChannel GetChannelInfo();
    tEvent GetPresentEvent();
    tEvent GetFollowingEvent();
    tReplayState GetReplayState();
    bool IsRecording(int CardNumber);
    std::string Recordings(int CardNumber, int selector);
    int NumRecordings(int CardNumber);
    tOsdState GetOsdState();
    void ResetOsdStateScroll();
    tVolumeState GetVolumeState();
    tAudioState  GetAudioState();
    bool ShowMessage();
};

#endif