diff --git a/agent/src/main.cpp b/agent/src/main.cpp index 5825508..3be90d9 100755 --- a/agent/src/main.cpp +++ b/agent/src/main.cpp @@ -16,6 +16,13 @@ int main(int argc, char** argv) { hazelnut::IvshmemDevice dev; + // Create a capture interface + auto pCaptureInterface = hazelnut::CreateDisplayCapture(hazelnut::GuessBestCaptureInterface()); + if(!pCaptureInterface) { + printf("Failed to create a capture interface\n"); + return 1; + } + if(!dev.Open()) { printf("Failed to open ivshmem device\n"); return 1; @@ -29,56 +36,29 @@ int main(int argc, char** argv) { // wipe the first 1mb memset(&ptr[0], 0, 1 * (1024 * 1024)); - printf("wiped memory\n"); - - // sex + // initalize laid-out IVSHMEM structs auto* pHeader = new(&ptr[0]) hazelnut::IvshHeader {}; auto* pFrameHeader = new(&ptr[0x1000]) hazelnut::FrameHeader {}; - // reset pingpong counter - + // Reset session ID pHeader->serverSessionId.store(rand()); - // Create a capture interface - auto capture = hazelnut::CreateDisplayCapture(hazelnut::GuessBestCaptureInterface()); - if(!capture) { - printf("Failed to create a capture interface\n"); - return 1; - } + printf("Agent loop starting\n"); - printf("Successfully created a framebuffer capture interface\n"); - - bool firstFrame = true; hazelnut::FramebufferInformation framebuffer {}; hazelnut::DiffInformation diff {}; while(true) { - bool changed = false; { auto guard = pHeader->lock.lock(); - - auto result = capture->CaptureFrameTemp(pFrameHeader->bits()); + auto result = pCaptureInterface->CaptureFrameTemp(pFrameHeader->bits()); if(result == hazelnut::DisplayCaptureResult::Ok) { - if(firstFrame == false) { - for(u32 y = 0; y < diff.diffMapHeight; ++y) { - for(u32 x = 0; x < diff.diffmapWidth; ++x) { - auto& bl = diff.pDiffMap[y * diff.diffmapWidth + x]; - if(bl != 0) { - changed = true; - } - } - } - - if(!changed) - continue; - } + // Do nothing. } else if(result == hazelnut::DisplayCaptureResult::OkButResized) { // We resized. Notify of that - framebuffer = capture->GetFramebufferInformation(); - diff = capture->GetDiffInformation(); - firstFrame = true; - + framebuffer = pCaptureInterface->GetFramebufferInformation(); + diff = pCaptureInterface->GetDiffInformation(); } else { printf("Failed to capture\n"); break; @@ -87,13 +67,6 @@ int main(int argc, char** argv) { pFrameHeader->serial.fetch_add(1); pFrameHeader->width.store(framebuffer.width); pFrameHeader->height.store(framebuffer.height); - - // memcpy(pFrameHeader->bits(), &framebuffer.pFramebuffer[0], (framebuffer.width * framebuffer.height) * 4); - - // printf("FRAME SERIAL %u loaded\n", pFrameHeader->serial.load()); - - if(firstFrame) - firstFrame = false; } } diff --git a/shared/README.md b/shared/README.md index b369858..f0b71f7 100644 --- a/shared/README.md +++ b/shared/README.md @@ -1,3 +1,5 @@ # shared code -This is shared between the two ends. It is cross platform C++20. \ No newline at end of file +This is all of the things shared between the agent and client ends. + +It is cross platform C++20. \ No newline at end of file