[asterisk-commits] pcadach: branch pcadach/chan_h323-live r43581 - in /team/pcadach/chan_h323-li...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Sep 24 21:48:52 MST 2006


Author: pcadach
Date: Sun Sep 24 23:48:51 2006
New Revision: 43581

URL: http://svn.digium.com/view/asterisk?rev=43581&view=rev
Log:
Merged revisions 43522,43525-43526,43539-43540,43546,43554,43565,43571-43575 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r43522 | file | 2006-09-23 05:34:27 +0600 (Сбт, 23 Сен 2006) | 2 lines

You see nothing...

................
r43525 | kpfleming | 2006-09-23 05:45:14 +0600 (Сбт, 23 Сен 2006) | 10 lines

Merged revisions 43524 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r43524 | kpfleming | 2006-09-22 18:44:47 -0500 (Fri, 22 Sep 2006) | 2 lines

don't output the 'build complete' message when the target being run is already going to do an installation

........

................
r43526 | kpfleming | 2006-09-23 05:46:02 +0600 (Сбт, 23 Сен 2006) | 2 lines

file forgot one :-)

................
r43539 | pcadach | 2006-09-24 00:25:13 +0600 (Вск, 24 Сен 2006) | 1 line

Correct behavior on Cisco's DTMF
................
r43540 | pcadach | 2006-09-24 00:28:23 +0600 (Вск, 24 Сен 2006) | 1 line

Avoid possible deadlock on channel destruction
................
r43546 | pcadach | 2006-09-24 18:15:49 +0600 (Вск, 24 Сен 2006) | 1 line

Small Cisco's RTP DTMF update
................
r43554 | russell | 2006-09-24 19:57:19 +0600 (Вск, 24 Сен 2006) | 20 lines

Merged revisions 43553 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r43553 | russell | 2006-09-24 09:53:35 -0400 (Sun, 24 Sep 2006) | 12 lines

Merged revisions 43552 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r43552 | russell | 2006-09-24 09:50:30 -0400 (Sun, 24 Sep 2006) | 4 lines

