[asterisk-commits] mmichelson: branch mmichelson/direct_media r382804 - in /team/mmichelson/dire...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 11 12:42:39 CDT 2013


Author: mmichelson
Date: Mon Mar 11 12:42:35 2013
New Revision: 382804

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382804
Log:
Combine reinvite and update sending methods into a single one for sending a session refresh.


Modified:
    team/mmichelson/direct_media/channels/chan_gulp.c
    team/mmichelson/direct_media/include/asterisk/res_sip.h
    team/mmichelson/direct_media/include/asterisk/res_sip_session.h
    team/mmichelson/direct_media/res/res_sip/sip_configuration.c
    team/mmichelson/direct_media/res/res_sip_session.c
    team/mmichelson/direct_media/res/res_sip_session.exports.in

Modified: team/mmichelson/direct_media/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/channels/chan_gulp.c?view=diff&rev=382804&r1=382803&r2=382804
==============================================================================
--- team/mmichelson/direct_media/channels/chan_gulp.c (original)
+++ team/mmichelson/direct_media/channels/chan_gulp.c Mon Mar 11 12:42:35 2013
@@ -144,11 +144,7 @@
 static int send_direct_media_request(void *data)
 {
 	RAII_VAR(struct ast_sip_session *, session, data, ao2_cleanup);
-	if (session->endpoint->direct_media_method == AST_SIP_DIRECT_MEDIA_METHOD_INVITE) {
-		return ast_sip_session_send_reinvite(session, NULL);
-	} else {
-		return ast_sip_session_send_update(session);
-	}
+	return ast_sip_session_refresh(session, session->endpoint->direct_media_method);
 }
 
 /*! \brief Function called by RTP engine to change where the remote party should send media */
@@ -739,7 +735,7 @@
 	endpoint->min_se = 90;
 	endpoint->sess_expires = 1800;
 	endpoint->direct_media = 1;
-	endpoint->direct_media_method = AST_SIP_DIRECT_MEDIA_METHOD_UPDATE;
+	endpoint->direct_media_method = AST_SIP_SESSION_REFRESH_METHOD_UPDATE;
 
 	if (!(session = ast_sip_session_create_outgoing(endpoint, req_data->dest))) {
 		return -1;

Modified: team/mmichelson/direct_media/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/include/asterisk/res_sip.h?view=diff&rev=382804&r1=382803&r2=382804
==============================================================================
--- team/mmichelson/direct_media/include/asterisk/res_sip.h (original)
+++ team/mmichelson/direct_media/include/asterisk/res_sip.h Mon Mar 11 12:42:35 2013
@@ -213,11 +213,11 @@
 	AST_SIP_ENDPOINT_IDENTIFY_BY_LOCATION = (1 << 1),
 };
 
