增加扩展屏的框架
This commit is contained in:
64
demo/windows_sender/IddBridge.h
Normal file
64
demo/windows_sender/IddBridge.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <wrl/client.h>
|
||||
#include <windows.h>
|
||||
#include <cstdint>
|
||||
|
||||
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<ID3D11Texture2D>& texture);
|
||||
void ReleaseFrame();
|
||||
ID3D11Device* GetDevice() const { return device_.Get(); }
|
||||
ID3D11DeviceContext* GetContext() const { return context_.Get(); }
|
||||
|
||||
private:
|
||||
bool EnsureTexture(int width, int height);
|
||||
|
||||
ComPtr<ID3D11Device> device_;
|
||||
ComPtr<ID3D11DeviceContext> context_;
|
||||
ComPtr<ID3D11Texture2D> 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;
|
||||
};
|
||||
Reference in New Issue
Block a user