#include #include #include #include #include #include "VideoPlayer.h" #include "X11Window.h" int main(int argc, char* argv[]) { if (argc < 2) { std::cerr << "Usage: " << argv[0] << " " << std::endl; return -1; } // Initialize the VideoPlayer with the provided video path VideoPlayer videoPlayer(argv[1]); uint8_t* frameData = nullptr; int width = 0, height = 0; // Lambda for rendering a frame auto renderFrame = [&](Display* display, Window window, GC gc) { if (videoPlayer.getNextFrame(frameData, width, height)) { // Create XImage using BGRA data from VideoPlayer XImage* xImage = XCreateImage( display, DefaultVisual(display, DefaultScreen(display)), 24, // depth ZPixmap, 0, reinterpret_cast(frameData), width, height, 32, width * 4 ); if (!xImage) { std::cerr << "Error creating XImage from frame data." << std::endl; return; } XPutImage(display, window, gc, xImage, 0, 0, 0, 0, width, height); XFlush(display); // Clean up the XImage resource, not the frameData XDestroyImage(xImage); // Wait ~25 FPS usleep(40000); } }; // Create the X11 window and run the event loop X11Window window(640, 480, renderFrame); window.run(); return 0; }