Check to see if the channel that is activating the IAXPEER function is actually
an IAX2 channel before proceeding to process it to avoid crashing.
(issue #8017, reported by admott, fixed by myself)

........

................

................
r43565 | russell | 2006-09-24 21:01:09 +0600 (Вск, 24 Сен 2006) | 13 lines

Merged revisions 43564 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r43564 | russell | 2006-09-24 10:58:10 -0400 (Sun, 24 Sep 2006) | 5 lines

Fix a CLI command registration issue where an erroneous message claiming that
"iax2 show provisioning" was already registered.  This was because this command
was registering itself as both the command, as well as the command it is
deprecating.  (issue #8022, reported by bjweeks, fixed by myself)

........

................
r43571 | pcadach | 2006-09-25 00:12:35 +0600 (Пнд, 25 Сен 2006) | 1 line

Define DTMF payload types
................
r43572 | pcadach | 2006-09-25 00:16:44 +0600 (Пнд, 25 Сен 2006) | 1 line

Specify non-standard data independedly on OpenH323's codec name (it can be easily changed)
................
r43573 | pcadach | 2006-09-25 00:19:56 +0600 (Пнд, 25 Сен 2006) | 1 line

Define Cisco RTP capability
................
r43574 | pcadach | 2006-09-25 00:53:44 +0600 (Пнд, 25 Сен 2006) | 1 line

DTMF mode is bitmask, not valued field
................
r43575 | pcadach | 2006-09-25 00:59:38 +0600 (Пнд, 25 Сен 2006) | 1 line

Specify RFC2833 payload on dtmfmode option rather than dtmfcodec option (deprecated)
................

Modified:
    team/pcadach/chan_h323-live/   (props changed)
    team/pcadach/chan_h323-live/Makefile
    team/pcadach/chan_h323-live/channels/chan_h323.c
    team/pcadach/chan_h323-live/channels/chan_iax2.c
    team/pcadach/chan_h323-live/channels/h323/ast_h323.cxx
    team/pcadach/chan_h323-live/channels/h323/caps_h323.cxx
    team/pcadach/chan_h323-live/channels/h323/caps_h323.h
    team/pcadach/chan_h323-live/channels/h323/chan_h323.h
    team/pcadach/chan_h323-live/channels/iax2-provision.c
    team/pcadach/chan_h323-live/configs/h323.conf.sample
    team/pcadach/chan_h323-live/main/rtp.c

Propchange: team/pcadach/chan_h323-live/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/pcadach/chan_h323-live/
------------------------------------------------------------------------------
--- automerge-email (original)
+++ automerge-email Sun Sep 24 23:48:51 2006
@@ -1,1 +1,1 @@
-jcolp at digium.com
+paul at odt.east.telecom.kz

Propchange: team/pcadach/chan_h323-live/
------------------------------------------------------------------------------
--- branch-1.4-merged (original)
+++ branch-1.4-merged Sun Sep 24 23:48:51 2006
@@ -1,1 +1,1 @@
-/branches/1.4:1-43376,43383,43386,43388,43392,43396,43405,43410,43422,43441,43445,43450,43454,43456,43464,43466,43469,43477,43482,43486,43489,43492,43518
+/branches/1.4:1-43376,43383,43386,43388,43392,43396,43405,43410,43422,43441,43445,43450,43454,43456,43464,43466,43469,43477,43482,43486,43489,43492,43518,43524,43553,43564

Propchange: team/pcadach/chan_h323-live/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Sep 24 23:48:51 2006
@@ -1,1 +1,1 @@
-/trunk:1-43520
+/trunk:1-43580

Modified: team/pcadach/chan_h323-live/Makefile
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/Makefile?rev=43581&r1=43580&r2=43581&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/Makefile (original)
+++ team/pcadach/chan_h323-live/Makefile Sun Sep 24 23:48:51 2006
@@ -231,13 +231,15 @@
   HAVEDOT=no
 endif
 
-all: cleantest $(SUBDIRS)
+all: _all
 	@echo " +--------- Asterisk Build Complete ---------+"  
 	@echo " + Asterisk has successfully been built, and +"  
 	@echo " + can be installed by running:              +"
 	@echo " +                                           +"
 	@echo " +               make install                +"  
 	@echo " +-------------------------------------------+"  
+
+_all: cleantest $(SUBDIRS)
 
 makeopts: configure
 	@echo "****"
@@ -329,7 +331,7 @@
 	rm -rf doc/api
 	rm -f build_tools/menuselect-deps
 
-datafiles: all
+datafiles: _all
 	if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(ASTCFLAGS)" sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
 # Should static HTTP be installed during make samples or even with its own target ala
 # webvoicemail?  There are portions here that *could* be customized but might also be
@@ -363,7 +365,7 @@
 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
 
-bininstall: all
+bininstall: _all
 	mkdir -p $(DESTDIR)$(MODULES_DIR)
 	mkdir -p $(DESTDIR)$(ASTSBINDIR)
 	mkdir -p $(DESTDIR)$(ASTETCDIR)
@@ -427,7 +429,7 @@
 		echo " WARNING WARNING WARNING" ;\
 	fi
 
-install: all datafiles bininstall $(SUBDIRS_INSTALL)
+install: datafiles bininstall $(SUBDIRS_INSTALL)
 	@if [ -x /usr/sbin/asterisk-post-install ]; then \
 		/usr/sbin/asterisk-post-install $(DESTDIR) . ; \
 	fi
@@ -454,7 +456,7 @@
 	@echo " +-------------------------------------------+"
 	@$(MAKE) -s oldmodcheck
 
-upgrade: all bininstall
+upgrade: bininstall
 
 adsi:
 	mkdir -p $(DESTDIR)$(ASTETCDIR)

Modified: team/pcadach/chan_h323-live/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/chan_h323.c?rev=43581&r1=43580&r2=43581&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_h323.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_h323.c Sun Sep 24 23:48:51 2006
@@ -1247,21 +1247,37 @@
 static int update_common_options(struct ast_variable *v, struct call_options *options)
 {
 	int tmp;
+	char *val, *opt;
 
 	if (!strcasecmp(v->name, "allow")) {
 		ast_parse_allow_disallow(&options->prefs, &options->capability, v->value, 1);
 	} else if (!strcasecmp(v->name, "disallow")) {
 		ast_parse_allow_disallow(&options->prefs, &options->capability, v->value, 0);
 	} else if (!strcasecmp(v->name, "dtmfmode")) {
+		val = strdupa(v->value);
+		if ((opt = strchr(val, ':')) != (char *)NULL) {
+			*opt++ = '\0';
+			tmp = atoi(opt);
+		}
 		if (!strcasecmp(v->value, "inband")) {
-			options->dtmfmode = H323_DTMF_INBAND;
-		} else if (!strcasecmp(v->value, "rfc2833")) {
-			options->dtmfmode = H323_DTMF_RFC2833;
+			options->dtmfmode |= H323_DTMF_INBAND;
+		} else if (!strcasecmp(val, "rfc2833")) {
+			options->dtmfmode |= H323_DTMF_RFC2833;
+			if (!opt)
+				options->dtmfcodec = H323_DTMF_RFC2833_PT;
+			else if ((tmp >= 96) && (tmp < 128))
+				options->dtmfcodec = tmp;
+			else {
+				options->dtmfcodec = H323_DTMF_RFC2833_PT;
+				ast_log(LOG_WARNING, "Unknown rfc2833 payload %s specified at line %d, using default %d\n", opt, v->lineno, options->dtmfcodec);
+			}
 		} else {
 			ast_log(LOG_WARNING, "Unknown dtmf mode '%s', using rfc2833\n", v->value);
-			options->dtmfmode = H323_DTMF_RFC2833;
+			options->dtmfmode |= H323_DTMF_RFC2833;
+			options->dtmfcodec = H323_DTMF_RFC2833_PT;
 		}
 	} else if (!strcasecmp(v->name, "dtmfcodec")) {
+		ast_log(LOG_NOTICE, "Option %s at line %d is deprecated. Use dtmfmode=rfc2833[:<payload>] instead.\n", v->name, v->lineno);
 		tmp = atoi(v->value);
 		if (tmp < 96)
 			ast_log(LOG_WARNING, "Invalid %s value %s at line %d\n", v->name, v->value, v->lineno);
@@ -1333,6 +1349,7 @@
 	oldha = user->ha;
 	user->ha = (struct ast_ha *)NULL;
 	memcpy(&user->options, &global_options, sizeof(user->options));
+	user->options.dtmfmode = 0;
 	/* Set default context */
 	strncpy(user->context, default_context, sizeof(user->context) - 1);
 	if (user && !found)
@@ -1377,6 +1394,8 @@
 			user->ha = ast_append_ha(v->name, v->value, user->ha);
 		}
 	}
+	if (!user->options.dtmfmode)
+		user->options.dtmfmode = global_options.dtmfmode;
 	ASTOBJ_UNMARK(user);
 	ast_free_ha(oldha);
 	return user;
@@ -1438,6 +1457,7 @@
 	oldha = peer->ha;
 	peer->ha = NULL;
 	memcpy(&peer->options, &global_options, sizeof(peer->options));
+	peer->options.dtmfmode = 0;
 	peer->addr.sin_port = htons(h323_signalling_port);
 	peer->addr.sin_family = AF_INET;
 	if (!found && name)
@@ -1475,6 +1495,8 @@
 			ast_copy_string(peer->mailbox, v->value, sizeof(peer->mailbox));
 		}
 	}
