1 Star 0 Fork 3

jeremy/hi3516dv300-rtsp-h264

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sample_comm_sys.c 21.55 KB
一键复制 编辑 原始数据 按行查看 历史
rinetd 提交于 2019-12-03 18:18 . imx335
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/time.h>
#include <fcntl.h>
#include <errno.h>
#include <pthread.h>
#include <math.h>
#include <unistd.h>
#include <signal.h>
#include <sys/mman.h>
#include "sample_comm.h"
static HI_S32 s_s32SampleMemDev = -1;
#define SAMPLE_MEM_DEV_OPEN if (s_s32SampleMemDev <= 0)\
{\
s_s32SampleMemDev = open("/dev/mem", O_RDWR|O_SYNC);\
if (s_s32SampleMemDev < 0)\
{\
perror("Open dev/mem error");\
return NULL;\
}\
}\
HI_VOID * SAMPLE_SYS_IOMmap(HI_U64 u64PhyAddr, HI_U32 u32Size)
{
HI_U32 u32Diff;
HI_U64 u64PagePhy;
HI_U8 * pPageAddr;
HI_UL ulPageSize;
SAMPLE_MEM_DEV_OPEN;
/**********************************************************
PageSize will be 0 when u32size is 0 and u32Diff is 0,
and then mmap will be error (error: Invalid argument)
***********************************************************/
if (!u32Size)
{
printf("Func: %s u32Size can't be 0.\n", __FUNCTION__);
return NULL;
}
/* The mmap address should align with page */
u64PagePhy = u64PhyAddr & 0xfffffffffffff000ULL;
u32Diff = u64PhyAddr - u64PagePhy;
/* The mmap size shuld be mutliples of 1024 */
ulPageSize = ((u32Size + u32Diff - 1) & 0xfffff000UL) + 0x1000;
pPageAddr = mmap ((void *)0, ulPageSize, PROT_READ|PROT_WRITE,
MAP_SHARED, s_s32SampleMemDev, u64PagePhy);
if (MAP_FAILED == pPageAddr )
{
perror("mmap error");
return NULL;
}
return (HI_VOID *) (pPageAddr + u32Diff);
}
HI_S32 SAMPLE_SYS_Munmap(HI_VOID* pVirAddr, HI_U32 u32Size)
{
HI_U64 u64PageAddr;
HI_U32 u32PageSize;
HI_U32 u32Diff;
u64PageAddr = (((HI_UL)pVirAddr) & 0xfffffffffffff000ULL);
u32Diff = (HI_UL)pVirAddr - u64PageAddr;
u32PageSize = ((u32Size + u32Diff - 1) & 0xfffff000UL) + 0x1000;
return munmap((HI_VOID*)(HI_UL)u64PageAddr, u32PageSize);
}
HI_S32 SAMPLE_SYS_SetReg(HI_U64 u64Addr, HI_U32 u32Value)
{
HI_U32 *pu32RegAddr = NULL;
HI_U32 u32MapLen = sizeof(u32Value);
pu32RegAddr = (HI_U32 *)SAMPLE_SYS_IOMmap(u64Addr, u32MapLen);
if(NULL == pu32RegAddr)
{
return HI_FAILURE;
}
*pu32RegAddr = u32Value;
return SAMPLE_SYS_Munmap(pu32RegAddr, u32MapLen);
}
HI_S32 SAMPLE_SYS_GetReg(HI_U64 u64Addr, HI_U32 *pu32Value)
{
HI_U32 *pu32RegAddr = NULL;
HI_U32 u32MapLen;
if (NULL == pu32Value)
{
return HI_ERR_SYS_NULL_PTR;
}
u32MapLen = sizeof(*pu32Value);
pu32RegAddr = (HI_U32 *)SAMPLE_SYS_IOMmap(u64Addr, u32MapLen);
if(NULL == pu32RegAddr)
{
return HI_FAILURE;
}
*pu32Value = *pu32RegAddr;
return SAMPLE_SYS_Munmap(pu32RegAddr, u32MapLen);
}
/******************************************************************************
* function : get picture size(w*h), according enPicSize
******************************************************************************/
HI_S32 SAMPLE_COMM_SYS_GetPicSize(PIC_SIZE_E enPicSize, SIZE_S* pstSize)
{
switch (enPicSize)
{
case PIC_CIF: /* 352 * 288 */
pstSize->u32Width = 352;
pstSize->u32Height = 288;
break;
case PIC_360P: /* 640 * 360 */
pstSize->u32Width = 640;
pstSize->u32Height = 360;
break;
case PIC_D1_PAL: /* 720 * 576 */
pstSize->u32Width = 720;
pstSize->u32Height = 576;
break;
case PIC_D1_NTSC: /* 720 * 480 */
pstSize->u32Width = 720;
pstSize->u32Height = 480;
break;
case PIC_720P: /* 1280 * 720 */
pstSize->u32Width = 1280;
pstSize->u32Height = 720;
break;
case PIC_1080P: /* 1920 * 1080 */
pstSize->u32Width = 1920;
pstSize->u32Height = 1080;
break;
case PIC_2592x1520:
pstSize->u32Width = 2592;
pstSize->u32Height = 1520;
break;
case PIC_2592x1944:
pstSize->u32Width = 2592;
pstSize->u32Height = 1944;
break;
case PIC_2592x1536:
pstSize->u32Width = 2592;
pstSize->u32Height = 1536;
break;
case PIC_2716x1524:
pstSize->u32Width = 2716;
pstSize->u32Height = 1524;
break;
case PIC_3840x2160:
pstSize->u32Width = 3840;
pstSize->u32Height = 2160;
break;
case PIC_3000x3000:
pstSize->u32Width = 3000;
pstSize->u32Height = 3000;
break;
case PIC_4000x3000:
pstSize->u32Width = 4000;
pstSize->u32Height = 3000;
break;
case PIC_4096x2160:
pstSize->u32Width = 4096;
pstSize->u32Height = 2160;
break;
case PIC_7680x4320:
pstSize->u32Width = 7680;
pstSize->u32Height = 4320;
break;
case PIC_3840x8640:
pstSize->u32Width = 3840;
pstSize->u32Height = 8640;
break;
case PIC_2688x1536:
pstSize->u32Width = 2688;
pstSize->u32Height = 1536;
break;
default:
return HI_FAILURE;
}
return HI_SUCCESS;
}
/******************************************************************************
* function : Set system memory location
******************************************************************************/
HI_S32 SAMPLE_COMM_SYS_MemConfig(HI_VOID)
{
HI_S32 i, j;
HI_S32 s32Ret = HI_SUCCESS;
HI_CHAR* pcMmzName = NULL;
MPP_CHN_S stMppChn;
/*config memory for vi*/
for (i = 0; i < VI_MAX_PIPE_NUM; i++)
{
for (j = 0; j < VI_MAX_CHN_NUM; j++)
{
stMppChn.enModId = HI_ID_VI;
stMppChn.s32DevId = i;
stMppChn.s32ChnId = j;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret)
{
SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
return HI_FAILURE;
}
}
}
/*config memory for avs */
for (i = 0; i < AVS_MAX_GRP_NUM; i++)
{
stMppChn.enModId = HI_ID_AVS;
stMppChn.s32DevId = i;
stMppChn.s32ChnId = 0;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret)
{
SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
return HI_FAILURE;
}
}
/*config memory for vpss */
for (i = 0; i < VPSS_MAX_GRP_NUM; i++)
{
stMppChn.enModId = HI_ID_VPSS;
stMppChn.s32DevId = i;
stMppChn.s32ChnId = 0;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret)
{
SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
return HI_FAILURE;
}
}
/*config memory for venc */
for (i = 0; i < VENC_MAX_CHN_NUM; i++)
{
stMppChn.enModId = HI_ID_VENC;
stMppChn.s32DevId = 0;
stMppChn.s32ChnId = i;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret)
{
SAMPLE_PRT("HI_MPI_SYS_SetMemConf ERR !\n");
return HI_FAILURE;
}
}
/*config memory for vo*/
for (i = 0; i < VO_MAX_LAYER_NUM; i++)
{
for (j = 0; j < VO_MAX_CHN_NUM; j++)
{
stMppChn.enModId = HI_ID_VO;
stMppChn.s32DevId = i;
stMppChn.s32ChnId = j;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret)
{
SAMPLE_PRT("HI_MPI_SYS_SetMemConfig ERR !\n");
return HI_FAILURE;
}
}
}
/*config memory for vdec */
for (i = 0; i < VDEC_MAX_CHN_NUM; i++)
{
stMppChn.enModId = HI_ID_VDEC;
stMppChn.s32DevId = 0;
stMppChn.s32ChnId = i;
s32Ret = HI_MPI_SYS_SetMemConfig(&stMppChn, pcMmzName);
if (s32Ret)
{
SAMPLE_PRT("HI_MPI_SYS_SetMemConf ERR !\n");
return HI_FAILURE;
}
}
return s32Ret;
}
/******************************************************************************
* function : vb init & MPI system init
******************************************************************************/
HI_S32 SAMPLE_COMM_SYS_Init(VB_CONFIG_S* pstVbConfig)
{
HI_S32 s32Ret = HI_FAILURE;
HI_MPI_SYS_Exit();
HI_MPI_VB_Exit();
if (NULL == pstVbConfig)
{
SAMPLE_PRT("input parameter is null, it is invaild!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_VB_SetConfig(pstVbConfig);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_VB_SetConf failed!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_VB_Init();
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_VB_Init failed!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_SYS_Init();
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_SYS_Init failed!\n");
HI_MPI_VB_Exit();
return HI_FAILURE;
}
return HI_SUCCESS;
}
/******************************************************************************
* function : vb init with VbSupplement & MPI system init
******************************************************************************/
HI_S32 SAMPLE_COMM_SYS_InitWithVbSupplement(VB_CONFIG_S* pstVbConf, HI_U32 u32SupplementConfig)
{
VB_SUPPLEMENT_CONFIG_S stSupplementConf = {0};
HI_S32 s32Ret = HI_FAILURE;
HI_MPI_SYS_Exit();
HI_MPI_VB_Exit();
if (NULL == pstVbConf)
{
SAMPLE_PRT("input parameter is null, it is invaild!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_VB_SetConfig(pstVbConf);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_VB_SetConf failed!\n");
return HI_FAILURE;
}
stSupplementConf.u32SupplementConfig = u32SupplementConfig;
s32Ret = HI_MPI_VB_SetSupplementConfig(&stSupplementConf);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_VB_SetSupplementConf failed!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_VB_Init();
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_VB_Init failed!\n");
return HI_FAILURE;
}
s32Ret = HI_MPI_SYS_Init();
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_SYS_Init failed!\n");
return HI_FAILURE;
}
return HI_SUCCESS;
}
/******************************************************************************
* function : vb exit & MPI system exit
******************************************************************************/
HI_VOID SAMPLE_COMM_SYS_Exit(void)
{
SAMPLE_COMM_VO_Exit();
HI_MPI_SYS_Exit();
HI_MPI_VB_ExitModCommPool(VB_UID_VDEC);
HI_MPI_VB_Exit();
return;
}
HI_S32 SAMPLE_COMM_VI_Bind_VO(VI_PIPE ViPipe, VI_CHN ViChn, VO_LAYER VoLayer, VO_CHN VoChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VI-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VI_UnBind_VO(VI_PIPE ViPipe, VI_CHN ViChn, VO_LAYER VoLayer, VO_CHN VoChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VI-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VI_Bind_VPSS(VI_PIPE ViPipe, VI_CHN ViChn, VPSS_GRP VpssGrp)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VI-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VI_UnBind_VPSS(VI_PIPE ViPipe, VI_CHN ViChn, VPSS_GRP VpssGrp)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VI-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VI_Bind_VENC(VI_PIPE ViPipe, VI_CHN ViChn, VENC_CHN VencChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VI-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VI_UnBind_VENC(VI_PIPE ViPipe, VI_CHN ViChn, VENC_CHN VencChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VI;
stSrcChn.s32DevId = ViPipe;
stSrcChn.s32ChnId = ViChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VI-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_Bind_AVS(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, AVS_GRP AvsGrp, AVS_PIPE AvsPipe)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_AVS;
stDestChn.s32DevId = AvsGrp;
stDestChn.s32ChnId = AvsPipe;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VPSS-AVS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_UnBind_AVS(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, AVS_GRP AvsGrp, AVS_PIPE AvsPipe)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_AVS;
stDestChn.s32DevId = AvsGrp;
stDestChn.s32ChnId = AvsPipe;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VPSS-AVS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_Bind_VO(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VO_LAYER VoLayer, VO_CHN VoChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VPSS-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_UnBind_VO(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VO_LAYER VoLayer, VO_CHN VoChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VPSS-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_Bind_VENC(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VENC_CHN VencChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VPSS-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VPSS_UnBind_VENC(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, VENC_CHN VencChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VPSS;
stSrcChn.s32DevId = VpssGrp;
stSrcChn.s32ChnId = VpssChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VPSS-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_Bind_AVS(AVS_GRP AvsSrcGrp, AVS_CHN AvsSrcChn, AVS_GRP AvsDestGrp, AVS_CHN AvsDestChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsSrcGrp;
stSrcChn.s32ChnId = AvsSrcChn;
stDestChn.enModId = HI_ID_AVS;
stDestChn.s32DevId = AvsDestGrp;
stDestChn.s32ChnId = AvsDestChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(AVS-AVS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_UnBind_AVS(AVS_GRP AvsSrcGrp, AVS_CHN AvsSrcChn, AVS_GRP AvsDestGrp, AVS_CHN AvsDestChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsSrcGrp;
stSrcChn.s32ChnId = AvsSrcChn;
stDestChn.enModId = HI_ID_AVS;
stDestChn.s32DevId = AvsDestGrp;
stDestChn.s32ChnId = AvsDestChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(AVS-AVS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_Bind_VPSS(AVS_GRP AvsGrp, AVS_CHN AvsChn, VPSS_GRP VpssGrp)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(AVS-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_UnBind_VPSS(AVS_GRP AvsGrp, AVS_CHN AvsChn, VPSS_GRP VpssGrp)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(AVS-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_Bind_VENC(AVS_GRP AvsGrp, AVS_CHN AvsChn, VENC_CHN VencChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(AVS-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_UnBind_VENC(AVS_GRP AvsGrp, AVS_CHN AvsChn, VENC_CHN VencChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = VencChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(AVS-VENC)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_Bind_VO(AVS_GRP AvsGrp, AVS_CHN AvsChn, VO_LAYER VoLayer, VO_CHN VoChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(AVS-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_AVS_UnBind_VO(AVS_GRP AvsGrp, AVS_CHN AvsChn, VO_LAYER VoLayer, VO_CHN VoChn)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_AVS;
stSrcChn.s32DevId = AvsGrp;
stSrcChn.s32ChnId = AvsChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = VoLayer;
stDestChn.s32ChnId = VoChn;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(AVS-VO)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VDEC_Bind_VPSS(VDEC_CHN VdecChn, VPSS_GRP VpssGrp)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VDEC;
stSrcChn.s32DevId = 0;
stSrcChn.s32ChnId = VdecChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_Bind(&stSrcChn, &stDestChn), "HI_MPI_SYS_Bind(VDEC-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VDEC_UnBind_VPSS(VDEC_CHN VdecChn, VPSS_GRP VpssGrp)
{
MPP_CHN_S stSrcChn;
MPP_CHN_S stDestChn;
stSrcChn.enModId = HI_ID_VDEC;
stSrcChn.s32DevId = 0;
stSrcChn.s32ChnId = VdecChn;
stDestChn.enModId = HI_ID_VPSS;
stDestChn.s32DevId = VpssGrp;
stDestChn.s32ChnId = 0;
CHECK_RET(HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn), "HI_MPI_SYS_UnBind(VDEC-VPSS)");
return HI_SUCCESS;
}
HI_S32 SAMPLE_COMM_VO_Bind_VO(VO_LAYER SrcVoLayer, VO_CHN SrcVoChn, VO_LAYER DstVoLayer, VO_CHN DstVoChn)
{
MPP_CHN_S stSrcChn, stDestChn;
stSrcChn.enModId = HI_ID_VO;
stSrcChn.s32DevId = SrcVoLayer;
stSrcChn.s32ChnId = SrcVoChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = DstVoLayer;
stDestChn.s32ChnId = DstVoChn;
return HI_MPI_SYS_Bind(&stSrcChn, &stDestChn);
}
HI_S32 SAMPLE_COMM_VO_UnBind_VO(VO_LAYER DstVoLayer, VO_CHN DstVoChn)
{
MPP_CHN_S stDestChn;
stDestChn.enModId = HI_ID_VO;
stDestChn.s32DevId = DstVoLayer;
stDestChn.s32ChnId = DstVoChn;
return HI_MPI_SYS_UnBind(NULL, &stDestChn);
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jeremy111hz/hi3516dv300-rtsp-h264.git
[email protected]:jeremy111hz/hi3516dv300-rtsp-h264.git
jeremy111hz
hi3516dv300-rtsp-h264
hi3516dv300-rtsp-h264
master

搜索帮助