[asterisk-commits] branch oej/sdpcleanup r31637 - in /team/oej/sdpcleanup: ./ build_tools/ chann...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jun 1 23:24:57 MST 2006


Author: oej
Date: Fri Jun  2 01:24:57 2006
New Revision: 31637

URL: http://svn.digium.com/view/asterisk?rev=31637&view=rev
Log:
Reset automerge

Modified:
    team/oej/sdpcleanup/   (props changed)
    team/oej/sdpcleanup/build_tools/menuselect_curses.c
    team/oej/sdpcleanup/channel.c
    team/oej/sdpcleanup/channels/chan_sip.c
    team/oej/sdpcleanup/frame.c
    team/oej/sdpcleanup/include/asterisk/channel.h
    team/oej/sdpcleanup/include/asterisk/utils.h
    team/oej/sdpcleanup/res/res_musiconhold.c
    team/oej/sdpcleanup/utils.c

Propchange: team/oej/sdpcleanup/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/oej/sdpcleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jun  2 01:24:57 2006
@@ -1,1 +1,1 @@
-/trunk:1-31484
+/trunk:1-31635

Modified: team/oej/sdpcleanup/build_tools/menuselect_curses.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/build_tools/menuselect_curses.c?rev=31637&r1=31636&r2=31637&view=diff
==============================================================================
--- team/oej/sdpcleanup/build_tools/menuselect_curses.c (original)
+++ team/oej/sdpcleanup/build_tools/menuselect_curses.c Fri Jun  2 01:24:57 2006
@@ -160,7 +160,7 @@
 	}
 	if (!AST_LIST_EMPTY(&curmem->deps)) {
 		wmove(menu, end - start + 3, max_x / 2 - 16);
-		snprintf(buf, sizeof(buf), "Depends on: ");
+		strcpy(buf, "Depends on: ");
 		AST_LIST_TRAVERSE(&curmem->deps, dep, list) {
 			strncat(buf, dep->name, sizeof(buf) - strlen(buf) - 1);
 			if (AST_LIST_NEXT(dep, list))
@@ -170,7 +170,7 @@
 	}
 	if (!AST_LIST_EMPTY(&curmem->conflicts)) {
 		wmove(menu, end - start + 4, max_x / 2 - 16);
-		snprintf(buf, sizeof(buf), "Conflicts with: ");
+		strcpy(buf, "Conflicts with: ");
 		AST_LIST_TRAVERSE(&curmem->conflicts, con, list) {
 			strncat(buf, con->name, sizeof(buf) - strlen(buf) - 1);
 			if (AST_LIST_NEXT(con, list))

Modified: team/oej/sdpcleanup/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/channel.c?rev=31637&r1=31636&r2=31637&view=diff
==============================================================================
--- team/oej/sdpcleanup/channel.c (original)
+++ team/oej/sdpcleanup/channel.c Fri Jun  2 01:24:57 2006
@@ -2831,6 +2831,14 @@
 {
 	int res = -1;
 
+	/* each of these channels may be sitting behind a channel proxy (i.e. chan_agent)
+	   and if so, we don't really want to masquerade it, but its proxy */
+	if (original->_bridge && (original->_bridge != ast_bridged_channel(original)))
+		original = original->_bridge;
+
+	if (clone->_bridge && (clone->_bridge != ast_bridged_channel(clone)))
+		clone = clone->_bridge;
+
 	if (original == clone) {
 		ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name);
 		return -1;

Modified: team/oej/sdpcleanup/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/channels/chan_sip.c?rev=31637&r1=31636&r2=31637&view=diff
==============================================================================
--- team/oej/sdpcleanup/channels/chan_sip.c (original)
+++ team/oej/sdpcleanup/channels/chan_sip.c Fri Jun  2 01:24:57 2006
@@ -2243,13 +2243,13 @@
 	natflags = ast_test_flag(&r->flags[0], SIP_NAT) & SIP_NAT_ROUTE;
 	if (r->rtp) {
 		if (option_debug)
-			ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", natflags);
+			ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", natflags ? "On" : "Off");
 		ast_rtp_setnat(r->rtp, natflags);
 		ast_rtp_setdtmf(r->rtp, ast_test_flag(&r->flags[0], SIP_DTMF) != SIP_DTMF_INFO);
 	}
 	if (r->vrtp) {
 		if (option_debug)
-			ast_log(LOG_DEBUG, "Setting NAT on VRTP to %d\n", natflags);
+			ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", natflags ? "On" : "Off");
 		ast_rtp_setnat(r->vrtp, natflags);
 		ast_rtp_setdtmf(r->vrtp, 0);
 	}
@@ -3267,7 +3267,7 @@
 	tmp = ast_channel_alloc(1);
 	ast_mutex_lock(&i->lock);
 	if (!tmp) {
-		ast_log(LOG_WARNING, "Unable to allocate SIP channel structure\n");
+		ast_log(LOG_WARNING, "Unable to allocate AST channel structure for SIP channel\n");
 		return NULL;
 	}
 	tmp->tech = &sip_tech;
@@ -4072,10 +4072,10 @@
 	return 0;
 }
 
-/*! \brief Process SIP SDP and activate RTP channels */
+/*! \brief Process SIP SDP, select formats and activate RTP channels */
 static int process_sdp(struct sip_pvt *p, struct sip_request *req)
 {
-	const char *m;
+	const char *m;		/* SDP media offer */
 	const char *c;
 	const char *a;
 	char host[258];
@@ -4083,10 +4083,13 @@
 	int len = -1;
 	int portno = -1;		/*!< RTP Audio port number */
 	int vportno = -1;		/*!< RTP Video port number */
+
+	/* Peer capability is the capability in the SDP, non codec is RFC2833 DTMF (101) */	
 	int peercapability, peernoncodeccapability;
 	int vpeercapability = 0, vpeernoncodeccapability = 0;
 	struct sockaddr_in sin;		/*!< media socket address */
 	struct sockaddr_in vsin;	/*!< Video socket address */
+
 	const char *codecs;
 	struct hostent *hp;		/*!< RTP Audio host IP */
 	struct hostent *vhp = NULL;	/*!< RTP video host IP */
@@ -7873,12 +7876,12 @@
 
 		if (p->rtp) {
 			if (option_debug)
-				ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", usenatroute);
+				ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", usenatroute ? "On" : "Off");
 			ast_rtp_setnat(p->rtp, usenatroute);
 		}
 		if (p->vrtp) {
 			if (option_debug)
-				ast_log(LOG_DEBUG, "Setting NAT on VRTP to %d\n", usenatroute);
+				ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", usenatroute ? "On" : "Off");
 			ast_rtp_setnat(p->vrtp, usenatroute);
 		}
 		if (!(res = check_auth(p, req, user->name, user->secret, user->md5secret, sipmethod, uri, reliable, ast_test_flag(req, SIP_PKT_IGNORE)))) {
@@ -7980,11 +7983,11 @@
 			}
 			usenatroute = ast_test_flag(&p->flags[0], SIP_NAT_ROUTE);
 			if (p->rtp) {
-				ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", usenatroute);
+				ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", usenatroute ? "On" : "Off");
 				ast_rtp_setnat(p->rtp, usenatroute);
 			}
 			if (p->vrtp) {
-				ast_log(LOG_DEBUG, "Setting NAT on VRTP to %d\n", usenatroute);
+				ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", usenatroute ? "On" : "Off");
 				ast_rtp_setnat(p->vrtp, usenatroute);
 			}
 			ast_string_field_set(p, peersecret, peer->secret);

Modified: team/oej/sdpcleanup/frame.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/frame.c?rev=31637&r1=31636&r2=31637&view=diff
==============================================================================
--- team/oej/sdpcleanup/frame.c (original)
+++ team/oej/sdpcleanup/frame.c Fri Jun  2 01:24:57 2006
@@ -18,7 +18,7 @@
 
 /*! \file
  *
- * \brief Frame manipulation routines
+ * \brief Frame and codec manipulation routines
  *
  * \author Mark Spencer <markster at digium.com> 
  */
@@ -91,7 +91,7 @@
 	{ 1, AST_FORMAT_LPC10, "lpc10", "LPC10" },	/*!< codec_lpc10.c */
 	{ 1, AST_FORMAT_G729A, "g729", "G.729A" },	/*!< Binary commercial distribution */
 	{ 1, AST_FORMAT_SPEEX, "speex", "SpeeX" },	/*!< codec_speex.c */
-	{ 1, AST_FORMAT_ILBC, "ilbc", "iLBC"},	/*!< codec_ilbc.c */
+	{ 1, AST_FORMAT_ILBC, "ilbc", "iLBC"},		/*!< codec_ilbc.c */
 	{ 0, 0, "nothing", "undefined" },
 	{ 0, 0, "nothing", "undefined" },
 	{ 0, 0, "nothing", "undefined" },
@@ -198,6 +198,7 @@
 {
 	struct ast_frame *opt;
 	int len;
+
 	/* IF we have an optimization frame, send it */
 	if (s->opt) {
 		if (s->opt->offset < AST_FRIENDLY_OFFSET)
@@ -480,13 +481,14 @@
 }
 
 #endif /* unused functions */
+
 void ast_swapcopy_samples(void *dst, const void *src, int samples)
 {
 	int i;
 	unsigned short *dst_s = dst;
 	const unsigned short *src_s = src;
 
-	for (i=0; i<samples; i++)
+	for (i = 0; i < samples; i++)
 		dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
 }
 
@@ -515,12 +517,14 @@
 	return ret;
 }
 
-char *ast_getformatname_multiple(char *buf, size_t size, int format) {
-
+char *ast_getformatname_multiple(char *buf, size_t size, int format)
+{
 	int x;
 	unsigned len;
 	char *start, *end = buf;
-	if (!size) return buf;
+
+	if (!size)
+		return buf;
 	snprintf(end, size, "0x%x (", format);
 	len = strlen(end);
 	end += len;
@@ -544,13 +548,13 @@
 static struct ast_codec_alias_table {
 	char *alias;
 	char *realname;
-
 } ast_codec_alias_table[] = {
-	{"slinear","slin"},
-	{"g723.1","g723"},
+	{ "slinear", "slin"},
+	{ "g723.1", "g723"},
 };
 
-static const char *ast_expand_codec_alias(const char *in) {
+static const char *ast_expand_codec_alias(const char *in)
+{
 	int x;
 
 	for (x = 0; x < sizeof(ast_codec_alias_table) / sizeof(ast_codec_alias_table[0]); x++) {
@@ -567,8 +571,8 @@
 	all = strcasecmp(name, "all") ? 0 : 1;
 	for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
 		if(AST_FORMAT_LIST[x].visible && (all || 
-										  !strcasecmp(AST_FORMAT_LIST[x].name,name) ||
-										  !strcasecmp(AST_FORMAT_LIST[x].name,ast_expand_codec_alias(name)))) {
+			  !strcasecmp(AST_FORMAT_LIST[x].name,name) ||
+			  !strcasecmp(AST_FORMAT_LIST[x].name,ast_expand_codec_alias(name)))) {
 			format |= AST_FORMAT_LIST[x].bits;
 			if(!all)
 				break;
@@ -578,7 +582,8 @@
 	return format;
 }
 
-char *ast_codec2str(int codec) {
+char *ast_codec2str(int codec)
+{
 	int x;
 	char *ret = "unknown";
 	for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
@@ -648,13 +653,13 @@
 	if (sscanf(argv[2],"%d",&codec) != 1)
 		return RESULT_SHOWUSAGE;
 
-	for (i=0;i<32;i++)
+	for (i = 0; i < 32; i++)
 		if (codec & (1 << i)) {
 			found = 1;
 			ast_cli(fd, "%11u (1 << %2d)  %s\n",1 << i,i,ast_codec2str(1<<i));
 		}
 
-	if (! found)
+	if (!found)
 		ast_cli(fd, "Codec %d not found\n", codec);
 
 	return RESULT_SUCCESS;
@@ -938,7 +943,7 @@
 	return slot ? AST_FORMAT_LIST[slot-1].bits : 0;
 }
 
-/*! \brief ast_codec_pref_remove: Remove codec from pref list ---*/
+/*! \brief Remove codec from pref list */
 void ast_codec_pref_remove(struct ast_codec_pref *pref, int format)
 {
 	struct ast_codec_pref oldorder;
@@ -961,7 +966,7 @@
 	
 }
 
-/*! \brief ast_codec_pref_append: Append codec to list ---*/
+/*! \brief Append codec to list */
 int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
 {
 	int x, newindex = -1;
@@ -988,7 +993,7 @@
 }
 
 
-/*! \brief ast_codec_choose: Pick a codec ---*/
+/*! \brief Pick a codec */
 int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
 {
 	int x, ret = 0, slot;
@@ -996,9 +1001,9 @@
 	for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
 		slot = pref->order[x];
 
-		if(!slot)
-			break;
-		if ( formats & AST_FORMAT_LIST[slot-1].bits ) {
+		if (!slot)
+			break;
+		if (formats & AST_FORMAT_LIST[slot-1].bits) {
 			ret = AST_FORMAT_LIST[slot-1].bits;
 			break;
 		}

Modified: team/oej/sdpcleanup/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/include/asterisk/channel.h?rev=31637&r1=31636&r2=31637&view=diff
==============================================================================
--- team/oej/sdpcleanup/include/asterisk/channel.h (original)
+++ team/oej/sdpcleanup/include/asterisk/channel.h Fri Jun  2 01:24:57 2006
@@ -311,8 +311,9 @@
 	/*! Current active data generator */
 	struct ast_generator *generator;
 
-	/*! Who are we bridged to, if we're bridged  Do not access directly,
-	    use ast_bridged_channel(chan) */
+	/*! Who are we bridged to, if we're bridged. Who is proxying for us,
+	  if we are proxied (i.e. chan_agent).
+	  Do not access directly, use ast_bridged_channel(chan) */
 	struct ast_channel *_bridge;
 	/*! Channel that will masquerade as us */
 	struct ast_channel *masq;		

Modified: team/oej/sdpcleanup/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/include/asterisk/utils.h?rev=31637&r1=31636&r2=31637&view=diff
==============================================================================
--- team/oej/sdpcleanup/include/asterisk/utils.h (original)
+++ team/oej/sdpcleanup/include/asterisk/utils.h Fri Jun  2 01:24:57 2006
@@ -157,6 +157,7 @@
 	\brief Produces SHA1 hash based on input string */
 void ast_sha1_hash(char *output, char *input);
 
+int ast_base64encode_full(char *dst, const unsigned char *src, int srclen, int max, int linebreaks);
 int ast_base64encode(char *dst, const unsigned char *src, int srclen, int max);
 int ast_base64decode(unsigned char *dst, const char *src, int max);
 

Modified: team/oej/sdpcleanup/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/res/res_musiconhold.c?rev=31637&r1=31636&r2=31637&view=diff
==============================================================================
--- team/oej/sdpcleanup/res/res_musiconhold.c (original)
+++ team/oej/sdpcleanup/res/res_musiconhold.c Fri Jun  2 01:24:57 2006
@@ -133,6 +133,7 @@
 	char dir[256];
 	char args[256];
 	char mode[80];
+	/* XXX This means that we are allocating 64KB of memory for every musiconhold class XXX */
 	char filearray[MAX_MOHFILES][MAX_MOHFILE_LEN];
 	unsigned int flags;
 	int total_files;
@@ -226,10 +227,6 @@
 
 	state->pos = state->pos % state->class->total_files;
 	
-	if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
-		ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name);
-		return -1;
-	}
 	if (!ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) {
 		ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", state->class->filearray[state->pos], strerror(errno));
 		state->pos++;
@@ -303,14 +300,8 @@
 
 		state->origwfmt = chan->writeformat;
 
-		if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
-			ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name);
-			free(chan->music_state);
-			chan->music_state = NULL;
-		} else {
-			if (option_verbose > 2)
-				ast_verbose(VERBOSE_PREFIX_3 "Started music on hold, class '%s', on %s\n", class->name, chan->name);
-		}
+		if (option_verbose > 2)
+			ast_verbose(VERBOSE_PREFIX_3 "Started music on hold, class '%s', on %s\n", class->name, chan->name);
 	}
 	
 	return chan->music_state;

Modified: team/oej/sdpcleanup/utils.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/utils.c?rev=31637&r1=31636&r2=31637&view=diff
==============================================================================
--- team/oej/sdpcleanup/utils.c (original)
+++ team/oej/sdpcleanup/utils.c Fri Jun  2 01:24:57 2006
@@ -324,17 +324,11 @@
 	unsigned int byte = 0;
 	unsigned int bits = 0;
 	int incnt = 0;
-#if 0
-	unsigned char *odst = dst;
-#endif
 	while(*src && (cnt < max)) {
 		/* Shift in 6 bits of input */
 		byte <<= 6;
 		byte |= (b2a[(int)(*src)]) & 0x3f;
 		bits += 6;
-#if 0
-		printf("Add: %c %s\n", *src, binary(b2a[(int)(*src)] & 0x3f, 6));
-#endif
 		src++;
 		incnt++;
 		/* If we have at least 8 bits left over, take that character 
@@ -342,64 +336,69 @@
 		if (bits >= 8)  {
 			bits -= 8;
 			*dst = (byte >> bits) & 0xff;
-#if 0
-			printf("Remove: %02x %s\n", *dst, binary(*dst, 8));
-#endif
 			dst++;
 			cnt++;
 		}
 	}
-#if 0
-	dump(odst, cnt);
-#endif
 	/* Dont worry about left over bits, they're extra anyway */
 	return cnt;
 }
 
 /*! \brief encode text to BASE64 coding */
-int ast_base64encode(char *dst, const unsigned char *src, int srclen, int max)
+int ast_base64encode_full(char *dst, const unsigned char *src, int srclen, int max, int linebreaks)
 {
 	int cnt = 0;
+	int col = 0;
 	unsigned int byte = 0;
 	int bits = 0;
-	int index;
 	int cntin = 0;
-#if 0
-	char *odst = dst;
-	dump(src, srclen);
-#endif
-	/* Reserve one bit for end */
+	/* Reserve space for null byte at end of string */
 	max--;
 	while((cntin < srclen) && (cnt < max)) {
 		byte <<= 8;
-#if 0
-		printf("Add: %02x %s\n", *src, binary(*src, 8));
-#endif
 		byte |= *(src++);
 		bits += 8;
 		cntin++;
-		while((bits >= 6) && (cnt < max)) {
-			bits -= 6;
-			/* We want only the top */
-			index = (byte >> bits) & 0x3f;
-			*dst = base64[index];
-#if 0
-			printf("Remove: %c %s\n", *dst, binary(index, 6));
-#endif
-			dst++;
+		if ((bits == 24) && (cnt + 4 < max)) {
+			*dst++ = base64[(byte >> 18) & 0x3f];
+			*dst++ = base64[(byte >> 12) & 0x3f];
+			*dst++ = base64[(byte >> 6) & 0x3f];
+			*dst++ = base64[byte & 0x3f];
+			cnt += 4;
+			col += 4;
+			bits = 0;
+			byte = 0;
+		}
+		if (linebreaks && (cnt < max) && (col == 64)) {
+			*dst++ = '\n';
 			cnt++;
-		}
-	}
-	if (bits && (cnt < max)) {
+			col = 0;
+		}
+	}
+	if (bits && (cnt + 4 < max)) {
 		/* Add one last character for the remaining bits, 
 		   padding the rest with 0 */
-		byte <<= (6 - bits);
-		index = (byte) & 0x3f;
-		*(dst++) = base64[index];
+		byte <<= 24 - bits;
+		*dst++ = base64[(byte >> 18) & 0x3f];
+		*dst++ = base64[(byte >> 12) & 0x3f];
+		if (bits == 16)
+			*dst++ = base64[(byte >> 6) & 0x3f];
+		else
+			*dst++ = '=';
+		*dst++ = '=';
+		cnt += 4;
+	}
+	if (linebreaks && (cnt < max)) {
+		*dst++ = '\n';
 		cnt++;
 	}
 	*dst = '\0';
 	return cnt;
+}
+
+int ast_base64encode(char *dst, const unsigned char *src, int srclen, int max)
+{
+	return ast_base64encode_full(dst, src, srclen, max, 0);
 }
 
 static void base64_init(void)



More information about the asterisk-commits mailing list