[asterisk-commits] dlee: branch dlee/stasis-core r382688 - in /team/dlee/stasis-core: ./ apps/ c...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 8 09:18:49 CST 2013


Author: dlee
Date: Fri Mar  8 09:18:43 2013
New Revision: 382688

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382688
Log:
Merged revisions 382555-382671 from http://svn.asterisk.org/svn/asterisk/trunk

Modified:
    team/dlee/stasis-core/   (props changed)
    team/dlee/stasis-core/apps/app_voicemail.c
    team/dlee/stasis-core/channels/chan_sip.c
    team/dlee/stasis-core/include/asterisk/rtp_engine.h
    team/dlee/stasis-core/main/logger.c
    team/dlee/stasis-core/main/rtp_engine.c
    team/dlee/stasis-core/main/threadpool.c
    team/dlee/stasis-core/main/xmldoc.c
    team/dlee/stasis-core/res/res_rtp_asterisk.c
    team/dlee/stasis-core/res/res_sorcery_config.c
    team/dlee/stasis-core/res/res_sorcery_memory.c

Propchange: team/dlee/stasis-core/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/dlee/stasis-core/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Mar  8 09:18:43 2013
@@ -1,1 +1,1 @@
-/trunk:1-382490
+/trunk:1-382671

Modified: team/dlee/stasis-core/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/apps/app_voicemail.c?view=diff&rev=382688&r1=382687&r2=382688
==============================================================================
--- team/dlee/stasis-core/apps/app_voicemail.c (original)
+++ team/dlee/stasis-core/apps/app_voicemail.c Fri Mar  8 09:18:43 2013
@@ -15059,8 +15059,9 @@
 	int i;
 	int this_index_only = -1;
 	int open = 0;
