[asterisk-commits] file: branch file/pimp_sip_media r381277 - in /team/file/pimp_sip_media: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 12 09:40:27 CST 2013


Author: file
Date: Tue Feb 12 09:40:23 2013
New Revision: 381277

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381277
Log:
When applying negotiated SDP we need information from both the local and remote SDP.

Modified:
    team/file/pimp_sip_media/include/asterisk/res_sip_session.h
    team/file/pimp_sip_media/res/res_sip_sdp_audio.c
    team/file/pimp_sip_media/res/res_sip_session.c

Modified: team/file/pimp_sip_media/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/include/asterisk/res_sip_session.h?view=diff&rev=381277&r1=381276&r2=381277
==============================================================================
--- team/file/pimp_sip_media/include/asterisk/res_sip_session.h (original)
+++ team/file/pimp_sip_media/include/asterisk/res_sip_session.h Tue Feb 12 09:40:23 2013
@@ -158,13 +158,16 @@
 	/*!
 	 * \brief Apply a negotiated SDP media stream
 	 * \param session The session for which media is being applied
-	 * \param sdp The entire SDP
-	 * \param stream The stream which to apply
+	 * \param local The entire local negotiated SDP
+	 * \param local_stream The local stream which to apply
+	 * \param remote The entire remote negotiated SDP
+	 * \param remote_stream The remote stream which to apply
 	 * \retval 0 The stream was not applied by this handler. If there are other registered handlers for this stream type, they will be called.
 	 * \retval <0 There was an error encountered. No further operation will take place and the current application will be abandoned.
 	 * \retval >0 The stream was handled by this handler. No further handler of this stream type will be called.
 	 */
-	int (*apply_negotiated_sdp_stream)(struct ast_sip_session *session, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream);
+	int (*apply_negotiated_sdp_stream)(struct ast_sip_session *session, const struct pjmedia_sdp_session *local, const struct pjmedia_sdp_media *local_stream,
+		const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream);
 	/*! Next item int he list. */
 	AST_LIST_ENTRY(ast_sip_session_sdp_handler) next;
 };

Modified: team/file/pimp_sip_media/res/res_sip_sdp_audio.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/res/res_sip_sdp_audio.c?view=diff&rev=381277&r1=381276&r2=381277
==============================================================================
--- team/file/pimp_sip_media/res/res_sip_sdp_audio.c (original)
+++ team/file/pimp_sip_media/res/res_sip_sdp_audio.c Tue Feb 12 09:40:23 2013
@@ -56,7 +56,8 @@
 /*! \brief Forward declarations for SDP handler functions */
 static int audio_negotiate_incoming_sdp_stream(struct ast_sip_session *session, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream);
 static int audio_create_outgoing_sdp_stream(struct ast_sip_session *session, struct pjmedia_sdp_session *sdp);
-static int audio_apply_negotiated_sdp_stream(struct ast_sip_session *session, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream);
+static int audio_apply_negotiated_sdp_stream(struct ast_sip_session *session, const struct pjmedia_sdp_session *local, const struct pjmedia_sdp_media *local_stream,
+	const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream);
 
 /*! \brief Forward declaration for session supplement functions */
 static void audio_session_destroy(struct ast_sip_session *session);
@@ -253,7 +254,8 @@
 }
 
 /*! \brief Function which applies a negotiated SDP stream */
-static int audio_apply_negotiated_sdp_stream(struct ast_sip_session *session, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream)
+static int audio_apply_negotiated_sdp_stream(struct ast_sip_session *session, const struct pjmedia_sdp_session *local, const struct pjmedia_sdp_media *local_stream,
+	const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream)
 {
 	int format, othercapability = 0;
 	char host[NI_MAXHOST];
@@ -270,7 +272,7 @@
 		return -1;
 	}
 
-	ast_copy_pj_str(host, stream->conn ? &stream->conn->addr : &sdp->conn->addr, sizeof(host));
+	ast_copy_pj_str(host, remote_stream->conn ? &remote_stream->conn->addr : &remote->conn->addr, sizeof(host));
 
 	/* Ensure that the address provided is valid */
 	if (ast_sockaddr_resolve(&addrs, host, PARSE_PORT_FORBID, AST_AF_UNSPEC) <= 0) {
@@ -286,18 +288,18 @@
 	}
 
 	/* Apply connection information to the RTP instance */
-	ast_sockaddr_set_port(addrs, stream->desc.port);
+	ast_sockaddr_set_port(addrs, remote_stream->desc.port);
 	ast_rtp_instance_set_remote_address(session->media[AST_SIP_MEDIA_AUDIO].rtp, addrs);
 
 	ast_rtp_codecs_payloads_initialize(&codecs);
 
 	/* Iterate through provided formats */
