在oRTP库

时间:2017-04-24 15:08:28

标签: rtp rtcp

我正在尝试在oRTP中的RECVONLY会话中接收RTCP时遇到段错误。 RTCP在SENDRECV会话中接收时工作正常但在RECVONLY会话中不起作用。

这是我的代码。 segfault来自第42行的函数:err = rtp_session_recv_with_ts(session,buffer,160,ts,& have_more); 这是在接收文件的while循环中。

但是,这只发生在第32行

rtp_session_enable_rtcp(会话,TRUE);设置为TRUE。

如果我通过将RTCP设置为FALSE来禁用它,则RECVONLY会话将起作用。

#include <ortp/ortp.h>
#include <bctoolbox/vfs.h>
#include <signal.h>
#include <stdlib.h>

int cond=1;

void stop_handler(int signum)
{
    cond=0;
}

int main(int argc, char*argv[])
{
    RtpSession *session;
    unsigned char buffer[160];
    int err;
    uint32_t ts=0;
    int stream_received=0;
    FILE *outfile;
    int local_port;
    int have_more;
    int i;
    local_port=atoi(argv[2]);
    outfile=fopen(argv[1],"wb");

    //initialization of the session
    ortp_init();
    ortp_scheduler_init();
    ortp_set_log_level_mask(NULL, ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
    signal(SIGINT,stop_handler);
    session=rtp_session_new(RTP_SESSION_RECVONLY);
    rtp_session_enable_rtcp(session,TRUE);
    rtp_session_set_scheduling_mode(session,1);
    rtp_session_set_blocking_mode(session,1);
    rtp_session_set_local_addr(session,"0.0.0.0",local_port,local_port+1);
    rtp_session_set_payload_type(session,0);

    //receiving of incoming file
    while(cond)
    {
        have_more=1;
        while (have_more){
            err=rtp_session_recv_with_ts(session,buffer,160,ts,&have_more);
            if (err>0) stream_received=1;
            /* this is to avoid to write to disk some silence before the first RTP packet is returned*/
            if ((stream_received) && (err>0)) {
                size_t ret = fwrite(buffer,1,err,outfile);
            }
        }
        ts+=160;
    }

    rtp_session_destroy(session);
    ortp_exit();
    ortp_global_stats_display();
    return 0;
}

使用gdb进行调试,我得到了段错误的回溯。

Thread 1 "err" received signal SIGSEGV, Segmentation fault.
0x00007ffff7bd0a53 in concatb (mp=mp@entry=0x606ec0, newm=newm@entry=0x0)
    at /usr/src/debug/ortp-1.0.1-18/src/str_utils.c:337
337     while(newm->b_cont!=NULL) newm=newm->b_cont;
(gdb) bt
#0  0x00007ffff7bd0a53 in concatb (mp=mp@entry=0x606ec0, newm=newm@entry=0x0)
    at /usr/src/debug/ortp-1.0.1-18/src/str_utils.c:337

#1  0x00007ffff7bc4ada in append_sdes (full=1 '\001', m=0x606ec0, session=0x602750)
    at /usr/src/debug/ortp-1.0.1-18/src/rtcp.c:397

#2  rtp_session_create_and_send_rtcp_packet (session=session@entry=0x602750, full=full@entry=1 '\001')
    at /usr/src/debug/ortp-1.0.1-18/src/rtcp.c:460

#3  0x00007ffff7bc4d3e in rtp_session_send_regular_rtcp_packet_and_reschedule (
    session=session@entry=0x602750, tc=607522024) at /usr/src/debug/ortp-1.0.1-18/src/rtcp.c:569

#4  0x00007ffff7bc4ebd in rtp_session_run_rtcp_send_scheduler (session=session@entry=0x602750)
    at /usr/src/debug/ortp-1.0.1-18/src/rtcp.c:604

#5  0x00007ffff7bc5085 in rtp_session_rtcp_process_recv (session=session@entry=0x602750)
    at /usr/src/debug/ortp-1.0.1-18/src/rtcp.c:620

#6  0x00007ffff7bca985 in rtp_session_recvm_with_ts (session=session@entry=0x602750, 
    user_ts=user_ts@entry=30880) at /usr/src/debug/ortp-1.0.1-18/src/rtpsession.c:1287

#7  0x00007ffff7bcab24 in rtp_session_recv_with_ts (session=0x602750, 
    buffer=0x7fffffffdf90 "\226ˢT\277\274\350/։c\276e\257\377\377\377\377\376\177\357\377\377\377\277\372\377\377\377\377\377\377\377\356?r\337\301h\225s`\020HvHfJv\312\062\364\332\333\036\364\332fͽL\002\220d\"\206\354b\006\003\060\241cHV21\243Z!\v\r\202\271\214x0\004Pc$\306<\306\006;\270i\352\206l\030`\244@\244\303\071\253\070\"T\356\002\017\004\"8e\377\062\260\225\376\245bG\310\320H", len=160, ts=30880, have_more=0x7fffffffdf8c)
    at /usr/src/debug/ortp-1.0.1-18/src/rtpsession.c:1364

#8  0x0000000000400d15 in main ()

从回溯中看起来好像库文件str_utils.c中存在问题,但我不确定在设置RECVONLY会话时我是否忘记初始化某些内容。

总的来说,看起来第42行的接收器功能在RECVONLY会话中不能与RTCP一起使用。如果禁用RTCP,则没有问题。

0 个答案:

没有答案