コード例 #1
0
ファイル: pciv_test_slave.c プロジェクト: mglz/Drv
HI_S32 PCIV_Slave_StopGrp(PCIV_MSGHEAD_S *pMsg)
{
    HI_S32   s32Ret;
    VENC_GRP vencGrp;
    PCIV_GRPCMD_DESTROY_S *pCmd     = (PCIV_GRPCMD_DESTROY_S *)pMsg->cMsgBody;
    PCIV_GRPCMD_ECHO_S    *pCmdEcho = (PCIV_GRPCMD_ECHO_S   *)pMsg->cMsgBody;

    /* Start the VI first */
    vencGrp = pCmd->vencGrp;
    s32Ret = HI_MPI_VENC_UnbindInput(vencGrp);
    HI_ASSERT((HI_SUCCESS == s32Ret));

    /* Create new group first */
    s32Ret = HI_MPI_VENC_DestroyGroup(vencGrp);
    HI_ASSERT((HI_SUCCESS == s32Ret));

    /* Echo the cmd */
    pMsg->enMsgType   = PCIV_MSGTYPE_CMDECHO;
    pMsg->enDevType   = PCIV_DEVTYPE_GROUP;
    pMsg->u32Target   = 0;
    pMsg->u32MsgLen   = sizeof(PCIV_GRPCMD_ECHO_S);
    pCmdEcho->vencGrp = vencGrp;
    pCmdEcho->s32Echo = HI_SUCCESS;
    s32Ret = PCIV_SendMsg(0, PCIV_MSGPORT_USERCMD, pMsg);
    HI_ASSERT((HI_FAILURE != s32Ret));

    return HI_SUCCESS;
}
コード例 #2
0
ファイル: hi3515_enc.c プロジェクト: Hi-Spy/hidvr-git
static int enc_release_h264_stream(int vin, int stream)
{
	SDK_ENC_H264_STREAM_ATTR_t* stream_attr = &_sdk_enc.attr.video_stream_attr[vin][stream];
	if(vin < HI_VENC_CH_BACKLOG_REF && stream < HI_VENC_STREAM_BACKLOG_REF){
		if(ENC_H264_STREAM_ATTR_MAGIC == stream_attr->magic){
			int const venc_group = vin;
			int const venc_ch = vin * HI_VENC_STREAM_BACKLOG_REF + stream;

			SOC_TRACE("Release video encode (%d,%d)", vin, stream);
			SOC_CHECK(HI_MPI_VENC_StopRecvPic(venc_ch));
			SOC_CHECK(HI_MPI_VENC_UnRegisterChn(venc_ch));
			SOC_CHECK(HI_MPI_VENC_DestroyChn(venc_ch));

			if(0 == stream){
				SOC_CHECK(HI_MPI_VENC_UnbindInput(venc_group));
				SOC_CHECK(HI_MPI_VENC_DestroyGroup(venc_group));
			}

			// clear the magic
			stream_attr->magic = 0;
			return SDK_SUCCESS;
		}
	}
	return SDK_FAILURE;
}
コード例 #3
0
ファイル: v_producer.c プロジェクト: AxelLin/Drv
HI_S32 SampleStartSnap(VENC_GRP VeGroup,VENC_CHN SnapChn,
										VI_DEV ViDev,VI_CHN ViChn,FILE *pFile)
{
	HI_S32 s32Ret;

	s32Ret = HI_MPI_VENC_BindInput(VeGroup, ViDev, ViChn);
	if (s32Ret != HI_SUCCESS)
	{
		printf("HI_MPI_VENC_BindInput err 0x%x\n",s32Ret);
		return HI_FAILURE;
	}

	s32Ret = HI_MPI_VENC_RegisterChn(VeGroup, SnapChn);
	if(s32Ret != HI_SUCCESS)
	{
		printf("HI_MPI_VENC_RegisterChn err 0x%x\n",s32Ret);
		return HI_FAILURE;
	}

	s32Ret = HI_MPI_VENC_StartRecvPic(SnapChn);
	if(s32Ret != HI_SUCCESS)
	{
		printf("HI_MPI_VENC_StartRecvPic err 0x%x\n",s32Ret);
		return HI_FAILURE;
	}

	/*save jpeg picture*/
	s32Ret = SampleSaveSnapPic(SnapChn,pFile);
	if(s32Ret != HI_SUCCESS)
	{
		printf("SampleSaveSnapPic err 0x%x\n",s32Ret);
		return HI_FAILURE;
	}

	s32Ret = HI_MPI_VENC_StopRecvPic(SnapChn);
	if(s32Ret != HI_SUCCESS)
	{
		printf("HI_MPI_VENC_StopRecvPic err 0x%x\n",s32Ret);
		return HI_FAILURE;
	}

	s32Ret = HI_MPI_VENC_UnRegisterChn(SnapChn);
	if(s32Ret != HI_SUCCESS)
	{
		printf("HI_MPI_VENC_UnRegisterChn err 0x%x\n",s32Ret);
		return HI_FAILURE;
	}

	s32Ret = HI_MPI_VENC_UnbindInput(VeGroup);
	if (s32Ret != HI_SUCCESS)
	{
		printf("HI_MPI_VENC_UnbindInput err 0x%x\n",s32Ret);
		return HI_FAILURE;
	}

	return HI_SUCCESS;
}
コード例 #4
0
ファイル: sample_venc.c プロジェクト: 119/myimpsrc2
/*****************************************************************************
                    snap by mode 2
 how to snap:
 1)create snap group for each vichn,and bind them (not unbind until program end),
   that is muti snap group exit, instead of only one
 2)create one snap channel for each snap group
 3)register snap chn to its corresponding group, snapping, and then unregister
 4)repeat 3) to snap muti pictures of the channel

 features:
 1)need more memory than mode 1, because muti snap group and snap channel exit
 2)higher efficiency, because all snap chn run simultaneity.
*****************************************************************************/
HI_VOID* thread_StartSnapByMode2(HI_VOID *p)
{
    HI_S32 s32Ret;
    VENC_GRP VeGroup;
    VENC_CHN SnapChn;
    VI_DEV ViDev;
    VI_CHN ViChn;
    FILE *pFile = NULL;
    HI_S32 s32SnapCnt;
    HI_S32 s32SnapTotal;
    SNAP_SINGLE_CHN_S *pstSnapSingleChn = NULL;

    pstSnapSingleChn = (SNAP_SINGLE_CHN_S*)p;
    VeGroup = pstSnapSingleChn->VeGroup;
    SnapChn = pstSnapSingleChn->SnapChn;
    ViDev = pstSnapSingleChn->ViDev;
    ViChn = pstSnapSingleChn->ViChn;
    s32SnapTotal = pstSnapSingleChn->s32SnapTotal;

    /*note: bind snap group to vichn, not unbind while snapping*/
    s32Ret = HI_MPI_VENC_BindInput(VeGroup, ViDev, ViChn);
    if (s32Ret != HI_SUCCESS)
    {
        printf("HI_MPI_VENC_BindInput err 0x%x\n", s32Ret);
        return NULL;
    }

    s32SnapCnt = 0;
    while (HI_TRUE == pstSnapSingleChn->bThreadStart)
    {
        s32Ret = HI_MPI_VENC_RegisterChn(VeGroup, SnapChn);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VENC_RegisterChn err 0x%x\n", s32Ret);
            return NULL;
        }

        s32Ret = HI_MPI_VENC_StartRecvPic(SnapChn);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VENC_StartRecvPic err 0x%x\n", s32Ret);
            return NULL;
        }

        {
            /*save jpeg picture*/
            char acFile[128]  = {0};
            //struct timeval timenow;
            sprintf(acFile, "Vichn%d_num%d.jpg", ViChn, s32SnapCnt);
            pFile = fopen(acFile, "wb");
            if (pFile == NULL)
            {
                printf("open file err\n");
                return NULL;
            }

            s32Ret = SAMPLE_GetSnapPic(SnapChn, pFile);
            if (s32Ret != HI_SUCCESS)
            {
                printf("SAMPLE_GetSnapPic err 0x%x\n", s32Ret);
                fclose(pFile);
                return NULL;
            }
            fclose(pFile);
        }

        s32Ret = HI_MPI_VENC_StopRecvPic(SnapChn);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VENC_StopRecvPic err 0x%x\n", s32Ret);
            return NULL;
        }

        s32Ret = HI_MPI_VENC_UnRegisterChn(SnapChn);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VENC_UnRegisterChn err 0x%x\n", s32Ret);
            return NULL;
        }

        s32SnapCnt++;
    }

    s32Ret = HI_MPI_VENC_UnbindInput(VeGroup);
    if (s32Ret != HI_SUCCESS)
    {
        printf("HI_MPI_VENC_UnbindInput err 0x%x\n", s32Ret);
        return NULL;
    }

    return NULL;
}
コード例 #5
0
ファイル: sample_venc.c プロジェクト: 119/myimpsrc2
/*****************************************************************************
                    snap by mode 1
 how to snap:
 1)only creat one snap group
 2)bind to a vichn to snap and then unbind
 3)repeat 2) to snap all vichn in turn

 features:
 1)save memory, because only one snap group and snap channel
 2)efficiency lower than mode 2, pictures snapped will not more than 8.
*****************************************************************************/
HI_VOID* thread_StartSnapByMode1(HI_VOID *p)
{
    HI_S32 s32Ret;
    VENC_GRP VeGroup = 0;
    VENC_CHN SnapChn = 0;
    VI_DEV ViDev = 0;
    VI_CHN ViChn = 0;
    FILE *pFile = NULL;
    HI_S32 s32SnapCnt = 0;
    HI_S32 s32SnapTotal;
    SNAP_MULTI_CHN_S *pstSnapMultiChn = NULL;
    HI_S32 s32ViChnTotal;

    pstSnapMultiChn = (SNAP_MULTI_CHN_S*)p;
    VeGroup = pstSnapMultiChn->SnapGroup;
    SnapChn = pstSnapMultiChn->SnapChn;
    ViDev = pstSnapMultiChn->ViDev;
    s32ViChnTotal = pstSnapMultiChn->s32ViChnCnt;
    s32SnapTotal = pstSnapMultiChn->s32SnapTotal;

    /* snap all vi channels in sequence.
      * step 1: bind vi
      * step 2: register snap channel to group.
      * step 3: start snap channel to receiver picture.
      * step 4: get one-picture stream and save as jpeg file.
      * step 5: undo step 3, step 2, step 1.
      * step 6: chose next vi to snap, then go to step 1
      */
    ViChn = 0;
    while (HI_TRUE == pstSnapMultiChn->bThreadStart)
    {
        s32Ret = HI_MPI_VENC_BindInput(VeGroup, ViDev, ViChn);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VENC_BindInput err 0x%x\n", s32Ret);
            return NULL;
        }

        s32Ret = HI_MPI_VENC_RegisterChn(VeGroup, SnapChn);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VENC_RegisterChn err 0x%x\n", s32Ret);
            return NULL;
        }

        s32Ret = HI_MPI_VENC_StartRecvPic(SnapChn);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VENC_StartRecvPic err 0x%x\n", s32Ret);
            return NULL;
        }

        {
            /*save jpeg picture*/
            char acFile[128]  = {0};
            //struct timeval timenow;
            //gettimeofday(&timenow, NULL);
            sprintf(acFile, "Vichn%d_num%d.jpg", ViChn, s32SnapCnt);
            pFile = fopen(acFile, "wb");
            if (pFile == NULL)
            {
                printf("open file err\n");
                return NULL;
            }

            s32Ret = SAMPLE_GetSnapPic(SnapChn, pFile);
            if (s32Ret != HI_SUCCESS)
            {
                printf("SAMPLE_GetSnapPic err 0x%x\n", s32Ret);
                fclose(pFile);
                return NULL;
            }

            fclose(pFile);
        }

        s32Ret = HI_MPI_VENC_StopRecvPic(SnapChn);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VENC_StopRecvPic err 0x%x\n", s32Ret);
            return NULL;
        }

        s32Ret = HI_MPI_VENC_UnRegisterChn(SnapChn);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VENC_UnRegisterChn err 0x%x\n", s32Ret);
            return NULL;
        }

        s32Ret = HI_MPI_VENC_UnbindInput(VeGroup);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VENC_UnbindInput err 0x%x\n", s32Ret);
            return NULL;
        }

        /* continue to snap next vi channel */
        ViChn++;
        if(ViChn >= s32ViChnTotal)
        {
            ViChn = 0;
            s32SnapCnt++;
        }
    }

    return NULL;
}