-	int inbox_index = 0;
-	int old_index = 1;
+	int inbox_index = get_folder_by_name("INBOX");
+	int old_index = get_folder_by_name("Old");
+	int urgent_index = get_folder_by_name("Urgent");
 
 	if (ast_strlen_zero(mailbox)) {
 		ast_log(LOG_WARNING, "Cannot create a mailbox snapshot since no mailbox was specified\n");
@@ -15102,7 +15103,14 @@
 
 	for (i = 0; i < mailbox_snapshot->folders; i++) {
 		int combining_old = 0;
-		if ((i == old_index) && (combine_INBOX_and_OLD)) {
+		/* Assume we are combining folders if:
+		 *  - The current index is the old folder index OR
+		 *  - The current index is urgent and we were looking for INBOX or all folders OR
+		 *  - The current index is INBOX and we were looking for Urgent or all folders
+		 */
+		if ((i == old_index ||
+			(i == urgent_index && (this_index_only == inbox_index || this_index_only == -1)) ||
+			(i == inbox_index && (this_index_only == urgent_index || this_index_only == -1))) && (combine_INBOX_and_OLD)) {
 			combining_old = 1;
 		}
 

Modified: team/dlee/stasis-core/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/channels/chan_sip.c?view=diff&rev=382688&r1=382687&r2=382688
==============================================================================
--- team/dlee/stasis-core/channels/chan_sip.c (original)
+++ team/dlee/stasis-core/channels/chan_sip.c Fri Mar  8 09:18:43 2013
@@ -9858,64 +9858,6 @@
 	return;
 }
 
-
-static int get_ip_and_port_from_sdp(struct sip_request *req, const enum media_type media, struct ast_sockaddr *addr)
-{
-	const char *m;
-	const char *c;
-	int miterator = req->sdp_start;
-	int citerator = req->sdp_start;
-	int x = 0;
-	int numberofports;
-	int len;
-	int af;
-	char proto[4], host[258] = ""; /*Initialize to empty so we will know if we have any input */
-
-	c = get_sdp_iterate(&citerator, req, "c");
-	if (sscanf(c, "IN %3s %256s", proto, host) != 2) {
-			ast_log(LOG_WARNING, "Invalid host in c= line, '%s'\n", c);
-			/* Continue since there may be a valid host in a c= line specific to the audio stream */
-	}
-	/* We only want the m and c lines for audio */
-	for (m = get_sdp_iterate(&miterator, req, "m"); !ast_strlen_zero(m); m = get_sdp_iterate(&miterator, req, "m")) {
-		if ((media == SDP_AUDIO && ((sscanf(m, "audio %30u/%30u RTP/AVP %n", &x, &numberofports, &len) == 2 && len > 0) ||
-		    (sscanf(m, "audio %30u RTP/AVP %n", &x, &len) == 1 && len > 0))) ||
-			(media == SDP_VIDEO && ((sscanf(m, "video %30u/%30u RTP/AVP %n", &x, &numberofports, &len) == 2 && len > 0) ||
-		    (sscanf(m, "video %30u RTP/AVP %n", &x, &len) == 1 && len > 0)))) {
-			/* See if there's a c= line for this media stream.
-			 * XXX There is no guarantee that we'll be grabbing the c= line for this
-			 * particular media stream here. However, this is the same logic used in process_sdp.
-			 */
-			c = get_sdp_iterate(&citerator, req, "c");
-			if (!ast_strlen_zero(c)) {
-				sscanf(c, "IN %3s %256s", proto, host);
-			}
-			break;
-		}
-	}
-
-	if (!strcmp("IP4", proto)) {
-		af = AF_INET;
-	} else if (!strcmp("IP6", proto)) {
-		af = AF_INET6;
-	} else {
-		ast_log(LOG_WARNING, "Unknown protocol '%s'.\n", proto);
-		return -1;
-	}
-
-	if (ast_strlen_zero(host) || x == 0) {
-		ast_log(LOG_WARNING, "Failed to read an alternate host or port in SDP. Expect %s problems\n", media == SDP_AUDIO ? "audio" : "video");
-		return -1;
-	}
-
-	if (ast_sockaddr_resolve_first_af(addr, host, 0, af)) {
-		ast_log(LOG_WARNING, "Could not look up IP address of alternate hostname. Expect %s problems\n", media == SDP_AUDIO? "audio" : "video");
-		return -1;
-	}
-
-	return 0;
-}
-
 /*! \internal
  * \brief Returns whether or not the address is null or ANY / unspecified (0.0.0.0 or ::)
  * \retval TRUE if the address is null or any
@@ -25305,21 +25247,6 @@
 		} else {
 			/* We already have a pending invite. Sorry. You are on hold. */
 			p->glareinvite = seqno;
-			if (p->rtp && find_sdp(req)) {
-				struct ast_sockaddr addr;
-				if (get_ip_and_port_from_sdp(req, SDP_AUDIO, &addr)) {
-					ast_log(LOG_WARNING, "Failed to set an alternate media source on glared reinvite. Audio may not work properly on this call.\n");
-				} else {
-					ast_rtp_instance_set_alt_remote_address(p->rtp, &addr);
-				}
-				if (p->vrtp) {
-					if (get_ip_and_port_from_sdp(req, SDP_VIDEO, &addr)) {
-						ast_log(LOG_WARNING, "Failed to set an alternate media source on glared reinvite. Video may not work properly on this call.\n");
-					} else {
-						ast_rtp_instance_set_alt_remote_address(p->vrtp, &addr);
-					}
-				}
-			}
 			transmit_response_reliable(p, "491 Request Pending", req);
 			check_via(p, req);
 			ast_debug(1, "Got INVITE on call where we already have pending INVITE, deferring that - %s\n", p->callid);

Modified: team/dlee/stasis-core/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/include/asterisk/rtp_engine.h?view=diff&rev=382688&r1=382687&r2=382688
==============================================================================
--- team/dlee/stasis-core/include/asterisk/rtp_engine.h (original)
+++ team/dlee/stasis-core/include/asterisk/rtp_engine.h Fri Mar  8 09:18:43 2013
@@ -443,8 +443,6 @@
 	void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref);
 	/*! Callback for setting the remote address that RTP is to be sent to */
 	void (*remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa);
-	/*! Callback for setting an alternate remote address */
-	void (*alt_remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa);
 	/*! Callback for changing DTMF mode */
 	int (*dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
 	/*! Callback for getting DTMF mode */
@@ -791,29 +789,6 @@
  */
 int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address);
 
-
-/*!
- * \brief Set the address of an an alternate RTP address to receive from
- *
- * \param instance The RTP instance to change the address on
- * \param address Address to set it to
- *
- * \retval 0 success
- * \retval -1 failure
- *
- * Example usage:
- *
- * \code
- * ast_rtp_instance_set_alt_remote_address(instance, &address);
- * \endcode
- *
- * This changes the alternate remote address that RTP will be sent to on instance to the address given in the sin
- * structure.
- *
- * \since 1.8
- */
-int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address);
-
 /*!
  * \brief Set the address that we are expecting to receive RTP on
  *

Modified: team/dlee/stasis-core/main/logger.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/main/logger.c?view=diff&rev=382688&r1=382687&r2=382688
==============================================================================
--- team/dlee/stasis-core/main/logger.c (original)
+++ team/dlee/stasis-core/main/logger.c Fri Mar  8 09:18:43 2013
@@ -1537,7 +1537,7 @@
 		AST_LIST_LOCK(&logmsgs);
 		if (close_logger_thread) {
 			/* Logger is either closing or closed.  We cannot log this message. */