+	if (!peer->options.dtmfmode)
+		peer->options.dtmfmode = global_options.dtmfmode;
 	ASTOBJ_UNMARK(peer);
 	ast_free_ha(oldha);
 	return peer;
@@ -2433,34 +2455,36 @@
 			h323_do_reload();
 		}
 		/* Check for interfaces needing to be killed */
-		ast_mutex_lock(&iflock);
+		if (!ast_mutex_trylock(&iflock)) {
 #if 1
-		do {
-			for (oh323 = iflist; oh323; oh323 = oh323->next) {
+			do {
+				for (oh323 = iflist; oh323; oh323 = oh323->next) {
+					if (!ast_mutex_trylock(&oh323->lock)) {
+						if (oh323->needdestroy) {
+							__oh323_destroy(oh323);
+							break;
+						}
+						ast_mutex_unlock(&oh323->lock);
+					}
+				}
+			} while (/*oh323*/ 0);
+#else
+restartsearch:
+			oh323 = iflist;
+			while(oh323) {
 				if (!ast_mutex_trylock(&oh323->lock)) {
 					if (oh323->needdestroy) {
 						__oh323_destroy(oh323);
-						break;
+						goto restartsearch;
 					}
 					ast_mutex_unlock(&oh323->lock);
+					oh323 = oh323->next;
 				}
 			}
-		} while (/*oh323*/ 0);
-#else
-restartsearch:
-		oh323 = iflist;
-		while(oh323) {
-			if (!ast_mutex_trylock(&oh323->lock)) {
-				if (oh323->needdestroy) {
-					__oh323_destroy(oh323);
-					goto restartsearch;
-				}
-				ast_mutex_unlock(&oh323->lock);
-				oh323 = oh323->next;
-			}
-		}
 #endif
-		ast_mutex_unlock(&iflock);
+			ast_mutex_unlock(&iflock);
+		} else
+			oh323 = (struct oh323_pvt *)1;	/* Force fast loop */
 		pthread_testcancel();
 		/* Wait for sched or io */
 		res = ast_sched_wait(sched);
@@ -2726,8 +2750,8 @@
 	memset(&global_options, 0, sizeof(global_options));
 	global_options.fastStart = 1;
 	global_options.h245Tunneling = 1;
-	global_options.dtmfcodec = 101;
-	global_options.dtmfmode = H323_DTMF_RFC2833;
+	global_options.dtmfcodec = H323_DTMF_RFC2833_PT;
+	global_options.dtmfmode = 0;
 	global_options.capability = GLOBAL_CAPABILITY;
 	global_options.bridge = 1;		/* Do native bridging by default */
 	strncpy(default_context, "default", sizeof(default_context) - 1);
@@ -2820,6 +2844,8 @@
 			/* dummy */
 		}
 	}
