#pragma once #include #include #include #include using Microsoft::WRL::ComPtr; struct IddSharedHeader { uint32_t width; uint32_t height; uint32_t format; // 0 = BGRA32 uint32_t stride; // bytes per row uint64_t timestamp; uint32_t frameId; uint32_t dataSize; }; class IddBridge { public: IddBridge(); ~IddBridge(); bool Initialize(); bool CaptureFrame(ComPtr& texture); void ReleaseFrame(); ID3D11Device* GetDevice() const { return device_.Get(); } ID3D11DeviceContext* GetContext() const { return context_.Get(); } private: bool EnsureTexture(int width, int height); ComPtr device_; ComPtr context_; ComPtr gpuTexture_; bool frame_acquired_ = false; HANDLE hMap_ = nullptr; HANDLE hReadyEvent_ = nullptr; HANDLE hConsumedEvent_ = nullptr; uint8_t* shared_ = nullptr; size_t shared_size_ = 0; int tex_width_ = 0; int tex_height_ = 0; }; class IddProducer { public: IddProducer(); ~IddProducer(); bool Initialize(); // Submit a frame. Data should be BGRA32. bool SubmitFrame(const void* data, uint32_t width, uint32_t height, uint32_t stride); private: HANDLE hMap_ = nullptr; HANDLE hReadyEvent_ = nullptr; HANDLE hConsumedEvent_ = nullptr; uint8_t* shared_ = nullptr; size_t shared_size_ = 0; uint32_t frameId_ = 0; };