上传者: p731heminyang
|
上传时间: 2021-11-30 17:59:54
|
文件大小: 157KB
|
文件类型: -
缓冲区的代码 #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "stream.h"
int quit;
#define DELAY_MAX 5000 //最大延时5000毫秒
#define IN_NUM (2)
#define MAIN_STREAM (0)
#define SLAVE_STREAM (1)
void Init_Interface(int Msg_id)
{
int qid;
if(ApproDrvInit(Msg_id))
exit(1);
if (func_get_mem(&qid))
{
ApproDrvExit();
exit(1);
}
}
void Clean_Interface(void)
{
ApproInterfaceExit();
}
static int alarm_rec_enable;
static unsigned int deltime;
static unsigned int GetTimeStamp(void)
{
struct timeval timeval;
gettimeofday(&timeval, NULL);
return (timeval.tv_sec * 1000) + (timeval.tv_usec + 500) / 1000;;
}
void *get_frame(void *arg)
{
FILE *filefd=NULL;
char filename[80];
int ch=0;
stream_rpos_t rpos;
frame_head_t frame_head;
int first_frame_type=0;
int first_frame=0;
char *frame_pos;
char *data;
unsigned int cur_time;
printf("get ch %d stream\n", ch);
memset(&rpos, 0, sizeof(rpos));
st_stream_getStartPos(ch, MAIN_STREAM, &rpos);
st_stream_getOneFrame(ch, MAIN_STREAM, 10, &rpos);
while(!quit)
{
if(alarm_rec_enable)
{
if(st_stream_getOneFrame(ch, MAIN_STREAM, 200, &rpos) <= 0)
{
usleep(10*1000);
continue;
}
frame_pos = &rpos.p_buf_data[rpos.data_start_pos];
memcpy(&frame_head,&rpos.p_buf_data[rpos.data_start_pos],sizeof(frame_head));
data=frame_pos+sizeof(frame_head_t