-	for (format = 0; format < stream->desc.fmt_count; format++) {
+	for (format = 0; format < local_stream->desc.fmt_count; format++) {
 		/* The payload is kept as a string for things like t38 but for audio it is always numerical */
-		ast_rtp_codecs_payloads_set_m_type(&codecs, NULL, pj_strtoul(&stream->desc.fmt[format]));
+		ast_rtp_codecs_payloads_set_m_type(&codecs, NULL, pj_strtoul(&local_stream->desc.fmt[format]));
 
 		/* Look for the optional rtpmap attribute */
-		if ((attr = pjmedia_sdp_media_find_attr2(stream, "rtpmap", &stream->desc.fmt[format]))) {
+		if ((attr = pjmedia_sdp_media_find_attr2(local_stream, "rtpmap", &local_stream->desc.fmt[format]))) {
 			pjmedia_sdp_rtpmap *rtpmap;
 
 			/* Interpret the attribute as an rtpmap */
@@ -305,7 +307,7 @@
 				char name[32];
 
 				ast_copy_pj_str(name, &rtpmap->enc_name, sizeof(name));
-				ast_rtp_codecs_payloads_set_rtpmap_type_rate(&codecs, NULL, pj_strtoul(&stream->desc.fmt[format]),
+				ast_rtp_codecs_payloads_set_rtpmap_type_rate(&codecs, NULL, pj_strtoul(&local_stream->desc.fmt[format]),
 									     "audio", name, 0, rtpmap->clock_rate);
 			}
 		}
@@ -314,7 +316,7 @@
 	ast_rtp_codecs_payload_formats(&codecs, peercap, &othercapability);
 
 	/* Apply packetization if available and configured to do so */
-	if (session->endpoint->use_ptime && (attr = pjmedia_sdp_media_find_attr2(stream, "ptime", NULL))) {
+	if (session->endpoint->use_ptime && (attr = pjmedia_sdp_media_find_attr2(remote_stream, "ptime", NULL))) {
 		pj_str_t value = attr->value;
 		unsigned long framing = pj_strtoul(pj_strltrim(&value));
 		int codec;
@@ -371,12 +373,12 @@
 	ast_channel_set_fd(session->channel, 1, ast_rtp_instance_fd(session->media[AST_SIP_MEDIA_AUDIO].rtp, 1));
 
 	if (session->media[AST_SIP_MEDIA_AUDIO].held && (!ast_sockaddr_isnull(addrs) ||
-							  !pjmedia_sdp_media_find_attr2(stream, "sendonly", NULL))) {
+							  !pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL))) {
 		/* The remote side has taken us off hold */
 		ast_queue_control(session->channel, AST_CONTROL_UNHOLD);
 		ast_queue_frame(session->channel, &ast_null_frame);
 		session->media[AST_SIP_MEDIA_AUDIO].held = 0;
-	} else if (ast_sockaddr_isnull(addrs) || ast_sockaddr_is_any(addrs) || pjmedia_sdp_media_find_attr2(stream, "sendonly", NULL)) {
+	} else if (ast_sockaddr_isnull(addrs) || ast_sockaddr_is_any(addrs) || pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL)) {
 		/* The remote side has put us on hold */
 		ast_queue_control_data(session->channel, AST_CONTROL_HOLD, S_OR(session->endpoint->mohsuggest, NULL),
 				       !ast_strlen_zero(session->endpoint->mohsuggest) ? strlen(session->endpoint->mohsuggest) + 1 : 0);

Modified: team/file/pimp_sip_media/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/res/res_sip_session.c?view=diff&rev=381277&r1=381276&r2=381277
==============================================================================
--- team/file/pimp_sip_media/res/res_sip_session.c (original)
+++ team/file/pimp_sip_media/res/res_sip_session.c Tue Feb 12 09:40:23 2013
@@ -189,17 +189,17 @@
 	return 0;
 }
 
-static int handle_negotiated_sdp(struct ast_sip_session *session, const pjmedia_sdp_session *sdp)
+static int handle_negotiated_sdp(struct ast_sip_session *session, const pjmedia_sdp_session *local, const pjmedia_sdp_session *remote)
 {
 	int i;
-	for (i = 0; i < sdp->media_count; ++i) {
+	for (i = 0; i < local->media_count; ++i) {
 		/* See if there are registered handlers for this media stream type */
 		char media[20];
 		struct ast_sip_session_sdp_handler *handler;
 		RAII_VAR(struct sdp_handler_list *, handler_list, NULL, ao2_cleanup);
 
 		/* We need a null-terminated version of the media string */
-		ast_copy_pj_str(media, &sdp->media[i]->desc.media, sizeof(media));
+		ast_copy_pj_str(media, &local->media[i]->desc.media, sizeof(media));
 
 		handler_list = ao2_find(sdp_handlers, media, OBJ_KEY);
 		if (!handler_list) {
@@ -207,7 +207,7 @@
 			continue;
 		}
 		AST_LIST_TRAVERSE(&handler_list->list, handler, next) {
-			int res = handler->apply_negotiated_sdp_stream(session, sdp, sdp->media[i]);
+			int res = handler->apply_negotiated_sdp_stream(session, local, local->media[i], remote, remote->media[i]);
 			if (res < 0) {
 				/* Catastrophic failure. Abort! */
 				return -1;
@@ -1133,9 +1133,10 @@
 static void session_inv_on_media_update(pjsip_inv_session *inv, pj_status_t status)
 {
 	struct ast_sip_session *session = inv->mod_data[session_module.id];
-	const pjmedia_sdp_session *negotiated;
-
-	if ((status != PJ_SUCCESS) || (pjmedia_sdp_neg_get_active_local(inv->neg, &negotiated) != PJ_SUCCESS)) {
+	const pjmedia_sdp_session *local, *remote;
+
+	if ((status != PJ_SUCCESS) || (pjmedia_sdp_neg_get_active_local(inv->neg, &local) != PJ_SUCCESS) ||
+		(pjmedia_sdp_neg_get_active_remote(inv->neg, &remote) != PJ_SUCCESS)) {
 		if (session->channel) {
 			ast_channel_hangupcause_set(session->channel, AST_CAUSE_BEARERCAPABILITY_NOTAVAIL);
 			ast_queue_hangup(session->channel);
@@ -1143,7 +1144,7 @@
 		return;
 	}
 
-	handle_negotiated_sdp(session, negotiated);
+	handle_negotiated_sdp(session, local, remote);
 }
 
 static pjsip_redirect_op session_inv_on_redirected(pjsip_inv_session *inv, const pjsip_uri *target, const pjsip_event *e)




More information about the asterisk-commits mailing list