-			ast_free(logmsg);
+			logmsg_free(logmsg);
 		} else {
 			AST_LIST_INSERT_TAIL(&logmsgs, logmsg, list);
 			ast_cond_signal(&logcond);

Modified: team/dlee/stasis-core/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/main/rtp_engine.c?view=diff&rev=382688&r1=382687&r2=382688
==============================================================================
--- team/dlee/stasis-core/main/rtp_engine.c (original)
+++ team/dlee/stasis-core/main/rtp_engine.c Fri Mar  8 09:18:43 2013
@@ -61,8 +61,6 @@
 	struct ast_sockaddr local_address;
 	/*! Address that we are sending RTP to */
 	struct ast_sockaddr remote_address;
-	/*! Alternate address that we are receiving RTP from */
-	struct ast_sockaddr alt_remote_address;
 	/*! Instance that we are bridged to if doing remote or local bridging */
 	struct ast_rtp_instance *bridged;
 	/*! Payload and packetization information */
@@ -330,20 +328,6 @@
 
 	if (instance->engine->remote_address_set) {
 		instance->engine->remote_address_set(instance, &instance->remote_address);
-	}
-
-	return 0;
-}
-
-int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance,
-		const struct ast_sockaddr *address)
-{
-	ast_sockaddr_copy(&instance->alt_remote_address, address);
-
-	/* oink */
-
-	if (instance->engine->alt_remote_address_set) {
-		instance->engine->alt_remote_address_set(instance, &instance->alt_remote_address);
 	}
 
 	return 0;

Modified: team/dlee/stasis-core/main/threadpool.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/main/threadpool.c?view=diff&rev=382688&r1=382687&r2=382688
==============================================================================
--- team/dlee/stasis-core/main/threadpool.c (original)
+++ team/dlee/stasis-core/main/threadpool.c Fri Mar  8 09:18:43 2013
@@ -792,7 +792,7 @@
  */
 static int queued_set_size(void *data)
 {
-	struct set_size_data *ssd = data;
+	RAII_VAR(struct set_size_data *, ssd, data, ao2_cleanup);
 	struct ast_threadpool *pool = ssd->pool;
 	unsigned int num_threads = ssd->size;
 
@@ -801,8 +801,8 @@
 		ao2_container_count(pool->idle_threads);
 
 	if (current_size == num_threads) {
-		ast_log(LOG_NOTICE, "Not changing threadpool size since new size %u is the same as current %u\n",
-				num_threads, current_size);
+		ast_debug(3, "Not changing threadpool size since new size %u is the same as current %u\n",
+			  num_threads, current_size);
 		return 0;
 	}
 
@@ -813,7 +813,6 @@
 	}
 
 	threadpool_send_state_changed(pool);
-	ao2_ref(ssd, -1);
 	return 0;
 }
 

