[Asterisk-cvs] asterisk/channels/h323 ast_h323.cpp, 1.63, 1.64 ast_h323.h, 1.27, 1.28 chan_h323.h, 1.31, 1.32

jeremy at lists.digium.com jeremy at lists.digium.com
Fri Oct 22 22:39:41 CDT 2004


Update of /usr/cvsroot/asterisk/channels/h323
In directory mongoose.digium.com:/tmp/cvs-serv29418/h323

Modified Files:
	ast_h323.cpp ast_h323.h chan_h323.h 
Log Message:
implement type=alias to deprecate type=h323 and a whole lot more code clean up

Index: ast_h323.cpp
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/ast_h323.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- ast_h323.cpp	22 Oct 2004 19:04:02 -0000	1.63
+++ ast_h323.cpp	23 Oct 2004 02:43:41 -0000	1.64
@@ -78,14 +78,14 @@
 
 void MyProcess::Main()
 {
-	ast_verbose("  == Creating H.323 Endpoint\n");
+	cout << "  == Creating H.323 Endpoint" << endl;
 	endPoint = new MyH323EndPoint();
 	PTrace::Initialise(0, NULL, PTrace::Timestamp | PTrace::Thread | PTrace::FileAndLine);
 }
 
-#define H323_G7231 OPAL_G7231_6k3"{sw}"
-#define H323_G729  OPAL_G729 "{sw}"
-#define H323_G729A OPAL_G729A"{sw}"
+#define H323_G7231 OPAL_G7231_6k3 "{sw}"
+#define H323_G729 OPAL_G729 "{sw}"
+#define H323_G729A OPAL_G729A "{sw}"
 
 H323_REGISTER_CAPABILITY(H323_G7231Capability, H323_G7231);
 H323_REGISTER_CAPABILITY(AST_G729Capability,  H323_G729);
@@ -94,70 +94,67 @@
 H323_G7231Capability::H323_G7231Capability(BOOL annexA_)
   : H323AudioCapability(7, 4)
 {
-  annexA = annexA_;
+  	annexA = annexA_;
 }
 
 PObject::Comparison H323_G7231Capability::Compare(const PObject & obj) const
 {
-  Comparison result = H323AudioCapability::Compare(obj);
-  if (result != EqualTo)
-    return result;
-
-  PINDEX otherAnnexA = ((const H323_G7231Capability &)obj).annexA;
-  if (annexA < otherAnnexA)
-    return LessThan;
-  if (annexA > otherAnnexA)
-    return GreaterThan;
-  return EqualTo;
+  	Comparison result = H323AudioCapability::Compare(obj);
+  	if (result != EqualTo) {
+    		return result;
+	}
+  	PINDEX otherAnnexA = ((const H323_G7231Capability &)obj).annexA;
+  	if (annexA < otherAnnexA) {
+    		return LessThan;
+	}
+  	if (annexA > otherAnnexA) {
+    		return GreaterThan;
+	}
+	return EqualTo;
 }
 
 PObject * H323_G7231Capability::Clone() const
 {
-  return new H323_G7231Capability(*this);
+ 	 return new H323_G7231Capability(*this);
 }
 
 PString H323_G7231Capability::GetFormatName() const
 {
-  return H323_G7231;
+  	return H323_G7231;
 }
 
 unsigned H323_G7231Capability::GetSubType() const
 {
-  return H245_AudioCapability::e_g7231;
+  	return H245_AudioCapability::e_g7231;
 }
 
 BOOL H323_G7231Capability::OnSendingPDU(H245_AudioCapability & cap,
                                           unsigned packetSize) const
 {
-  cap.SetTag(H245_AudioCapability::e_g7231);
-
-  H245_AudioCapability_g7231 & g7231 = cap;
-  g7231.m_maxAl_sduAudioFrames = packetSize;
-  g7231.m_silenceSuppression = annexA;
-
-  return TRUE;
+  	cap.SetTag(H245_AudioCapability::e_g7231);
+  	H245_AudioCapability_g7231 & g7231 = cap;
+  	g7231.m_maxAl_sduAudioFrames = packetSize;
+  	g7231.m_silenceSuppression = annexA;
+  	return TRUE;
 }
 
 BOOL H323_G7231Capability::OnReceivedPDU(const H245_AudioCapability & cap,
                                            unsigned & packetSize)
 {
-  if (cap.GetTag() != H245_AudioCapability::e_g7231)
-    return FALSE;
-
-  const H245_AudioCapability_g7231 & g7231 = cap;
-  packetSize = g7231.m_maxAl_sduAudioFrames;
-  annexA = g7231.m_silenceSuppression;
-
-  return TRUE;
+	if (cap.GetTag() != H245_AudioCapability::e_g7231) {
+    		return FALSE;
+	}
+  	const H245_AudioCapability_g7231 & g7231 = cap;
+  	packetSize = g7231.m_maxAl_sduAudioFrames;
+  	annexA = g7231.m_silenceSuppression;
+  	return TRUE;
 }
 
 H323Codec * H323_G7231Capability::CreateCodec(H323Codec::Direction direction) const
 {
-  return NULL;
+  	return NULL;
 }
 
-/////////////////////////////////////////////////////////////////////////////
-
 AST_G729Capability::AST_G729Capability()
   : H323AudioCapability(24, 6)
 {
@@ -165,26 +162,24 @@
 
 PObject * AST_G729Capability::Clone() const
 {
-  return new AST_G729Capability(*this);
+  	return new AST_G729Capability(*this);
 }
 
 unsigned AST_G729Capability::GetSubType() const
 {
-  return H245_AudioCapability::e_g729;
+  	return H245_AudioCapability::e_g729;
 }
 
 PString AST_G729Capability::GetFormatName() const
 {
-  return H323_G729;
+  	return H323_G729;
 }
 
 H323Codec * AST_G729Capability::CreateCodec(H323Codec::Direction direction) const
 {
-  return NULL;
+  	return NULL;
 }
 
-/////////////////////////////////////////////////////////////////////////////
-
 AST_G729ACapability::AST_G729ACapability()
   : H323AudioCapability(24, 6)
 {
@@ -192,22 +187,22 @@
 
 PObject * AST_G729ACapability::Clone() const
 {
-  return new AST_G729ACapability(*this);
+  	return new AST_G729ACapability(*this);
 }
 
 unsigned AST_G729ACapability::GetSubType() const
 {
-  return H245_AudioCapability::e_g729AnnexA;
+  	return H245_AudioCapability::e_g729AnnexA;
 }
 
 PString AST_G729ACapability::GetFormatName() const
 {
-  return H323_G729A;
+  	return H323_G729A;
 }
 
 H323Codec * AST_G729ACapability::CreateCodec(H323Codec::Direction direction) const
 {
-  return NULL;
+  	return NULL;
 }
 
 /** MyH323EndPoint 
@@ -218,7 +213,7 @@
   *					transport = ip.
   *					port = 1720.
   */
-int MyH323EndPoint::MakeCall(const PString & dest, PString & token, unsigned int *callReference, unsigned int port, char *cid_name, char *cid_name)
+int MyH323EndPoint::MakeCall(const PString & dest, PString & token, unsigned int *callReference, unsigned int port, char *cid_name, char *cid_num)
 {
 	PString fullAddress;
 	MyH323Connection * connection;
@@ -253,9 +248,9 @@
                 connection->SetLocalPartyName(PString(cid_num));
         }
 	if (h323debug) {
-		cout << "	-- " << GetLocalUserName() << " is calling host " << fullAddress << endl;
-		cout << "	-- " << "Call token is " << (const char *)token << endl;
-		cout << "	-- Call reference is " << *callReference << endl;
+		cout << "\t-- " << GetLocalUserName() << " is calling host " << fullAddress << endl;
+		cout << "\t--" << "Call token is " << (const char *)token << endl;
+		cout << "\t-- Call reference is " << *callReference << endl;
 	}
 	connection->Unlock(); 	
 	return 0;
@@ -263,16 +258,16 @@
 
 void MyH323EndPoint::SetEndpointTypeInfo( H225_EndpointType & info ) const
 {
-  H323EndPoint::SetEndpointTypeInfo(info);
-  info.m_gateway.IncludeOptionalField(H225_GatewayInfo::e_protocol);
-  info.m_gateway.m_protocol.SetSize(1);
-  H225_SupportedProtocols &protocol=info.m_gateway.m_protocol[0];
-  protocol.SetTag(H225_SupportedProtocols::e_voice);
-  PINDEX as=SupportedPrefixes.GetSize();
-  ((H225_VoiceCaps &)protocol).m_supportedPrefixes.SetSize(as);
-  for (PINDEX p=0; p<as; p++) {
-    H323SetAliasAddress(SupportedPrefixes[p], ((H225_VoiceCaps &)protocol).m_supportedPrefixes[p].m_prefix);
-  }
+  	H323EndPoint::SetEndpointTypeInfo(info);
+  	info.m_gateway.IncludeOptionalField(H225_GatewayInfo::e_protocol);
+  	info.m_gateway.m_protocol.SetSize(1);
+  	H225_SupportedProtocols &protocol=info.m_gateway.m_protocol[0];
+  	protocol.SetTag(H225_SupportedProtocols::e_voice);
+  	PINDEX as=SupportedPrefixes.GetSize();
+  	((H225_VoiceCaps &)protocol).m_supportedPrefixes.SetSize(as);
+  	for (PINDEX p=0; p<as; p++) {
+    		H323SetAliasAddress(SupportedPrefixes[p], ((H225_VoiceCaps &)protocol).m_supportedPrefixes[p].m_prefix);
+  	}
 }
 
 void MyH323EndPoint::SetGateway(void)
@@ -288,7 +283,7 @@
 BOOL MyH323EndPoint::ClearCall(const PString & token)
 {
 	if (h323debug) {
-		cout << "	-- ClearCall: Request to clear call with token " << token << endl;
+		cout << "\t-- ClearCall: Request to clear call with token " << token << endl;
 	}
 	return H323EndPoint::ClearCall(token);
 }
@@ -307,8 +302,9 @@
 void MyH323EndPoint::OnClosedLogicalChannel(H323Connection & connection, const H323Channel & channel)
 {
 	channelsOpen--;
-	if (h323debug)
-		cout << "		channelsOpen = " << channelsOpen << endl;
+	if (h323debug) {
+		cout << "\t\tchannelsOpen = " << channelsOpen << endl;
+	}
 	H323EndPoint::OnClosedLogicalChannel(connection, channel);
 }
 
@@ -317,7 +313,7 @@
  		const H323SignalPDU & pdu)
  {
  	if (h323debug) {
-	 	cout << "       -- Call Forwarded to " << forwardParty << endl;
+	 	cout << "\t-- Call Forwarded to " << forwardParty << endl;
  	}
 	return FALSE;
  }
@@ -327,7 +323,7 @@
  		const H323SignalPDU & pdu)
 {
  	if (h323debug) {
- 		cout << "       -- Forwarding call to " << forwardParty << endl;
+ 		cout << "\t-- Forwarding call to " << forwardParty << endl;
  	}
 	return H323EndPoint::ForwardConnection(connection, forwardParty, pdu);
 }
@@ -352,105 +348,119 @@
 	WORD sourcePort;
 
 	remoteName = connection.GetRemotePartyName();
