diff options
author | Benny Prijono <bennylp@teluu.com> | 2009-05-29 13:04:03 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2009-05-29 13:04:03 +0000 |
commit | 08640cc9411ca092e6456304bcce41f81b3bd3ce (patch) | |
tree | 6d1ad4e6304b1fb8d95b00858648cfbcd829a2ea /pjmedia/src/pjmedia-codec | |
parent | ad8907b8ea9f5715c05b19b41ea7b85509591153 (diff) |
Integration of Sipit24 branch, many tickets involved:
- #793: AMR encoder should regard 'mode-set' param specified by remote decoder.
- #831: Automatically switch to TCP transport when sending large request
- #832: Support for outbound proxy setting without using Route header
- #849: Modify conference audio switch behavior in connecting ports.
- #850: Remove 'Require=replaces' param in 'Refer-To' header (in call transfer with replaces).
- #851: Support for regular nomination in ICE
- #852: --ip-addr support for IPv6 for media transport in pjsua
- #854: Adding SOFTWARE attribute in all outgoing requests may cause compatibility problem with older STUN server (thanks Alexei Kuznetsov for the report)
- #855: Bug in digit map frequencies for DTMF digits (thanks FCCH for the report)
- #856: Put back the ICE candidate priority values according to the default values in the draft-mmusic-ice
- #857: Support for ICE keep-alive with Binding indication
- #858: Do not authenticate STUN 438 response
- #859: AMR-WB format param in the SDP is not negotiated correctly.
- #867: Return error instead of asserting when PJSUA-LIB fails to open log file
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2724 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia/src/pjmedia-codec')
-rw-r--r-- | pjmedia/src/pjmedia-codec/ipp_codecs.c | 80 |
1 files changed, 67 insertions, 13 deletions
diff --git a/pjmedia/src/pjmedia-codec/ipp_codecs.c b/pjmedia/src/pjmedia-codec/ipp_codecs.c index b22b4f19..4777b0bb 100644 --- a/pjmedia/src/pjmedia-codec/ipp_codecs.c +++ b/pjmedia/src/pjmedia-codec/ipp_codecs.c @@ -233,17 +233,19 @@ static struct ipp_codec { ipp_codec[] = { # if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR + /* AMR-NB SID seems to produce noise, so let's just disable its VAD. */ {1, "AMR", PJMEDIA_RTP_PT_AMR, &USC_GSMAMR_Fxns, 8000, 1, 160, - 5900, 12200, 4, 1, 1, - &predecode_amr, &parse_amr, &pack_amr - /*, {1, {{{"octet-align", 11}, {"1", 1}}} } */ + 7400, 12200, 2, 0, 1, + &predecode_amr, &parse_amr, &pack_amr, + {1, {{{"octet-align", 11}, {"1", 1}}} } }, # endif # if PJMEDIA_HAS_INTEL_IPP_CODEC_AMRWB {1, "AMR-WB", PJMEDIA_RTP_PT_AMRWB, &USC_AMRWB_Fxns, 16000, 1, 320, 15850, 23850, 1, 1, 1, - &predecode_amr, &parse_amr, &pack_amr + &predecode_amr, &parse_amr, &pack_amr, + {1, {{{"octet-align", 11}, {"1", 1}}} } }, # endif @@ -560,7 +562,14 @@ static pj_status_t parse_amr(ipp_private_t *codec_data, void *pkt, /* Check Change Mode Request. */ if ((setting->amr_nb && cmr <= 7) || (!setting->amr_nb && cmr <= 8)) { + struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx]; + s->enc_mode = cmr; + codec_data->info->params.modes.bitrate = s->enc_setting.amr_nb? + pjmedia_codec_amrnb_bitrates[s->enc_mode] : + pjmedia_codec_amrwb_bitrates[s->enc_mode]; + ippc->fxns->std.Control(&codec_data->info->params.modes, + codec_data->enc); } return PJ_SUCCESS; @@ -1033,7 +1042,7 @@ static pj_status_t ipp_codec_open( pjmedia_codec *codec, codec_data->info->params.direction = USC_DECODE; /* Not sure if VAD affects decoder, just try to be safe */ - codec_data->info->params.modes.vad = ippc->has_native_vad; + //codec_data->info->params.modes.vad = ippc->has_native_vad; /* Get number of memory blocks needed by the decoder */ if (USC_NoError != ippc->fxns->std.NumAlloc(&codec_data->info->params, @@ -1084,34 +1093,79 @@ static pj_status_t ipp_codec_open( pjmedia_codec *codec, if (ippc->pt == PJMEDIA_RTP_PT_AMR || ippc->pt == PJMEDIA_RTP_PT_AMRWB) { amr_settings_t *s; pj_uint8_t octet_align = 0; - const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11}; + pj_int8_t enc_mode = -1; + + /* Check AMR specific attributes */ - /* Check octet-align */ for (i = 0; i < attr->setting.dec_fmtp.cnt; ++i) { + /* octet-align, one of the parameters that must have same value + * in offer & answer (RFC 4867 Section 8.3.1). Just check fmtp + * in the decoder side, since it's value is guaranteed to fulfil + * above requirement (by SDP negotiator). + */ + const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11}; + if (pj_stricmp(&attr->setting.dec_fmtp.param[i].name, &STR_FMTP_OCTET_ALIGN) == 0) { octet_align=(pj_uint8_t) - (pj_strtoul(&attr->setting.dec_fmtp.param[i].val)); + pj_strtoul(&attr->setting.dec_fmtp.param[i].val); + break; + } + } + for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) { + /* mode-set */ + const pj_str_t STR_FMTP_MODE_SET = {"mode-set", 8}; + + if (pj_stricmp(&attr->setting.enc_fmtp.param[i].name, + &STR_FMTP_MODE_SET) == 0) + { + pj_int8_t tmp; + + /* Just get the first value. */ + tmp = (pj_int8_t) + pj_strtoul(&attr->setting.enc_fmtp.param[i].val); + + if ((ippc->pt == PJMEDIA_RTP_PT_AMR && tmp > 0 && tmp < 8) || + (ippc->pt == PJMEDIA_RTP_PT_AMRWB && tmp > 0 && tmp < 9)) + { + enc_mode = tmp; + PJ_LOG(4,(THIS_FILE, "Remote specifies AMR mode-set attr, " + "selected: %d", enc_mode)); + } break; } } + /* Initialize AMR specific settings */ s = PJ_POOL_ZALLOC_T(pool, amr_settings_t); codec_data->codec_setting = s; - s->enc_mode = pjmedia_codec_amr_get_mode(ippc->def_bitrate); - if (s->enc_mode < 0) - goto on_error; - s->enc_setting.amr_nb = (pj_uint8_t)(ippc->pt == PJMEDIA_RTP_PT_AMR); s->enc_setting.octet_aligned = octet_align; s->enc_setting.reorder = PJ_TRUE; s->enc_setting.cmr = 15; - + s->dec_setting.amr_nb = (pj_uint8_t)(ippc->pt == PJMEDIA_RTP_PT_AMR); s->dec_setting.octet_aligned = octet_align; s->dec_setting.reorder = PJ_TRUE; + + s->enc_mode = pjmedia_codec_amr_get_mode( + codec_data->info->params.modes.bitrate); + if (s->enc_mode < 0) + goto on_error; + + if (enc_mode != -1) { + s->enc_mode = enc_mode; + + /* Apply requested encoder bitrate */ + codec_data->info->params.modes.bitrate = s->enc_setting.amr_nb? + pjmedia_codec_amrnb_bitrates[s->enc_mode] : + pjmedia_codec_amrwb_bitrates[s->enc_mode]; + ippc->fxns->std.Control(&codec_data->info->params.modes, + codec_data->enc); + } + } #endif |