Access to a VM screen.

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
siuks24
Posts: 12
Joined: 28. Mar 2019, 18:04

Access to a VM screen.

Post by siuks24 »

Hi everyone,
I'm trying to write the program which will have direct access to the screen of VM. I would like to gain every frames/updates of the frame from VM and I would like to process it by my own application.
I'm using C/C++ to writing the application. I expect 30-60 FPS in FullHD resolution. I tried to do it using function IDisplay_TakeScreenShotToArray() but in FullHD resolution, I get only 8 FPS with is too low value for me.
I found the source code(link in next post because of forum policy) of application witch scanning memory of VirtualBox and looking for a place when framebuffer is allocated, but it's a complicated way to do easy thing IMHO. I'm pretty sure that exist other, better way to do it.
So, is any way to gain direct access to the VM screen or exist other more effective function/way to grab screen content?
siuks24
Posts: 12
Joined: 28. Mar 2019, 18:04

Re: Access to a VM screen.

Post by siuks24 »

lxndr0
Posts: 1
Joined: 2. Apr 2019, 13:06

Re: Access to a VM screen.

Post by lxndr0 »

Hi,

I am trying to do the same thing, but in addition to this I do need audio. I am using C.

What I did already:

1. Using Remote Desktop Protocol (RDP) Server of VirtualBox and connecting to it from my program (I used Java). That works fine for screen and audio, but it is very slow.

2. Using VirtualBox API and IDisplay_TakeScreenShotToArray(). That's easy to implement, but it's slow and I don't find audio functions in the API.
Is it possible to get an audio stream by API?

3. Using Linux as guest, it is possible to grab the desktop by X-Window function XGetImage(). That's fast, but there seems to be no fast way to get the image data out of VirtualBox guest and therefore I did use a socket connection - that's not a good and fast solution.

Unfortunately I am not an experienced C or C++ programmer. That's why I can't check this quickly: Could it be possible to use or change something in the video/audio-recording functions of VirtualBox? Is it possible not to write an encoded and compressed video to disk, but instead raw data to shared memory?

Thanks in advance!
siuks24
Posts: 12
Joined: 28. Mar 2019, 18:04

Re: Access to a VM screen.

Post by siuks24 »

to get access to framebuffer I'm trying to use function "IDisplaySourceBitmap::queryBitmapInfo()" but I get an error 0x8000ffff. In the documentation I found information:

"Warning
This method is non-scriptable. In particular, this also means that an attempt to call it from a process other than the process that has created and owns the object will most likely fail or
crash your application."

How can I use this function from the level of my application?
I start virtual machines using the function "IMachine::launchVMProcess()" but, if I understand correctly, machines starting in another process. It cause that function "IDisplaySourceBitmap::queryBitmapInfo()" give me an error right?
Does anyone know how to use this function correctly?
siuks24
Posts: 12
Joined: 28. Mar 2019, 18:04

Re: Access to a VM screen.

Post by siuks24 »

to gain direct access to framebuffer i use:

Pseudocode:

Code: Select all

class MyFramebuffer : public IFramebuffer
{"I overridden all functions and added several of mine"};

...

machine->LockMachne(session, LockType::VM);
session-> GetConsole(&console);
console->GetDisplay(&display);
MyFrameBuffer myFramebuffer;
display->AttachFramebuffer(0, myFramebuffer, &retUUID);
console->powerUp();
...
I added several functions to my class of frame-buffer and in this way I gain direct access to screen.
Now I'm working on connect my own frame-buffer to working virtual machine. I have problem because if I want to attach my frame-buffer, I have to detach old one.
It makes some problems because for detaching frame-buffer is function IDisplay::DetachFramebuffer(in unsigned long screenId, in wstringUUID id).
This function needs two arguments id of screen and UUID. My question is: how to gain UUID of attached frame-buffer? UUID is necessary for detach frame-buffer but I don't know how to get it.
IFramebuffer has no getter which can give me it.
Post Reply