-enum ast_sip_direct_media_method {
+enum ast_sip_session_refresh_method {
 	/*! Use reinvite to negotiate direct media */
-	AST_SIP_DIRECT_MEDIA_METHOD_INVITE,
+	AST_SIP_SESSION_REFRESH_METHOD_INVITE,
 	/*! Use UPDATE to negotiate direct media */
-	AST_SIP_DIRECT_MEDIA_METHOD_UPDATE,
+	AST_SIP_SESSION_REFRESH_METHOD_UPDATE,
 };
 
 /*!
@@ -270,7 +270,7 @@
 	/*! Boolean indicating if direct_media is permissible */
 	unsigned int direct_media;
 	/*! When using direct media, which method should be used */
-	enum ast_sip_direct_media_method direct_media_method;
+	enum ast_sip_session_refresh_method direct_media_method;
 };
 
 /*!

Modified: team/mmichelson/direct_media/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/include/asterisk/res_sip_session.h?view=diff&rev=382804&r1=382803&r2=382804
==============================================================================
--- team/mmichelson/direct_media/include/asterisk/res_sip_session.h (original)
+++ team/mmichelson/direct_media/include/asterisk/res_sip_session.h Mon Mar 11 12:42:35 2013
@@ -367,27 +367,18 @@
 int ast_sip_session_get_identity(struct pjsip_rx_data *rdata, struct ast_party_id *id);
 
 /*!
- * \brief Send a reinvite on a session
+ * \brief Send a reinvite or UPDATE on a session
  *
  * This method will inspect the session in order to construct an appropriate
- * reinvite. As with any outgoing request in res_sip_session, this will
- * call into registered supplements in case they wish to add anything.
+ * session refresh request. As with any outgoing request in res_sip_session,
+ * this will call into registered supplements in case they wish to add anything.
  * 
  * \param session The session on which the reinvite will be sent
- * \param response_cb Optional callback that can be called when the reinvite response is received. The callback is identical in nature to the incoming_response() callback for session supplements.
- * \retval 0 Successfully sent reinvite
- * \retval -1 Failure to send reinvite
- */
-int ast_sip_session_send_reinvite(struct ast_sip_session *session, int (*response_cb)(struct ast_sip_session *session, struct pjsip_rx_data *rdata));
-
-/*!
- * \brief Send an UPDATE on a session
- *
- * \param session The session on which to send the UPDATE
- * \retval 0 Successfully sent UPDATE
- * \retval -1 Failure to send UPDATE
- */
-int ast_sip_session_send_update(struct ast_sip_session *session);
+ * \param method The method that should be used when constructing the session refresh
+ * \retval 0 Successfully sent refresh
+ * \retval -1 Failure to send refresh
+ */
+int ast_sip_session_refresh(struct ast_sip_session *session, enum ast_sip_session_refresh_method method);
 
 /*!
  * \brief Send a SIP response

Modified: team/mmichelson/direct_media/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/res/res_sip/sip_configuration.c?view=diff&rev=382804&r1=382803&r2=382804
==============================================================================
--- team/mmichelson/direct_media/res/res_sip/sip_configuration.c (original)
+++ team/mmichelson/direct_media/res/res_sip/sip_configuration.c Mon Mar 11 12:42:35 2013
@@ -259,9 +259,9 @@
 	struct ast_sip_endpoint *endpoint = obj;
 
 	if (!strcasecmp(var->value, "invite") || !strcasecmp(var->value, "reinvite")) {
-		endpoint->direct_media_method = AST_SIP_DIRECT_MEDIA_METHOD_INVITE;
+		endpoint->direct_media_method = AST_SIP_SESSION_REFRESH_METHOD_INVITE;
 	} else if (!strcasecmp(var->value, "update")) {
-		endpoint->direct_media_method = AST_SIP_DIRECT_MEDIA_METHOD_UPDATE;
+		endpoint->direct_media_method = AST_SIP_SESSION_REFRESH_METHOD_UPDATE;
 	} else {
 		ast_log(LOG_NOTICE, "Unrecognized option value %s for %s on endpoint %s\n",
 				var->value, var->name, ast_sorcery_object_get_id(endpoint));

Modified: team/mmichelson/direct_media/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/res/res_sip_session.c?view=diff&rev=382804&r1=382803&r2=382804
==============================================================================
--- team/mmichelson/direct_media/res/res_sip_session.c (original)
+++ team/mmichelson/direct_media/res/res_sip_session.c Mon Mar 11 12:42:35 2013
@@ -29,6 +29,7 @@
 #include "pjsip_ua.h"
 #include "pjlib.h"
 
+#include "asterisk/res_sip.h"
 #include "asterisk/res_sip_session.h"
 #include "asterisk/datastore.h"
 #include "asterisk/module.h"
@@ -363,7 +364,9 @@
 	ast_debug(3, "Sending delayed %s request to %s\n", delay->method, ast_sorcery_object_get_id(session->endpoint));
 
 	if (!strcmp(delay->method, "INVITE")) {
-		ast_sip_session_send_reinvite(session, NULL);
+		ast_sip_session_refresh(session, AST_SIP_SESSION_REFRESH_METHOD_INVITE);
+	} else if (!strcmp(delay->method, "UPDATE")) {
+		ast_sip_session_refresh(session, AST_SIP_SESSION_REFRESH_METHOD_UPDATE);
 	} else if (!strcmp(delay->method, "BYE")) {
 		pjsip_tx_data *tdata;
 		pjsip_inv_end_session(session->inv_session, 500, 0, &tdata);
@@ -399,11 +402,11 @@
 	return 0;
 }
 
-int ast_sip_session_send_reinvite(struct ast_sip_session *session, int (*response_cb)(struct ast_sip_session *session, struct pjsip_rx_data *rdata))
+int ast_sip_session_refresh(struct ast_sip_session *session, enum ast_sip_session_refresh_method method)
 {
 	pjsip_inv_session *inv_session = session->inv_session;
-	pjmedia_sdp_session *reinvite_sdp;
-	const pjmedia_sdp_session *last_sdp;
+	pjmedia_sdp_session *new_sdp;
+	const pjmedia_sdp_session *previous_sdp;
 	pjsip_tx_data *tdata;
 
 	if (inv_session->state == PJSIP_INV_STATE_DISCONNECTED) {
@@ -421,41 +424,17 @@
 	}
 
 	if (pjmedia_sdp_neg_was_answer_remote(inv_session->neg)) {
-		pjmedia_sdp_neg_get_active_remote(inv_session->neg, &last_sdp);
+		pjmedia_sdp_neg_get_active_remote(inv_session->neg, &previous_sdp);
 	} else {
-		pjmedia_sdp_neg_get_active_local(inv_session->neg, &last_sdp);
-	}
-	reinvite_sdp = create_local_sdp(inv_session, session, last_sdp);
-	if (pjsip_inv_reinvite(inv_session, NULL, reinvite_sdp, &tdata)) {
-		ast_log(LOG_WARNING, "Failed to create reinvite properly.\n");
-		return -1;
-	}
-	ast_sip_session_send_request(session, tdata);
-	return 0;
-}
-
-int ast_sip_session_send_update(struct ast_sip_session *session)
-{
-	pjsip_inv_session *inv_session = session->inv_session;
-	pjmedia_sdp_session *update_sdp;
-	const pjmedia_sdp_session *last_sdp;
-	pjsip_tx_data *tdata;
-
-	if (inv_session->state == PJSIP_INV_STATE_DISCONNECTED) {
-		/* Don't try to do anything with a hung-up call */
-		ast_debug(3, "Not sending reinvite to %s because of disconnected state...\n",
-				S_OR(ast_sorcery_object_get_id(session->endpoint), "outbound"));
-		return 0;
-	}
-
-	if (pjmedia_sdp_neg_was_answer_remote(inv_session->neg)) {
-		pjmedia_sdp_neg_get_active_remote(inv_session->neg, &last_sdp);
-	} else {
-		pjmedia_sdp_neg_get_active_local(inv_session->neg, &last_sdp);
-	}
-
-	update_sdp = create_local_sdp(inv_session, session, last_sdp);
-	if (pjsip_inv_update(inv_session, NULL, update_sdp, &tdata)) {
+		pjmedia_sdp_neg_get_active_local(inv_session->neg, &previous_sdp);
+	}
+	new_sdp = create_local_sdp(inv_session, session, previous_sdp);
+	if (method == AST_SIP_SESSION_REFRESH_METHOD_INVITE) {
+		if (pjsip_inv_reinvite(inv_session, NULL, new_sdp, &tdata)) {
+			ast_log(LOG_WARNING, "Failed to create reinvite properly.\n");
+			return -1;
+		}
+	} else if (pjsip_inv_update(inv_session, NULL, new_sdp, &tdata)) {
 		ast_log(LOG_WARNING, "Failed to create UPDATE properly.\n");
 		return -1;
 	}
