VirtualBox

source: vbox/trunk/src/VBox/Main/include/ConsoleVRDPServer.h@ 34906

Last change on this file since 34906 was 34906, checked in by vboxsync, 14 years ago

Initial audio filter implementation, which is used for audio input via remote desktop server.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.0 KB
Line 
1/* $Id: ConsoleVRDPServer.h 34906 2010-12-09 16:29:49Z vboxsync $ */
2
3/** @file
4 *
5 * VBox Console VRDE Server Helper class and implementation of IVRDEServerInfo
6 */
7
8/*
9 * Copyright (C) 2006-2010 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#ifndef ____H_CONSOLEVRDPSERVER
21#define ____H_CONSOLEVRDPSERVER
22
23#include "RemoteUSBBackend.h"
24#include <hgcm/HGCM.h>
25
26#include <VBox/VBoxAuth.h>
27
28#include <VBox/HostServices/VBoxClipboardExt.h>
29
30#include "SchemaDefs.h"
31
32// ConsoleVRDPServer
33///////////////////////////////////////////////////////////////////////////////
34
35typedef struct _VRDPInputSynch
36{
37 int cGuestNumLockAdaptions;
38 int cGuestCapsLockAdaptions;
39
40 bool fGuestNumLock;
41 bool fGuestCapsLock;
42 bool fGuestScrollLock;
43
44 bool fClientNumLock;
45 bool fClientCapsLock;
46 bool fClientScrollLock;
47} VRDPInputSynch;
48
49/* Member of Console. Helper class for VRDP server management. Not a COM class. */
50class ConsoleVRDPServer
51{
52public:
53 ConsoleVRDPServer (Console *console);
54 ~ConsoleVRDPServer ();
55
56 int Launch (void);
57
58 void NotifyAbsoluteMouse (bool fGuestWantsAbsolute)
59 {
60 m_fGuestWantsAbsolute = fGuestWantsAbsolute;
61 }
62
63 void NotifyKeyboardLedsChange (BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
64 {
65 bool fGuestNumLock = (fNumLock != FALSE);
66 bool fGuestCapsLock = (fCapsLock != FALSE);
67 bool fGuestScrollLock = (fScrollLock != FALSE);
68
69 /* Might need to resync in case the guest itself changed the LED status. */
70 if (m_InputSynch.fClientNumLock != fGuestNumLock)
71 {
72 m_InputSynch.cGuestNumLockAdaptions = 2;
73 }
74
75 if (m_InputSynch.fClientCapsLock != fGuestCapsLock)
76 {
77 m_InputSynch.cGuestCapsLockAdaptions = 2;
78 }
79
80 m_InputSynch.fGuestNumLock = fGuestNumLock;
81 m_InputSynch.fGuestCapsLock = fGuestCapsLock;
82 m_InputSynch.fGuestScrollLock = fGuestScrollLock;
83 }
84
85 void EnableConnections (void);
86 void DisconnectClient (uint32_t u32ClientId, bool fReconnect);
87 void MousePointerUpdate (const VRDECOLORPOINTER *pPointer);
88 void MousePointerHide (void);
89
90 void Stop (void);
91
92 AuthResult Authenticate (const Guid &uuid, AuthGuestJudgement guestJudgement,
93 const char *pszUser, const char *pszPassword, const char *pszDomain,
94 uint32_t u32ClientId);
95
96 void AuthDisconnect (const Guid &uuid, uint32_t u32ClientId);
97
98 void USBBackendCreate (uint32_t u32ClientId, void **ppvIntercept);
99 void USBBackendDelete (uint32_t u32ClientId);
100
101 void *USBBackendRequestPointer (uint32_t u32ClientId, const Guid *pGuid);
102 void USBBackendReleasePointer (const Guid *pGuid);
103
104 /* Private interface for the RemoteUSBBackend destructor. */
105 void usbBackendRemoveFromList (RemoteUSBBackend *pRemoteUSBBackend);
106
107 /* Private methods for the Remote USB thread. */
108 RemoteUSBBackend *usbBackendGetNext (RemoteUSBBackend *pRemoteUSBBackend);
109
110 void notifyRemoteUSBThreadRunning (RTTHREAD thread);
111 bool isRemoteUSBThreadRunning (void);
112 void waitRemoteUSBThreadEvent (RTMSINTERVAL cMillies);
113
114 void ClipboardCreate (uint32_t u32ClientId);
115 void ClipboardDelete (uint32_t u32ClientId);
116
117 /*
118 * Forwarders to VRDP server library.
119 */
120 void SendUpdate (unsigned uScreenId, void *pvUpdate, uint32_t cbUpdate) const;
121 void SendResize (void) const;
122 void SendUpdateBitmap (unsigned uScreenId, uint32_t x, uint32_t y, uint32_t w, uint32_t h) const;
123
124 void SendAudioSamples (void *pvSamples, uint32_t cSamples, VRDEAUDIOFORMAT format) const;
125 void SendAudioVolume (uint16_t left, uint16_t right) const;
126 void SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const;
127
128 void QueryInfo (uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const;
129
130 int SendAudioInputBegin(void **ppvUserCtx,
131 void *pvContext,
132 uint32_t cSamples,
133 uint32_t iSampleHz,
134 uint32_t cChannels,
135 uint32_t cBits);
136
137 void SendAudioInputEnd(void *pvUserCtx);
138
139private:
140 /* Note: This is not a ComObjPtr here, because the ConsoleVRDPServer object
141 * is actually just a part of the Console.
142 */
143 Console *mConsole;
144
145 HVRDESERVER mhServer;
146 int mServerInterfaceVersion;
147
148 static int loadVRDPLibrary (const char *pszLibraryName);
149
150 /** Static because will never load this more than once! */
151 static RTLDRMOD mVRDPLibrary;
152
153 static PFNVRDECREATESERVER mpfnVRDECreateServer;
154
155 static VRDEENTRYPOINTS_3 mEntryPoints;
156 static VRDEENTRYPOINTS_3 *mpEntryPoints;
157 static VRDECALLBACKS_3 mCallbacks;
158
159 static DECLCALLBACK(int) VRDPCallbackQueryProperty (void *pvCallback, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut);
160 static DECLCALLBACK(int) VRDPCallbackClientLogon (void *pvCallback, uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
161 static DECLCALLBACK(void) VRDPCallbackClientConnect (void *pvCallback, uint32_t u32ClientId);
162 static DECLCALLBACK(void) VRDPCallbackClientDisconnect (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercepted);
163 static DECLCALLBACK(int) VRDPCallbackIntercept (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercept, void **ppvIntercept);
164 static DECLCALLBACK(int) VRDPCallbackUSB (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint8_t u8Code, const void *pvRet, uint32_t cbRet);
165 static DECLCALLBACK(int) VRDPCallbackClipboard (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
166 static DECLCALLBACK(bool) VRDPCallbackFramebufferQuery (void *pvCallback, unsigned uScreenId, VRDEFRAMEBUFFERINFO *pInfo);
167 static DECLCALLBACK(void) VRDPCallbackFramebufferLock (void *pvCallback, unsigned uScreenId);
168 static DECLCALLBACK(void) VRDPCallbackFramebufferUnlock (void *pvCallback, unsigned uScreenId);
169 static DECLCALLBACK(void) VRDPCallbackInput (void *pvCallback, int type, const void *pvInput, unsigned cbInput);
170 static DECLCALLBACK(void) VRDPCallbackVideoModeHint (void *pvCallback, unsigned cWidth, unsigned cHeight, unsigned cBitsPerPixel, unsigned uScreenId);
171 static DECLCALLBACK(void) VRDECallbackAudioIn (void *pvCallback, void *pvCtx, uint32_t u32ClientId, uint32_t u32Event, const void *pvData, uint32_t cbData);
172
173 bool m_fGuestWantsAbsolute;
174 int m_mousex;
175 int m_mousey;
176
177 IFramebuffer *maFramebuffers[SchemaDefs::MaxGuestMonitors];
178
179 IEventListener *mConsoleListener;
180
181 VRDPInputSynch m_InputSynch;
182
183 int32_t mVRDPBindPort;
184
185 RTCRITSECT mCritSect;
186
187 int lockConsoleVRDPServer (void);
188 void unlockConsoleVRDPServer (void);
189
190 int mcClipboardRefs;
191 HGCMSVCEXTHANDLE mhClipboard;
192 PFNVRDPCLIPBOARDEXTCALLBACK mpfnClipboardCallback;
193
194 static DECLCALLBACK(int) ClipboardCallback (void *pvCallback, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData);
195 static DECLCALLBACK(int) ClipboardServiceExtension (void *pvExtension, uint32_t u32Function, void *pvParm, uint32_t cbParms);
196
197#ifdef VBOX_WITH_USB
198 RemoteUSBBackend *usbBackendFindByUUID (const Guid *pGuid);
199 RemoteUSBBackend *usbBackendFind (uint32_t u32ClientId);
200
201 typedef struct _USBBackends
202 {
203 RemoteUSBBackend *pHead;
204 RemoteUSBBackend *pTail;
205
206 RTTHREAD thread;
207
208 bool fThreadRunning;
209
210 RTSEMEVENT event;
211 } USBBackends;
212
213 USBBackends mUSBBackends;
214
215 void remoteUSBThreadStart (void);
216 void remoteUSBThreadStop (void);
217#endif /* VBOX_WITH_USB */
218
219 /* External authentication library handle. The library is loaded in the
220 * Authenticate method and unloaded at the object destructor.
221 */
222 RTLDRMOD mAuthLibrary;
223 PAUTHENTRY mpfnAuthEntry;
224 PAUTHENTRY2 mpfnAuthEntry2;
225 PAUTHENTRY3 mpfnAuthEntry3;
226
227 uint32_t volatile mu32AudioInputClientId;
228};
229
230
231class Console;
232
233class ATL_NO_VTABLE VRDEServerInfo :
234 public VirtualBoxBase,
235 VBOX_SCRIPTABLE_IMPL(IVRDEServerInfo)
236{
237public:
238
239 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VRDEServerInfo, IVRDEServerInfo)
240
241 DECLARE_NOT_AGGREGATABLE(VRDEServerInfo)
242
243 DECLARE_PROTECT_FINAL_CONSTRUCT()
244
245 BEGIN_COM_MAP(VRDEServerInfo)
246 COM_INTERFACE_ENTRY(ISupportErrorInfo)
247 COM_INTERFACE_ENTRY(IVRDEServerInfo)
248 COM_INTERFACE_ENTRY(IDispatch)
249 END_COM_MAP()
250
251 DECLARE_EMPTY_CTOR_DTOR (VRDEServerInfo)
252
253 HRESULT FinalConstruct();
254 void FinalRelease();
255
256 /* Public initializer/uninitializer for internal purposes only. */
257 HRESULT init (Console *aParent);
258 void uninit();
259
260 /* IVRDEServerInfo properties */
261 #define DECL_GETTER(_aType, _aName) STDMETHOD(COMGETTER(_aName)) (_aType *a##_aName)
262 DECL_GETTER (BOOL, Active);
263 DECL_GETTER (LONG, Port);
264 DECL_GETTER (ULONG, NumberOfClients);
265 DECL_GETTER (LONG64, BeginTime);
266 DECL_GETTER (LONG64, EndTime);
267 DECL_GETTER (LONG64, BytesSent);
268 DECL_GETTER (LONG64, BytesSentTotal);
269 DECL_GETTER (LONG64, BytesReceived);
270 DECL_GETTER (LONG64, BytesReceivedTotal);
271 DECL_GETTER (BSTR, User);
272 DECL_GETTER (BSTR, Domain);
273 DECL_GETTER (BSTR, ClientName);
274 DECL_GETTER (BSTR, ClientIP);
275 DECL_GETTER (ULONG, ClientVersion);
276 DECL_GETTER (ULONG, EncryptionStyle);
277 #undef DECL_GETTER
278
279private:
280
281 Console * const mParent;
282};
283
284#endif // ____H_CONSOLEVRDPSERVER
285/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette