Ignore:
Timestamp:
May 30, 2018 7:41:23 AM (6 years ago)
Author:
nanang
Message:

Re #2089:

  • Set default max Opus RX frame length, i.e: param.info.max_rx_frame_size, to 1275. This is to avoid issue of truncated frame in jitter buffer when incoming frame length gets increased (after remote Opus encoder changes Opus params on the fly, e.g: ptime, VBR/CBR, sampling rate). Thanks Marcus Froeschl for the report, the investigation, and the solution.
  • Fixed pjmedia_codec_opus_set_default_param() to initiate codec param with current default settings.
  • Fixed some compile warnings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/opus.c

    r5734 r5799  
    374374 
    375375    TRACE_((THIS_FILE, "%s:%d: - TRACE", __FUNCTION__, __LINE__)); 
    376     PJ_ASSERT_RETURN(cfg, PJ_EINVAL); 
     376    PJ_ASSERT_RETURN(cfg && param, PJ_EINVAL); 
    377377 
    378378    codec_mgr = pjmedia_endpt_get_codec_mgr(opus_codec_factory.endpt); 
     
    390390        return PJ_EINVAL; 
    391391    } 
     392 
     393    status = pjmedia_codec_mgr_get_default_param(codec_mgr, info[0], param); 
     394    if (status != PJ_SUCCESS) 
     395        return status; 
     396 
    392397    param->info.clock_rate = opus_cfg.sample_rate = cfg->sample_rate; 
    393398    param->info.max_bps = opus_cfg.sample_rate * 2; 
    394     param->info.frm_ptime = opus_cfg.frm_ptime = cfg->frm_ptime; 
     399    opus_cfg.frm_ptime = cfg->frm_ptime; 
     400    param->info.frm_ptime = (pj_uint16_t)cfg->frm_ptime; 
    395401 
    396402    /* Set channel count */ 
     
    474480    attr->info.avg_bps             = opus_cfg.bit_rate; 
    475481    attr->info.max_bps             = opus_cfg.sample_rate * 2; 
    476     attr->info.frm_ptime           = opus_cfg.frm_ptime; 
     482    attr->info.frm_ptime           = (pj_uint16_t)opus_cfg.frm_ptime; 
    477483    attr->setting.frm_per_pkt      = 1; 
    478484    attr->info.pcm_bits_per_sample = 16; 
    479485    attr->setting.vad              = OPUS_DEFAULT_VAD; 
    480486    attr->setting.plc              = OPUS_DEFAULT_PLC; 
     487 
     488    /* Set max RX frame size to 1275 (max Opus frame size) to anticipate 
     489     * possible ptime change on the fly. 
     490     */ 
     491    attr->info.max_rx_frame_size   = 1275; 
    481492 
    482493    generate_fmtp(attr); 
     
    808819    int i, num_frames; 
    809820    int size, out_pos; 
    810     unsigned samples_per_frame; 
     821    unsigned samples_per_frame = 0; 
    811822#if (USE_INCOMING_WORSE_SETTINGS) 
    812823    int bw; 
     
    10021013               opus_data->cfg.channel_cnt); 
    10031014    if (inframe->type != PJMEDIA_FRAME_TYPE_AUDIO || fec) { 
    1004         frm_size = PJ_MIN(frm_size, 
     1015        frm_size = PJ_MIN((unsigned)frm_size, 
    10051016                          opus_data->cfg.sample_rate * 
    10061017                          opus_data->dec_ptime / 1000); 
     
    10631074    if (opus_data->dec_frame_index == -1) { 
    10641075        /* Recover the first packet? Don't think so, fill it with zeroes. */ 
    1065         pj_uint16_t samples_per_frame; 
     1076        unsigned samples_per_frame; 
    10661077        samples_per_frame = opus_data->cfg.sample_rate * opus_data->dec_ptime/ 
    10671078                            1000; 
     
    10781089               opus_data->cfg.channel_cnt); 
    10791090    if (inframe->type != PJMEDIA_FRAME_TYPE_AUDIO) { 
    1080         frm_size = PJ_MIN(frm_size, opus_data->cfg.sample_rate * 
     1091        frm_size = PJ_MIN((unsigned)frm_size, opus_data->cfg.sample_rate * 
    10811092                          opus_data->dec_ptime/1000); 
    10821093    } 
Note: See TracChangeset for help on using the changeset viewer.