[asterisk-commits] kmoore: branch kmoore/stasis-bridging-channel_events r385709 - in /team/kmoor...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 15 10:40:50 CDT 2013


Author: kmoore
Date: Mon Apr 15 10:40:47 2013
New Revision: 385709

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385709
Log:
Multiple revisions 385552,385597,385639

........
  r385552 | root | 2013-04-12 17:17:20 -0500 (Fri, 12 Apr 2013) | 5 lines
  
  Fix documentation.
  ........
  
  Merged revisions 385548 from file:///srv/subversion/repos/asterisk/trunk
........
  r385597 | root | 2013-04-12 18:17:20 -0500 (Fri, 12 Apr 2013) | 84 lines
  
  Multiple revisions 385573,385585,385595
  
  ........
    r385573 | elguero | 2013-04-12 17:22:58 -0500 (Fri, 12 Apr 2013) | 36 lines
    
    Fix app_voicemail Segfault And A Few Memory Leaks
    
    The original report was that app_voicemail would crash.  This was caused by
    ast_config_load() returning CONFIG_STATUS_FILEINVALID but no checks being
    performed for that return status.  After adding the initial patch to fix this
    issue, Jaco Kroon (jkroon) added some fixes to memory leaks he had discovered.
    
    During review, Walter Doekes (wdoekes) suggested adding a helper function in
    order to determine if we had a valid configuration or not.
    
    This patch does the following:
    
    * Creates a helper function to check if the configuration is valid
    
    * Adds calls to the new helper function where appropiate
    
    * Fixes memory leaks where the code returned without running
      ast_config_destroy() on the configuration that was loaded
    
    (closes issue ASTERISK-21302)
    Reported by: Jaco Kroon
    Tested by: Jaco Kroon, Michael L. Young
    Patches:
        asterisk-11.3.0-app_voicemail-ast_config-fixes.patch
                                                           Jaco Kroon (license 5671)
        asterisk-21302-valid_cfg_and_mem_leaks_v3-1.8.diff
                                                     Michael L. Young (license 5026)
    
    Review: https://reviewboard.asterisk.org/r/2443/
    ........
    
    Merged revisions 385551 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 385557 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
    r385585 | kmoore | 2013-04-12 17:26:17 -0500 (Fri, 12 Apr 2013) | 14 lines
    
    Allow codec_resample to be unloaded
    
    Ensure that trans_size is correct to prevent uninitialized entries from
    preventing reload.
    
    (closes issue ASTERISK-21401)
    Reported by: Corey Farrell
    Tested by: Corey Farrell
    Patches:
        codec_resample-unload.patch uploaded by Corey Farrell
    ........
    
    Merged revisions 385582 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
    r385595 | elguero | 2013-04-12 17:38:56 -0500 (Fri, 12 Apr 2013) | 22 lines
    
    Fix Manager Segfault When app_queue Is Unloaded
    
    When app_queue is unloaded, some manager commands are not being unregistered
    which result in a segfault.  This patch corrects this.
    
    (closes issue ASTERISK-21397)
    Reported by: Peter Katzmann, Corey Farrell
    Tested by: Corey Farrell
    Patches:
        asterisk-21397-missing-unreg-manager-cmd_1.8.diff
                                                     Michael L. Young (license 5026)
        asterisk-21397-missing-unreg-manager-cmd_11.diff
                                                     Michael L. Young (license 5026)
    
    Review: https://reviewboard.asterisk.org/r/2444/
    ........
    
    Merged revisions 385593 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 385594 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
  
  Merged revisions 385573,385585,385595 from file:///srv/subversion/repos/asterisk/trunk
