[svn-commits] pcadach: branch pcadach/chan_h323-live r40665 - in /team/pcadach/chan_h323-li...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sun Aug 20 11:50:36 MST 2006


Author: pcadach
Date: Sun Aug 20 13:50:36 2006
New Revision: 40665

URL: http://svn.digium.com/view/asterisk?rev=40665&view=rev
Log:
Update DTMF operations:
1) treat "dtmfmode=inband" as H.323-specific (i.e. non-RFC2833);
2) handle dtmfmode option per connection, not per endpoint;
3) don't DTMFs by RFC2833 (in RTP) if UserInput/RFC2833 capability
   is not negotiated.

Modified:
    team/pcadach/chan_h323-live/channels/chan_h323.c
    team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp
    team/pcadach/chan_h323-live/channels/h323/ast_h323.h

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=40665&r1=40664&r2=40665&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_h323.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_h323.c Sun Aug 20 13:50:36 2006
@@ -183,6 +183,7 @@
 	int pref_codec;						/* Preferred codec */
 	int peercapability;					/* Capabilities learned from peer */
 	int jointcapability;				/* Common capabilities for local and remote side */
+	int dtmf_pt;						/* Payload code used for RFC2833 messages */
 	struct oh323_pvt *next;				/* Next channel in list */
 } *iflist = NULL;
 
@@ -401,7 +402,7 @@
 		return -1;
 	}
 	ast_mutex_lock(&pvt->lock);
