RTP FIR 视频关键帧重传请求 在Freeswitch proxy media 下被丢弃的解决办法.

来源:互联网 发布:手机淘宝触屏版登陆 编辑:程序博客网 时间:2024/05/22 04:33

<关于Webrtc 不支持 RFC 2032 5.2.1. Full intra-frame Request (FIR) packet的解决办法> 

一文中提到了: 如何在Webrtc 上的实现 RTP FIR, 但是在和Freeswitch采用proxy_media 模式时,发现这个特殊的rtp包被freeswitch丢弃了.

按照分工本来这个问题是交给其他部门同事解决, 搞了很久, 不知道什么原因, 那我就说用RTCP吧. 因为RTCP 也可以发送这种请求的定义.

过了三,四个星期,  RTCP 也没搞定, 通过freeswitch还是不能透传.  

实在没办法, 自己动手,丰衣足食. 花了几个小时终于发现 rtp 被freeswitch丢弃的原因. 虽然是设置成 proxy_meida ,但是

在  SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp_session, switch_frame_t *frame, switch_io_flag_t io_flags)

函数里面的最后.

  if (bytes < 0) { 
        frame->datalen = 0; 
        return bytes == -2 ? SWITCH_STATUS_TIMEOUT : SWITCH_STATUS_GENERR;
    } else if (bytes < rtp_header_len) {

//在这里, 由于这个rtp包只有8 个字节,比rtp包头12个字节要少, 所有frame->datalen 被设置成 0
        frame->datalen = 0; 
        return SWITCH_STATUS_BREAK;
    } else {
        bytes -= rtp_header_len;
    }    

而在 mod_sofia.c 的

static switch_status_t sofia_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)

函数中,发现datelen =0 , 这个rtp包就被丢弃了.

  if (tech_pvt->video_read_frame.datalen == 0) { 
        *frame = NULL;
        return SWITCH_STATUS_GENERR;
    }    

知道原因,怎么修复就很简单了!