VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxHeadless/FramebufferVNC.cpp@ 33223

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

Main, frontends: unsigned long long -> long long

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.9 KB
Line 
1/* $Id: FramebufferVNC.cpp 31698 2010-08-16 15:00:05Z vboxsync $ */
2/** @file
3 * VBoxHeadless - VNC server implementation for VirtualBox.
4 *
5 * Uses LibVNCServer (http://sourceforge.net/projects/libvncserver/)
6 */
7
8/*
9 * Contributed by Ivo Smits <[email protected]>
10 *
11 * Copyright (C) 2006-2007 Oracle Corporation
12 *
13 * This file is part of VirtualBox Open Source Edition (OSE), as
14 * available from http://www.virtualbox.org. This file is free software;
15 * you can redistribute it and/or modify it under the terms of the GNU
16 * General Public License (GPL) as published by the Free Software
17 * Foundation, in version 2 as it comes in the "COPYING" file of the
18 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20 */
21
22#include "FramebufferVNC.h"
23
24#include <iprt/assert.h>
25#include <iprt/mem.h>
26#include <VBox/log.h>
27#include <iprt/param.h>
28#include <iprt/stream.h>
29#include <iprt/thread.h>
30
31#include <png.h>
32#include <rfb/rfb.h>
33
34// constructor / destructor
35/////////////////////////////////////////////////////////////////////////////
36
37/**
38 * Perform parts of initialisation which are guaranteed not to fail
39 * unless we run out of memory. In this case, we just set the guest
40 * buffer to 0 so that RequestResize() does not free it the first time
41 * it is called.
42 */
43VNCFB::VNCFB(ComPtr <IConsole> console, int port, const char *password) :
44 mPixelFormat(FramebufferPixelFormat_Opaque),
45 mBitsPerPixel(0),
46 mBytesPerLine(0),
47 mRGBBuffer(0),
48 mScreenBuffer(0),
49 mVncPort(port),
50 mConsole(console),
51 mKeyboard(0),
52 mMouse(0),
53 mWidth(800), mHeight(600),
54 vncServer(0),
55 mVncPassword(password)
56{
57 LogFlow(("Creating VNC object %p, width=%u, height=%u, port=%u\n",
58 this, mWidth, mHeight, mVncPort));
59}
60
61VNCFB::~VNCFB()
62{
63 LogFlow(("Destroying VNCFB object %p\n", this));
64 RTCritSectDelete(&mCritSect);
65 if (vncServer)
66 {
67 RTStrFree((char*)vncServer->desktopName);
68 if (vncServer->authPasswdData)
69 {
70 char **papszPassword = (char **)vncServer->authPasswdData;
71 vncServer->authPasswdData = NULL;
72 RTMemFree(papszPassword[0]);
73 RTMemFree(papszPassword);
74 }
75 rfbScreenCleanup(vncServer);
76 }
77 RTMemFree(mRGBBuffer);
78 mRGBBuffer = NULL;
79 RTMemFree(mScreenBuffer);
80 mScreenBuffer = NULL;
81}
82
83HRESULT VNCFB::init(const char *pszName)
84{
85 LogFlow(("Initialising VNCFB object %p\n", this));
86 int rc = RTCritSectInit(&mCritSect);
87 AssertReturn(rc == VINF_SUCCESS, E_UNEXPECTED);
88
89 vncServer = rfbGetScreen(0, NULL, mWidth, mHeight, 8, 3, 1);
90 vncServer->screenData = (void*)this;
91 if (mVncPort)
92 vncServer->port = mVncPort;
93 char *pszDesktopName;
94 rc = RTStrAPrintf(&pszDesktopName, "%s - VirtualBox", pszName);
95 if (RT_SUCCESS(rc))
96 vncServer->desktopName = (const char*)pszDesktopName;
97 else
98 vncServer->desktopName = "VirtualBox";
99 if (mVncPassword)
100 {
101 char **papszPasswords = (char **)RTMemAlloc(2 * sizeof(char **));
102 papszPasswords[0] = RTStrDup(mVncPassword);
103 papszPasswords[1] = NULL;
104 vncServer->authPasswdData = papszPasswords;
105 vncServer->passwordCheck = rfbCheckPasswordByList; //Password list based authentication function
106 }
107 else
108 vncServer->authPasswdData = NULL;
109
110 rfbInitServer(vncServer);
111 vncServer->kbdAddEvent = vncKeyboardEvent;
112 vncServer->kbdReleaseAllKeys = vncReleaseKeysEvent;
113 vncServer->ptrAddEvent = vncMouseEvent;
114
115 /* Set the initial framebuffer size */
116 BOOL finished;
117 RequestResize(0, FramebufferPixelFormat_Opaque, NULL, 0, 0, mWidth, mHeight, &finished);
118
119 rc = RTThreadCreate(&mVncThread, vncThreadFn, vncServer,
120 0 /*cbStack*/, RTTHREADTYPE_GUI, 0 /*fFlags*/, "VNC");
121 AssertRCReturn(rc, E_UNEXPECTED);
122
123 return S_OK;
124}
125
126void VNCFB::enableAbsMouse(bool fEnable)
127{
128 fAbsMouseEnabled = fEnable;
129}
130
131DECLCALLBACK(int) VNCFB::vncThreadFn(RTTHREAD hThreadSelf, void *pvUser)
132{
133 rfbRunEventLoop((rfbScreenInfoPtr)pvUser, -1, FALSE);
134 return VINF_SUCCESS;
135}
136
137void VNCFB::vncMouseEvent(int buttonMask, int x, int y, rfbClientPtr cl)
138{
139 ((VNCFB*)(cl->screen->screenData))->handleVncMouseEvent(buttonMask, x, y);
140 rfbDefaultPtrAddEvent(buttonMask, x, y, cl);
141}
142
143void VNCFB::handleVncMouseEvent(int buttonMask, int x, int y)
144{
145 //RTPrintf("VNC mouse: button=%d x=%d y=%d\n", buttonMask, x, y);
146 if (!mMouse)
147 {
148 this->mConsole->COMGETTER(Mouse)(mMouse.asOutParam());
149 if (!mMouse)
150 {
151 RTPrintf("Warning: could not get mouse object!\n");
152 return;
153 }
154 }
155 int dz = 0, buttons = 0;
156 if (buttonMask & 16)
157 dz = 1;
158 else if (buttonMask & 8)
159 dz = -1;
160 if (buttonMask & 1)
161 buttons |= 1;
162 if (buttonMask & 2)
163 buttons |= 4;
164 if (buttonMask & 4)
165 buttons |= 2;
166 if (fAbsMouseEnabled)
167 mMouse->PutMouseEventAbsolute(x, y, dz, 0, buttons);
168 else
169 mMouse->PutMouseEvent(x - mouseX, y - mouseY, dz, 0, buttons);
170 mouseX = x;
171 mouseY = y;
172}
173
174void VNCFB::kbdPutCode(int code)
175{
176 mKeyboard->PutScancode(code);
177}
178
179void VNCFB::kbdSetShift(int state)
180{
181 if (state && !kbdShiftState)
182 {
183 kbdPutCode(0x2a, 1);
184 kbdShiftState = 1;
185 }
186 else if (!state && kbdShiftState)
187 {
188 kbdPutCode(0x2a, 0);
189 kbdShiftState = 0;
190 }
191}
192void VNCFB::kbdPutCode(int code, int down)
193{
194 if (code & 0xff00)
195 kbdPutCode((code >> 8) & 0xff);
196 kbdPutCode((code & 0xff) | (down ? 0 : 0x80));
197}
198
199void VNCFB::kbdPutCodeShift(int shift, int code, int down)
200{
201 if (shift != kbdShiftState)
202 kbdPutCode(0x2a, shift);
203 kbdPutCode(code, down);
204 if (shift != kbdShiftState)
205 kbdPutCode(0x2a, kbdShiftState);
206}
207
208/* Handle VNC keyboard code (X11 compatible?) to AT scancode conversion.
209 * Have tried the code from the SDL frontend, but that didn't work.
210 * Now we're using one lookup table for the lower X11 key codes (ASCII characters)
211 * and a switch() block to handle some special keys. */
212void VNCFB::handleVncKeyboardEvent(int down, int keycode)
213{
214 //RTPrintf("VNC keyboard: down=%d code=%d -> ", down, keycode);
215 if (mKeyboard == NULL)
216 {
217 this->mConsole->COMGETTER(Keyboard)(mKeyboard.asOutParam());
218 if (!mKeyboard)
219 {
220 RTPrintf("Warning: could not get keyboard object!\n");
221 return;
222 }
223 }
224 /* Conversion table for key code range 32-127 (which happen to equal the ASCII codes)
225 * The values in the table differ slightly from the actual scancode values that will be sent,
226 * values 0xe0?? indicate that a 0xe0 scancode will be sent first (extended keys), then code ?? is sent
227 * values 0x01?? indicate that the shift key must be 'down', then ?? is sent
228 * values 0x00?? or 0x?? indicate that the shift key must be 'up', then ?? is sent
229 * values 0x02?? indicate that the shift key can be ignored, and scancode ?? is sent
230 * This is necessary because the VNC protocol sends a shift key sequence, but also
231 * sends the 'shifted' version of the characters. */
232 static int codes_low[] =
233 {
234 //Conversion table for VNC key code range 32-127
235 0x0239, 0x0102, 0x0128, 0x0104, 0x0105, 0x0106, 0x0108, 0x0028, 0x010a, 0x010b, 0x0109, 0x010d, 0x0029, 0x000c, 0x0034, 0x0035, //space, !"#$%&'()*+`-./
236 0x0b, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, //0123456789
237 0x0127, 0x0027, 0x0133, 0x000d, 0x0134, 0x0135, 0x0103, //:;<=>?@
238 0x11e, 0x130, 0x12e, 0x120, 0x112, 0x121, 0x122, 0x123, 0x117, 0x124, 0x125, 0x126, 0x132, 0x131, 0x118, 0x119, 0x110, 0x113, 0x11f, 0x114, 0x116, 0x12f, 0x111, 0x12d, 0x115, 0x12c, //A-Z
239 0x001a, 0x002b, 0x001b, 0x0107, 0x010c, 0x0029, //[\]^_`
240 0x1e, 0x30, 0x2e, 0x20, 0x12, 0x21, 0x22, 0x23, 0x17, 0x24, 0x25, 0x26, 0x32, 0x31, 0x18, 0x19, 0x10, 0x13, 0x1f, 0x14, 0x16, 0x2f, 0x11, 0x2d, 0x15, 0x2c, //a-z
241 0x011a, 0x012b, 0x011b, 0x0129 //{|}~
242 };
243 int shift = -1, code = -1;
244 if (keycode < 32)
245 {
246 //ASCII control codes.. unused..
247 }
248 else if (keycode < 127)
249 {
250 //DEL is in high area
251 code = codes_low[keycode - 32];
252 shift = (code >> 8) & 0x03;
253 if (shift == 0x02 || code & 0xe000)
254 shift = -1;
255 code = code & 0xe0ff;
256 }
257 else if ((keycode & 0xFF00) != 0xFF00)
258 {
259 }
260 else
261 {
262 switch(keycode)
263 {
264/*Numpad keys - these have to be implemented yet
265Todo: numpad arrows, home, pageup, pagedown, end, insert, delete
26665421 Numpad return
267
26865450 Numpad *
26965451 Numpad +
27065453 Numpad -
27165454 Numpad .
27265455 Numpad /
27365457 Numpad 1
27465458 Numpad 2
27565459 Numpad 3
276
27765460 Numpad 4
27865461 Numpad 5
27965462 Numpad 6
28065463 Numpad 7
28165464 Numpad 8
28265465 Numpad 9
28365456 Numpad 0
284*/
285 case 65288: code = 0x0e; break; //Backspace
286 case 65289: code = 0x0f; break; //Tab
287
288 case 65293: code = 0x1c; break; //Return
289 //case 65299: break; Pause/break
290 case 65307: code = 0x01; break; //Escape
291
292 case 65360: code = 0xe047; break; //Home
293 case 65361: code = 0xe04b; break; //Left
294 case 65362: code = 0xe048; break; //Up
295 case 65363: code = 0xe04d; break; //Right
296 case 65364: code = 0xe050; break; //Down
297 case 65365: code = 0xe049; break; //Page up
298 case 65366: code = 0xe051; break; //Page down
299 case 65367: code = 0xe04f; break; //End
300
301 //case 65377: break; //Print screen
302 case 65379: code = 0xe052; break; //Insert
303
304 case 65383: code = 0xe05d; break; //Menu
305
306 case 65470: code = 0x3b; break; //F1
307 case 65471: code = 0x3c; break; //F2
308 case 65472: code = 0x3d; break; //F3
309 case 65473: code = 0x3e; break; //F4
310 case 65474: code = 0x3f; break; //F5
311 case 65475: code = 0x40; break; //F6
312 case 65476: code = 0x41; break; //F7
313 case 65477: code = 0x42; break; //F8
314 case 65478: code = 0x43; break; //F9
315 case 65479: code = 0x44; break; //F10
316 case 65480: code = 0x57; break; //F11
317 case 65481: code = 0x58; break; //F12
318
319 case 65505: shift = down; break; //Shift (left + right)
320 case 65507: code = 0x1d; break; //Left ctrl
321 case 65508: code = 0xe01d; break; //Right ctrl
322 case 65513: code = 0x38; break; //Left Alt
323 case 65514: code = 0xe038; break; //Right Alt
324 case 65515: code = 0xe05b; break; //Left windows key
325 case 65516: code = 0xe05c; break; //Right windows key
326 case 65535: code = 0xe053; break; //Delete
327 default: RTPrintf("VNC unhandled keyboard code: down=%d code=%d\n", down, keycode); break;
328 }
329 }
330 //RTPrintf("down=%d shift=%d code=%d\n", down, shift, code);
331 if (shift != -1 && code != -1)
332 {
333 kbdPutCodeShift(shift, code, down);
334 }
335 else if (shift != -1)
336 {
337 kbdSetShift(shift);
338 }
339 else if (code != -1)
340 {
341 kbdPutCode(code, down);
342 }
343}
344void VNCFB::handleVncKeyboardReleaseEvent()
345{
346 kbdSetShift(0);
347 kbdPutCode(0x1d, 0); //Left ctrl
348 kbdPutCode(0xe01d, 0); //Right ctrl
349 kbdPutCode(0x38, 0); //Left alt
350 kbdPutCode(0xe038, 0); //Right alt
351}
352
353void VNCFB::vncKeyboardEvent(rfbBool down, rfbKeySym keySym, rfbClientPtr cl)
354{
355 ((VNCFB*)(cl->screen->screenData))->handleVncKeyboardEvent(down, keySym);
356}
357
358void VNCFB::vncReleaseKeysEvent(rfbClientPtr cl)
359{
360 //Release modifier keys
361 ((VNCFB*)(cl->screen->screenData))->handleVncKeyboardReleaseEvent();
362}
363
364// IFramebuffer properties
365/////////////////////////////////////////////////////////////////////////////
366/**
367 * Requests a resize of our "screen".
368 *
369 * @returns COM status code
370 * @param pixelFormat Layout of the guest video RAM (i.e. 16, 24,
371 * 32 bpp)
372 * @param vram host context pointer to the guest video RAM,
373 * in case we can cope with the format
374 * @param bitsPerPixel color depth of the guest video RAM
375 * @param bytesPerLine length of a screen line in the guest video RAM
376 * @param w video mode width in pixels
377 * @param h video mode height in pixels
378 * @retval finished set to true if the method is synchronous and
379 * to false otherwise
380 *
381 * This method is called when the guest attempts to resize the virtual
382 * screen. The pointer to the guest's video RAM is supplied in case
383 * the framebuffer can handle the pixel format. If it can't, it should
384 * allocate a memory buffer itself, and the virtual VGA device will copy
385 * the guest VRAM to that in a format we can handle. The
386 * COMGETTER(UsesGuestVRAM) method is used to tell the VGA device which method
387 * we have chosen, and the other COMGETTER methods tell the device about
388 * the layout of our buffer. We currently handle all VRAM layouts except
389 * FramebufferPixelFormat_Opaque (which cannot be handled by
390 * definition).
391 */
392STDMETHODIMP VNCFB::RequestResize(ULONG aScreenId, ULONG pixelFormat,
393 BYTE *vram, ULONG bitsPerPixel,
394 ULONG bytesPerLine,
395 ULONG w, ULONG h, BOOL *finished)
396{
397 NOREF(aScreenId);
398 if (!finished)
399 return E_POINTER;
400
401 /* For now, we are doing things synchronously */
402 *finished = true;
403
404 if (mRGBBuffer)
405 RTMemFree(mRGBBuffer);
406
407 mWidth = w;
408 mHeight = h;
409
410 if (pixelFormat == FramebufferPixelFormat_FOURCC_RGB && bitsPerPixel == 32)
411 {
412 mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
413 mBufferAddress = reinterpret_cast<uint8_t *>(vram);
414 mBytesPerLine = bytesPerLine;
415 mBitsPerPixel = bitsPerPixel;
416 mRGBBuffer = NULL;
417 }
418 else
419 {
420 mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
421 mBytesPerLine = w * 4;
422 mBitsPerPixel = 32;
423 mRGBBuffer = reinterpret_cast<uint8_t *>(RTMemAlloc(mBytesPerLine * h));
424 AssertReturn(mRGBBuffer != 0, E_OUTOFMEMORY);
425 mBufferAddress = mRGBBuffer;
426 }
427
428 uint8_t *oldBuffer = mScreenBuffer;
429 mScreenBuffer = reinterpret_cast<uint8_t *>(RTMemAlloc(mBytesPerLine * h));
430 AssertReturn(mScreenBuffer != 0, E_OUTOFMEMORY);
431
432 for (ULONG i = 0; i < mBytesPerLine * h; i += 4)
433 {
434 mScreenBuffer[i] = mBufferAddress[i+2];
435 mScreenBuffer[i+1] = mBufferAddress[i+1];
436 mScreenBuffer[i+2] = mBufferAddress[i];
437 }
438
439 RTPrintf("Set framebuffer: buffer=%llx w=%lu h=%lu bpp=%d\n",
440 (uint64_t)mBufferAddress, mWidth, mHeight, (int)mBitsPerPixel);
441 rfbNewFramebuffer(vncServer, (char*)mScreenBuffer, mWidth, mHeight, 8, 3, mBitsPerPixel / 8);
442 if (oldBuffer)
443 RTMemFree(oldBuffer);
444 return S_OK;
445}
446
447//Guest framebuffer update notification
448STDMETHODIMP VNCFB::NotifyUpdate(ULONG x, ULONG y, ULONG w, ULONG h)
449{
450 if (!mBufferAddress || !mScreenBuffer)
451 return S_OK;
452 ULONG joff = y * mBytesPerLine + x * 4;
453 for (ULONG j = joff; j < joff + h * mBytesPerLine; j += mBytesPerLine)
454 for (ULONG i = j; i < j + w * 4; i += 4)
455 {
456 mScreenBuffer[i] = mBufferAddress[i+2];
457 mScreenBuffer[i+1] = mBufferAddress[i+1];
458 mScreenBuffer[i+2] = mBufferAddress[i];
459 }
460 rfbMarkRectAsModified(vncServer, x, y, x+w, y+h);
461 return S_OK;
462}
463
464
465/**
466 * Return the address of the frame buffer for the virtual VGA device to
467 * write to. If COMGETTER(UsesGuestVRAM) returns FLASE (or if this address
468 * is not the same as the guests VRAM buffer), the device will perform
469 * translation.
470 *
471 * @returns COM status code
472 * @retval address The address of the buffer
473 */
474STDMETHODIMP VNCFB::COMGETTER(Address) (BYTE **address)
475{
476 if (!address)
477 return E_POINTER;
478 LogFlow(("FFmpeg::COMGETTER(Address): returning address %p\n", mBufferAddress));
479 *address = mBufferAddress;
480 return S_OK;
481}
482
483/**
484 * Return the width of our frame buffer.
485 *
486 * @returns COM status code
487 * @retval width The width of the frame buffer
488 */
489STDMETHODIMP VNCFB::COMGETTER(Width) (ULONG *width)
490{
491 if (!width)
492 return E_POINTER;
493 LogFlow(("FFmpeg::COMGETTER(Width): returning width %lu\n", (unsigned long) mWidth));
494 *width = mWidth;
495 return S_OK;
496}
497
498/**
499 * Return the height of our frame buffer.
500 *
501 * @returns COM status code
502 * @retval height The height of the frame buffer
503 */
504STDMETHODIMP VNCFB::COMGETTER(Height) (ULONG *height)
505{
506 if (!height)
507 return E_POINTER;
508 LogFlow(("FFmpeg::COMGETTER(Height): returning height %lu\n", (unsigned long) mHeight));
509 *height = mHeight;
510 return S_OK;
511}
512
513/**
514 * Return the colour depth of our frame buffer. Note that we actually
515 * store the pixel format, not the colour depth internally, since
516 * when display sets FramebufferPixelFormat_Opaque, it
517 * wants to retreive FramebufferPixelFormat_Opaque and
518 * nothing else.
519 *
520 * @returns COM status code
521 * @retval bitsPerPixel The colour depth of the frame buffer
522 */
523STDMETHODIMP VNCFB::COMGETTER(BitsPerPixel) (ULONG *bitsPerPixel)
524{
525 if (!bitsPerPixel)
526 return E_POINTER;
527 *bitsPerPixel = mBitsPerPixel;
528 LogFlow(("FFmpeg::COMGETTER(BitsPerPixel): returning depth %lu\n",
529 (unsigned long) *bitsPerPixel));
530 return S_OK;
531}
532
533/**
534 * Return the number of bytes per line in our frame buffer.
535 *
536 * @returns COM status code
537 * @retval bytesPerLine The number of bytes per line
538 */
539STDMETHODIMP VNCFB::COMGETTER(BytesPerLine) (ULONG *bytesPerLine)
540{
541 if (!bytesPerLine)
542 return E_POINTER;
543 LogFlow(("FFmpeg::COMGETTER(BytesPerLine): returning line size %lu\n", (unsigned long) mBytesPerLine));
544 *bytesPerLine = mBytesPerLine;
545 return S_OK;
546}
547
548/**
549 * Return the pixel layout of our frame buffer.
550 *
551 * @returns COM status code
552 * @retval pixelFormat The pixel layout
553 */
554STDMETHODIMP VNCFB::COMGETTER(PixelFormat) (ULONG *pixelFormat)
555{
556 if (!pixelFormat)
557 return E_POINTER;
558 LogFlow(("FFmpeg::COMGETTER(PixelFormat): returning pixel format: %lu\n", (unsigned long) mPixelFormat));
559 *pixelFormat = mPixelFormat;
560 return S_OK;
561}
562
563/**
564 * Return whether we use the guest VRAM directly.
565 *
566 * @returns COM status code
567 * @retval pixelFormat The pixel layout
568 */
569STDMETHODIMP VNCFB::COMGETTER(UsesGuestVRAM) (BOOL *usesGuestVRAM)
570{
571 if (!usesGuestVRAM)
572 return E_POINTER;
573 LogFlow(("FFmpeg::COMGETTER(UsesGuestVRAM): uses guest VRAM? %d\n", mRGBBuffer == NULL));
574 *usesGuestVRAM = (mRGBBuffer == NULL);
575 return S_OK;
576}
577
578/**
579 * Return the number of lines of our frame buffer which can not be used
580 * (e.g. for status lines etc?).
581 *
582 * @returns COM status code
583 * @retval heightReduction The number of unused lines
584 */
585STDMETHODIMP VNCFB::COMGETTER(HeightReduction) (ULONG *heightReduction)
586{
587 if (!heightReduction)
588 return E_POINTER;
589 /* no reduction */
590 *heightReduction = 0;
591 LogFlow(("FFmpeg::COMGETTER(HeightReduction): returning 0\n"));
592 return S_OK;
593}
594
595/**
596 * Return a pointer to the alpha-blended overlay used to render status icons
597 * etc above the framebuffer.
598 *
599 * @returns COM status code
600 * @retval aOverlay The overlay framebuffer
601 */
602STDMETHODIMP VNCFB::COMGETTER(Overlay) (IFramebufferOverlay **aOverlay)
603{
604 if (!aOverlay)
605 return E_POINTER;
606 /* not yet implemented */
607 *aOverlay = 0;
608 LogFlow(("FFmpeg::COMGETTER(Overlay): returning 0\n"));
609 return S_OK;
610}
611
612/**
613 * Return id of associated window
614 *
615 * @returns COM status code
616 * @retval winId Associated window id
617 */
618STDMETHODIMP VNCFB::COMGETTER(WinId) (LONG64 *winId)
619{
620 if (!winId)
621 return E_POINTER;
622 *winId = 0;
623 return S_OK;
624}
625
626// IFramebuffer methods
627/////////////////////////////////////////////////////////////////////////////
628
629STDMETHODIMP VNCFB::Lock()
630{
631 LogFlow(("VNCFB::Lock: called\n"));
632 int rc = RTCritSectEnter(&mCritSect);
633 AssertRC(rc);
634 if (rc == VINF_SUCCESS)
635 return S_OK;
636 return E_UNEXPECTED;
637}
638
639STDMETHODIMP VNCFB::Unlock()
640{
641 LogFlow(("VNCFB::Unlock: called\n"));
642 RTCritSectLeave(&mCritSect);
643 return S_OK;
644}
645
646/**
647 * Returns whether we like the given video mode.
648 *
649 * @returns COM status code
650 */
651STDMETHODIMP VNCFB::VideoModeSupported(ULONG width, ULONG height, ULONG bpp, BOOL *supported)
652{
653 if (!supported)
654 return E_POINTER;
655 *supported = true;
656 return S_OK;
657}
658
659/** Stubbed */
660STDMETHODIMP VNCFB::GetVisibleRegion(BYTE *rectangles, ULONG /* count */, ULONG * /* countCopied */)
661{
662 if (!rectangles)
663 return E_POINTER;
664 *rectangles = 0;
665 return S_OK;
666}
667
668/** Stubbed */
669STDMETHODIMP VNCFB::SetVisibleRegion(BYTE *rectangles, ULONG /* count */)
670{
671 if (!rectangles)
672 return E_POINTER;
673 return S_OK;
674}
675
676STDMETHODIMP VNCFB::ProcessVHWACommand(BYTE *pCommand)
677{
678 return E_NOTIMPL;
679}
680
681#ifdef VBOX_WITH_XPCOM
682NS_DECL_CLASSINFO(VNCFB)
683NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VNCFB, IFramebuffer)
684#endif
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