Ignore:
Timestamp:
Jul 15, 2009 5:55:16 PM (15 years ago)
Author:
nanang
Message:

Ticket #919:

  • Added default ilbc mode into codec passthrough setting.
  • Added iLBC mode 'negotiation' in iLBC codec_open().
  • Updated stream_create() to prioritize codec_open(), that may update the codec params, over stream initializations involving codec params.
File:
1 edited

Legend:

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

    r2760 r2834  
    377377    struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)codec; 
    378378    pj_status_t status; 
    379     unsigned i, dec_fmtp_mode = 0, enc_fmtp_mode = 0; 
     379    unsigned i; 
     380    pj_uint16_t dec_fmtp_mode = DEFAULT_MODE,  
     381                enc_fmtp_mode = DEFAULT_MODE; 
    380382 
    381383    pj_assert(ilbc_codec != NULL); 
     
    387389        if (pj_stricmp(&attr->setting.dec_fmtp.param[i].name, &STR_MODE) == 0) 
    388390        { 
    389             dec_fmtp_mode = (unsigned) 
     391            dec_fmtp_mode = (pj_uint16_t) 
    390392                            pj_strtoul(&attr->setting.dec_fmtp.param[i].val); 
    391393            break; 
     
    401403        if (pj_stricmp(&attr->setting.enc_fmtp.param[i].name, &STR_MODE) == 0) 
    402404        { 
    403             enc_fmtp_mode = (unsigned) 
     405            enc_fmtp_mode = (pj_uint16_t) 
    404406                            pj_strtoul(&attr->setting.enc_fmtp.param[i].val); 
    405407            break; 
     
    407409    } 
    408410 
    409     /* The enc mode must be set in the attribute  
    410      * (from the mode parameter in fmtp attribute in the SDP 
    411      * received from remote)  
     411    PJ_ASSERT_RETURN(enc_fmtp_mode==20 || enc_fmtp_mode==30,  
     412                     PJMEDIA_CODEC_EINMODE); 
     413 
     414    /* Both sides of a bi-directional session MUST use the same "mode" value. 
     415     * In this point, possible values are only 20 or 30, so when encoder and 
     416     * decoder modes are not same, just use the default mode, it is 30. 
    412417     */ 
    413     if (enc_fmtp_mode == 0) 
    414         enc_fmtp_mode = dec_fmtp_mode; 
    415  
    416     PJ_ASSERT_RETURN(enc_fmtp_mode==20 || 
    417                      enc_fmtp_mode==30, PJMEDIA_CODEC_EINMODE); 
    418  
    419     /* Update enc_ptime in the param */ 
    420418    if (enc_fmtp_mode != dec_fmtp_mode) { 
    421         attr->info.enc_ptime = (pj_uint16_t)enc_fmtp_mode; 
    422     } else { 
    423         attr->info.enc_ptime = 0; 
    424     } 
    425  
    426     /* Create enc */ 
     419        enc_fmtp_mode = dec_fmtp_mode = DEFAULT_MODE; 
     420        PJ_LOG(4,(ilbc_codec->obj_name,  
     421                  "Normalized iLBC encoder and decoder modes to %d",  
     422                  DEFAULT_MODE)); 
     423    } 
     424 
     425    /* Update some attributes based on negotiated mode. */ 
     426    attr->info.avg_bps = (dec_fmtp_mode == 30? 13333 : 15200); 
     427    attr->info.frm_ptime = dec_fmtp_mode; 
     428 
     429    /* Create encoder */ 
    427430    ilbc_codec->enc_frame_size = initEncode(&ilbc_codec->enc, enc_fmtp_mode); 
    428431    ilbc_codec->enc_samples_per_frame = CLOCK_RATE * enc_fmtp_mode / 1000; 
     
    433436                                                   dec_fmtp_mode, 
    434437                                                   attr->setting.penh); 
    435     if (dec_fmtp_mode == 20) 
    436         ilbc_codec->dec_frame_size = 38; 
    437     else if (dec_fmtp_mode == 30) 
    438         ilbc_codec->dec_frame_size = 50; 
    439     else { 
    440         pj_assert(!"Invalid iLBC mode"); 
    441         ilbc_codec->dec_frame_size = ilbc_codec->enc_frame_size; 
    442     } 
     438    ilbc_codec->dec_frame_size = (dec_fmtp_mode == 20? 38 : 50); 
    443439    ilbc_codec->dec_ready = PJ_TRUE; 
    444440 
     
    460456 
    461457    PJ_LOG(5,(ilbc_codec->obj_name,  
    462               "iLBC codec opened, encoder mode=%d, decoder mode=%d", 
    463               enc_fmtp_mode, dec_fmtp_mode)); 
     458              "iLBC codec opened, mode=%d", dec_fmtp_mode)); 
    464459 
    465460    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.