-
 	cd.call_reference = connection.GetCallReference();
 	cd.call_token = strdup((const char *)clearedCallToken);
 	cd.call_source_aliases = strdup((const char *)connection.GetRemotePartyName());
-	
   	connection.GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort);
 	cd.sourceIp = strdup((const char *)Ip.AsString());
 	
 	/* Convert complex strings */
 	char *s;
-	if ((s = strchr(cd.call_source_aliases, ' ')) != NULL)
+	if ((s = strchr(cd.call_source_aliases, ' ')) != NULL) {
 		*s = '\0';
-
+	}
 	switch (connection.GetCallEndReason()) {
-		case H323Connection::EndedByCallForwarded :
-			if (h323debug)
-				cout << " -- " << remoteName << " has forwarded the call" << endl;
+		case H323Connection::EndedByCallForwarded:
+			if (h323debug) {
+				cout << "-- " << remoteName << " has forwarded the call" << endl;
+			}
 			break;
-		case H323Connection::EndedByRemoteUser :
-			if (h323debug)
-				cout << " -- " << remoteName << " has cleared the call" << endl;
+		case H323Connection::EndedByRemoteUser:
+			if (h323debug) {
+				cout << "-- " << remoteName << " has cleared the call" << endl;
+			}
 			break;
-		case H323Connection::EndedByCallerAbort :
-			if (h323debug)
-				cout << " -- " << remoteName << " has stopped calling" << endl;
+		case H323Connection::EndedByCallerAbort:
+			if (h323debug) {
+				cout << "-- " << remoteName << " has stopped calling" << endl;
+			}
 			break;
-		case H323Connection::EndedByRefusal :
-			if (h323debug)
-				cout << " -- " << remoteName << " did not accept your call" << endl;
+		case H323Connection::EndedByRefusal:
+			if (h323debug) {
+				cout << "-- " << remoteName << " did not accept your call" << endl;
+			}
 			break;
-		case H323Connection::EndedByRemoteBusy :
-			if (h323debug)
-			cout << " -- " << remoteName << " was busy" << endl;
+		case H323Connection::EndedByRemoteBusy:
+			if (h323debug) {
+				cout << "-- " << remoteName << " was busy" << endl;
+			}
 			break;
-		case H323Connection::EndedByRemoteCongestion :
-			if (h323debug)
-				cout << " -- Congested link to " << remoteName << endl;
+		case H323Connection::EndedByRemoteCongestion:
+			if (h323debug) {
+				cout << "-- Congested link to " << remoteName << endl;
+			}
 			break;
-		case H323Connection::EndedByNoAnswer :
-			if (h323debug)
-				cout << " -- " << remoteName << " did not answer your call" << endl;
+		case H323Connection::EndedByNoAnswer:
+			if (h323debug) {
+				cout << "-- " << remoteName << " did not answer your call" << endl;
+			}
 			break;
-		case H323Connection::EndedByTransportFail :
-			if (h323debug)
-				cout << " -- Call with " << remoteName << " ended abnormally" << endl;
+		case H323Connection::EndedByTransportFail:
+			if (h323debug) {
+				cout << "-- Call with " << remoteName << " ended abnormally" << endl;
+			}
 			break;
-		case H323Connection::EndedByCapabilityExchange :
-			if (h323debug)
-				cout << " -- Could not find common codec with " << remoteName << endl;
+		case H323Connection::EndedByCapabilityExchange:
+			if (h323debug) {
+				cout << "-- Could not find common codec with " << remoteName << endl;
+			}
 			break;
-		case H323Connection::EndedByNoAccept :
-			if (h323debug)
-				cout << " -- Did not accept incoming call from " << remoteName << endl;
+		case H323Connection::EndedByNoAccept:
+			if (h323debug) {
+				cout << "-- Did not accept incoming call from " << remoteName << endl;
+			}
 			break;
-		case H323Connection::EndedByAnswerDenied :
-			if (h323debug)
-				cout << " -- Refused incoming call from " << remoteName << endl;
+		case H323Connection::EndedByAnswerDenied:
+			if (h323debug) {
+				cout << "-- Refused incoming call from " << remoteName << endl;
+			}
 			break;
-		case H323Connection::EndedByNoUser :
-			if (h323debug)
-				cout << " -- Remote endpoint could not find user: " << remoteName << endl;
+		case H323Connection::EndedByNoUser:
+			if (h323debug) {
+				cout << "-- Remote endpoint could not find user: " << remoteName << endl;
+			}
 			break;
-		case H323Connection::EndedByNoBandwidth :
-			if (h323debug)
-				cout << " -- Call to " << remoteName << " aborted, insufficient bandwidth." << endl;
+		case H323Connection::EndedByNoBandwidth:
+			if (h323debug) {
+				cout << "-- Call to " << remoteName << " aborted, insufficient bandwidth." << endl;
+			}
 			break;
-		case H323Connection::EndedByUnreachable :
-			if (h323debug)
-				cout << " -- " << remoteName << " could not be reached." << endl;
+		case H323Connection::EndedByUnreachable:
+			if (h323debug) {
+				cout << "-- " << remoteName << " could not be reached." << endl;
+			}
 			break;
-		case H323Connection::EndedByHostOffline :
-			if (h323debug)
-				cout << " -- " << remoteName << " is not online." << endl;
+		case H323Connection::EndedByHostOffline:
+			if (h323debug) {
+				cout << "-- " << remoteName << " is not online." << endl;
+			}
 			break;
-		case H323Connection::EndedByNoEndPoint :
-			if (h323debug)
-				cout << " -- No phone running for " << remoteName << endl;
+		case H323Connection::EndedByNoEndPoint:
+			if (h323debug) {
+				cout << "-- No phone running for " << remoteName << endl;
+			}
 			break;
-		case H323Connection::EndedByConnectFail :
-			if (h323debug)
-				cout << " -- Transport error calling " << remoteName << endl;
+		case H323Connection::EndedByConnectFail:
+			if (h323debug) {
+				cout << "-- Transport error calling " << remoteName << endl;
+			}
 			break;
-		default :
+		default:
 			if (h323debug)
 				cout << " -- Call with " << remoteName << " completed (" << connection.GetCallEndReason() << ")" << endl;
 
 	}
 
-	if(connection.IsEstablished()) 
-		if (h323debug)
-			cout << "	 -- Call duration " << setprecision(0) << setw(5) << (PTime() - connection.GetConnectionStartTime()) << endl;
-
+	if (connection.IsEstablished()) {
+		if (h323debug) {
+			cout << "\t-- Call duration " << setprecision(0) << setw(5) << (PTime() - connection.GetConnectionStartTime()) << endl;
+		}
+	}	
 	/* Invoke the PBX application registered callback */
 	on_connection_cleared(cd);
-
 	return;
 }
 
-
 H323Connection * MyH323EndPoint::CreateConnection(unsigned callReference, void *o)
 {
 	unsigned options = 0;
@@ -466,6 +476,7 @@
 	} else {
 		options |= H323Connection::H245TunnelingOptionEnable;
 	}
+/* Disable until I can figure out the proper way to deal with this */
 #if 0
 	if (opts->noSilenceSuppression) {
 		options |= H323Connection::SilenceSuppresionOptionDisable;
@@ -476,7 +487,7 @@
 	return new MyH323Connection(*this, callReference, options);
 }
 
-/* MyH323Connection */    
+/* MyH323Connection Implementation */    
 MyH323Connection::MyH323Connection(MyH323EndPoint & ep, unsigned callReference,
 							unsigned options)
 	: H323Connection(ep, callReference, options)
@@ -500,9 +511,9 @@
 								  H323SignalPDU & /*connectPDU*/)
 {
 
-       if (h323debug)
+       if (h323debug) {
                cout << "\t=-= In OnAnswerCall for call " << GetCallReference() << endl;
-	
+	}
 	if (!on_answer_call(GetCallReference(), (const char *)GetCallToken())) {
 		return H323Connection::AnswerCallDenied;
 	}
@@ -511,12 +522,12 @@
 	return H323Connection::AnswerCallDeferred;
 }
 
-BOOL  MyH323Connection::OnAlerting(const H323SignalPDU & /*alertingPDU*/, const PString & username)
+BOOL MyH323Connection::OnAlerting(const H323SignalPDU & /*alertingPDU*/, const PString & username)
 {
 	if (h323debug) {
-	        cout << "\t =-= In OnAlerting for call " << GetCallReference()
+	        cout << "\t=-= In OnAlerting for call " << GetCallReference()
 	              << ": sessionId=" << sessionId << endl;
-                 cout << "       -- Ringing phone for \"" << username << "\"" << endl;
+                 cout << "\t-- Ringing phone for \"" << username << "\"" << endl;
 	}     
         on_chan_ringing(GetCallReference(), (const char *)GetCallToken() );
         return TRUE;
@@ -524,11 +535,6 @@
 
 BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
 {
-	
-	if (h323debug) {
-		ast_verbose("	-- Received SETUP message\n");
-	}
-	
 	call_details_t cd;
 	PString sourceE164;
 	PString destE164;
@@ -539,6 +545,10 @@
 	WORD sourcePort;
 	char *s, *s1; 
 
+	if (h323debug) {
+		cout << ("\t--Received SETUP message\n");
+	}
+
 	sourceAliases = setupPDU.GetSourceAliases();
 	destAliases = setupPDU.GetDestinationAlias();
 			
@@ -551,21 +561,24 @@
 
 	/* Convert complex strings */
 	//  FIXME: deal more than one source alias 
-    	if ((s = strchr(sourceAliases, ' ')) != NULL)
+    	if ((s = strchr(sourceAliases, ' ')) != NULL) {
                 *s = '\0';
-    	if ((s = strchr(sourceAliases, '\t')) != NULL)
+	}
+    	if ((s = strchr(sourceAliases, '\t')) != NULL) {
                 *s = '\0';
- 	if ((s1 = strchr(destAliases, ' ')) != NULL)
+	}
+ 	if ((s1 = strchr(destAliases, ' ')) != NULL) {
          	*s1 = '\0';
-	if ((s1 = strchr(destAliases, '\t')) != NULL)
+	}
+	if ((s1 = strchr(destAliases, '\t')) != NULL) {
          	*s1 = '\0';
-
+	}
 
 	cd.call_reference = GetCallReference();
 	Lock();
 	cd.call_token = strdup((const char *)GetCallToken());
 	Unlock();
-	cd.call_source_aliases  =  strdup((const char *)sourceAliases);
+	cd.call_source_aliases = strdup((const char *)sourceAliases);
 	cd.call_dest_alias = strdup((const char *)destAliases);
 	cd.call_source_e164 = strdup((const char *)sourceE164);
 	cd.call_dest_e164 = strdup((const char *)destE164);
@@ -583,7 +596,6 @@
 		}
 		return FALSE;
 	}
-	
 	return H323Connection::OnReceivedSignalSetup(setupPDU);
 }
 
@@ -606,15 +618,18 @@
 	/* Convert complex strings */
 	//  FIXME: deal more than one source alias 
 	
