62 lines
1.5 KiB
C
62 lines
1.5 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <memory>
|
||
|
|
#include <functional>
|
||
|
|
#include <vector>
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
namespace scar {
|
||
|
|
|
||
|
|
enum class ScreenCaptureBackend {
|
||
|
|
FFMPEG_X11, // X11 via ffmpeg
|
||
|
|
FFMPEG_WAYLAND, // Wayland via ffmpeg + portal
|
||
|
|
FFMPEG_WINDOWS, // Windows GDI via ffmpeg
|
||
|
|
PORTAL_PIPEWIRE // xdg-desktop-portal + Pipewire (Wayland/Hyprland)
|
||
|
|
};
|
||
|
|
|
||
|
|
// Screen capture supporting multiple backends
|
||
|
|
class ScreenCapture {
|
||
|
|
public:
|
||
|
|
ScreenCapture();
|
||
|
|
~ScreenCapture();
|
||
|
|
|
||
|
|
// Auto-detect and start screen capture
|
||
|
|
bool start();
|
||
|
|
|
||
|
|
// Start with specific backend
|
||
|
|
bool start(ScreenCaptureBackend backend);
|
||
|
|
|
||
|
|
// Stop capturing
|
||
|
|
void stop();
|
||
|
|
|
||
|
|
// Check if currently capturing
|
||
|
|
bool isCapturing() const { return capturing_; }
|
||
|
|
|
||
|
|
// Set frame callback
|
||
|
|
using FrameCallback = std::function<void(const std::vector<uint8_t>& frameData, int width, int height)>;
|
||
|
|
void setFrameCallback(FrameCallback callback);
|
||
|
|
|
||
|
|
private:
|
||
|
|
ScreenCaptureBackend detectBestBackend();
|
||
|
|
|
||
|
|
bool startX11Capture();
|
||
|
|
bool startWaylandCapture();
|
||
|
|
bool startWindowsCapture();
|
||
|
|
bool startPortalCapture();
|
||
|
|
|
||
|
|
bool capturing_;
|
||
|
|
ScreenCaptureBackend backend_;
|
||
|
|
FrameCallback frameCallback_;
|
||
|
|
|
||
|
|
// TODO: FFmpeg-specific members
|
||
|
|
// AVFormatContext* formatCtx_;
|
||
|
|
// AVCodecContext* codecCtx_;
|
||
|
|
// AVFrame* frame_;
|
||
|
|
|
||
|
|
// TODO: DBus/Portal-specific members for Wayland
|
||
|
|
// DBusConnection* dbusConn_;
|
||
|
|
// pw_stream* pipewireStream_;
|
||
|
|
};
|
||
|
|
|
||
|
|
} // namespace scar
|