48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
#include "speaker/ffmpeg_speaker/include/ffmpeg_ptr.h"
|
|
|
|
namespace cmvr::device {
|
|
|
|
struct FfmpegEncoderInfo {
|
|
std::string codec_name;
|
|
int width = 0;
|
|
int height = 0;
|
|
int fps = 0;
|
|
int64_t frame_pts = 0;
|
|
bool bRunning = false;
|
|
AVCodecContext* codec_context = nullptr;
|
|
AVFrame* frame = nullptr;
|
|
AVPacket* packet = nullptr;
|
|
SwsContext* sws_context = nullptr;
|
|
|
|
~FfmpegEncoderInfo();
|
|
};
|
|
|
|
struct CameraStreamEncodeOptions {
|
|
bool draw_timestamp = false;
|
|
};
|
|
|
|
class CameraStreamEncoder {
|
|
public:
|
|
static bool init(std::shared_ptr<FfmpegEncoderInfo>& encoder,
|
|
const std::string& codec_name,
|
|
int width,
|
|
int height,
|
|
int fps);
|
|
|
|
static bool encode(std::shared_ptr<FfmpegEncoderInfo>& encoder,
|
|
const cv::Mat& frame,
|
|
std::vector<uint8_t>& encoded_frame,
|
|
bool& is_key,
|
|
const CameraStreamEncodeOptions& options = {});
|
|
};
|
|
|
|
} // namespace cmvr::device
|