Revision
15905
Author
bottleman
Date
2009-12-11 06:18:29 -0600 (Fri, 11 Dec 2009)

Log Message

fix rtp timer initialisation.
implement alerting-indication option and channel variable.
implement progress-indication option and channel variable.

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_h323/changes.txt (15904 => 15905)


--- freeswitch/trunk/src/mod/endpoints/mod_h323/changes.txt	2009-12-11 05:14:45 UTC (rev 15904)
+++ freeswitch/trunk/src/mod/endpoints/mod_h323/changes.txt	2009-12-11 12:18:29 UTC (rev 15905)
@@ -1,5 +1,7 @@
-
-fix to build with trunk changes.
+fix rtp timer initialisation.
+implement alerting-indication option and channel variable.
+implement progress-indication option and channel variable.
+fix short DTMF warnings.
 remove SWITCH_RTP_FLAG_AUTOADJ because its not work correctly and not do anything reliable in our cases.
 fix faststart in progress handling
 fixxxxes

Modified: freeswitch/trunk/src/mod/endpoints/mod_h323/h323.conf.xml (15904 => 15905)


--- freeswitch/trunk/src/mod/endpoints/mod_h323/h323.conf.xml	2009-12-11 05:14:45 UTC (rev 15904)
+++ freeswitch/trunk/src/mod/endpoints/mod_h323/h323.conf.xml	2009-12-11 12:18:29 UTC (rev 15905)
@@ -12,6 +12,8 @@
     <param name="h245tunneling" value="true"/>  <!-- optional -->
     <param name="h245insetup" value="true"/>  <!-- optional -->
     <param name="jitter-size" value="60"/>  <!-- optional -->
+    <param name="progress-indication" value="8"/> <!-- optional - PI value in progress message-->
+    <param name="alerting-indication" value="8"/> <!-- optional - PI value in alerting message-->
   </settings>
   <listeners>
     <listener name="default">

Modified: freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.cpp (15904 => 15905)


--- freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.cpp	2009-12-11 05:14:45 UTC (rev 15904)
+++ freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.cpp	2009-12-11 12:18:29 UTC (rev 15905)
@@ -1,5 +1,5 @@
 /*
-	Version 0.0.13
+	Version 0.0.16
 */
 
 #include "mod_h323.h"
@@ -361,6 +361,8 @@
     }
 
     switch_xml_t xmlSettings = switch_xml_child(cfg, "settings");
+	m_pi = 8;
+	m_ai = 0;
     if (xmlSettings) {
         for (switch_xml_t xmlParam = switch_xml_child(xmlSettings, "param"); xmlParam != NULL; xmlParam = xmlParam->next) {
             const char *var = switch_xml_attr_soft(xmlParam, "name");
@@ -405,8 +407,11 @@
 				m_gkPrefixes.AppendString(val);
 			} else if (!strcasecmp(var, "gk-retry")) {
 				m_gkretry = atoi(val);
-			} 
-			
+			} else if (!strcasecmp(var, "progress-indication")) {
+				m_pi = atoi(val);
+			} else if (!strcasecmp(var, "alerting-indication")) {
+				m_ai = atoi(val);
+			}			
         }
     }
 
@@ -821,6 +826,89 @@
 	return ( status == SWITCH_STATUS_SUCCESS);
 }
 
+void FSH323Connection::AnsweringCall(AnswerCallResponse response){
+
+	PTRACE(4, "mod_h323\t======>FSH323Connection::AnsweringCall ["<<*this<<"]");
+	
+	switch (response) {
+		case AnswerCallDeferredWithMedia:{
+			PTRACE(2, "H323\tAnswering call: " << response);
+			if (!Lock())
+				return;
+			if (!mediaWaitForConnect) {
+				// create a new facility PDU if doing AnswerDeferredWithMedia
+				H323SignalPDU want245PDU;
+				H225_Progress_UUIE & prog = want245PDU.BuildProgress(*this);
+				PBoolean sendPDU = TRUE;
+
+				if (SendFastStartAcknowledge(prog.m_fastStart))
+					prog.IncludeOptionalField(H225_Progress_UUIE::e_fastStart);
+				else {
+					// See if aborted call
+					if (connectionState == ShuttingDownConnection){
+						Unlock();
+						return;
+					}
+					// Do early H.245 start
+					H225_Facility_UUIE & fac = *want245PDU.BuildFacility(*this, FALSE, H225_FacilityReason::e_startH245);
+					earlyStart = TRUE;
+					if (!h245Tunneling && (controlChannel == NULL)) {
+						if (!StartControlChannel()){
+							Unlock();
+							return;
+						}
+						fac.IncludeOptionalField(H225_Facility_UUIE::e_h245Address);
+						controlChannel->SetUpTransportPDU(fac.m_h245Address, TRUE);
+					} 
+					else
+						sendPDU = FALSE;
+				}
+				const char *vpi = switch_channel_get_variable(m_fsChannel, "progress-indication"); 
+				unsigned pi = 8;
+				if (vpi){
+					pi = atoi(vpi); 
+				}
+				else pi = m_endpoint->m_pi;
+				if ((pi< 1) || (pi > 8)||(pi == 7)) pi = 8;
+				want245PDU.GetQ931().SetProgressIndicator(pi);
+				if (sendPDU) {
+					HandleTunnelPDU(&want245PDU);
+					WriteSignalPDU(want245PDU);
+				}
+			}
+			InternalEstablishedConnectionCheck();
+			Unlock();
+			return;
+		} 
+		case AnswerCallPending :{
+			if (alertingPDU != NULL) {
+				if (!Lock())
+					return;
+				// send Q931 Alerting PDU
+				PTRACE(3, "H225\tSending Alerting PDU");
+				
+				const char *vai = switch_channel_get_variable(m_fsChannel, "alerting-indication"); 
+				unsigned ai = 0;
+				if (vai){
+					ai = atoi(vai); 
+				}
+				else ai = m_endpoint->m_ai;
+				if ((ai< 0) || (ai > 8)||(ai == 7)) ai = 8;
+				if (ai > 0)
+					(*alertingPDU).GetQ931().SetProgressIndicator(ai);
+				
+				HandleTunnelPDU(alertingPDU);
+				WriteSignalPDU(*alertingPDU);
+				alertingTime = PTime();
+				InternalEstablishedConnectionCheck();
+				Unlock();
+				return;
+			}
+		}
+		default :H323Connection::AnsweringCall(response);
+	} 
+}
+
 void FSH323Connection::OnEstablished(){
 
 	PTRACE(4, "mod_h323\t======>PFSH323Connection::OnEstablished ["<<*this<<"]");
@@ -1229,6 +1317,7 @@
                 m_switchCodec = NULL;
                 return false;
             }
+			switch_channel_set_variable(m_fsChannel,"timer_name","soft");
         } else {
             switch_core_session_set_video_read_codec(m_fsSession, m_switchCodec);
             switch_channel_set_flag(m_fsChannel, CF_VIDEO);
@@ -1278,11 +1367,13 @@
 	PTRACE(4, "mod_h323\t------------------->samples_per_packet = "<<m_switchCodec->implementation->samples_per_packet);
 	PTRACE(4, "mod_h323\t------------------->actual_samples_per_second = "<<m_switchCodec->implementation->actual_samples_per_second);
 	
-	if (!m_conn->m_startRTP) {			
-		flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_DATAWAIT|SWITCH_RTP_FLAG_AUTO_CNG|SWITCH_RTP_FLAG_RAW_WRITE);		
+	if ((!m_conn->m_startRTP)&&(GetDirection() == IsReceiver)) {			
+		flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_DATAWAIT|SWITCH_RTP_FLAG_AUTO_CNG|SWITCH_RTP_FLAG_RAW_WRITE);
+		PTRACE(4, "mod_h323\t------------------->timer_name = "<<switch_channel_get_variable(m_fsChannel, "timer_name"));
 		if ((var = switch_channel_get_variable(m_fsChannel, "timer_name"))) {
 			timer_name = (char *) var;
 		}
+		PTRACE(4, "mod_h323\t------------------->timer_name = "<<timer_name);
 		tech_pvt->rtp_session = switch_rtp_new((const char *)m_RTPlocalIP,
 											   m_RTPlocalPort,
 											   (const char *)m_RTPremoteIP,

Modified: freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h (15904 => 15905)


--- freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h	2009-12-11 05:14:45 UTC (rev 15904)
+++ freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h	2009-12-11 12:18:29 UTC (rev 15905)
@@ -126,6 +126,7 @@
     PString gatekeeper;
 };
 class FSGkRegThread;
+
 class FSH323EndPoint:public H323EndPoint {
 
     PCLASSINFO(FSH323EndPoint, H323EndPoint);
@@ -156,7 +157,8 @@
     }
 	FSH323Connection * FSMakeCall(const PString & dest,void *userData);
 	list <FSListener> m_listeners;
-	
+	int m_ai;
+	int m_pi;
 	protected:
 		PStringList m_gkPrefixes;
 		switch_endpoint_interface_t *m_freeswitch;
@@ -168,7 +170,6 @@
 		bool m_h245insetup;
 		int m_gkretry;
 		FSGkRegThread* m_thread;
-		
 };
 
 
@@ -219,6 +220,7 @@
     void setRemoteAddress(const char* remoteIP, WORD remotePort);
 	virtual void OnSetLocalCapabilities();
 	virtual bool OnAlerting(const H323SignalPDU &alertingPDU, const PString &user);
+	virtual void AnsweringCall(AnswerCallResponse response);
 	virtual void OnEstablished();
 	bool SetLocalCapabilities();
 	static bool decodeCapability(const H323Capability& capability, const char** dataFormat, int* payload = 0, PString* capabName = 0);