[Asterisk-code-review] res/res pjsip: Add preferred codec only config to pjsip endp... (asterisk[master])

Aaron An asteriskteam at digium.com
Thu Sep 1 22:25:17 CDT 2016


Aaron An has uploaded a new change for review.

  https://gerrit.asterisk.org/3781

Change subject: res/res_pjsip: Add preferred_codec_only config to pjsip endpoint.
......................................................................

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: I8be7dc287560a34bf6a3352ae875efe429859975
---
M include/asterisk/res_pjsip.h
M res/res_pjsip.c
M res/res_pjsip/pjsip_configuration.c
M res/res_pjsip_session.c
4 files changed, 15 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/81/3781/1

diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index 9ec43b4..8a5ad29 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -757,8 +757,8 @@
 	unsigned int faxdetect_timeout;
 	/*! Override the user on the outgoing Contact header with this value. */
 	char *contact_user;
-    /*! Whether to response SDP offer with single most preferred codec. */
-    unsigned int preferred_codec_only;
+	/*! Whether to response SDP offer with single most preferred codec. */
+	unsigned int preferred_codec_only;
 };
 
 /*!
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 39dbbc6..7bb10c0 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -833,9 +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="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>
@@ -2025,10 +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[
- at name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='preferred_codec_only']/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 88ef7cc..97c357a 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -1933,7 +1933,7 @@
 	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));
+	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_session.c b/res/res_pjsip_session.c
index a0cde2d..0ab45c7 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1247,9 +1247,9 @@
 	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
-    if (!session->endpoint->preferred_codec_only) {
-        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
 
 	/*
@@ -2143,9 +2143,9 @@
 		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
-        if (!invite->session->endpoint->preferred_codec_only) {
-		    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
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/3781
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8be7dc287560a34bf6a3352ae875efe429859975
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Aaron An <anjb at ti-net.com.cn>



More information about the asterisk-code-review mailing list