增加扩展屏的框架

This commit is contained in:
huanglinhuan
2025-12-22 13:48:06 +08:00
parent 1bf30d3c4c
commit 065251f727
13 changed files with 834 additions and 28 deletions

View File

@@ -5,12 +5,14 @@
#include <vector>
#include <cstdint>
#ifndef NO_FFMPEG
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/imgutils.h>
#include <libavutil/opt.h>
#include <libswscale/swscale.h>
}
#endif
using Microsoft::WRL::ComPtr;
@@ -20,17 +22,26 @@ public:
~VideoEncoder();
bool Initialize(ID3D11Device* device, int width, int height, int fps, int bitrate);
bool Reinitialize(int width, int height, int fps, int bitrate);
bool EncodeFrame(ID3D11Texture2D* texture, std::vector<uint8_t>& outputData, bool& isKeyFrame);
void Release();
private:
ID3D11Device* device_ = nullptr;
ID3D11DeviceContext* context_ = nullptr;
ComPtr<ID3D11Texture2D> stagingTexture_;
#ifndef NO_FFMPEG
AVCodecContext* codecContext_ = nullptr;
AVFrame* frame_ = nullptr;
AVPacket* packet_ = nullptr;
SwsContext* swsContext_ = nullptr;
#else
void* codecContext_ = nullptr;
void* frame_ = nullptr;
void* packet_ = nullptr;
void* swsContext_ = nullptr;
#endif
int width_ = 0;
int height_ = 0;