........
  r385639 | root | 2013-04-13 22:17:22 -0500 (Sat, 13 Apr 2013) | 52 lines
  
  Multiple revisions 385635,385638
  
  ........
    r385635 | mjordan | 2013-04-13 21:35:04 -0500 (Sat, 13 Apr 2013) | 23 lines
    
    Don't attempt to create a voice frame on a read error
    
    Prior to this patch, a read error in snd_pcm_readi would still be treated as a
    nominal result when constructing a voice frame from the expected data. Since
    the value returned is negative, as opposed to the number of samples read,
    this could result in a crash. With this patch, we now return a null frame
    when a read error is detected.
    
    Note that the patch on ASTERISK-21329 was modified slightly for this commit,
    in that we bail immediately on detecting the read error, rather than bypassing
    the construction of the voice frame.
    
    (closes issue ASTERISK-21329)
    Reported by: Keiichiro Kawasaki
    patches:
      chan_alsa.diff uploaded by kawasaki (License 6489)
    ........
    
    Merged revisions 385633 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 385634 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
    r385638 | mjordan | 2013-04-13 22:01:33 -0500 (Sat, 13 Apr 2013) | 19 lines
    
    Calculate the timestamp for outbound RTP if we don't have timing information
    
    This patch calculates the timestamp for outbound RTP when we don't have timing
    information. This uses the same approach in res_rtp_asterisk. Thanks to both
    Pietro and Tzafrir for providing patches.
    
    (closes issue ASTERISK-19883)
    Reported by: Giacomo Trovato
    Tested by: Pietro Bertera, Tzafrir Cohen
    patches:
      rtp-timestamp-1.8.patch uploaded by tzafrir (License 5035)
      rtp-timestamp.patch uploaded by pbertera (License 5943)
    ........
    
    Merged revisions 385636 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 385637 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
  
  Merged revisions 385635,385638 from file:///srv/subversion/repos/asterisk/trunk
........

Merged revisions 385552,385597,385639 from http://svn.asterisk.org/svn/asterisk/team/group/bridge_construction

Modified:
    team/kmoore/stasis-bridging-channel_events/   (props changed)
    team/kmoore/stasis-bridging-channel_events/apps/app_queue.c
    team/kmoore/stasis-bridging-channel_events/apps/app_voicemail.c
    team/kmoore/stasis-bridging-channel_events/channels/chan_alsa.c
    team/kmoore/stasis-bridging-channel_events/codecs/codec_resample.c
    team/kmoore/stasis-bridging-channel_events/include/asterisk/sorcery.h
    team/kmoore/stasis-bridging-channel_events/res/res_rtp_multicast.c

Propchange: team/kmoore/stasis-bridging-channel_events/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/kmoore/stasis-bridging-channel_events/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Apr 15 10:40:47 2013
@@ -1,1 +1,1 @@
-/team/group/bridge_construction:1-385544
+/team/group/bridge_construction:1-385708

Modified: team/kmoore/stasis-bridging-channel_events/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/apps/app_queue.c?view=diff&rev=385709&r1=385708&r2=385709
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/apps/app_queue.c (original)
+++ team/kmoore/stasis-bridging-channel_events/apps/app_queue.c Mon Apr 15 10:40:47 2013
@@ -9866,6 +9866,9 @@
 	res |= ast_manager_unregister("QueuePause");
 	res |= ast_manager_unregister("QueueLog");
 	res |= ast_manager_unregister("QueuePenalty");
+	res |= ast_manager_unregister("QueueReload");
+	res |= ast_manager_unregister("QueueReset");
+	res |= ast_manager_unregister("QueueMemberRingInUse");
 	res |= ast_unregister_application(app_aqm);
 	res |= ast_unregister_application(app_rqm);
 	res |= ast_unregister_application(app_pqm);

Modified: team/kmoore/stasis-bridging-channel_events/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/apps/app_voicemail.c?view=diff&rev=385709&r1=385708&r2=385709
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/apps/app_voicemail.c (original)
+++ team/kmoore/stasis-bridging-channel_events/apps/app_voicemail.c Mon Apr 15 10:40:47 2013
@@ -1719,6 +1719,14 @@
 	return res;
 }
 
+/*!
+ * \brief Check if configuration file is valid
+ */
+static inline int valid_config(const struct ast_config *cfg)
+{
+	return cfg && cfg != CONFIG_STATUS_FILEINVALID;
+}
+
 /*! 
  * \brief The handler for the change password option.
  * \param vmu The voicemail user to work with.
@@ -1755,7 +1763,7 @@
 		}
 		/* Fall-through */
 	case OPT_PWLOC_VOICEMAILCONF:
-		if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
+		if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) && valid_config(cfg)) {
 			while ((category = ast_category_browse(cfg, category))) {
 				if (!strcasecmp(category, vmu->context)) {
 					if (!(tmp = ast_variable_retrieve(cfg, category, vmu->mailbox))) {
@@ -1784,14 +1792,17 @@
 				reset_user_pw(vmu->context, vmu->mailbox, newpassword);
 				ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
 				ast_config_text_file_save(VOICEMAIL_CONFIG, cfg, "AppVoicemail");
+				ast_config_destroy(cfg);
 				break;
 			}
+
+			ast_config_destroy(cfg);
 		}
 		/* Fall-through */
 	case OPT_PWLOC_USERSCONF:
 		/* check users.conf and update the password stored for the mailbox */
 		/* if no vmsecret entry exists create one. */
-		if ((cfg = ast_config_load("users.conf", config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
+		if ((cfg = ast_config_load("users.conf", config_flags)) && valid_config(cfg)) {
 			ast_debug(4, "we are looking for %s\n", vmu->mailbox);
 			for (category = ast_category_browse(cfg, NULL); category; category = ast_category_browse(cfg, category)) {
 				ast_debug(4, "users.conf: %s\n", category);
@@ -1825,6 +1836,8 @@
 				ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
 				ast_config_text_file_save("users.conf", cfg, "AppVoicemail");
 			}
+
+			ast_config_destroy(cfg);
 		}
 	}
 }
@@ -4179,7 +4192,7 @@
 			res = -1;
 			break;
 		}
-		if (cfg && cfg != CONFIG_STATUS_FILEINVALID) {
+		if (valid_config(cfg)) {
 			if (!(idata.context = ast_variable_retrieve(cfg, "message", "context"))) {
 				idata.context = "";
 			}
@@ -4235,7 +4248,7 @@
 	if (obj) {
 		ast_odbc_release_obj(obj);
 	}
-	if (cfg)
+	if (valid_config(cfg))
 		ast_config_destroy(cfg);
 	if (fdm != MAP_FAILED)
 		munmap(fdm, fdlen);
@@ -4714,7 +4727,7 @@
 	if (strlen(fromfile) < sizeof(fromfile) - 5) {
 		strcat(fromfile, ".txt");
 	}
-	if (!(msg_cfg = ast_config_load(fromfile, config_flags))) {
+	if (!(msg_cfg = ast_config_load(fromfile, config_flags)) || !(valid_config(msg_cfg))) {
 		ast_debug(1, "Config load for message text file '%s' failed\n", fromfile);
 		return;
 	}
@@ -5106,7 +5119,7 @@
 			if (strlen(fromfile) < sizeof(fromfile) - 5) {
 				strcat(fromfile, ".txt");
 			}
-			if ((msg_cfg = ast_config_load(fromfile, config_flags))) {
+			if ((msg_cfg = ast_config_load(fromfile, config_flags)) && valid_config(msg_cfg)) {
 				if ((v = ast_variable_retrieve(msg_cfg, "message", "callerid"))) {
 					ast_copy_string(origcallerid, v, sizeof(origcallerid));
 				}
@@ -7592,7 +7605,7 @@
 	strncat(backup, "-bak", sizeof(backup) - strlen(backup) - 1);
 	strncat(backup_textfile, "-bak.txt", sizeof(backup_textfile) - strlen(backup_textfile) - 1);
 
-	if ((msg_cfg = ast_config_load(textfile, config_flags)) && msg_cfg != CONFIG_STATUS_FILEINVALID && (duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) {
+	if ((msg_cfg = ast_config_load(textfile, config_flags)) && valid_config(msg_cfg) && (duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) {
 		*duration = atoi(duration_str);
 	} else {
 		*duration = 0;
@@ -7628,7 +7641,7 @@
 			*duration = 0;
 
 			/* if we can't read the message metadata, stop now */
-			if (!msg_cfg) {
+			if (!valid_config(msg_cfg)) {
 				cmd = 0;
 				break;
 			}
@@ -7712,7 +7725,7 @@
 		}
 	}
 
-	if (msg_cfg)
+	if (valid_config(msg_cfg))
 		ast_config_destroy(msg_cfg);
 	if (prepend_duration)
 		*duration = prepend_duration;
@@ -8463,7 +8476,7 @@
 	snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
 	RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
 	msg_cfg = ast_config_load(filename, config_flags);
-	if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) {
+	if (!valid_config(msg_cfg)) {
 		ast_log(LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
 		return 0;
 	}
@@ -8541,7 +8554,7 @@
 		}
 	}
 
-	if (!msg_cfg) {
+	if (!valid_config(msg_cfg)) {
 		ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
 		return 0;
 	}
@@ -13637,7 +13650,7 @@
 	struct ast_flags config_flags = { 0 };
 
 	pwconf = ast_config_load(secretfn, config_flags);
-	if (pwconf) {
+	if (valid_config(pwconf)) {
 		const char *val = ast_variable_retrieve(pwconf, "general", "password");
 		if (val) {
 			ast_copy_string(password, val, passwordlen);
@@ -14124,7 +14137,7 @@
 	fputs("00000002 => 9999,Mrs. Test\n", file);
 	fclose(file);
 
-	if (!(cfg = ast_config_load(config_filename, config_flags))) {
+	if (!(cfg = ast_config_load(config_filename, config_flags)) || !valid_config(cfg)) {
 		res = AST_TEST_FAIL;
 		goto cleanup;
 	}
@@ -14454,7 +14467,7 @@
 	RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
 	msg_cfg = ast_config_load(filename, config_flags);
 	DISPOSE(vms->curdir, vms->curmsg);
-	if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) {
+	if (!valid_config(msg_cfg)) {
 		ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
 		return 0;
 	}
@@ -14616,9 +14629,9 @@
 		break;
 	}
 
+	ast_config_destroy(msg_cfg);
+
 #ifndef IMAP_STORAGE
-	ast_config_destroy(msg_cfg);
-
 	if (!res) {
 		make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
 		vms->heard[msg] = 1;

Modified: team/kmoore/stasis-bridging-channel_events/channels/chan_alsa.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/channels/chan_alsa.c?view=diff&rev=385709&r1=385708&r2=385709
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/channels/chan_alsa.c (original)
+++ team/kmoore/stasis-bridging-channel_events/channels/chan_alsa.c Mon Apr 15 10:40:47 2013
@@ -483,6 +483,13 @@
 	} else if (r < 0) {
 		ast_log(LOG_ERROR, "Read error: %s\n", snd_strerror(r));
 	}
+
+	/* Return NULL frame on error */
+	if (r < 0) {
+		ast_mutex_unlock(&alsalock);
+		return &f;
+	}
+
 	/* Update positions */
 	readpos += r;
 	left -= r;

Modified: team/kmoore/stasis-bridging-channel_events/codecs/codec_resample.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/codecs/codec_resample.c?view=diff&rev=385709&r1=385708&r2=385709
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/codecs/codec_resample.c (original)
+++ team/kmoore/stasis-bridging-channel_events/codecs/codec_resample.c Mon Apr 15 10:40:47 2013
@@ -113,7 +113,7 @@
 	int res = 0;
 	int x, y, idx = 0;
 
-	trans_size = ARRAY_LEN(id_list) * ARRAY_LEN(id_list);
+	trans_size = ARRAY_LEN(id_list) * (ARRAY_LEN(id_list) - 1);
 	if (!(translators = ast_calloc(1, sizeof(struct ast_translator) * trans_size))) {
 		return AST_MODULE_LOAD_FAILURE;
 	}

Modified: team/kmoore/stasis-bridging-channel_events/include/asterisk/sorcery.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/include/asterisk/sorcery.h?view=diff&rev=385709&r1=385708&r2=385709
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/include/asterisk/sorcery.h (original)
+++ team/kmoore/stasis-bridging-channel_events/include/asterisk/sorcery.h Mon Apr 15 10:40:47 2013
@@ -44,7 +44,7 @@
  * override configured mappings. They are only used in the case where no configured mapping exists.
  *
  * Configuring object mappings implicitly creates a basic version of an object type. The object type
- * must be fully registered, however, using the \ref ast_sorcery_object_type_register API call before any
+ * must be fully registered, however, using the \ref ast_sorcery_object_register API call before any
  * objects of the type can be allocated, created, or retrieved.
  *
  * Once the object type itself has been fully registered the individual fields within the object must

Modified: team/kmoore/stasis-bridging-channel_events/res/res_rtp_multicast.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging-channel_events/res/res_rtp_multicast.c?view=diff&rev=385709&r1=385708&r2=385709
==============================================================================
--- team/kmoore/stasis-bridging-channel_events/res/res_rtp_multicast.c (original)
+++ team/kmoore/stasis-bridging-channel_events/res/res_rtp_multicast.c Mon Apr 15 10:40:47 2013
@@ -90,6 +90,8 @@
 	unsigned int ssrc;
 	/*! Sequence number, used when creating/sending the RTP packet */
 	uint16_t seqno;
+	unsigned int lastts;	
+	struct timeval txcore;
 };
 
 /* Forward Declarations */
@@ -140,6 +142,30 @@
 	return 0;
 }
 
+static int rtp_get_rate(struct ast_format *format)
+{
+        return (format->id == AST_FORMAT_G722) ? 8000 : ast_format_rate(format);
+}
+
+static unsigned int calc_txstamp(struct multicast_rtp *rtp, struct timeval *delivery)
+{
+        struct timeval t;
+        long ms;
+
+        if (ast_tvzero(rtp->txcore)) {
+                rtp->txcore = ast_tvnow();
+                rtp->txcore.tv_usec -= rtp->txcore.tv_usec % 20000;
+        }
+
+        t = (delivery && !ast_tvzero(*delivery)) ? *delivery : ast_tvnow();
+        if ((ms = ast_tvdiff_ms(t, rtp->txcore)) < 0) {
+                ms = 0;
+        }
+        rtp->txcore = t;
+
+        return (unsigned int) ms;
+}
+
 /*! \brief Helper function which populates a control packet with useful information and sends it */
 static int multicast_send_control_packet(struct ast_rtp_instance *instance, struct multicast_rtp *multicast, int command)
 {
@@ -210,6 +236,8 @@
 	struct ast_sockaddr remote_address;
 	int hdrlen = 12, res = 0, codec;
 	unsigned char *rtpheader;
+	unsigned int ms = calc_txstamp(multicast, &frame->delivery);
+	int rate = rtp_get_rate(&frame->subclass.format) / 1000;
 
 	/* We only accept audio, nothing else */
 	if (frame->frametype != AST_FRAME_VOICE) {
@@ -225,12 +253,21 @@
 	if (frame->offset < hdrlen) {
 		f = ast_frdup(frame);
 	}
-
+	
+	/* Calucate last TS */
+	multicast->lastts = multicast->lastts + ms * rate;
+	
 	/* Construct an RTP header for our packet */
 	rtpheader = (unsigned char *)(f->data.ptr - hdrlen);
 	put_unaligned_uint32(rtpheader, htonl((2 << 30) | (codec << 16) | (multicast->seqno)));
-	put_unaligned_uint32(rtpheader + 4, htonl(f->ts * 8));
-	put_unaligned_uint32(rtpheader + 8, htonl(multicast->ssrc));
+	put_unaligned_uint32(rtpheader + 4, htonl(multicast->lastts));
+	
+	if (ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO)) {
+		put_unaligned_uint32(rtpheader + 4, htonl(f->ts * 8));
+	} 
+	else {
+		put_unaligned_uint32(rtpheader + 8, htonl(multicast->ssrc));
+	}
 
 	/* Increment sequence number and wrap to 0 if it overflows 16 bits. */
 	multicast->seqno = 0xFFFF & (multicast->seqno + 1);




More information about the asterisk-commits mailing list