Ignore:
Timestamp:
Aug 25, 2008 1:58:25 PM (16 years ago)
Author:
nanang
Message:

Ticket #599:

  • Added "dec_fmtp" and "enc_fmtp" fields to pjmedia_codec_param.setting.
  • Codec factory puts its default parameters in "dec_fmtp" field.
  • pjmedia_stream_info_from_sdp() puts the "fmtp" attribute in SDP to pjmedia_codec_param.
  • Special treatment for fmtp "bitrate" parameter (of G722.1) during SDP negotiation
  • Added maxptime field in stream_info.
  • Replaced iLBC's fmtp "mode" implementation to use general fmtp mechanism.
  • Added some test scripts for G722.1 bitrate negotiation.
File:
1 edited

Legend:

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

    r2039 r2236  
    144144}; 
    145145 
    146  
     146static pj_str_t STR_MODE = {"mode", 4}; 
    147147 
    148148/* 
     
    274274    attr->setting.plc = 1; 
    275275    attr->setting.penh = 1; 
    276     attr->setting.dec_fmtp_mode = (pj_uint8_t)ilbc_factory.mode; 
     276    attr->setting.dec_fmtp.cnt = 1; 
     277    attr->setting.dec_fmtp.param[0].name = STR_MODE; 
     278    if (ilbc_factory.mode == 30) 
     279        attr->setting.dec_fmtp.param[0].val = pj_str("30"); 
     280    else 
     281        attr->setting.dec_fmtp.param[0].val = pj_str("20"); 
    277282 
    278283    return PJ_SUCCESS; 
     
    371376    struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)codec; 
    372377    pj_status_t status; 
     378    unsigned i, dec_fmtp_mode = 0, enc_fmtp_mode = 0; 
    373379 
    374380    pj_assert(ilbc_codec != NULL); 
     
    376382              ilbc_codec->dec_ready == PJ_FALSE); 
    377383 
     384    /* Get decoder mode */ 
     385    for (i = 0; i < attr->setting.dec_fmtp.cnt; ++i) { 
     386        if (pj_stricmp(&attr->setting.dec_fmtp.param[i].name, &STR_MODE) == 0) 
     387        { 
     388            dec_fmtp_mode = (unsigned) 
     389                            pj_strtoul(&attr->setting.dec_fmtp.param[i].val); 
     390            break; 
     391        } 
     392    } 
     393 
    378394    /* Decoder mode must be set */ 
    379     PJ_ASSERT_RETURN(attr->setting.dec_fmtp_mode==20 || 
    380                      attr->setting.dec_fmtp_mode==30, PJMEDIA_CODEC_EINMODE); 
     395    PJ_ASSERT_RETURN(dec_fmtp_mode == 20 || dec_fmtp_mode == 30,  
     396                     PJMEDIA_CODEC_EINMODE); 
     397 
     398    /* Get encoder mode */ 
     399    for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) { 
     400        if (pj_stricmp(&attr->setting.enc_fmtp.param[i].name, &STR_MODE) == 0) 
     401        { 
     402            enc_fmtp_mode = (unsigned) 
     403                            pj_strtoul(&attr->setting.enc_fmtp.param[i].val); 
     404            break; 
     405        } 
     406    } 
    381407 
    382408    /* The enc mode must be set in the attribute  
     
    384410     * received from remote)  
    385411     */ 
    386     if (attr->setting.enc_fmtp_mode == 0) 
    387         attr->setting.enc_fmtp_mode = attr->setting.dec_fmtp_mode; 
    388  
    389     PJ_ASSERT_RETURN(attr->setting.enc_fmtp_mode==20 || 
    390                      attr->setting.enc_fmtp_mode==30, PJMEDIA_CODEC_EINMODE); 
     412    if (enc_fmtp_mode == 0) 
     413        enc_fmtp_mode = dec_fmtp_mode; 
     414 
     415    PJ_ASSERT_RETURN(enc_fmtp_mode==20 || 
     416                     enc_fmtp_mode==30, PJMEDIA_CODEC_EINMODE); 
    391417 
    392418    /* Update enc_ptime in the param */ 
    393     if (attr->setting.enc_fmtp_mode != attr->setting.dec_fmtp_mode) { 
    394         attr->info.enc_ptime = attr->setting.enc_fmtp_mode; 
     419    if (enc_fmtp_mode != dec_fmtp_mode) { 
     420        attr->info.enc_ptime = (pj_uint16_t)enc_fmtp_mode; 
    395421    } else { 
    396422        attr->info.enc_ptime = 0; 
     
    398424 
    399425    /* Create enc */ 
    400     ilbc_codec->enc_frame_size = initEncode(&ilbc_codec->enc,  
    401                                             attr->setting.enc_fmtp_mode); 
    402     ilbc_codec->enc_samples_per_frame = CLOCK_RATE*attr->setting.enc_fmtp_mode/ 
    403                                         1000; 
     426    ilbc_codec->enc_frame_size = initEncode(&ilbc_codec->enc, enc_fmtp_mode); 
     427    ilbc_codec->enc_samples_per_frame = CLOCK_RATE * enc_fmtp_mode / 1000; 
    404428    ilbc_codec->enc_ready = PJ_TRUE; 
    405429 
    406430    /* Create decoder */ 
    407431    ilbc_codec->dec_samples_per_frame = initDecode(&ilbc_codec->dec, 
    408                                                    attr->setting.dec_fmtp_mode, 
     432                                                   dec_fmtp_mode, 
    409433                                                   attr->setting.penh); 
    410     if (attr->setting.dec_fmtp_mode == 20) 
     434    if (dec_fmtp_mode == 20) 
    411435        ilbc_codec->dec_frame_size = 38; 
    412     else if (attr->setting.dec_fmtp_mode == 30) 
     436    else if (dec_fmtp_mode == 30) 
    413437        ilbc_codec->dec_frame_size = 50; 
    414438    else { 
     
    436460    PJ_LOG(5,(ilbc_codec->obj_name,  
    437461              "iLBC codec opened, encoder mode=%d, decoder mode=%d", 
    438               attr->setting.enc_fmtp_mode, attr->setting.dec_fmtp_mode)); 
     462              enc_fmtp_mode, dec_fmtp_mode)); 
    439463 
    440464    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.