Ignore:
Timestamp:
Jun 3, 2017 9:22:34 AM (7 years ago)
Author:
nanang
Message:

Re #2018: Initial version of DTLS-SRTP implementation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c

    r5539 r5597  
    5656    unsigned            media_options;  /**< Transport media options.       */ 
    5757    void               *user_data;      /**< Only valid when attached       */ 
    58     pj_bool_t           attached;       /**< Has attachment?                */ 
     58    //pj_bool_t         attached;       /**< Has attachment?                */ 
    5959    pj_sockaddr         rem_rtp_addr;   /**< Remote RTP address             */ 
     60    unsigned            rem_rtp_cnt;    /**< How many pkt from this addr.   */ 
    6061    pj_sockaddr         rem_rtcp_addr;  /**< Remote RTCP address            */ 
    6162    int                 addr_len;       /**< Length of addresses.           */ 
     
    480481                /* We're still receiving from rem_rtp_addr. Don't switch. */ 
    481482                udp->rtp_src_cnt = 0; 
     483                udp->rem_rtp_cnt++; 
    482484            } else { 
    483485                udp->rtp_src_cnt++; 
    484486 
    485487                if (udp->rtp_src_cnt < PJMEDIA_RTP_NAT_PROBATION_CNT) { 
    486                     discard = PJ_TRUE; 
     488                    /* Only discard if we have ever received packet from 
     489                     * remote address (rem_rtp_addr). 
     490                     */ 
     491                    //discard = PJ_TRUE; 
     492                    discard = (udp->rem_rtp_cnt != 0); 
    487493                } else { 
    488494                 
     
    530536        } 
    531537 
    532         if (!discard && udp->attached && cb) 
     538        //if (!discard && udp->attached && cb) 
     539        if (!discard && cb) 
    533540            (*cb)(user_data, udp->rtp_pkt, bytes_read); 
    534541 
     
    566573        user_data = udp->user_data; 
    567574 
    568         if (udp->attached && cb) 
     575        //if (udp->attached && cb) 
     576        if (cb) 
    569577            (*cb)(user_data, udp->rtcp_pkt, bytes_read); 
    570578 
     
    650658 
    651659    /* Must not be "attached" to existing application */ 
    652     PJ_ASSERT_RETURN(!udp->attached, PJ_EINVALIDOP); 
     660    //PJ_ASSERT_RETURN(!udp->attached, PJ_EINVALIDOP); 
    653661 
    654662    /* Lock the ioqueue keys to make sure that callbacks are 
     
    686694 
    687695    /* Last, mark transport as attached */ 
    688     udp->attached = PJ_TRUE; 
     696    //udp->attached = PJ_TRUE; 
    689697 
    690698    /* Reset source RTP & RTCP addresses and counter */ 
     
    693701    udp->rtp_src_cnt = 0; 
    694702    udp->rtcp_src_cnt = 0; 
     703    udp->rem_rtp_cnt = 0; 
    695704 
    696705    /* Set buffer size for RTP socket */ 
     
    752761    pj_assert(tp); 
    753762 
    754     if (udp->attached) { 
     763    //if (udp->attached) { 
     764    if (1) { 
    755765        int i; 
    756766 
     
    768778 
    769779        /* First, mark transport as unattached */ 
    770         udp->attached = PJ_FALSE; 
     780        //udp->attached = PJ_FALSE; 
    771781 
    772782        /* Clear up application infos from transport */ 
     
    801811 
    802812    /* Must be attached */ 
    803     PJ_ASSERT_RETURN(udp->attached, PJ_EINVALIDOP); 
     813    //PJ_ASSERT_RETURN(udp->attached, PJ_EINVALIDOP); 
    804814 
    805815    /* Check that the size is supported */ 
     
    862872    pj_status_t status; 
    863873 
    864     PJ_ASSERT_RETURN(udp->attached, PJ_EINVALIDOP); 
     874    //PJ_ASSERT_RETURN(udp->attached, PJ_EINVALIDOP); 
    865875 
    866876    if (addr == NULL) { 
Note: See TracChangeset for help on using the changeset viewer.