-	if (pvt->rtp && (pvt->options.dtmfmode & H323_DTMF_RFC2833)) {
+	if (pvt->rtp && (pvt->options.dtmfmode & H323_DTMF_RFC2833) && (pvt->dtmf_pt > 0)) {
 		/* out-of-band DTMF */
 		if (h323debug) {
 			ast_log(LOG_DEBUG, "Sending out-of-band digit %c on %s\n", digit, c->name);
@@ -1618,6 +1619,7 @@
 	if (pvt->rtp) {
 		ast_rtp_set_rtpmap_type(pvt->rtp, payload, "audio", "telephone-event", 0);
 	}
+	pvt->dtmf_pt = payload;
 	ast_mutex_unlock(&pvt->lock);
 	if (h323debug)
 		ast_log(LOG_DEBUG, "DTMF payload on %s set to %d\n", token, payload);

Modified: team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp?rev=40665&r1=40664&r2=40665&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp (original)
+++ team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp Sun Aug 20 13:50:36 2006
@@ -61,9 +61,6 @@
 /** Counter for the number of connections */
 int channelsOpen;
 
-/* DTMF Mode */
-int mode = H323_DTMF_RFC2833;
-
 /**
  * We assume that only one endPoint should exist.
  * The application cannot run the h323_end_point_create() more than once
@@ -405,6 +402,7 @@
 	}
 
 	connection->dtmfCodec = (RTP_DataFrame::PayloadTypes)opts->dtmfcodec;
+	connection->dtmfMode = opts->dtmfmode;
 
 	if (h323debug) {
 		cout << "\t-- " << GetLocalUserName() << " is calling host " << fullAddress << endl;
@@ -846,6 +844,7 @@
 	else
 		h245Tunneling = TRUE;
 	dtmfCodec = (RTP_DataFrame::PayloadTypes)res->dtmfcodec;
+	dtmfMode = res->dtmfmode;
 
 
 	return H323Connection::OnReceivedSignalSetup(setupPDU);
@@ -964,23 +963,20 @@
 
 void MyH323Connection::OnUserInputTone(char tone, unsigned duration, unsigned logicalChannel, unsigned rtpTimestamp)
 {
-	if (mode == H323_DTMF_INBAND) {
+	if (dtmfMode == H323_DTMF_RFC2833) {
 		if (h323debug) {
 			cout << "\t-- Received user input tone (" << tone << ") from remote" << endl;
 		}
 		on_send_digit(GetCallReference(), tone, (const char *)GetCallToken());
 	}
-	H323Connection::OnUserInputTone(tone, duration, logicalChannel, rtpTimestamp);
 }
 
 void MyH323Connection::OnUserInputString(const PString &value)
 {
-	if (mode == H323_DTMF_RFC2833) {
-		if (h323debug) {
-			cout <<  "\t-- Received user input string (" << value << ") from remote." << endl;
-		}
-		on_send_digit(GetCallReference(), value[0], (const char *)GetCallToken());
-	}	
+	if (h323debug) {
+		cout <<  "\t-- Received user input string (" << value << ") from remote." << endl;
+	}
+	on_send_digit(GetCallReference(), value[0], (const char *)GetCallToken());
 }
 
 void MyH323Connection::OnSendCapabilitySet(H245_TerminalCapabilitySet & pdu)
@@ -998,7 +994,7 @@
 			if (cap.GetTag() == H245_Capability::e_receiveRTPAudioTelephonyEventCapability) {
 				H245_AudioTelephonyEventCapability & atec = cap;
 				atec.m_dynamicRTPPayloadType = dtmfCodec;
-				on_set_rfc2833_payload(GetCallReference(), (const char *)GetCallToken(), (int)dtmfCodec);
+//				on_set_rfc2833_payload(GetCallReference(), (const char *)GetCallToken(), (int)dtmfCodec);
 				if (h323debug) {
 					cout << "\t-- Transmitting RFC2833 on payload " <<
 						atec.m_dynamicRTPPayloadType << endl;
@@ -1059,6 +1055,8 @@
 	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))
+			sendUserInputMode = SendUserInputAsInlineRFC2833;
 		if (h323debug) {
 			cout << "\t-- Inbound RFC2833 on payload " << pt << endl;
 		}
@@ -1148,7 +1146,7 @@
 	return connectionState != ShuttingDownConnection;
 }
 
-void MyH323Connection::SetCapabilities(int cap, int dtmfMode, struct ast_codec_pref *prefs, int pref_codec)
+void MyH323Connection::SetCapabilities(int cap, int dtmf_mode, struct ast_codec_pref *prefs, int pref_codec)
 {
 	int g711Frames = 20;
 	int gsmFrames  = 4;
@@ -1231,13 +1229,15 @@
 	lastcap = localCapabilities.SetCapability(0, lastcap, new H323_UserInputCapability(H323_UserInputCapability::HookFlashH245));
 
 	lastcap++;
-	mode = dtmfMode;
-	if (dtmfMode == H323_DTMF_INBAND) {
-		localCapabilities.SetCapability(0, lastcap, new H323_UserInputCapability(H323_UserInputCapability::SignalToneH245));
-		sendUserInputMode = SendUserInputAsTone;
+	dtmfMode = dtmf_mode;
+	if (dtmf_mode == H323_DTMF_INBAND) {
+		localCapabilities.SetCapability(0, lastcap, new H323_UserInputCapability(H323_UserInputCapability::BasicString));
+		sendUserInputMode = SendUserInputAsString;
 	} else {
-		localCapabilities.SetCapability(0, lastcap, new H323_UserInputCapability(H323_UserInputCapability::SignalToneRFC2833));
-		sendUserInputMode = SendUserInputAsInlineRFC2833;
+		lastcap = localCapabilities.SetCapability(0, lastcap, new H323_UserInputCapability(H323_UserInputCapability::SignalToneRFC2833));
+		/* Cisco sends DTMF only through h245-alphanumeric or h245-signal, no support for RFC2833 */
+		lastcap = localCapabilities.SetCapability(0, lastcap, new H323_UserInputCapability(H323_UserInputCapability::SignalToneH245));
+		sendUserInputMode = SendUserInputAsTone;	/* RFC2833 transmission handled at Asterisk level */
 	}
 
 	if (h323debug) {
@@ -1407,7 +1407,7 @@
 /**
  * Add capability to the capability table of the end point. 
  */
-int h323_set_capabilities(const char *token, int cap, int dtmfMode, struct ast_codec_pref *prefs, int pref_codec)
+int h323_set_capabilities(const char *token, int cap, int dtmf_mode, struct ast_codec_pref *prefs, int pref_codec)
 {
 	MyH323Connection *conn;
 
@@ -1426,7 +1426,7 @@
 		cout << " ERROR: [h323_set_capabilities] Unable to find connection " << token << endl;
 		return 1;
 	}
-	conn->SetCapabilities((/*conn->bridging ? conn->redir_capabilities :*/ cap), dtmfMode, prefs, pref_codec);
+	conn->SetCapabilities((/*conn->bridging ? conn->redir_capabilities :*/ cap), dtmf_mode, prefs, pref_codec);
 	conn->Unlock();
 
 	return 0;

Modified: team/pcadach/chan_h323-live/channels/h323/ast_h323.h
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/ast_h323.h?rev=40665&r1=40664&r2=40665&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/ast_h323.h (original)
+++ team/pcadach/chan_h323-live/channels/h323/ast_h323.h Sun Aug 20 13:50:36 2006
@@ -226,6 +226,7 @@
 	int cause;
 
 	RTP_DataFrame::PayloadTypes dtmfCodec;
+	int dtmfMode;
 
 	PString ast_cid_num;
 	PString ast_cid_name;



More information about the svn-commits mailing list