+	if (!global_options.dtmfmode)
+		global_options.dtmfmode = H323_DTMF_RFC2833;
 
 	for (cat = ast_category_browse(cfg, NULL); cat; cat = ast_category_browse(cfg, cat)) {
 		if (strcasecmp(cat, "general")) {

Modified: team/pcadach/chan_h323-live/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/chan_iax2.c?rev=43581&r1=43580&r2=43581&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_iax2.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_iax2.c Sun Sep 24 23:48:51 2006
@@ -9483,8 +9483,10 @@
 	struct iax2_peer *peer;
 	char *peername, *colname;
 
-	if (!(peername = ast_strdupa(data)))
+	if (chan->tech != &iax2_tech)
 		return -1;
+
+	peername = ast_strdupa(data);
 
 	/* if our channel, return the IP address of the endpoint of current channel */
 	if (!strcmp(peername,"CURRENTCHANNEL")) {

Modified: team/pcadach/chan_h323-live/channels/h323/ast_h323.cxx
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/ast_h323.cxx?rev=43581&r1=43580&r2=43581&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/ast_h323.cxx (original)
+++ team/pcadach/chan_h323-live/channels/h323/ast_h323.cxx Sun Sep 24 23:48:51 2006
@@ -1204,7 +1204,7 @@
 
 void MyH323Connection::OnUserInputTone(char tone, unsigned duration, unsigned logicalChannel, unsigned rtpTimestamp)
 {
-	if (dtmfMode == H323_DTMF_RFC2833) {
+	if ((dtmfMode & H323_DTMF_RFC2833)) {
 		if (h323debug) {
 			cout << "\t-- Received user input tone (" << tone << ") from remote" << endl;
 		}
@@ -1299,7 +1299,7 @@
 	if (cap != NULL) {
 		RTP_DataFrame::PayloadTypes pt = ((H323_UserInputCapability*)cap)->GetPayloadType();
 		on_set_rfc2833_payload(GetCallReference(), (const char *)GetCallToken(), (int)pt);
-		if ((dtmfMode == H323_DTMF_RFC2833) && (sendUserInputMode == SendUserInputAsTone))
+		if ((dtmfMode & H323_DTMF_RFC2833) && (sendUserInputMode == SendUserInputAsTone))
 			sendUserInputMode = SendUserInputAsInlineRFC2833;
 		if (h323debug) {
 			cout << "\t-- Inbound RFC2833 on payload " << pt << endl;
@@ -1514,7 +1514,7 @@
 
 	lastcap++;
 	dtmfMode = dtmf_mode;
-	if (dtmf_mode == H323_DTMF_INBAND) {
+	if ((dtmfMode & H323_DTMF_INBAND)) {
 		localCapabilities.SetCapability(0, lastcap, new H323_UserInputCapability(H323_UserInputCapability::BasicString));
 		sendUserInputMode = SendUserInputAsString;
 	} else {

Modified: team/pcadach/chan_h323-live/channels/h323/caps_h323.cxx
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/caps_h323.cxx?rev=43581&r1=43580&r2=43581&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/caps_h323.cxx (original)
+++ team/pcadach/chan_h323-live/channels/h323/caps_h323.cxx Sun Sep 24 23:48:51 2006
@@ -326,7 +326,7 @@
 AST_CiscoG726Capability::AST_CiscoG726Capability(int rx_frames)
 	: H323NonStandardAudioCapability(rx_frames, 240,
 		181, 0, 18,
-		(const BYTE *)CISCO_G726r32, sizeof(CISCO_G726r32)-1, 0)
+		(const BYTE *)"G726r32", 0)
 {
 }
 
@@ -344,3 +344,27 @@
 {
 	return PString(CISCO_G726r32);
 }
+
+/*
+ * Capability: Cisco RTP DTMF Relay
+ */
+AST_CiscoDtmfCapability::AST_CiscoDtmfCapability()
+	: H323NonStandardDataCapability(0, 181, 0, 18, (const BYTE *)"RtpDtmfRelay", 0)
+{
+	rtpPayloadType = (RTP_DataFrame::PayloadTypes)121;
+}
+
+PObject *AST_CiscoDtmfCapability::Clone() const
+{
+	return new AST_CiscoDtmfCapability(*this);
+}
+
+H323Codec *AST_CiscoDtmfCapability::CreateCodec(H323Codec::Direction direction) const
+{
+	return NULL;
+}
+
+PString AST_CiscoDtmfCapability::GetFormatName() const
+{
+	return PString(CISCO_DTMF_RELAY);
+}

Modified: team/pcadach/chan_h323-live/channels/h323/caps_h323.h
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/caps_h323.h?rev=43581&r1=43580&r2=43581&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/caps_h323.h (original)
+++ team/pcadach/chan_h323-live/channels/h323/caps_h323.h Sun Sep 24 23:48:51 2006
@@ -140,4 +140,33 @@
 	/* Get the name of the media data format this class represents. */
 	virtual PString GetFormatName() const;
 };
+
+#define CISCO_DTMF_RELAY "UserInput/RtpDtmfRelay"
+
+class AST_CiscoDtmfCapability : public H323NonStandardDataCapability
+{
+	PCLASSINFO(AST_CiscoDtmfCapability, H323NonStandardDataCapability);
+
+public:
+	/* Create a new Cisco RTP DTMF Relay capability */
+	AST_CiscoDtmfCapability();
+
+	/* Create a copy of the object. */	
+	virtual PObject *Clone() const;
+
+	/* Create the codec instance, allocating resources as required. */
+	virtual H323Codec * CreateCodec(H323Codec::Direction direction) const;
+
+	/* Get the name of the media data format this class represents. */
+	virtual PString GetFormatName() const;
+	
+	virtual H323Channel *CreateChannel(H323Connection &,
+										H323Channel::Directions,
+										unsigned,
+										const H245_H2250LogicalChannelParameters *) const
+	{
+		return NULL;
+	}
+};
+
 #endif /* __AST_H323CAPS_H */

Modified: team/pcadach/chan_h323-live/channels/h323/chan_h323.h
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/chan_h323.h?rev=43581&r1=43580&r2=43581&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/chan_h323.h (original)
+++ team/pcadach/chan_h323-live/channels/h323/chan_h323.h Sun Sep 24 23:48:51 2006
@@ -190,6 +190,9 @@
 #define H323_DTMF_RFC2833	(1 << 0)
 #define H323_DTMF_INBAND	(1 << 1)
 
+#define H323_DTMF_RFC2833_PT	101
+#define H323_DTMF_CISCO_PT		121
+
 #ifndef BOOL
 #define BOOL int
 #endif

Modified: team/pcadach/chan_h323-live/channels/iax2-provision.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/iax2-provision.c?rev=43581&r1=43580&r2=43581&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/iax2-provision.c (original)
+++ team/pcadach/chan_h323-live/channels/iax2-provision.c Sun Sep 24 23:48:51 2006
@@ -466,15 +466,10 @@
 	return RESULT_SUCCESS;
 }
 
-static struct ast_cli_entry cli_iax2_show_provisioning = {
-	{ "iax2", "show", "provisioning", NULL },
-	iax_show_provisioning, NULL,
-	NULL, iax_prov_complete_template };
-
 static struct ast_cli_entry cli_iax2_provision[] = {
 	{ { "iax2", "show", "provisioning", NULL },
 	iax_show_provisioning, "Display iax provisioning",
-	show_provisioning_usage, iax_prov_complete_template, &cli_iax2_show_provisioning },
+	show_provisioning_usage, iax_prov_complete_template, },
 };
 
 static int iax_provision_init(void)

Modified: team/pcadach/chan_h323-live/configs/h323.conf.sample
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/configs/h323.conf.sample?rev=43581&r1=43580&r2=43581&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/configs/h323.conf.sample (original)
+++ team/pcadach/chan_h323-live/configs/h323.conf.sample Sun Sep 24 23:48:51 2006
@@ -35,9 +35,9 @@
 ; Default RTP Payload to send RFC2833 DTMF on.  This is used to
 ; interoperate with broken gateways which cannot successfully
 ; negotiate a RFC2833 payload type in the TerminalCapabilitySet.
-;
-; You may also specify on either a per-peer or per-user basis below.
-;dtmfcodec=101
+; To specify required payload type, put it after colon in dtmfmode
+; option like
+;dtmfmode=rfc2833:101
 ;
 ; Set the gatekeeper 
 ; DISCOVER			- Find the Gk address using multicast

Modified: team/pcadach/chan_h323-live/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/main/rtp.c?rev=43581&r1=43580&r2=43581&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/main/rtp.c (original)
+++ team/pcadach/chan_h323-live/main/rtp.c Sun Sep 24 23:48:51 2006
@@ -604,10 +604,51 @@
 	unsigned int event;
 	char resp = 0;
 	struct ast_frame *f = NULL;
-	event = ntohl(*((unsigned int *)(data)));
-	event &= 0x001F;
+	unsigned char seq;
+	unsigned int flags;
+	unsigned int power;
+
+	/* We should have at least 4 bytes in RTP data */
+	if (len < 4)
+		return f;
+
+	/*	The format of Cisco RTP DTMF packet looks like next:
+		+0				- sequence number of DTMF RTP packet (begins from 1,
+						  wrapped to 0)
+		+1				- set of flags
+		+1 (bit 0)		- flaps by different DTMF digits delimited by audio
+						  or repeated digit without audio???
+		+2 (+4,+6,...)	- power level? (rises from 0 to 32 at begin of tone
+						  then falls to 0 at its end)
+		+3 (+5,+7,...)	- detected DTMF digit (0..9,*,#,A-D,...)
+		Repeated DTMF information (bytes 4/5, 6/7) is history shifted right
+		by each new packet and thus provides some redudancy.
+		
+		Sample of Cisco RTP DTMF packet is (all data in hex):
+			19 07 00 02 12 02 20 02
+		showing end of DTMF digit '2'.
+
+		The packets
+			27 07 00 02 0A 02 20 02
+			28 06 20 02 00 02 0A 02
+		shows begin of new digit '2' with very short pause (20 ms) after
+		previous digit '2'. Bit +1.0 flips at begin of new digit.
+		
+		Cisco RTP DTMF packets comes as replacement of audio RTP packets
+		so its uses the same sequencing and timestamping rules as replaced
+		audio packets. Repeat interval of DTMF packets is 20 ms and not rely
+		on audio framing parameters. Marker bit isn't used within stream of
+		DTMFs nor audio stream coming immediately after DTMF stream. Timestamps
+		are not sequential at borders between DTMF and audio streams,
+	*/
+
+	seq = data[0];
+	flags = data[1];
+	power = data[2];
+	event = data[3] & 0x1f;
+
 	if (option_debug > 2 || rtpdebug)
-		ast_log(LOG_DEBUG, "Cisco DTMF Digit: %08x (len = %d)\n", event, len);
+		ast_log(LOG_DEBUG, "Cisco DTMF Digit: %02x (len=%d, seq=%d, flags=%02x, power=%d, history count=%d)\n", event, len, seq, flags, power, (len - 4) / 2);
 	if (event < 10) {
 		resp = '0' + event;
 	} else if (event < 11) {
@@ -619,10 +660,19 @@
 	} else if (event < 17) {
 		resp = 'X';
 	}
-	if (rtp->resp && (rtp->resp != resp)) {
+	if ((!rtp->resp && power) || (rtp->resp && (rtp->resp != resp))) {
+		rtp->resp = resp;
+		/* Why we should care on DTMF compensation at receiption? */
+		if (!ast_test_flag(rtp, FLAG_DTMF_COMPENSATE)) {
+			f = send_dtmf(rtp, AST_FRAME_DTMF_BEGIN);
+			rtp->dtmfduration = 0;
+		}
+	} else if ((rtp->resp == resp) && !power) {
 		f = send_dtmf(rtp, AST_FRAME_DTMF_END);
-	}
-	rtp->resp = resp;
+		f->samples = rtp->dtmfduration * 8;
+		rtp->resp = 0;
+	} else if (rtp->resp == resp)
+		rtp->dtmfduration += 20 * 8;
 	rtp->dtmfcount = dtmftimeout;
 	return f;
 }



More information about the asterisk-commits mailing list