读取和接收呼叫冲突

时间:2012-08-27 12:07:44

标签: sockets thread-safety socket.io vlc recv

我正在使用vlc播放器进行实验室设置。我在vlc中的单独线程中运行以下代码。

做{

 ret = conManager->read(block);// basically calls the read system call 

 int rcvbuf=0;     /* Receive buffer size */
 socklen_t optlen; /* Option length */
 optlen = sizeof rcvbuf;
 int z = conManager->downloadQueue.front()->getConnection()->getsocket();
 if(z>0)
 {
 if (!(getsockopt(z,SOL_SOCKET,SO_RCVBUF, &rcvbuf,&optlen) ))
     printf(" The socket buffer size is  %d \n", rcvbuf);
 }
 if(rcvbuf!=0)
 {
    t_block=block_Alloc(rcvbuf);
    rec = conManager->recv(t_block);//recv call with MSG_PEEK option set 
    printf("Received bytes : %d \n",rec);
    block_Release(t_block);
 }

如果(保留大于0)     {

    block_t *bufBlock = block_Alloc(ret);
    memcpy(bufBlock->p_buffer, block->p_buffer, ret);
    bufBlock->i_length = block->i_length;
    buffer->put(bufBlock);

}

}     while(ret&&!buffer-> getEOF());

当我从网络启动视频时,它会显示两到三帧,然后会出现一些错误。我的recv调用是修改缓冲区中的数据吗? ..

[h264 @ 0x7f2060cfa5a0] AVC: nal size -1870460177
[h264 @ 0x7f2060cfa5a0] AVC: nal size -1870460177
[h264 @ 0x7f2060cfa5a0] no frame!
[h264 @ 0x7f2060cfaa40] AVC: nal size -66001185
[h264 @ 0x7f2060cfaa40] AVC: nal size -66001185
[h264 @ 0x7f2060cfaa40] no frame!
[h264 @ 0x7f2060cfaee0] AVC: nal size -16048796

我检查了错误,但是它说数据包被截断而不是文件的末尾。但如果我没有recv运行。它工作正常。任何关于它出错的地方的任何想法。

最佳

佳日

0 个答案:

没有答案