45a46
> #include <sys/stat.h>
46a48,49
> #include <sys/types.h>
> #include <fcntl.h>
54a58
> #include "base/bitmap.hh"
55a60
> #include "base/output.hh"
59a65
> #include "sim/core.hh"
101c107,108
< vc(NULL)
---
> vc(NULL), captureEnabled(p->frame_capture), captureCurrentFrame(0),
> captureLastHash(0), captureBitmap(0)
108d114
<
123a130,137
> if (captureEnabled) {
> // remove existing frame output directory if it exists, then create a
> // clean empty directory
> const string FRAME_OUTPUT_SUBDIR = "frames_" + name();
> simout.remove(FRAME_OUTPUT_SUBDIR, true);
> captureOutputDirectory = simout.createSubdirectory(
> FRAME_OUTPUT_SUBDIR);
> }
688a703,712
> if (captureEnabled) {
> // create bitmap of the frame with new attributes
> if (captureBitmap)
> delete captureBitmap;
>
> assert(clientRfb);
> captureBitmap = new Bitmap(videoMode, width, height, clientRfb);
> assert(captureBitmap);
> }
>
704a729,754
>
> void
> VncServer::captureFrameBuffer()
> {
> assert(captureBitmap);
>
> // skip identical frames
> uint64_t new_hash = captureBitmap->getHash();
> if (captureLastHash == new_hash)
> return;
> captureLastHash = new_hash;
>
> // get the filename for the current frame
> char frameFilenameBuffer[64];
> snprintf(frameFilenameBuffer, 64, "fb.%06d.%lld.bmp.gz",
> captureCurrentFrame, static_cast<long long int>(curTick()));
> const string frameFilename(frameFilenameBuffer);
>
> // create the compressed framebuffer file
> ostream *fb_out = simout.create(captureOutputDirectory + frameFilename,
> true);
> captureBitmap->write(fb_out);
> simout.close(fb_out);
>
> ++captureCurrentFrame;
> }