oRTP 0.16.3 的 RTPReceiver.exe 无法成功收到数据问题原因

    技术2024-07-25  12

    如果还没编译,参照如下文章:

    ortp 0.16.3在vs2008下的编译

     

     

    ortp源码有些问题,按上文改过之后终于编译成功。但是发现RTPReceiver.exe不能正常工作。google百度都没找到,自己经过一番查找后,终于找到问题所在。找到RTPReceiver.cpp,定位至rtp2disk函数:

    int rtp2disk(RtpSession *session,uint32_t ts, FILE * fd) { char buffer[160]; int err,havemore=1; while (havemore) { err=rtp_session_recv_with_ts(session,(uint8_t*)buffer,160,ts,&havemore); if (havemore) printf("==> Warning: havemore=1!/n"); if (err>0) { rtp_session_set_data(session,(void*)1); /* to indicate that (for the application) the stream has started, so we can start recording on disk */ } if (session->user_data != NULL) { fwrite(&buffer,1,160, fd); } } return 0; }

    如果在rtp2disk函数里把err输出,发现是有值的,说明服务器是收到数据了。再调试发现是rtp_session_set_data(session,(void*)1);这句没有起作用,进而导致下面的 if  (session->user_data != NULL) 一直是false。

    查了一下rtp_session_set_data函数的定义,

    void rtp_session_set_data(RtpSession *session, void *data){ session->user_data=data; }

    没问题呀?!这里很奇怪,就是没作用。不过既然找到问题所在,就不用这个函数了~直接让session->user_data为非0就行了。

    特此写上来,希望能帮助需要的朋友。

    最新回复(0)