-    	if ((s = strchr(sourceAliases, ' ')) != NULL)
+    	if ((s = strchr(sourceAliases, ' ')) != NULL) {
                 *s = '\0';
-    	if ((s = strchr(sourceAliases, '\t')) != NULL)
+	}
+    	if ((s = strchr(sourceAliases, '\t')) != NULL) {
                 *s = '\0';
-    	if ((s1 = strchr(destAliases, ' ')) != NULL)
+	}
+    	if ((s1 = strchr(destAliases, ' ')) != NULL) {
         	 *s1 = '\0';
-	if ((s1 = strchr(destAliases, '\t')) != NULL)
+	}
+	if ((s1 = strchr(destAliases, '\t')) != NULL) {
          	*s1 = '\0';
-
+	}
 	cd.call_reference = GetCallReference();
 	Lock();
 	cd.call_token = strdup((const char *)GetCallToken());
@@ -624,22 +639,20 @@
 	cd.call_source_e164 = strdup((const char *)sourceE164);
 	cd.call_dest_e164 = strdup((const char *)destE164);
 
-	int res = on_outgoing_call(cd);	
-		
+	int res = on_outgoing_call(cd);		
 	if (!res) {
 		if (h323debug) {
-			cout << "	-- Call Failed" << endl;
+			cout << "\t-- Call Failed" << endl;
 		}
 		return FALSE;
 	}
-
 	return H323Connection::OnSendSignalSetup(setupPDU);
 }
 
 BOOL MyH323Connection::OnSendReleaseComplete(H323SignalPDU & releaseCompletePDU)
 {
 	if (h323debug) {
-		cout << "	-- Sending RELEASE COMPLETE" << endl;
+		cout << "\t-- Sending RELEASE COMPLETE" << endl;
 	}
 	return H323Connection::OnSendReleaseComplete(releaseCompletePDU);
 }
@@ -647,7 +660,7 @@
 BOOL MyH323Connection::OnReceivedFacility(const H323SignalPDU & pdu)
 {
 	if (h323debug) {
-		cout << "	-- Received Facility message... " << endl;
+		cout << "\t-- Received Facility message... " << endl;
 	}	
 	return H323Connection::OnReceivedFacility(pdu);
 }
@@ -655,7 +668,7 @@
 void MyH323Connection::OnReceivedReleaseComplete(const H323SignalPDU & pdu)
 {
 	if (h323debug) {
-		cout <<  "	-- Received RELEASE COMPLETE message..." << endl;
+		cout <<  "\t-- Received RELEASE COMPLETE message..." << endl;
 	}
 	return H323Connection::OnReceivedReleaseComplete(pdu);
 }
@@ -663,16 +676,15 @@
 BOOL MyH323Connection::OnClosingLogicalChannel(H323Channel & channel)
 {
 	if (h323debug) {
-		cout << "	-- Closing logical channel..." << endl;
+		cout << "\t-- Closing logical channel..." << endl;
 	}
 	return H323Connection::OnClosingLogicalChannel(channel);
 }
 
-
 void MyH323Connection::SendUserInputTone(char tone, unsigned duration)
 {
 	if (h323debug) {
-		cout << "	-- Sending user input tone (" << tone << ") to remote" << endl;
+		cout << "\t-- Sending user input tone (" << tone << ") to remote" << endl;
 	}
 	on_send_digit(GetCallReference(), tone, (const char *)GetCallToken());	
 	H323Connection::SendUserInputTone(tone, duration);
@@ -682,7 +694,7 @@
 {
 	if (mode == H323_DTMF_INBAND) {
 		if (h323debug) {
-			cout << "	-- Received user input tone (" << tone << ") from remote" << endl;
+			cout << "\t-- Received user input tone (" << tone << ") from remote" << endl;
 		}
 		on_send_digit(GetCallReference(), tone, (const char *)GetCallToken());
 	}
@@ -693,7 +705,7 @@
 {
 	if (mode == H323_DTMF_RFC2833) {
 		if (h323debug) {
-			cout <<  "	-- Received user input string (" << value << ") from remote." << endl;
+			cout <<  "\t-- Received user input string (" << value << ") from remote." << endl;
 		}
 		on_send_digit(GetCallReference(), value[0], (const char *)GetCallToken());
 	}	
@@ -719,13 +731,12 @@
 		cout << (const char *)(channel.GetCapability()).GetFormatName() << endl;
 	}
 
-	/* adjust the count of channels we have open */
+	/* Increase the count of channels we have open */
 	channelsOpen++;
 
 	if (h323debug) {
 		cout <<  "\t\t-- channelsOpen = " << channelsOpen << endl;
 	}
-
 	return TRUE;	
 }
 
@@ -752,7 +763,7 @@
 		free(info);
 	}
 
-	// Get the payload code	
+	/* Get the payload code	*/
 	OpalMediaFormat format(capability.GetFormatName(), FALSE);
 	payloadCode = format.GetPayloadType();
 } 
@@ -880,8 +891,8 @@
 	oldcaps = endPoint->GetCapabilities();
 	for (PINDEX i=0; i< oldcaps.GetSize(); i++) {
                  codecs.AppendString(oldcaps[i].GetFormatName());
-         }
-         endPoint->RemoveCapabilities(codecs);
+        }
+        endPoint->RemoveCapabilities(codecs);
 
 	mode = dtmfMode;
 	if (dtmfMode == H323_DTMF_INBAND) {
@@ -948,16 +959,12 @@
 	}
 	
 	PIPSocket::Address interfaceAddress(bindaddr.sin_addr);
-
 	if (!listenPort) {
 		listenPort = 1720;
 	}
-
 	/** H.323 listener */  
 	H323ListenerTCP *tcpListener;
-
 	tcpListener = new H323ListenerTCP(*endPoint, interfaceAddress, (WORD)listenPort);
-
 	if (!endPoint->StartListener(tcpListener)) {
 		cout << "ERROR: Could not open H.323 listener port on " << ((H323ListenerTCP *) tcpListener)->GetListenerPort() << endl;
 		delete tcpListener;
@@ -965,11 +972,9 @@
 		
 	}
 	cout << "  == H.323 listener started" << endl;
-
 	return 0;
 };
  
-   
 int h323_set_alias(struct oh323_alias *alias)
 {
 	char *p;
@@ -982,29 +987,27 @@
 		return 1;
 	}
 
-	cout << "  == Adding alias \"" << h323id << "\" to endpoint" << endl;
+	cout << "== Adding alias \"" << h323id << "\" to endpoint" << endl;
 	endPoint->AddAliasName(h323id);	
 	endPoint->RemoveAliasName(localProcess->GetUserName());
 
 	if (!e164.IsEmpty()) {
-		cout << "  == Adding E.164 \"" << e164 << "\" to endpoint" << endl;
+		cout << "== Adding E.164 \"" << e164 << "\" to endpoint" << endl;
 		endPoint->AddAliasName(e164);
 	}
 	if (strlen(alias->prefix)) {
 		p = alias->prefix;
 		num = strsep(&p, ",");
 		while(num) {
-	        cout << "  == Adding Prefix \"" << num << "\" to endpoint" << endl;
-			endPoint->SupportedPrefixes += PString(num);
-			endPoint->SetGateway();
+	        cout << "== Adding Prefix \"" << num << "\" to endpoint" << endl;
+		endPoint->SupportedPrefixes += PString(num);
+		endPoint->SetGateway();
 	        num = strsep(&p, ",");		
 		}
 	}
-
 	return 0;
 }
 
-
 void h323_set_id(char *id)
 {
 	PString h323id(id);
@@ -1012,7 +1015,6 @@
 	if (h323debug) {
 		cout << "  == Using '" << h323id << "' as our H.323ID for this call" << endl;
 	}
-
 	/* EVIL HACK */
 	endPoint->SetLocalUserName(h323id);
 }
@@ -1022,14 +1024,13 @@
 	cout << "Current call tokens: " << setprecision(2) << endPoint->GetAllConnections() << endl;
 }
 
-
 /** Establish Gatekeeper communiations, if so configured, 
   *	register aliases for the H.323 endpoint to respond to.
   */
 int h323_set_gk(int gatekeeper_discover, char *gatekeeper, char *secret)
 {
 	PString gkName = PString(gatekeeper);
-	PString pass   = PString(secret);
+	PString pass = PString(secret);
 	H323TransportUDP *rasChannel;
 
 	if (!h323_end_point_exist()) {
@@ -1041,36 +1042,32 @@
 		cout << "Error: Gatekeeper cannot be NULL" << endl;
 		return 1;
 	}
-
 	if (strlen(secret)) {
 		endPoint->SetGatekeeperPassword(pass);
 	}
-
 	if (gatekeeper_discover) {
 		/* discover the gk using multicast */
 		if (endPoint->DiscoverGatekeeper(new H323TransportUDP(*endPoint))) {
-			cout << "  == Using " << (endPoint->GetGatekeeper())->GetName() << " as our Gatekeeper." << endl;
+			cout << "== Using " << (endPoint->GetGatekeeper())->GetName() << " as our Gatekeeper." << endl;
 		} else {
-			cout << "  *** Could not find a gatekeeper." << endl;
+			cout << "Warning: Could not find a gatekeeper." << endl;
 			return 1;
 		}	
 	} else {
 		rasChannel = new H323TransportUDP(*endPoint);
 
 		if (!rasChannel) {
-			cout << "  *** No RAS Channel, this is bad" << endl;
+			cout << "Error: No RAS Channel, this is bad" << endl;
 			return 1;
 		}
 		if (endPoint->SetGatekeeper(gkName, rasChannel)) {
-			cout << "  == Using " << (endPoint->GetGatekeeper())->GetName() << " as our Gatekeeper." << endl;
+			cout << "== Using " << (endPoint->GetGatekeeper())->GetName() << " as our Gatekeeper." << endl;
 		} else {
-			cout << "  *** Error registering with gatekeeper \"" << gkName << "\". " << endl;
-			
+			cout << "Error registering with gatekeeper \"" << gkName << "\". " << endl;
 			/* XXX Maybe we should fire a new thread to attempt to re-register later and not kill asterisk here? */
 			return 1;
 		}
 	}
-	
 	return 0;
 }
 
@@ -1083,7 +1080,6 @@
 		cout << "ERROR: [h323_send_tone] No Endpoint, this is bad!" << endl;
 		return;
 	}
-
 	PString token = PString(call_token);
 	endPoint->SendUserTone(token, tone);
 }
@@ -1109,7 +1105,6 @@
 	if (!h323_end_point_exist()) {
 		return 1;
 	}
-
         endPoint->ClearCall(PString(call_token));
 	return 0;
 };
@@ -1120,19 +1115,16 @@
         const PString currentToken(token);
         H323Connection * connection;
 
+        if (h323debug) {
+        	cout << "\tSending alerting\n" << endl;
+        }
         connection = endPoint->FindConnectionWithLock(currentToken);
-
-        if (h323debug)
-        	ast_verbose("\tSending alerting\n");
-        
         if (!connection) {
                 cout << "No connection found for " << token << endl;
                 return -1;
         }
-
         connection->AnsweringCall(H323Connection::AnswerCallPending);
         connection->Unlock();
-
         return 0; 
 
 }
@@ -1144,15 +1136,12 @@
         H323Connection * connection;
 
         connection = endPoint->FindConnectionWithLock(currentToken);
-
         if (!connection) {
                 cout << "No connection found for " << token << endl;
                 return -1;
         }