Modified: team/dlee/stasis-core/main/xmldoc.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/main/xmldoc.c?view=diff&rev=382688&r1=382687&r2=382688
==============================================================================
--- team/dlee/stasis-core/main/xmldoc.c (original)
+++ team/dlee/stasis-core/main/xmldoc.c Fri Mar  8 09:18:43 2013
@@ -760,6 +760,7 @@
 				if ((paramtype = ast_xml_get_attribute(node, "required"))) {
 					if (!ast_true(paramtype)) {
 						optmidnode = 1;
+						ast_xml_free_attr(paramtype);
 						break;
 					}
 					ast_xml_free_attr(paramtype);
@@ -1150,6 +1151,7 @@
 		text = ast_xml_get_text(tmp);
 		ast_str_set(&syntax, 0, "category %s /%s/", match ? "=~" : "!~", text);
 		ast_xml_free_attr(attr_value);
+		ast_xml_free_text(text);
 	}
 
 	if ((tmp = ast_xml_find_element(ast_xml_node_get_children(matchinfo), "field", NULL, NULL))) {
@@ -1157,6 +1159,7 @@
 		attr_value = ast_xml_get_attribute(tmp, "name");
 		ast_str_append(&syntax, 0, " matchfield: %s = %s", S_OR(attr_value, "Unknown"), text);
 		ast_xml_free_attr(attr_value);
+		ast_xml_free_text(text);
 	}
 	return ast_strdup(ast_str_buffer(syntax));
 }
