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
|
/* Copyright (C) 2004 TightVNC Team. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
// -=- RfbPlayer.h
#include <windows.h>
#include <rfb_win32/DIBSectionBuffer.h>
//#include <rfbplayer/RfbProto.h>
#include <rfbplayer/ToolBar.h>
#include <rfbplayer/rfbSessionReader.h>
using namespace rfb;
using namespace rfb::win32;
class RfbPlayer : public RfbProto {
public:
RfbPlayer(char *filename, long _pos, double s_peed, bool autoplay,
bool _showControls, bool _acceptBell);
~RfbPlayer();
// -=- Window Message handling
LRESULT processMainMessage(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT processFrameMessage(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam);
// -=- Window interface
HWND getMainHandle() const {return mainHwnd;}
HWND getFrameHandle() const {return frameHwnd;}
void createToolBar(HWND parentHwnd);
void setFrameSize(int width, int height);
void setVisible(bool visible);
void setTitle(const char *title);
void calculateScrollBars();
void close(const char* reason=0);
void updatePos();
// -=- Coordinate conversions
inline Point bufferToClient(const Point& p) {
Point pos = p;
if (client_size.width() > buffer->width())
pos.x += (client_size.width() - buffer->width()) / 2;
else if (client_size.width() < buffer->width())
pos.x -= scrolloffset.x;
if (client_size.height() > buffer->height())
pos.y += (client_size.height() - buffer->height()) / 2;
else if (client_size.height() < buffer->height())
pos.y -= scrolloffset.y;
return pos;
}
inline Rect bufferToClient(const Rect& r) {
return Rect(bufferToClient(r.tl), bufferToClient(r.br));
}
inline Point clientToBuffer(const Point& p) {
Point pos = p;
if (client_size.width() > buffer->width())
pos.x -= (client_size.width() - buffer->width()) / 2;
else if (client_size.width() < buffer->width())
pos.x += scrolloffset.x;
if (client_size.height() > buffer->height())
pos.y -= (client_size.height() - buffer->height()) / 2;
else if (client_size.height() < buffer->height())
pos.y += scrolloffset.y;
return pos;
}
inline Rect clientToBuffer(const Rect& r) {
return Rect(clientToBuffer(r.tl), clientToBuffer(r.br));
}
bool setViewportOffset(const Point& tl);
// -=- RfbProto interface overrides
virtual void processMsg();
virtual void serverInit();
virtual void frameBufferUpdateEnd();
virtual void setColourMapEntries(int first, int count, U16* rgbs);
virtual void serverCutText(const char* str, int len);
virtual void bell();
virtual void beginRect(const Rect& r, unsigned int encoding);
virtual void endRect(const Rect& r, unsigned int encoding);
virtual void fillRect(const Rect& r, Pixel pix);
virtual void imageRect(const Rect& r, void* pixels);
virtual void copyRect(const Rect& r, int srcX, int srcY);
// -=- Functions used to manage player's parameters
void setOptions(long pos, double speed, bool autoPlay, bool showControls);
void applyOptions();
// -=- Player functions
// openSessionFile() opens the new session file and starts play it
void openSessionFile(char *fileName);
// skipHandshaking() - is implemented to skip the initial handshaking when
// perform backward seeking OR replaying.
void skipHandshaking();
void blankBuffer();
void rewind();
void setPaused(bool paused);
long getTimeOffset();
bool isSeekMode();
bool isSeeking();
bool isPaused();
long getSeekOffset();
void setPos(long pos);
void setSpeed(double speed);
double getSpeed();
char *fileName;
private:
bool seekMode;
long lastPos;
char fullSessionTime[20];
int time_pos_m;
int time_pos_s;
int CTRL_BAR_HEIGHT;
protected:
// rfbReader is a class which used to reading the rfb data from the file
rfbSessionReader *rfbReader;
// Returns true if part of the supplied rect is visible, false otherwise
bool invalidateBufferRect(const Rect& crect);
// Local window state
HWND mainHwnd;
HWND frameHwnd;
HWND timeStatic;
HWND speedEdit;
HWND speedTrackBar;
HWND speedUpDown;
Rect window_size;
Rect client_size;
Point scrolloffset;
Point maxscrolloffset;
char *cutText;
win32::DIBSectionBuffer* buffer;
ToolBar tb;
// The player's parameters
bool showControls;
bool autoplay;
double playbackSpeed;
long initTime;
long serverInitTime;
bool acceptBell;
};
|