[asterisk-commits] mmichelson: branch mmichelson/sip_options r394003 - in /team/mmichelson/sip_o...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jul 10 14:32:17 CDT 2013
Author: mmichelson
Date: Wed Jul 10 14:32:15 2013
New Revision: 394003
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394003
Log:
Add various QoS settings for SIP.
Modified:
team/mmichelson/sip_options/include/asterisk/res_sip.h
team/mmichelson/sip_options/res/res_sip.c
team/mmichelson/sip_options/res/res_sip/config_transport.c
team/mmichelson/sip_options/res/res_sip/sip_configuration.c
team/mmichelson/sip_options/res/res_sip_sdp_rtp.c
Modified: team/mmichelson/sip_options/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/include/asterisk/res_sip.h?view=diff&rev=394003&r1=394002&r2=394003
==============================================================================
--- team/mmichelson/sip_options/include/asterisk/res_sip.h (original)
+++ team/mmichelson/sip_options/include/asterisk/res_sip.h Wed Jul 10 14:32:15 2013
@@ -115,6 +115,10 @@
struct ast_sockaddr external_address;
/*! Transport state information */
struct ast_sip_transport_state *state;
+ /*! QOS DSCP TOS bits */
+ unsigned int tos;
+ /*! QOS COS value */
+ unsigned int cos;
};
/*!
@@ -424,6 +428,14 @@
unsigned int devicestate_busy_at;
/*! Determines if transfers (using REFER) are allowed by this endpoint */
unsigned int allowtransfer;
+ /*! DSCP TOS bits for audio streams */
+ unsigned int tos_audio;
+ /*! Priority for audio streams */
+ unsigned int cos_audio;
+ /*! DSCP TOS bits for video streams */
+ unsigned int tos_video;
+ /*! Priority for video streams */
+ unsigned int cos_video;
};
/*!
Modified: team/mmichelson/sip_options/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/res/res_sip.c?view=diff&rev=394003&r1=394002&r2=394003
==============================================================================
--- team/mmichelson/sip_options/res/res_sip.c (original)
+++ team/mmichelson/sip_options/res/res_sip.c Wed Jul 10 14:32:15 2013
@@ -437,6 +437,30 @@
<configOption name="sdpsession" default="Asterisk">
<synopsis>String used for the SDP session (s=) line.</synopsis>
</configOption>
+ <configOption name="tos_audio">
+ <synopsis>DSCP TOS bits for audio streams</synopsis>
+ <description><para>
+ See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
+ </para></description>
+ </configOption>
+ <configOption name="tos_video">
+ <synopsis>DSCP TOS bits for video streams</synopsis>
+ <description><para>
+ See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
+ </para></description>
+ </configOption>
+ <configOption name="cos_audio">
+ <synopsis>Priority for audio streams</synopsis>
+ <description><para>
+ See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
+ </para></description>
+ </configOption>
+ <configOption name="cos_video">
+ <synopsis>Priority for video streams</synopsis>
+ <description><para>
+ See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
+ </para></description>
+ </configOption>
</configObject>
<configObject name="auth">
<synopsis>Authentication type</synopsis>
Modified: team/mmichelson/sip_options/res/res_sip/config_transport.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/res/res_sip/config_transport.c?view=diff&rev=394003&r1=394002&r2=394003
==============================================================================
--- team/mmichelson/sip_options/res/res_sip/config_transport.c (original)
+++ team/mmichelson/sip_options/res/res_sip/config_transport.c Wed Jul 10 14:32:15 2013
@@ -79,6 +79,18 @@
return transport;
}
+static void set_qos(struct ast_sip_transport *transport, pj_qos_params *qos)
+{
+ if (transport->tos) {
+ qos->flags |= PJ_QOS_PARAM_HAS_DSCP;
+ qos->dscp_val = transport->tos;
+ }
+ if (transport->cos) {
+ qos->flags |= PJ_QOS_PARAM_HAS_SO_PRIO;
+ qos->so_prio = transport->cos;
+ }
+}
+
/*! \brief Apply handler for transports */
static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
{
@@ -135,12 +147,23 @@
} else if (transport->host.addr.sa_family == pj_AF_INET6()) {
res = pjsip_udp_transport_start6(ast_sip_get_pjsip_endpoint(), &transport->host.ipv6, NULL, transport->async_operations, &transport->state->transport);
}
+
+ if (res == PJ_SUCCESS && (transport->tos || transport->cos)) {
+ pj_sock_t sock;
+ pj_qos_params qos_params;
+
+ sock = pjsip_udp_transport_get_socket(transport->state->transport);
+ pj_sock_get_qos_params(sock, &qos_params);
+ set_qos(transport, &qos_params);
+ pj_sock_set_qos_params(sock, &qos_params);
+ }
} else if (transport->type == AST_TRANSPORT_TCP) {
pjsip_tcp_transport_cfg cfg;
pjsip_tcp_transport_cfg_default(&cfg, transport->host.addr.sa_family);
cfg.bind_addr = transport->host;
cfg.async_cnt = transport->async_operations;
+ set_qos(transport, &cfg.qos_params);
res = pjsip_tcp_transport_start3(ast_sip_get_pjsip_endpoint(), &cfg, &transport->state->factory);
} else if (transport->type == AST_TRANSPORT_TLS) {
@@ -148,9 +171,13 @@
transport->tls.cert_file = pj_str((char*)transport->cert_file);
transport->tls.privkey_file = pj_str((char*)transport->privkey_file);
transport->tls.password = pj_str((char*)transport->password);
+ set_qos(transport, &transport->tls.qos_params);
res = pjsip_tls_transport_start2(ast_sip_get_pjsip_endpoint(), &transport->tls, &transport->host, NULL, transport->async_operations, &transport->state->factory);
} else if ((transport->type == AST_TRANSPORT_WS) || (transport->type == AST_TRANSPORT_WSS)) {
+ if (transport->cos || transport->tos) {
+ ast_log(LOG_WARNING, "TOS and COS values ignored for websocket transport\n");
+ }
res = PJ_SUCCESS;
}
@@ -304,6 +331,8 @@
ast_sorcery_object_field_register_custom(sorcery, "transport", "method", "", transport_tls_method_handler, NULL, 0, 0);
ast_sorcery_object_field_register_custom(sorcery, "transport", "cipher", "", transport_tls_cipher_handler, NULL, 0, 0);
ast_sorcery_object_field_register_custom(sorcery, "transport", "localnet", "", transport_localnet_handler, NULL, 0, 0);
-
- return 0;
-}
+ ast_sorcery_object_field_register(sorcery, "transport", "tos", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, tos));
+ ast_sorcery_object_field_register(sorcery, "transport", "cos", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, cos));
+
+ return 0;
+}
Modified: team/mmichelson/sip_options/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/res/res_sip/sip_configuration.c?view=diff&rev=394003&r1=394002&r2=394003
==============================================================================
--- team/mmichelson/sip_options/res/res_sip/sip_configuration.c (original)
+++ team/mmichelson/sip_options/res/res_sip/sip_configuration.c Wed Jul 10 14:32:15 2013
@@ -666,6 +666,10 @@
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allowtransfer", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allowtransfer));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdpowner", "-", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, sdpowner));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdpsession", "Asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, sdpsession));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "tos_audio", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, tos_audio));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "tos_video", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, tos_video));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "cos_audio", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, cos_audio));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "cos_video", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, cos_video));
if (ast_sip_initialize_sorcery_transport(sip_sorcery)) {
ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");
Modified: team/mmichelson/sip_options/res/res_sip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/res/res_sip_sdp_rtp.c?view=diff&rev=394003&r1=394002&r2=394003
==============================================================================
--- team/mmichelson/sip_options/res/res_sip_sdp_rtp.c (original)
+++ team/mmichelson/sip_options/res/res_sip_sdp_rtp.c Wed Jul 10 14:32:15 2013
@@ -131,6 +131,16 @@
ast_rtp_instance_dtmf_mode_set(session_media->rtp, AST_RTP_DTMF_MODE_RFC2833);
} else if (session->endpoint->dtmf == AST_SIP_DTMF_INBAND) {
ast_rtp_instance_dtmf_mode_set(session_media->rtp, AST_RTP_DTMF_MODE_INBAND);
+ }
+
+ if (!strcmp(session_media->stream_type, STR_AUDIO) &&
+ (session->endpoint->tos_audio || session->endpoint->cos_video)) {
+ ast_rtp_instance_set_qos(session_media->rtp, session->endpoint->tos_audio,
+ session->endpoint->cos_audio, "SIP RTP Audio");
+ } else if (!strcmp(session_media->stream_type, STR_VIDEO) &&
+ (session->endpoint->tos_video || session->endpoint->cos_video)) {
+ ast_rtp_instance_set_qos(session_media->rtp, session->endpoint->tos_video,
+ session->endpoint->cos_video, "SIP RTP Video");
}
return 0;
More information about the asterisk-commits
mailing list