Ignore:
Timestamp:
Dec 28, 2016 3:40:07 AM (7 years ago)
Author:
nanang
Message:

Re #1900: More merged from trunk (r5512 mistakenly contains merged changes in third-party dir only).

Location:
pjproject/branches/projects/uwp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/uwp

  • pjproject/branches/projects/uwp/pjmedia/src/pjmedia/stream_info.c

    r4930 r5513  
    3434static const pj_str_t ID_TELEPHONE_EVENT = { "telephone-event", 15 }; 
    3535 
     36static void get_opus_channels_and_clock_rate(const pjmedia_codec_fmtp *enc_fmtp, 
     37                                             const pjmedia_codec_fmtp *dec_fmtp, 
     38                                             unsigned *channel_cnt, 
     39                                             unsigned *clock_rate) 
     40{ 
     41    unsigned i; 
     42    unsigned enc_channel_cnt = 0, local_channel_cnt = 0; 
     43    unsigned enc_clock_rate = 0, local_clock_rate = 0; 
     44 
     45    for (i = 0; i < dec_fmtp->cnt; ++i) { 
     46        if (!pj_stricmp2(&dec_fmtp->param[i].name, "sprop-maxcapturerate")) { 
     47            local_clock_rate = (unsigned)pj_strtoul(&dec_fmtp->param[i].val); 
     48        } else if (!pj_stricmp2(&dec_fmtp->param[i].name, "sprop-stereo")) { 
     49            local_channel_cnt = (unsigned)pj_strtoul(&dec_fmtp->param[i].val); 
     50            local_channel_cnt = (local_channel_cnt > 0) ? 2 : 1; 
     51        } 
     52    } 
     53    if (!local_clock_rate) local_clock_rate = *clock_rate; 
     54    if (!local_channel_cnt) local_channel_cnt = *channel_cnt; 
     55 
     56    for (i = 0; i < enc_fmtp->cnt; ++i) { 
     57        if (!pj_stricmp2(&enc_fmtp->param[i].name, "maxplaybackrate")) { 
     58            enc_clock_rate = (unsigned)pj_strtoul(&enc_fmtp->param[i].val); 
     59        } else if (!pj_stricmp2(&enc_fmtp->param[i].name, "stereo")) { 
     60            enc_channel_cnt = (unsigned)pj_strtoul(&enc_fmtp->param[i].val); 
     61            enc_channel_cnt = (enc_channel_cnt > 0) ? 2 : 1; 
     62        } 
     63    } 
     64    /* The default is a standard mono session with 48000 Hz clock rate 
     65     * (RFC 7587, section 7) 
     66     */ 
     67    if (!enc_clock_rate) enc_clock_rate = 48000; 
     68    if (!enc_channel_cnt) enc_channel_cnt = 1; 
     69 
     70    *clock_rate = (enc_clock_rate < local_clock_rate) ? enc_clock_rate : 
     71                  local_clock_rate; 
     72 
     73    *channel_cnt = (enc_channel_cnt < local_channel_cnt) ? enc_channel_cnt : 
     74                   local_channel_cnt; 
     75} 
     76 
    3677/* 
    3778 * Internal function for collecting codec info and param from the SDP media. 
     
    219260                                   &si->param->setting.dec_fmtp); 
    220261 
     262    if (!pj_stricmp2(&si->fmt.encoding_name, "opus")) { 
     263        get_opus_channels_and_clock_rate(&si->param->setting.enc_fmtp, 
     264                                         &si->param->setting.dec_fmtp, 
     265                                         &si->fmt.channel_cnt, 
     266                                         &si->fmt.clock_rate); 
     267    } 
     268 
     269 
    221270    /* Get the remote ptime for our encoder. */ 
    222271    attr = pjmedia_sdp_attr_find2(rem_m->attr_count, rem_m->attr, 
     
    428477    } 
    429478 
    430     /* Local and remote address family must match */ 
    431     if (local_af != rem_af) 
    432         return PJ_EAFNOTSUP; 
     479    /* Local and remote address family must match, except when ICE is used 
     480     * by both sides (see also ticket #1952). 
     481     */ 
     482    if (local_af != rem_af) { 
     483        const pj_str_t STR_ICE_CAND = { "candidate", 9 }; 
     484        if (pjmedia_sdp_media_find_attr(rem_m, &STR_ICE_CAND, NULL)==NULL || 
     485            pjmedia_sdp_media_find_attr(local_m, &STR_ICE_CAND, NULL)==NULL) 
     486        { 
     487            return PJ_EAFNOTSUP; 
     488        } 
     489    } 
    433490 
    434491    /* Media direction: */ 
Note: See TracChangeset for help on using the changeset viewer.