summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-05-29 13:04:03 +0000
committerBenny Prijono <bennylp@teluu.com>2009-05-29 13:04:03 +0000
commit08640cc9411ca092e6456304bcce41f81b3bd3ce (patch)
tree6d1ad4e6304b1fb8d95b00858648cfbcd829a2ea /pjmedia
parentad8907b8ea9f5715c05b19b41ea7b85509591153 (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')
-rw-r--r--pjmedia/src/pjmedia-codec/ipp_codecs.c80
-rw-r--r--pjmedia/src/pjmedia/conf_switch.c28
-rw-r--r--pjmedia/src/pjmedia/sdp_neg.c16
-rw-r--r--pjmedia/src/pjmedia/tonegen.c6
4 files changed, 105 insertions, 25 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
diff --git a/pjmedia/src/pjmedia/conf_switch.c b/pjmedia/src/pjmedia/conf_switch.c
index da239df7..616a85b3 100644
--- a/pjmedia/src/pjmedia/conf_switch.c
+++ b/pjmedia/src/pjmedia/conf_switch.c
@@ -553,10 +553,32 @@ PJ_DEF(pj_status_t) pjmedia_conf_connect_port( pjmedia_conf *conf,
return PJMEDIA_ENCSAMPLESPFRAME;
}
- /* Check if sink is listening to other ports */
+ /* If sink is currently listening to other ports, it needs to be released
+ * first before the new connection made.
+ */
if (dst_port->transmitter_cnt > 0) {
- pj_mutex_unlock(conf->mutex);
- return PJ_ETOOMANYCONN;
+ unsigned j;
+ pj_bool_t transmitter_found = PJ_FALSE;
+
+ pj_assert(dst_port->transmitter_cnt == 1);
+ for (j=0; j<conf->max_ports && !transmitter_found; ++j) {
+ if (conf->ports[j]) {
+ unsigned k;
+
+ for (k=0; k < conf->ports[j]->listener_cnt; ++k) {
+ if (conf->ports[j]->listener_slots[k] == sink_slot) {
+ PJ_LOG(4,(THIS_FILE, "Connection [%d->%d] is "
+ "disconnected forcedly for the new "
+ "connection [%d->%d]",
+ j, sink_slot, src_slot, sink_slot));
+ pjmedia_conf_disconnect_port(conf, j, sink_slot);
+ transmitter_found = PJ_TRUE;
+ break;
+ }
+ }
+ }
+ }
+ pj_assert(dst_port->transmitter_cnt == 0);
}
/* Check if connection has been made */
diff --git a/pjmedia/src/pjmedia/sdp_neg.c b/pjmedia/src/pjmedia/sdp_neg.c
index 60ca36ef..9c4e9cfa 100644
--- a/pjmedia/src/pjmedia/sdp_neg.c
+++ b/pjmedia/src/pjmedia/sdp_neg.c
@@ -865,12 +865,14 @@ static pj_status_t process_m_answer( pj_pool_t *pool,
(ar.param.slen==1 && *ar.param.ptr=='1')))
{
/* Further check for G7221, negotiate bitrate. */
- if (pj_strcmp2(&or_.enc_name, "G7221") == 0) {
+ if (pj_stricmp2(&or_.enc_name, "G7221") == 0) {
if (match_g7221(offer, i, answer, j))
break;
} else
/* Further check for AMR, negotiate fmtp. */
- if (pj_strcmp2(&or_.enc_name, "AMR") == 0) {
+ if (pj_stricmp2(&or_.enc_name, "AMR") == 0 ||
+ pj_stricmp2(&or_.enc_name, "AMR-WB") == 0)
+ {
if (match_amr(offer, i, answer, j, PJ_FALSE,
NULL))
break;
@@ -1070,7 +1072,7 @@ static pj_status_t match_offer(pj_pool_t *pool,
}
pjmedia_sdp_attr_get_rtpmap(a, &or_);
- if (!pj_strcmp2(&or_.enc_name, "telephone-event")) {
+ if (!pj_stricmp2(&or_.enc_name, "telephone-event")) {
master_has_telephone_event = 1;
if (found_matching_telephone_event)
continue;
@@ -1097,19 +1099,21 @@ static pj_status_t match_offer(pj_pool_t *pool,
*/
if (!pj_stricmp(&or_.enc_name, &lr.enc_name) &&
or_.clock_rate == lr.clock_rate &&
- (pj_strcmp(&or_.param, &lr.param)==0 ||
+ (pj_stricmp(&or_.param, &lr.param)==0 ||
(or_.param.slen==1 && *or_.param.ptr=='1')))
{
/* Match! */
if (is_codec) {
/* Further check for G7221, negotiate bitrate */
- if (pj_strcmp2(&or_.enc_name, "G7221") == 0 &&
+ if (pj_stricmp2(&or_.enc_name, "G7221") == 0 &&
!match_g7221(master, i, slave, j))
{
continue;
} else
/* Further check for AMR, negotiate fmtp */
- if (pj_strcmp2(&or_.enc_name, "AMR")==0) {
+ if (pj_stricmp2(&or_.enc_name, "AMR")==0 ||
+ pj_stricmp2(&or_.enc_name, "AMR-WB")==0)
+ {
unsigned o_med_idx, a_med_idx;
o_med_idx = prefer_remote_codec_order? i:j;
diff --git a/pjmedia/src/pjmedia/tonegen.c b/pjmedia/src/pjmedia/tonegen.c
index f160fb79..2a545055 100644
--- a/pjmedia/src/pjmedia/tonegen.c
+++ b/pjmedia/src/pjmedia/tonegen.c
@@ -384,13 +384,13 @@ static pjmedia_tone_digit_map digit_map =
{ '0', 941, 1336 },
{ '1', 697, 1209 },
{ '2', 697, 1336 },
- { '3', 697, 1447 },
+ { '3', 697, 1477 },
{ '4', 770, 1209 },
{ '5', 770, 1336 },
- { '6', 770, 1447 },
+ { '6', 770, 1477 },
{ '7', 852, 1209 },
{ '8', 852, 1336 },
- { '9', 852, 1447 },
+ { '9', 852, 1477 },
{ 'a', 697, 1633 },
{ 'b', 770, 1633 },
{ 'c', 852, 1633 },