2024-06-19 06:35:05 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* 拉流engine
|
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef INC_CAMERAENGINE_H
|
|
|
|
|
|
#define INC_CAMERAENGINE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
#include "AppCommon.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//编译器这部分代码按C语言(而不是C++)的方式进行编译
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
extern "C"
|
|
|
|
|
|
{
|
|
|
|
|
|
#endif // #ifdef __cplusplus
|
|
|
|
|
|
|
|
|
|
|
|
#include "libavutil/imgutils.h"
|
|
|
|
|
|
#include "libavutil/samplefmt.h"
|
|
|
|
|
|
#include "libavformat/avformat.h"
|
|
|
|
|
|
#include "libavcodec/avcodec.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif // #ifdef __cplusplus
|
|
|
|
|
|
|
|
|
|
|
|
#include "EngineBase.h"
|
|
|
|
|
|
#include "EngineFactory.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "MyYaml.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
|
{
|
|
|
|
|
|
int64_t i64Timeout;
|
|
|
|
|
|
} TimeoutContext;
|
|
|
|
|
|
|
|
|
|
|
|
//#define RTSP_PULL_CAMERA_VIDEO_STREAM
|
|
|
|
|
|
class CameraEngine : public ai_matrix::EngineBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CameraEngine();
|
|
|
|
|
|
~CameraEngine();
|
|
|
|
|
|
|
|
|
|
|
|
APP_ERROR Init() override;
|
|
|
|
|
|
APP_ERROR DeInit() override;
|
|
|
|
|
|
APP_ERROR Process() override;
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
AVFormatContext *CreateFormatContext();
|
|
|
|
|
|
APP_ERROR GetStreamInfo();
|
|
|
|
|
|
APP_ERROR ConnectCamera(); //连接相机
|
|
|
|
|
|
void ResetCamera(); //复位相机连接
|
2024-06-19 06:41:40 +00:00
|
|
|
|
static int InterruptCallback(void *pData);
|
2024-06-19 06:35:05 +00:00
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
AVFormatContext *pFormatCtx_ = nullptr;
|
|
|
|
|
|
int iVideoStream_ = 0;
|
|
|
|
|
|
bool bUseEngine_;
|
|
|
|
|
|
ai_matrix::DataSourceConfig dataSourceConfig_;
|
|
|
|
|
|
FrameInfo frameInfo_;
|
|
|
|
|
|
bool bReconnectFlag_ = false; //默认不重连相机
|
|
|
|
|
|
std::string strPort0_;
|
|
|
|
|
|
std::string strPort1_;
|
|
|
|
|
|
bool bHwDecode_;
|
|
|
|
|
|
int nDelayTime;
|
|
|
|
|
|
bool bIsAvc_ = false;
|
|
|
|
|
|
int iAudioStream_ = -1;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ENGINE_REGIST(CameraEngine)
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|