generated from zhangwei/Matrixai
72 lines
1.4 KiB
C
72 lines
1.4 KiB
C
|
|
/**
|
|||
|
|
* 拉流engine
|
|||
|
|
* */
|
|||
|
|
|
|||
|
|
#ifndef INC_VIDEOENGINE_H
|
|||
|
|
#define INC_VIDEOENGINE_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"
|
|||
|
|
|
|||
|
|
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
int64_t i64Timeout;
|
|||
|
|
} TimeoutContext;
|
|||
|
|
|
|||
|
|
//#define RTSP_PULL_CAMERA_VIDEO_STREAM
|
|||
|
|
class VideoEngine : public ai_matrix::EngineBase
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
VideoEngine();
|
|||
|
|
~VideoEngine();
|
|||
|
|
|
|||
|
|
APP_ERROR Init() override;
|
|||
|
|
APP_ERROR DeInit() override;
|
|||
|
|
APP_ERROR Process() override;
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
AVFormatContext *CreateFormatContext();
|
|||
|
|
APP_ERROR GetStreamInfo();
|
|||
|
|
APP_ERROR ConnectCamera(); //连接相机
|
|||
|
|
void ResetCamera(); //复位相机连接
|
|||
|
|
//static int InterruptCallback(void *pData);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
AVFormatContext *pFormatCtx_ = nullptr;
|
|||
|
|
AVCodecParameters *pCodecParameters_ = nullptr;
|
|||
|
|
int iVideoStream_ = 0;
|
|||
|
|
bool bIsAvc_ = false;
|
|||
|
|
int iAudioStream_ = -1;
|
|||
|
|
|
|||
|
|
ai_matrix::DataSourceConfig dataSourceConfig_;
|
|||
|
|
DataSourceInfo frameInfo_;
|
|||
|
|
bool bConnectFlag_ = true; //默认不重连相机
|
|||
|
|
std::string strPort0_;
|
|||
|
|
std::string strPort1_;
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
ENGINE_REGIST(VideoEngine)
|
|||
|
|
|
|||
|
|
#endif
|