Ignore:
Timestamp:
Mar 8, 2018 2:01:26 AM (3 years ago)
Author:
ming
Message:

Fixed #865: More clever RTP transport remote address switch

The summary of changes:

  • To solve no 2:

Add callback rtp_cb2(pjmedia_tp_cb_param *param) which allows application to get more info from the media transport, such as the packet's source address.

  • To solve no 3:

Add compile time option PJMEDIA_TRANSPORT_SWITCH_REMOTE_ADDR (by default enabled). Currently, there are already runtime options PJMEDIA_UDP_NO_SRC_ADDR_CHECKING and PJMEDIA_ICE_NO_SRC_ADDR_CHECKING, but there are a few drawbacks:

  • the options are not exported to the higher level, such as stream, or pjsua.
  • the options are separate for each transport, UDP and ICE, there's no single option to do this.
  • To solve no 1:

Using the new rtp_cb2() callback, move the functionality to check the packet's source address to the stream/video stream.
By checking the RTP pt and SSRC, there are a few advantages:

  • When receiving packets from multiple sources, stream can choose the packet with the correct SSRC as advertised from the SDP, and discard the others (see also ticket #1366).
  • If remote address switch is enabled, a faster switch can be achieved as soon as packet with correct ssrc is received, instead of waiting for several consecutive packets (according to setting PJMEDIA_RTP_NAT_PROBATION_CNT).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/transport.h

    r5750 r5752  
    564564}; 
    565565 
     566/** 
     567 * This structure describes the data passed when calling #rtp_cb2(). 
     568 */ 
     569typedef struct pjmedia_tp_cb_param 
     570{ 
     571    /** 
     572     * User data. 
     573     */ 
     574    void               *user_data; 
     575 
     576    /** 
     577     * Packet buffer. 
     578     */ 
     579    void               *pkt; 
     580 
     581    /** 
     582     * Packet size. 
     583     */ 
     584    pj_ssize_t          size; 
     585 
     586    /** 
     587     * Packet's source address. 
     588     */ 
     589    pj_sockaddr        *src_addr; 
     590 
     591    /** 
     592     * Should media transport switch remote address to \a rtp_src_addr? 
     593     * Media transport should initialize it to PJ_FALSE, and application 
     594     * can change the value as necessary. 
     595     */ 
     596    pj_bool_t           rem_switch; 
     597 
     598} pjmedia_tp_cb_param; 
    566599 
    567600/** 
     
    613646     */ 
    614647    void (*rtcp_cb)(void *user_data, void *pkt, pj_ssize_t); 
     648 
     649    /** 
     650     * Callback to be called when RTP packet is received on the transport. 
     651     */ 
     652    void (*rtp_cb2)(pjmedia_tp_cb_param *param); 
     653 
    615654}; 
    616655 
Note: See TracChangeset for help on using the changeset viewer.