[asterisk-commits] mmichelson: branch mmichelson/direct_media r382825 - /team/mmichelson/direct_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 11 17:18:23 CDT 2013


Author: mmichelson
Date: Mon Mar 11 17:18:19 2013
New Revision: 382825

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382825
Log:
Make change detection for RTP more generic.

This also adds support for detection of changes in video addresses.


Modified:
    team/mmichelson/direct_media/channels/chan_gulp.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=382825&r1=382824&r2=382825
==============================================================================
--- team/mmichelson/direct_media/channels/chan_gulp.c (original)
+++ team/mmichelson/direct_media/channels/chan_gulp.c Mon Mar 11 17:18:19 2013
@@ -180,6 +180,33 @@
 	return 0;
 }
 
+static int check_for_rtp_changes(struct ast_channel *chan, struct ast_rtp_instance *rtp,
+		struct ast_sip_session_media *media, int rtcp_fd)
+{
+	int changed = 0;
+
+	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)){
+		ast_sockaddr_setnull(&media->direct_media_addr);
+		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);
+		}
+	}
+
+	return changed;
+}
+
 /*! \brief Function called by RTP engine to change where the remote party should send media */
 static int gulp_set_rtp_peer(struct ast_channel *chan,
 		struct ast_rtp_instance *rtp,
@@ -195,26 +222,8 @@
 		return 0;
 	}
 
-	if (rtp) {
-		struct ast_sip_session_media *audio = &session->media[AST_SIP_MEDIA_AUDIO];
-		changed = ast_rtp_instance_get_and_cmp_remote_address(rtp, &audio->direct_media_addr);
-		if (audio->rtp) {
-			ast_channel_lock(chan);
-			ast_channel_set_fd(chan, 1, -1);
-			ast_channel_unlock(chan);
-			ast_rtp_instance_set_prop(audio->rtp, AST_RTP_PROPERTY_RTCP, 0);
-		}
-	} else {
-		struct ast_sip_session_media *audio = &session->media[AST_SIP_MEDIA_AUDIO];
-		ast_sockaddr_setnull(&audio->direct_media_addr);
-		changed = 1;
-		if (audio->rtp) {
-			ast_rtp_instance_set_prop(audio->rtp, AST_RTP_PROPERTY_RTCP, 1);
-			ast_channel_lock(chan);
-			ast_channel_set_fd(chan, 1, ast_rtp_instance_fd(audio->rtp, 1));
-			ast_channel_unlock(chan);
-		}
-	}
+	changed |= check_for_rtp_changes(chan, rtp, &session->media[AST_SIP_MEDIA_AUDIO], 1);
+	changed |= check_for_rtp_changes(chan, vrtp, &session->media[AST_SIP_MEDIA_VIDEO], 3);
 
 	if (direct_media_mitigate_glare(session)) {
 		return 0;




More information about the asterisk-commits mailing list