@@ -2345,16 +2348,22 @@
 	struct ast_xml_doc_item *item;
 
 	for (iter = ast_xml_node_get_children(cur); iter; iter = ast_xml_node_get_next(iter)) {
+		const char *iter_name;
 		if (strncasecmp(ast_xml_node_get_name(iter), "config", 6)) {
 			continue;
 		}
+		iter_name = ast_xml_get_attribute(iter, "name");
 		/* Now add all of the child config-related items to the list */
-		if (!(item = xmldoc_build_documentation_item(iter, ast_xml_get_attribute(iter, "name"), ast_xml_node_get_name(iter)))) {
-			ast_log(LOG_ERROR, "Could not build documentation for '%s:%s'\n", ast_xml_node_get_name(iter), ast_xml_get_attribute(iter, "name"));
+		if (!(item = xmldoc_build_documentation_item(iter, iter_name, ast_xml_node_get_name(iter)))) {
+			ast_log(LOG_ERROR, "Could not build documentation for '%s:%s'\n", ast_xml_node_get_name(iter), iter_name);
+			ast_xml_free_attr(iter_name);
 			break;
 		}
+		ast_xml_free_attr(iter_name);
 		if (!strcasecmp(ast_xml_node_get_name(iter), "configOption")) {
-			ast_string_field_set(item, ref, ast_xml_get_attribute(cur, "name"));
+			const char *name = ast_xml_get_attribute(cur, "name");
+			ast_string_field_set(item, ref, name);
+			ast_xml_free_attr(name);
 		}
 		(*tail)->next = item;
 		*tail = (*tail)->next;
@@ -2466,10 +2475,11 @@
 			case CONFIG_INFO_SYNTAX:
 			{
 				struct ast_xml_doc_item *tail;
+				RAII_VAR(const char *, name, ast_xml_get_attribute(node, "name"), ast_xml_free_attr);
 				if (item || !ast_xml_node_get_children(node) || strcasecmp(ast_xml_node_get_name(node), "configInfo")) {
 					break;
 				}
-				if (!(item = xmldoc_build_documentation_item(node, ast_xml_get_attribute(node, "name"), "configInfo"))) {
+				if (!(item = xmldoc_build_documentation_item(node, name, "configInfo"))) {
 					break;
 				}
 				tail = item;

Modified: team/dlee/stasis-core/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/res/res_rtp_asterisk.c?view=diff&rev=382688&r1=382687&r2=382688
==============================================================================
--- team/dlee/stasis-core/res/res_rtp_asterisk.c (original)
+++ team/dlee/stasis-core/res/res_rtp_asterisk.c Fri Mar  8 09:18:43 2013
@@ -168,6 +168,12 @@
 
 #define COMPONENT_RTP 1
 #define COMPONENT_RTCP 2
+
+/*! \brief RTP learning mode tracking information */
+struct rtp_learning_info {
+	int max_seq;	/*!< The highest sequence number received */
+	int packets;	/*!< The number of remaining packets before the source is accepted */
+};
 
 /*! \brief RTP session description */
 struct ast_rtp {
@@ -233,14 +239,13 @@
 
 	enum strict_rtp_state strict_rtp_state; /*!< Current state that strict RTP protection is in */
 	struct ast_sockaddr strict_rtp_address;  /*!< Remote address information for strict RTP purposes */
-	struct ast_sockaddr alt_rtp_address; /*!<Alternate remote address information */
 
 	/*
 	 * Learning mode values based on pjmedia's probation mode.  Many of these values are redundant to the above,
 	 * but these are in place to keep learning mode sequence values sealed from their normal counterparts.
 	 */
-	uint16_t learning_max_seq;		/*!< Highest sequence number heard */
-	int learning_probation;		/*!< Sequential packets untill source is valid */
+	struct rtp_learning_info rtp_source_learn;	/* Learning mode track for the expected RTP source */
+	struct rtp_learning_info alt_source_learn;	/* Learning mode tracking for a new RTP source after one has been chosen */
 
 	struct rtp_red *red;
 
@@ -371,7 +376,6 @@
 static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
 static int ast_rtp_fd(struct ast_rtp_instance *instance, int rtcp);
 static void ast_rtp_remote_address_set(struct ast_rtp_instance *instance, struct ast_sockaddr *addr);
-static void ast_rtp_alt_remote_address_set(struct ast_rtp_instance *instance, struct ast_sockaddr *addr);
 static int rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations);
 static int rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame);
 static int ast_rtp_local_bridge(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1);
@@ -1004,7 +1008,6 @@
 	.prop_set = ast_rtp_prop_set,
 	.fd = ast_rtp_fd,
 	.remote_address_set = ast_rtp_remote_address_set,
-	.alt_remote_address_set = ast_rtp_alt_remote_address_set,
 	.red_init = rtp_red_init,
 	.red_buffer = rtp_red_buffer,
 	.local_bridge = ast_rtp_local_bridge,
@@ -1021,7 +1024,7 @@
 #endif
 };
 
-static void rtp_learning_seq_init(struct ast_rtp *rtp, uint16_t seq);
+static void rtp_learning_seq_init(struct rtp_learning_info *info, uint16_t seq);
 
 static void ast_rtp_on_ice_complete(pj_ice_sess *ice, pj_status_t status)
 {
@@ -1032,7 +1035,7 @@
 	}
 
 	rtp->strict_rtp_state = STRICT_RTP_LEARN;
-	rtp_learning_seq_init(rtp, (uint16_t)rtp->seqno);
+	rtp_learning_seq_init(&rtp->rtp_source_learn, (uint16_t)rtp->seqno);
 }
 
 static void ast_rtp_on_ice_rx_data(pj_ice_sess *ice, unsigned comp_id, unsigned transport_id, void *pkt, pj_size_t size, const pj_sockaddr_t *src_addr, unsigned src_addr_len)
@@ -1592,13 +1595,13 @@
  * \brief Initializes sequence values and probation for learning mode.
  * \note This is an adaptation of pjmedia's pjmedia_rtp_seq_init function.
  *
- * \param rtp pointer to rtp struct used with the received rtp packet.
- * \param seq sequence number read from the rtp header
+ * \param info The learning information to track
+ * \param seq sequence number read from the rtp header to initialize the information with
  */
-static void rtp_learning_seq_init(struct ast_rtp *rtp, uint16_t seq)
-{
-	rtp->learning_max_seq = seq - 1;
-	rtp->learning_probation = learning_min_sequential;
+static void rtp_learning_seq_init(struct rtp_learning_info *info, uint16_t seq)
+{
+	info->max_seq = seq - 1;
+	info->packets = learning_min_sequential;
 }
 
 /*!
@@ -1606,29 +1609,23 @@
  * \brief Updates sequence information for learning mode and determines if probation/learning mode should remain in effect.
  * \note This function was adapted from pjmedia's pjmedia_rtp_seq_update function.
  *
- * \param rtp pointer to rtp struct used with the received rtp packet.
+ * \param info Structure tracking the learning progress of some address
  * \param seq sequence number read from the rtp header
- * \return boolean value indicating if probation mode is active at the end of the function
+ * \retval 0 if probation mode should exit for this address
+ * \retval non-zero if probation mode should continue
  */
-static int rtp_learning_rtp_seq_update(struct ast_rtp *rtp, uint16_t seq)
-{
-	int probation = 1;
-
-	ast_debug(1, "%p -- probation = %d, seq = %d\n", rtp, rtp->learning_probation, seq);
-
-	if (seq == rtp->learning_max_seq + 1) {
+static int rtp_learning_rtp_seq_update(struct rtp_learning_info *info, uint16_t seq)
+{
+	if (seq == info->max_seq + 1) {
 		/* packet is in sequence */
-		rtp->learning_probation--;
-		rtp->learning_max_seq = seq;
-		if (rtp->learning_probation == 0) {
-			probation = 0;
-		}
+		info->packets--;
 	} else {
-		rtp->learning_probation = learning_min_sequential - 1;
-		rtp->learning_max_seq = seq;
-	}
-
-	return probation;
+		/* Sequence discontinuity; reset */
+		info->packets = learning_min_sequential - 1;
+	}
+	info->max_seq = seq;
+
+	return (info->packets == 0);
 }
 
 static void rtp_add_candidates_to_ice(struct ast_rtp_instance *instance, struct ast_rtp *rtp, struct ast_sockaddr *addr, int port, int component,
@@ -1719,7 +1716,8 @@
 	rtp->seqno = ast_random() & 0xffff;
 	rtp->strict_rtp_state = (strictrtp ? STRICT_RTP_LEARN : STRICT_RTP_OPEN);
 	if (strictrtp) {
-		rtp_learning_seq_init(rtp, (uint16_t)rtp->seqno);
+		rtp_learning_seq_init(&rtp->rtp_source_learn, (uint16_t)rtp->seqno);
+		rtp_learning_seq_init(&rtp->alt_source_learn, (uint16_t)rtp->seqno);
 	}
 
 	/* Create a new socket for us to listen on and use */
@@ -3552,34 +3550,36 @@
 
 	/* If strict RTP protection is enabled see if we need to learn the remote address or if we need to drop the packet */
 	if (rtp->strict_rtp_state == STRICT_RTP_LEARN) {
-		ast_debug(1, "%p -- start learning mode pass with addr = %s\n", rtp, ast_sockaddr_stringify(&addr));
+		ast_debug(1, "%p -- Probation learning mode pass with source address %s\n", rtp, ast_sockaddr_stringify(&addr));
 		/* For now, we always copy the address. */
 		ast_sockaddr_copy(&rtp->strict_rtp_address, &addr);
 
 		/* Send the rtp and the seqno from header to rtp_learning_rtp_seq_update to see whether we can exit or not*/
-		if (rtp_learning_rtp_seq_update(rtp, ntohl(rtpheader[0]))) {
-			ast_debug(1, "%p -- Condition for learning hasn't exited, so reject the frame.\n", rtp);
+		if (rtp_learning_rtp_seq_update(&rtp->rtp_source_learn, seqno)) {
+			ast_debug(1, "%p -- Probation at seq %d with %d to go; discarding frame\n",
+				rtp, rtp->rtp_source_learn.max_seq, rtp->rtp_source_learn.packets);
 			return &ast_null_frame;
 		}
 
-		ast_debug(1, "%p -- Probation Ended. Set strict_rtp_state to STRICT_RTP_CLOSED with address %s\n", rtp, ast_sockaddr_stringify(&addr));
+		ast_verb(4, "%p -- Probation passed - setting RTP source address to %s\n", rtp, ast_sockaddr_stringify(&addr));
 		rtp->strict_rtp_state = STRICT_RTP_CLOSED;
-	} else if (rtp->strict_rtp_state == STRICT_RTP_CLOSED) {
-		if (ast_sockaddr_cmp(&rtp->strict_rtp_address, &addr)) {
-			/* Hmm, not the strict addres. Perhaps we're getting audio from the alternate? */
-			if (!ast_sockaddr_cmp(&rtp->alt_rtp_address, &addr)) {
-				/* ooh, we did! You're now the new expected address, son! */
-				ast_sockaddr_copy(&rtp->strict_rtp_address,
-						  &addr);
-			} else  {
-				const char *real_addr = ast_strdupa(ast_sockaddr_stringify(&addr));
-				const char *expected_addr = ast_strdupa(ast_sockaddr_stringify(&rtp->strict_rtp_address));
-
-				ast_debug(1, "Received RTP packet from %s, dropping due to strict RTP protection. Expected it to be from %s\n",
-						real_addr, expected_addr);
-
+	}
+	if (rtp->strict_rtp_state == STRICT_RTP_CLOSED) {
+		if (!ast_sockaddr_cmp(&rtp->strict_rtp_address, &addr)) {
+			/* Always reset the alternate learning source */
+			rtp_learning_seq_init(&rtp->alt_source_learn, seqno);
+		} else {
+			/* Start trying to learn from the new address. If we pass a probationary period with
+			 * it, that means we've stopped getting RTP from the original source and we should
+			 * switch to it.
+			 */
+			if (rtp_learning_rtp_seq_update(&rtp->alt_source_learn, seqno)) {
+				ast_debug(1, "%p -- Received RTP packet from %s, dropping due to strict RTP protection. Will switch to it in %d packets\n",
+						rtp, ast_sockaddr_stringify(&addr), rtp->alt_source_learn.packets);
 				return &ast_null_frame;
 			}
+			ast_verb(4, "%p -- Switching RTP source address to %s\n", rtp, ast_sockaddr_stringify(&addr));
+			ast_sockaddr_copy(&rtp->strict_rtp_address, &addr);
 		}
 	}
 
@@ -3958,20 +3958,8 @@
 
 	if (strictrtp && rtp->strict_rtp_state != STRICT_RTP_OPEN) {
 		rtp->strict_rtp_state = STRICT_RTP_LEARN;
-		rtp_learning_seq_init(rtp, rtp->seqno);
-	}
-
-	return;
-}
-
-static void ast_rtp_alt_remote_address_set(struct ast_rtp_instance *instance, struct ast_sockaddr *addr)
-{
-	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
-
-	/* No need to futz with rtp->rtcp here because ast_rtcp_read is already able to adjust if receiving
-	 * RTCP from an "unexpected" source
-	 */
-	ast_sockaddr_copy(&rtp->alt_rtp_address, addr);
+		rtp_learning_seq_init(&rtp->rtp_source_learn, rtp->seqno);
+	}
 
 	return;
 }

Modified: team/dlee/stasis-core/res/res_sorcery_config.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/res/res_sorcery_config.c?view=diff&rev=382688&r1=382687&r2=382688
==============================================================================
--- team/dlee/stasis-core/res/res_sorcery_config.c (original)
+++ team/dlee/stasis-core/res/res_sorcery_config.c Fri Mar  8 09:18:43 2013
@@ -387,5 +387,5 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Sorcery Configuration File Object Wizard",
 	.load = load_module,
 	.unload = unload_module,
-	.load_pri = AST_MODPRI_CHANNEL_DEPEND,
+	.load_pri = AST_MODPRI_REALTIME_DRIVER,
 );

Modified: team/dlee/stasis-core/res/res_sorcery_memory.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-core/res/res_sorcery_memory.c?view=diff&rev=382688&r1=382687&r2=382688
==============================================================================
--- team/dlee/stasis-core/res/res_sorcery_memory.c (original)
+++ team/dlee/stasis-core/res/res_sorcery_memory.c Fri Mar  8 09:18:43 2013
@@ -237,5 +237,5 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Sorcery In-Memory Object Wizard",
 	.load = load_module,
 	.unload = unload_module,
-	.load_pri = AST_MODPRI_CHANNEL_DEPEND,
+	.load_pri = AST_MODPRI_REALTIME_DRIVER,
 );




More information about the asterisk-commits mailing list