📄 main.c
字号:
/*
* Copyright 2006 by VisionMagic Ltd.
* All rights reserved. Property of VisionMagic Ltd.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*
*/
#include <std.h>
#include <tsk.h>
#include <sem.h>
#include <gio.h>
#include <log.h>
#include <csl_cache.h>
#include <fvid.h>
#include <edc.h>
#include "bsl.h"
#include "vstream.h"
#include "dm642_vcapparams.h"
#include "vport.h"
#include "vportcap.h"
#include "tvp5150.h"
#define DEFAULT_VIDEO_RESOLUTION VR_CIF
extern far LOG_Obj trace;
extern Uint32 SDRAM;
extern I2C_Handle g_dm642I2CHandle;
/*capture video port drivers*/
GIO_Handle g_capChan[MAX_CH_SIZE];
FVID_Frame *g_capFrameBuf[MAX_CH_SIZE];
#ifdef PAL_SYSTEM
VIDEO_MODE g_videoMode = VM_PAL;
#else
VIDEO_MODE g_videoMode = VM_NTSC;
#endif
/*
* ======== main ========
*/
main()
{
/******************************************************/
/* open CSL DAT module for fast copy */
/******************************************************/
CSL_init();
CACHE_clean(CACHE_L2ALL, 0, 0);
CACHE_setL2Mode(CACHE_64KCACHE);
CACHE_enableCaching(CACHE_EMIFA_CE00);
CACHE_enableCaching(CACHE_EMIFA_CE01);
g_vpCapChanParams.segId = SDRAM;
g_tvp5150Params.hI2C = g_dm642I2CHandle;
/* stream module initialization */
if (Stream_Init(g_videoMode, DEFAULT_VIDEO_RESOLUTION) == 0)
{
LOG_printf(&trace, "Network initialization failed\n");
}
LOG_printf(&trace, "Exit main\n");
}
/*
* ======== tskChannel ========
* video loopback function.
*/
void tskChannel(int _ch)
{
Int status, frameCount = 0;
VPChanCap_Params vccParams;
GIO_Attrs gioAttrs;
memset(&gioAttrs, 0, sizeof(gioAttrs));
gioAttrs.nPackets = 2;
gioAttrs.timeout = 2000;
memcpy(&vccParams, &g_vpCapChanParams, sizeof(VPChanCap_Params));
vccParams.segId = SDRAM;
SetVideoPortChannelParams(&vccParams, DEFAULT_VIDEO_RESOLUTION);
/******************************************************/
/* initialization of capture driver */
/******************************************************/
g_capChan[0] = GIO_create("/VP1CAPTURE/A/1",
IOM_INPUT, &status, (Ptr)&vccParams, &gioAttrs);
LOG_printf(&trace, "ch-%d before VPORT_CMD_EDC_BASE", _ch);
/******************************************************/
/* configure video encoder & decoder */
/******************************************************/
status = FVID_control(g_capChan[_ch],
VPORT_CMD_EDC_BASE+EDC_CONFIG,
(Ptr)&g_tvp5150Params);
if (status != IOM_COMPLETED)
{
LOG_printf(&trace, "[tskChannel]channel%d ERR-Config 5150 failed\n", _ch);
return;
}
/******************************************************/
/* start capture & display operation */
/******************************************************/
FVID_control(g_capChan[_ch], VPORT_CMD_START, NULL);
/********************************************************/
/* request a frame buffer from capture driver */
/********************************************************/
LOG_printf(&trace, "ch-%d before while", _ch);
status = FVID_alloc(g_capChan[_ch], &g_capFrameBuf[_ch]);
if (status == IOM_ETIMEOUT)
{
LOG_printf(&trace, "[tskChannel]Ch-%d FVID_alloc timeout\n", _ch);
return;
}
for(;;)
{
status = FVID_exchange(g_capChan[_ch], &g_capFrameBuf[_ch]);
if (status == IOM_ETIMEOUT)
{
LOG_printf(&trace, "[tskChannel]Ch-%d FVID_exchange timeout\n", _ch);
continue;
}
frameCount ++;
/* ready to streaming the video */
if (Stream_SendVideoData(_ch, (Uint8*)g_capFrameBuf[_ch]->frame.iFrm.y1) == 0)
{
LOG_printf(&trace, "[tskChannel]Ch-%d StreamVideoData failed\n", _ch);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -