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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 14 11:54:54 CDT 2013


Author: mmichelson
Date: Thu Mar 14 11:54:50 2013
New Revision: 383060

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383060
Log:
Address Joshua's review feedback:

1) Fixed incorrect logic in direct media glare mitigation in session_begin callback.
We could potentially allocate a datastore when we don't need to.
2) Unregister the gulp_supplement if the gulp_ack_supplement fails to register
3) Added a parameter to ast_sip_session_refresh() to indicate if an SDP should be added.
4) Removed unnecessary channel locks in direct media handling.


Modified:
    team/mmichelson/direct_media/channels/chan_gulp.c
    team/mmichelson/direct_media/include/asterisk/res_sip_session.h
    team/mmichelson/direct_media/res/res_sip_session.c

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=383060&r1=383059&r2=383060
==============================================================================
--- team/mmichelson/direct_media/channels/chan_gulp.c (original)
+++ team/mmichelson/direct_media/channels/chan_gulp.c Thu Mar 14 11:54:50 2013
@@ -145,7 +145,7 @@
 static int send_direct_media_request(void *data)
 {
 	RAII_VAR(struct ast_sip_session *, session, data, ao2_cleanup);
-	return ast_sip_session_refresh(session, NULL, NULL, session->endpoint->direct_media_method);
+	return ast_sip_session_refresh(session, NULL, NULL, session->endpoint->direct_media_method, 1);
 }
 
 static struct ast_datastore_info direct_media_mitigation_info = { };
@@ -187,9 +187,7 @@
 	if (rtp) {
 		changed = ast_rtp_instance_get_and_cmp_remote_address(rtp, &media->direct_media_addr);
 		if (media->rtp) {
-			ast_channel_lock(chan);
 			ast_channel_set_fd(chan, rtcp_fd, -1);
-			ast_channel_unlock(chan);
 			ast_rtp_instance_set_prop(media->rtp, AST_RTP_PROPERTY_RTCP, 0);
 		}
 	} else if (!ast_sockaddr_isnull(&media->direct_media_addr)){
@@ -197,9 +195,7 @@
 		changed = 1;
 		if (media->rtp) {
 			ast_rtp_instance_set_prop(media->rtp, AST_RTP_PROPERTY_RTCP, 1);
-			ast_channel_lock(chan);
 			ast_channel_set_fd(chan, rtcp_fd, ast_rtp_instance_fd(media->rtp, 1));
-			ast_channel_unlock(chan);
 		}
 	}
 
@@ -901,7 +897,7 @@
 {
 	RAII_VAR(struct ast_datastore *, datastore, NULL, ao2_cleanup);
 
-	if (!session->endpoint->direct_media_glare_mitigation ==
+	if (session->endpoint->direct_media_glare_mitigation ==
 			AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_NONE) {
 		return;
 	}
@@ -1040,6 +1036,7 @@
 
 	if (ast_sip_session_register_supplement(&gulp_ack_supplement)) {
 		ast_log(LOG_ERROR, "Unable to register Gulp ACK supplement\n");
+		ast_sip_session_unregister_supplement(&gulp_supplement);
 		goto end;
 	}
 

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=383060&r1=383059&r2=383060
==============================================================================
--- team/mmichelson/direct_media/include/asterisk/res_sip_session.h (original)
+++ team/mmichelson/direct_media/include/asterisk/res_sip_session.h Thu Mar 14 11:54:50 2013
@@ -387,13 +387,15 @@
  * \param on_request_creation Callback called when request is created
  * \param on_response Callback called when response for request is received
  * \param method The method that should be used when constructing the session refresh
+ * \param generate_new_sdp Boolean to indicate if a new SDP should be created
  * \retval 0 Successfully sent refresh
  * \retval -1 Failure to send refresh
  */
 int ast_sip_session_refresh(struct ast_sip_session *session,
 		ast_sip_session_request_creation_cb on_request_creation,
 		ast_sip_session_response_cb on_response,
-		enum ast_sip_session_refresh_method method);
+		enum ast_sip_session_refresh_method method,
+		int generate_new_sdp);
 
 /*!
  * \brief Send a SIP response

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=383060&r1=383059&r2=383060
==============================================================================
--- team/mmichelson/direct_media/res/res_sip_session.c (original)
+++ team/mmichelson/direct_media/res/res_sip_session.c Thu Mar 14 11:54:50 2013
@@ -395,10 +395,10 @@
 
 	if (!strcmp(delay->method, "INVITE")) {
 		ast_sip_session_refresh(session, delay->on_request_creation,
-				delay->on_response, AST_SIP_SESSION_REFRESH_METHOD_INVITE);
+				delay->on_response, AST_SIP_SESSION_REFRESH_METHOD_INVITE, 1);
 	} else if (!strcmp(delay->method, "UPDATE")) {
 		ast_sip_session_refresh(session, delay->on_request_creation,
-				delay->on_response, AST_SIP_SESSION_REFRESH_METHOD_UPDATE);
+				delay->on_response, AST_SIP_SESSION_REFRESH_METHOD_UPDATE, 1);
 	} else {
 		ast_log(LOG_WARNING, "Unexpected delayed %s request with no existing request structure\n", delay->method);
 		return -1;
@@ -447,13 +447,25 @@
 	return 0;
 }
 
+static pjmedia_sdp_session *generate_session_refresh_sdp(struct ast_sip_session *session)
+{
+	pjsip_inv_session *inv_session = session->inv_session;
+	const pjmedia_sdp_session *previous_sdp;
+
+	if (pjmedia_sdp_neg_was_answer_remote(inv_session->neg)) {
+		pjmedia_sdp_neg_get_active_remote(inv_session->neg, &previous_sdp);
+	} else {
+		pjmedia_sdp_neg_get_active_local(inv_session->neg, &previous_sdp);
+	}
+	return create_local_sdp(inv_session, session, previous_sdp);
+}
+
 int ast_sip_session_refresh(struct ast_sip_session *session,
 		ast_sip_session_request_creation_cb on_request_creation, ast_sip_session_response_cb on_response,
-		enum ast_sip_session_refresh_method method)
+		enum ast_sip_session_refresh_method method, int generate_new_sdp)
 {
 	pjsip_inv_session *inv_session = session->inv_session;
-	pjmedia_sdp_session *new_sdp;
-	const pjmedia_sdp_session *previous_sdp;
+	pjmedia_sdp_session *new_sdp = NULL;
 	pjsip_tx_data *tdata;
 
 	if (inv_session->state == PJSIP_INV_STATE_DISCONNECTED) {
@@ -470,12 +482,14 @@
 		return delay_request(session, on_request_creation, on_response, "INVITE", NULL);
 	}
 
-	if (pjmedia_sdp_neg_was_answer_remote(inv_session->neg)) {
-		pjmedia_sdp_neg_get_active_remote(inv_session->neg, &previous_sdp);
-	} else {
-		pjmedia_sdp_neg_get_active_local(inv_session->neg, &previous_sdp);
-	}
-	new_sdp = create_local_sdp(inv_session, session, previous_sdp);
+	if (generate_new_sdp) {
+		new_sdp = generate_session_refresh_sdp(session);
+		if (!new_sdp) {
+			ast_log(LOG_ERROR, "Failed to generate session refresh SDP. Not sending session refresh\n");
+			return -1;
+		}
+	}
+
 	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");




More information about the asterisk-commits mailing list