summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorAaron An <anjb@ti-net.com.cn>2016-08-30 11:26:03 +0800
committerJoshua Colp <jcolp@digium.com>2016-09-09 05:36:19 -0500
commit2a50c2910144e1b4095d171b1386fd5ebb0c5b5a (patch)
treebcc7712ca9397f1ae82f5e30905f21b247acde74 /res
parentd3c4b901d476a41b3f7df063aeba3852df4e26b7 (diff)
res/res_pjsip: Add preferred_codec_only config to pjsip endpoint.
This patch add config to pjsip by endpoint. ;preferred_codec_only=yes ; Respond to a SIP invite with the single most preferred codec ; rather than advertising all joint codec capabilities. This ; limits the other side's codec choice to exactly what we prefer. ASTERISK-26317 #close Reported by: AaronAn Tested by: AaronAn Change-Id: Iad04dc55055403bbf5ec050997aee2dadc4f0762
Diffstat (limited to 'res')
-rw-r--r--res/res_pjsip.c6
-rw-r--r--res/res_pjsip/pjsip_configuration.c1
-rw-r--r--res/res_pjsip_sdp_rtp.c9
-rw-r--r--res/res_pjsip_session.c8
4 files changed, 20 insertions, 4 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 34edc8ca5..7bb10c07f 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -833,6 +833,9 @@
have this accountcode set on it.
</para></description>
</configOption>
+ <configOption name="preferred_codec_only" default="no">
+ <synopsis>Respond to a SIP invite with the single most preferred codec rather than advertising all joint codec capabilities. This limits the other side's codec choice to exactly what we prefer.</synopsis>
+ </configOption>
<configOption name="rtp_keepalive">
<synopsis>Number of seconds between RTP comfort noise keepalive packets.</synopsis>
<description><para>
@@ -2022,6 +2025,9 @@
<parameter name="Accountcode">
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='accountcode']/synopsis/node())"/></para>
</parameter>
+ <parameter name="PreferredCodecOnly">
+ <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='preferred_codec_only']/synopsis/node())"/></para>
+ </parameter>
<parameter name="DeviceState">
<para>The aggregate device state for this endpoint.</para>
</parameter>
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 333be7143..97c357a9e 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -1933,6 +1933,7 @@ int ast_res_pjsip_initialize_configuration(void)
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_acl", "", endpoint_acl_handler, contact_acl_to_str, NULL, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "subscribe_context", "", OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct ast_sip_endpoint, subscription.context));
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "contact_user", "", contact_user_handler, contact_user_to_str, NULL, 0, 0);
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "preferred_codec_only", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, preferred_codec_only));
if (ast_sip_initialize_sorcery_transport()) {
ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index 6610ef126..68d5fdb56 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -360,8 +360,13 @@ static int set_caps(struct ast_sip_session *session,
ast_format_cap_append_from_cap(caps, ast_channel_nativeformats(session->channel),
AST_MEDIA_TYPE_UNKNOWN);
ast_format_cap_remove_by_type(caps, media_type);
- ast_format_cap_append_from_cap(caps, joint, media_type);
-
+ if (session->endpoint->preferred_codec_only){
+ struct ast_format *preferred_fmt = ast_format_cap_get_format(joint, 0);
+ ast_format_cap_append(caps, preferred_fmt, 0);
+ ao2_ref(preferred_fmt, -1);
+ } else {
+ ast_format_cap_append_from_cap(caps, joint, media_type);
+ }
/*
* Apply the new formats to the channel, potentially changing
* raw read/write formats and translation path while doing so.
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 315393fdb..0ab45c74e 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1247,7 +1247,9 @@ int ast_sip_session_create_invite(struct ast_sip_session *session, pjsip_tx_data
pjsip_inv_set_local_sdp(session->inv_session, offer);
pjmedia_sdp_neg_set_prefer_remote_codec_order(session->inv_session->neg, PJ_FALSE);
#ifdef PJMEDIA_SDP_NEG_ANSWER_MULTIPLE_CODECS
- pjmedia_sdp_neg_set_answer_multiple_codecs(session->inv_session->neg, PJ_TRUE);
+ if (!session->endpoint->preferred_codec_only) {
+ pjmedia_sdp_neg_set_answer_multiple_codecs(session->inv_session->neg, PJ_TRUE);
+ }
#endif
/*
@@ -2141,7 +2143,9 @@ static int new_invite(void *data)
pjsip_inv_set_local_sdp(invite->session->inv_session, local);
pjmedia_sdp_neg_set_prefer_remote_codec_order(invite->session->inv_session->neg, PJ_FALSE);
#ifdef PJMEDIA_SDP_NEG_ANSWER_MULTIPLE_CODECS
- pjmedia_sdp_neg_set_answer_multiple_codecs(invite->session->inv_session->neg, PJ_TRUE);
+ if (!invite->session->endpoint->preferred_codec_only) {
+ pjmedia_sdp_neg_set_answer_multiple_codecs(invite->session->inv_session->neg, PJ_TRUE);
+ }
#endif
}