-
         connection->AnsweringCall(H323Connection::AnswerCallDeferredWithMedia);
         connection->Unlock();
-
         return 0;  
 }
 
@@ -1165,25 +1154,25 @@
 	
 	connection = endPoint->FindConnectionWithLock(currentToken);
 	
-	if (connection == NULL) {
+	if (!connection) {
 		cout << "No connection found for " << token << endl;
 		return -1;
 	}
-
 	if (!busy) {
-		if (h323debug)
-			ast_verbose("\tanswering call\n");
+		if (h323debug) {
+			cout << "\tAnswering call " << token << endl;
+		}
 		connection->AnsweringCall(H323Connection::AnswerCallNow);
 	} else {
-		if (h323debug)
-			ast_verbose("\tdenying call\n");
+		if (h323debug) {
+			cout << "\tdenying call " << token << endl;
+		}
 		connection->AnsweringCall(H323Connection::AnswerCallDenied);
 	}
 	connection->Unlock();
 	return 0;
 }
 
-
 int h323_show_codec(int fd, int argc, char *argv[])
 {
 	cout <<  "Allowed Codecs:\n\t" << setprecision(2) << endPoint->GetCapabilities() << endl;
@@ -1205,7 +1194,7 @@
 	H323Channel *channel;
 	MyH323Connection *connection = (MyH323Connection *)endPoint->FindConnectionWithLock(token);
 	
-	if (!connection){
+	if (!connection) {
 		cout << "ERROR: No connection found, this is bad\n";
 		return;
 	}

Index: ast_h323.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/ast_h323.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- ast_h323.h	10 Oct 2004 12:20:01 -0000	1.27
+++ ast_h323.h	23 Oct 2004 02:43:41 -0000	1.28
@@ -30,8 +30,7 @@
 #define AST_H323_H
 
 /**  These need to be redefined here because the C++
-	 side of this driver is blind to the asterisk headers */
-	
+	 side of this driver is blind to the asterisk headers */	
 /*! G.723.1 compression */
 #define AST_FORMAT_G723_1	(1 << 0)
 /*! GSM compression */
@@ -61,31 +60,16 @@
 {
     PCLASSINFO(H323_G7231Capability, H323AudioCapability);
   public:
-    H323_G7231Capability(
-      BOOL annexA = TRUE  /// Enable Annex A silence insertion descriptors
-    );
-    Comparison Compare(const PObject & obj) const;
-
-    PObject * Clone() const;
-  
-	virtual H323Codec * CreateCodec(
-      H323Codec::Direction direction  /// Direction in which this instance runs
-    ) const;
-
+    	H323_G7231Capability(BOOL annexA = TRUE);
+    	Comparison Compare(const PObject & obj) const;
+   	PObject * Clone() const;
+  	virtual H323Codec * CreateCodec(H323Codec::Direction direction) const;
 	unsigned GetSubType() const;
-    PString GetFormatName() const;
-    BOOL OnSendingPDU(
-      H245_AudioCapability & pdu,  /// PDU to set information on
-      unsigned packetSize          /// Packet size to use in capability
-    ) const;
-
-    BOOL OnReceivedPDU(
-      const H245_AudioCapability & pdu,  /// PDU to get information from
-      unsigned & packetSize              /// Packet size to use in capability
-    );
-  
+	PString GetFormatName() const;
+    	BOOL OnSendingPDU(H245_AudioCapability & pdu, unsigned packetSize) const;
+	BOOL OnReceivedPDU(const H245_AudioCapability & pdu, unsigned & packetSize);
   protected:
-    BOOL annexA;
+    	BOOL annexA;
 };
 
 /**This class describes the (fake) G729 codec capability.
@@ -95,100 +79,56 @@
   PCLASSINFO(AST_G729Capability, H323AudioCapability);
 
   public:
-  /**@name Construction */
-  //@{
-    /**Create a new G.729 capability.
-     */
     AST_G729Capability();
-  //@}
-
-  /**@name Overrides from class PObject */
-  //@{
-    /**Create a copy of the object.
-      */
+    /* Create a copy of the object. */
     virtual PObject * Clone() const;
-  //@}
 
-  /**@name Operations */
-  //@{
-    /**Create the codec instance, allocating resources as required.
-     */
-    virtual H323Codec * CreateCodec(
-      H323Codec::Direction direction  /// Direction in which this instance runs
-    ) const;
-  //@}
+    /* Create the codec instance, allocating resources as required. */
+    virtual H323Codec * CreateCodec(H323Codec::Direction direction) const;
 
-  /**@name Identification functions */
-  //@{
-    /**Get the sub-type of the capability. This is a code dependent on the
+    /* Get the sub-type of the capability. This is a code dependent on the
        main type of the capability.
 
        This returns one of the four possible combinations of mode and speed
-       using the enum values of the protocol ASN H245_AudioCapability class.
-     */
+       using the enum values of the protocol ASN H245_AudioCapability class. */
     virtual unsigned GetSubType() const;
 
-    /**Get the name of the media data format this class represents.
-     */
+    /* Get the name of the media data format this class represents. */
     virtual PString GetFormatName() const;
-  //@}
-};
 
+};
 
-/**This class describes the VoiceAge G729A codec capability.
- */
+/* This class describes the VoiceAge G729A codec capability. */
 class AST_G729ACapability : public H323AudioCapability
 {
   PCLASSINFO(AST_G729ACapability, H323AudioCapability);
 
   public:
-  /**@name Construction */
-  //@{
-    /**Create a new G.729A capability.
-     */
+    /* Create a new G.729A capability. */
     AST_G729ACapability();
-  //@}
 
-  /**@name Overrides from class PObject */
-  //@{
-    /**Create a copy of the object.
-      */
+    /* Create a copy of the object. */
     virtual PObject * Clone() const;
-  //@}
-
-  /**@name Operations */
-  //@{
-    /**Create the codec instance, allocating resources as required.
-     */
-    virtual H323Codec * CreateCodec(
-      H323Codec::Direction direction  /// Direction in which this instance runs
-    ) const;
-  //@}
+    /* Create the codec instance, allocating resources as required. */
+    virtual H323Codec * CreateCodec(H323Codec::Direction direction) const;
 
-  /**@name Identification functions */
-  //@{
-    /**Get the sub-type of the capability. This is a code dependent on the
+    /* Get the sub-type of the capability. This is a code dependent on the
        main type of the capability.
 
        This returns one of the four possible combinations of mode and speed
-       using the enum values of the protocol ASN H245_AudioCapability class.
-     */
+       using the enum values of the protocol ASN H245_AudioCapability class. */
     virtual unsigned GetSubType() const;
 
-    /**Get the name of the media data format this class represents.
-     */
+    /* Get the name of the media data format this class represents. */
     virtual PString GetFormatName() const;
-  //@}
 };
 
-
 class MyH323EndPoint : public H323EndPoint {
 
 	PCLASSINFO(MyH323EndPoint, H323EndPoint);
 
 	public:
-
-	int MakeCall(const PString &, PString &, unsigned int *, unsigned int, char *, char *s);
+	int MakeCall(const PString &, PString &, unsigned int *, unsigned int, char *, char *);
 	BOOL ClearCall(const PString &);
 
 	void OnClosedLogicalChannel(H323Connection &, const H323Channel &);
@@ -198,13 +138,10 @@
 	void SendUserTone(const PString &, char);
 	H323Capabilities GetCapabilities(void);
 	BOOL OnConnectionForwarded(H323Connection &, const PString &, const H323SignalPDU &);
- 
 	BOOL ForwardConnection(H323Connection &, const PString &, const H323SignalPDU &);
-
-	PStringArray SupportedPrefixes;	
-	
     	void SetEndpointTypeInfo( H225_EndpointType & info ) const;
     	void SetGateway(void);
+	PStringArray SupportedPrefixes;	
 };
 
 class MyH323Connection : public H323Connection {
@@ -214,13 +151,14 @@
 	public:
 	MyH323Connection(MyH323EndPoint &, unsigned, unsigned);
 	~MyH323Connection();
-
 	H323Channel * CreateRealTimeLogicalChannel(const H323Capability &, 
 						   H323Channel::Directions, 
 					 	   unsigned, 
 						   const H245_H2250LogicalChannelParameters *,
 						   RTP_QOS *);
-	H323Connection::AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
+	H323Connection::AnswerCallResponse OnAnswerCall(const PString &, 
+							const H323SignalPDU &, 
+							H323SignalPDU &);
 	void OnReceivedReleaseComplete(const H323SignalPDU &);
 	BOOL OnAlerting(const H323SignalPDU &, const PString &);
 	BOOL OnSendReleaseComplete(H323SignalPDU &);
@@ -253,7 +191,6 @@
       		Directions direction,              
       		unsigned sessionID);
 
-	/* Destructor */
 	~MyH323_ExternalRTPChannel();
 	
 	/* Overrides */
@@ -270,7 +207,7 @@
 
 /**
  * The MyProcess is a necessary descendant PProcess class so that the H323EndPoint 
- * objected to be created from within that class. (Who owns main() problem). 
+ * objected to be created from within that class. (Solves the who owns main() problem). 
  */
 class MyProcess : public PProcess {
 

Index: chan_h323.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/chan_h323.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- chan_h323.h	22 Oct 2004 19:04:02 -0000	1.31
+++ chan_h323.h	23 Oct 2004 02:43:41 -0000	1.32
@@ -134,21 +134,23 @@
 typedef int (*setup_outbound_cb)(call_details_t);
 extern setup_outbound_cb on_outgoing_call; 
 
-/* This is a callback prototype function, called when openh323
+/* This is a callback prototype function, called when
    OnAlerting is invoked */
 typedef void (*chan_ringing_cb)(unsigned, const char *);
 extern chan_ringing_cb on_chan_ringing;
 
-/* This is a callback protoype function, called when the openh323
+/* This is a callback protoype function, called when
    OnConnectionEstablished is inovked */
 typedef void (*con_established_cb)(unsigned, const char *);
 extern con_established_cb on_connection_established;
 
-/* This is a callback prototype function, called when the openH323
+/* This is a callback prototype function, called when
    OnConnectionCleared callback is invoked */
 typedef void (*clear_con_cb)(call_details_t);
 extern clear_con_cb on_connection_cleared;
 
+/* This is a callback prototype function, called when
+    an H.323 call is answered */
 typedef int (*answer_call_cb)(unsigned, const char *);
 extern answer_call_cb on_answer_call;
 
@@ -179,12 +181,9 @@
 				    con_established_cb,
  				    send_digit_cb,
  				    answer_call_cb);
-
-
 	int h323_set_capability(int, int);
 	int h323_set_alias(struct oh323_alias *);
 	int h323_set_gk(int, char *, char *);
-
 	void h323_set_id(char *);
 	void h323_show_tokens(void);
 
@@ -203,12 +202,10 @@
 	/* H.323 alerting and progress */
 	int h323_send_alerting(const char *token);
 	int h323_send_progress(const char *token);
-
 	int h323_answering_call(const char *token, int);
 	int h323_soft_hangup(const char *data);	
 	int h323_show_codec(int fd, int argc, char *argv[]);
 
-
 #ifdef __cplusplus
 }
 #endif




More information about the svn-commits mailing list