Hi Nvidia:
One frame of JPEG encoded data is repeatly and continously sended via net use UDP,the time of sending about the first 10 frames is normal(about 40ms per frame),but the time become longer and longer,the time of 300th frame is about 700ms, it is not accepted. JPEG resolution is 4096x4096.
Reference code as below,could you give me some advise, is there some problem in my codes?
Thanks! Expected your reply!
static bool
net_initialize(context_t * ctx)
{
int ret = 0;
ctx->sockfd = socket(AF_INET,SOCK_DGRAM,0);
if(ctx->sockfd < 0)
{
printf(“Create socket failed\n”);
return false;
}
memset( &(ctx->saddr), 0, sizeof(ctx->saddr));
ctx->saddr.sin_family = AF_INET;
ctx->saddr.sin_addr.s_addr = htonl(INADDR_ANY);
ctx->saddr.sin_port = htons(8888);
memset( &(ctx->caddr), 0, sizeof(ctx->caddr));
ctx->caddr.sin_family = AF_INET;
ctx->caddr.sin_addr.s_addr = inet_addr("192.168.10.118");
ctx->caddr.sin_port = htons(2345);
ret = bind(ctx->sockfd, (struct sockaddr*) &(ctx->saddr), sizeof(ctx->saddr));
if(ret < 0)
{
printf("Bind socket failed\n");
return false;
}
return true;
}
send data segment:
for( int i=0;i<510;i++)
{
ctemp = (char )out_buf;
leftBytes = out_buf_size;
while(1)
{
ret = sendto(ctx.sockfd,ctemp,bytesPerTime,0,(struct sockaddr) &(ctx.caddr),len);
leftBytes -= bytesPerTime;
ctemp += bytesPerTime;
if( leftBytes < bytesPerTime && leftBytes != 0)
{
bytesPerTime = leftBytes;
}
if( leftBytes == 0 )
break;
}
}
Notice: JPEG encoded data save in out_buf,and out_buf_size is the data length.