@@ -1001,7 +980,7 @@
 {
 	struct ast_sip_session *session = data;
 
-	ast_sip_session_send_reinvite(session, NULL);
+	ast_sip_session_refresh(session, AST_SIP_SESSION_REFRESH_METHOD_INVITE);
 	ao2_ref(session, -1);
 	return 0;
 }

Modified: team/mmichelson/direct_media/res/res_sip_session.exports.in
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/res/res_sip_session.exports.in?view=diff&rev=382804&r1=382803&r2=382804
==============================================================================
--- team/mmichelson/direct_media/res/res_sip_session.exports.in (original)
+++ team/mmichelson/direct_media/res/res_sip_session.exports.in Mon Mar 11 12:42:35 2013
@@ -8,8 +8,7 @@
 		LINKER_SYMBOL_PREFIXast_sip_session_get_datastore;
 		LINKER_SYMBOL_PREFIXast_sip_session_remove_datastore;
 		LINKER_SYMBOL_PREFIXast_sip_session_get_identity;
-		LINKER_SYMBOL_PREFIXast_sip_session_send_reinvite;
-		LINKER_SYMBOL_PREFIXast_sip_session_send_update;
+		LINKER_SYMBOL_PREFIXast_sip_session_refresh;
 		LINKER_SYMBOL_PREFIXast_sip_session_send_response;
 		LINKER_SYMBOL_PREFIXast_sip_session_send_request;
 		LINKER_SYMBOL_PREFIXast_sip_session_create_outgoing;




More information about the asterisk-commits mailing list