[Asterisk-cvs] asterisk/channels/h323 Makefile, 1.18,
1.19 ast_h323.cpp, 1.61, 1.62 ast_h323.h, 1.26,
1.27 chan_h323.h, 1.29, 1.30
jeremy at lists.digium.com
jeremy at lists.digium.com
Sun Oct 10 08:19:13 CDT 2004
Update of /usr/cvsroot/asterisk/channels/h323
In directory mongoose.digium.com:/tmp/cvs-serv17127/h323
Modified Files:
Makefile ast_h323.cpp ast_h323.h chan_h323.h
Log Message:
finish implementing type=peer, implement setting of FastStart and H.245 Tunneling per user/peer, update External RTP implemenation, fixed compile process/other buglets to operate with Open H.323 v1.14.4 and PWLib v1.7.5, and massive code clean up. All of the above is untested, please test and report
Index: Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/Makefile,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- Makefile 30 Sep 2004 19:30:49 -0000 1.18
+++ Makefile 10 Oct 2004 12:20:01 -0000 1.19
@@ -35,8 +35,6 @@
#
# Only change below if you know WTF your doing
#
-#
-# Janus release directives, comment below if your brave enough for Janus
OSARCH=$(shell uname -s)
CFLAGS += -DNDEBUG -DDO_CRASH -DDEBUG_THREADS
CFLAGS += -pipe -Wall -fPIC -Wmissing-prototypes -Wmissing-declarations
@@ -45,25 +43,6 @@
CFLAGS += -I$(PWLIBDIR)/include
CFLAGS += -I$(OPENH323DIR)/include -Wno-missing-prototypes -Wno-missing-declarations
-# Pre Janus release directives
-#CFLAGS += -DNDEBUG -DDO_CRASH -DDEBUG_THREADS
-#CFLAGS += -pipe -Wall -fPIC
-#ifeq (${OSARCH},Linux)
-#CFLAGS += -DP_LINUX
-#LIBS+=-lpthread
-#endif
-#ifeq ($(findstring BSD,${OSARCH}),BSD)
-#CFLAGS += -pthread
-#endif
-#CFLAGS += -D_REENTRANT -D_GNU_SOURCE
-#CFLAGS += -DP_HAS_SEMAPHORES -DP_SSL -DP_PTHREADS
-#CFLAGS += -DPHAS_TEMPLATES -DPTRACING -DP_USE_PRAGMA
-#CFLAGS += -I../../include
-#CFLAGS += -I$(PWLIBDIR)/include/ptlib/unix -I$(PWLIBDIR)/include
-#CFLAGS += -I$(OPENH323DIR)/include
-#CFLAGS += -Wno-missing-prototypes -Wno-missing-declarations
-#LIBS+= -lcrypto -lssl -lexpat
-
all: libchanh323.a
samples:
@@ -76,10 +55,6 @@
ast_h323.o: ast_h323.cpp
$(CXX) -g -c -o $@ $(CFLAGS) $<
-#ast_h323.o: ast_h323.cpp
-# $(CXX) -g -c -fno-rtti -o $@ $(CFLAGS) $<
-
-
libchanh323.a: ast_h323.o
ar cr libchanh323.a ast_h323.o
Index: ast_h323.cpp
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/ast_h323.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- ast_h323.cpp 4 Oct 2004 10:18:06 -0000 1.61
+++ ast_h323.cpp 10 Oct 2004 12:20:01 -0000 1.62
@@ -70,7 +70,6 @@
/** PWLib entry point */
MyProcess *localProcess = NULL;
-
MyProcess::MyProcess(): PProcess("The NuFone Network's", "H.323 Channel Driver for Asterisk",
MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER)
{
@@ -84,11 +83,11 @@
PTrace::Initialise(0, NULL, PTrace::Timestamp | PTrace::Thread | PTrace::FileAndLine);
}
-#define H323_NAME OPAL_G7231_6k3"{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_NAME);
+H323_REGISTER_CAPABILITY(H323_G7231Capability, H323_G7231);
H323_REGISTER_CAPABILITY(AST_G729Capability, H323_G729);
H323_REGISTER_CAPABILITY(AST_G729ACapability, H323_G729A);
@@ -117,19 +116,16 @@
return new H323_G7231Capability(*this);
}
-
PString H323_G7231Capability::GetFormatName() const
{
- return H323_NAME;
+ return H323_G7231;
}
-
unsigned H323_G7231Capability::GetSubType() const
{
return H245_AudioCapability::e_g7231;
}
-
BOOL H323_G7231Capability::OnSendingPDU(H245_AudioCapability & cap,
unsigned packetSize) const
{
@@ -142,7 +138,6 @@
return TRUE;
}
-
BOOL H323_G7231Capability::OnReceivedPDU(const H245_AudioCapability & cap,
unsigned & packetSize)
{
@@ -156,13 +151,11 @@
return TRUE;
}
-
H323Codec * H323_G7231Capability::CreateCodec(H323Codec::Direction direction) const
{
return NULL;
}
-
/////////////////////////////////////////////////////////////////////////////
AST_G729Capability::AST_G729Capability()
@@ -170,29 +163,26 @@
{
}
-
PObject * AST_G729Capability::Clone() const
{
return new AST_G729Capability(*this);
}
-
unsigned AST_G729Capability::GetSubType() const
{
return H245_AudioCapability::e_g729;
}
-
PString AST_G729Capability::GetFormatName() const
{
return H323_G729;
}
-
H323Codec * AST_G729Capability::CreateCodec(H323Codec::Direction direction) const
{
return NULL;
}
+
/////////////////////////////////////////////////////////////////////////////
AST_G729ACapability::AST_G729ACapability()
@@ -200,25 +190,21 @@
{
}
-
PObject * AST_G729ACapability::Clone() const
{
return new AST_G729ACapability(*this);
}
-
unsigned AST_G729ACapability::GetSubType() const
{
return H245_AudioCapability::e_g729AnnexA;
}
-
PString AST_G729ACapability::GetFormatName() const
{
return H323_G729A;
}
-
H323Codec * AST_G729ACapability::CreateCodec(H323Codec::Direction direction) const
{
return NULL;
@@ -269,8 +255,6 @@
localAliasNames.RemoveAll();
connection->SetLocalPartyName(PString(callerid));
}
- connection->AST_Outgoing = TRUE;
-
if (h323debug) {
cout << " -- " << GetLocalUserName() << " is calling host " << fullAddress << endl;
cout << " -- " << "Call token is " << (const char *)token << endl;
@@ -475,12 +459,12 @@
unsigned options = 0;
call_options_t *opts = (call_options_t *)o;
- if (opts->noFastStart) {
+ if (opts && opts->noFastStart) {
options |= H323Connection::FastStartOptionDisable;
} else {
options |= H323Connection::FastStartOptionEnable;
}
- if (opts->noH245Tunneling) {
+ if (opts && opts->noH245Tunneling) {
options |= H323Connection::H245TunnelingOptionDisable;
} else {
options |= H323Connection::H245TunnelingOptionEnable;
@@ -503,8 +487,6 @@
if (h323debug) {
cout << " == New H.323 Connection created." << endl;
}
- AST_RTP_Connected = FALSE;
- AST_Outgoing = FALSE;
return;
}
@@ -534,43 +516,13 @@
BOOL MyH323Connection::OnAlerting(const H323SignalPDU & /*alertingPDU*/, const PString & username)
{
- PIPSocket::Address remoteIpAddress;
- WORD remotePort;
- H323_ExternalRTPChannel * channel;
-
- if (h323debug)
+ if (h323debug) {
cout << "\t =-= In OnAlerting for call " << GetCallReference()
<< ": sessionId=" << sessionId << endl;
-
- /* Connect RTP if logical channel has already been opened */
- if (Lock()) {
- if ( (channel = (H323_ExternalRTPChannel*) FindChannel(sessionId,TRUE)) ) {
- channel->GetRemoteAddress(remoteIpAddress, remotePort);
- if (h323debug) {
- cout << "\t\t--- found logical channel. Connecting RTP" << endl;
- cout << "\t\tRTP channel id " << sessionId << " parameters:" << endl;
- cout << "\t\t-- remoteIpAddress: " << remoteIpAddress << endl;
- cout << "\t\t-- remotePort: " << remotePort << endl;
- cout << "\t\t-- ExternalIpAddress: " << externalIpAddress << endl;
- cout << "\t\t-- ExternalPort: " << externalPort << endl;
- }
- on_start_logical_channel(GetCallReference(),(const char *)remoteIpAddress.AsString(), remotePort,
- (const char *)GetCallToken() );
- AST_RTP_Connected=TRUE;
- } else
- if (h323debug)
- cout << "\t\t--- no logical channels" << endl;
-
- if (h323debug) {
- cout << " -- Ringing phone for \"" << username << "\"" << endl;
- }
-
- on_chan_ringing(GetCallReference(), (const char *)GetCallToken() );
- Unlock();
- return TRUE;
- }
- ast_log(LOG_ERROR,"chan_h323: OnAlerting: Could not obtain connection lock");
- return FALSE;
+ cout << " -- Ringing phone for \"" << username << "\"" << endl;
+ }
+ on_chan_ringing(GetCallReference(), (const char *)GetCallToken() );
+ return TRUE;
}
BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
@@ -753,31 +705,10 @@
H323Channel * MyH323Connection::CreateRealTimeLogicalChannel(const H323Capability & capability,
H323Channel::Directions dir,
unsigned sessionID,
- const H245_H2250LogicalChannelParameters * /*param*/)
+ const H245_H2250LogicalChannelParameters * /*param*/,
+ RTP_QOS * /*param*/ )
{
- struct rtp_info *info;
- WORD port;
-
- /* Determine the Local (A side) IP Address and port */
- info = on_create_connection(GetCallReference(), (const char *)GetCallToken());
-
- if (!info) {
- return NULL;
- }
-
- GetControlChannel().GetLocalAddress().GetIpAndPort(externalIpAddress, port);
- externalPort = info->port;
- sessionId = sessionID;
-
- if (h323debug) {
- cout << " =*= In CreateRealTimeLogicalChannel for call " << GetCallReference() << endl;
- cout << " -- externalIpAddress: " << externalIpAddress << endl;
- cout << " -- externalPort: " << externalPort << endl;
- cout << " -- SessionID: " << sessionID << endl;
- cout << " -- Direction: " << dir << endl;
- }
-
- return new MyH323_ExternalRTPChannel(*this, capability, dir, sessionID, externalIpAddress, externalPort);
+ return new MyH323_ExternalRTPChannel(*this, capability, dir, sessionID);
}
/** This callback function is invoked once upon creation of each
@@ -785,11 +716,8 @@
*/
BOOL MyH323Connection::OnStartLogicalChannel(H323Channel & channel)
{
- PIPSocket::Address remoteIpAddress;
- WORD remotePort;
-
if (h323debug) {
- cout << " -- Started logical channel: ";
+ cout << "\t-- Started logical channel: ";
cout << ((channel.GetDirection()==H323Channel::IsTransmitter)?"sending ":((channel.GetDirection()==H323Channel::IsReceiver)?"receiving ":" "));
cout << (const char *)(channel.GetCapability()).GetFormatName() << endl;
}
@@ -798,101 +726,72 @@
channelsOpen++;
if (h323debug) {
- cout << " -- channelsOpen = " << channelsOpen << endl;
+ cout << "\t\t-- channelsOpen = " << channelsOpen << endl;
}
- if (!Lock()) {
- ast_log(LOG_ERROR,"chan_h323: OnStartLogicalChannel: Could not obtain connection lock");
- return FALSE;
- }
- /* Connect RTP for incoming calls */
- if (!AST_Outgoing) {
- H323_ExternalRTPChannel & external = (H323_ExternalRTPChannel &)channel;
- external.GetRemoteAddress(remoteIpAddress, remotePort);
- if (h323debug) {
- cout << "\t\tRTP channel id " << sessionId << " parameters:" << endl;
- cout << "\t\t-- remoteIpAddress: " << remoteIpAddress << endl;
- cout << "\t\t-- remotePort: " << remotePort << endl;
- cout << "\t\t-- ExternalIpAddress: " << externalIpAddress << endl;
- cout << "\t\t-- ExternalPort: " << externalPort << endl;
- }
- /* Notify Asterisk of remote RTP information */
- on_start_logical_channel(GetCallReference(), (const char *)remoteIpAddress.AsString(), remotePort,
- (const char *)GetCallToken());
- AST_RTP_Connected = TRUE;
- }
- Unlock();
return TRUE;
}
/* MyH323_ExternalRTPChannel */
MyH323_ExternalRTPChannel::MyH323_ExternalRTPChannel(MyH323Connection & connection,
const H323Capability & capability,
- Directions direction,
- unsigned sessionID,
- const PIPSocket::Address & ip,
- WORD dataPort)
- : H323_ExternalRTPChannel(connection, capability, direction, sessionID, ip, dataPort)
-{
-}
-
-MyH323_ExternalRTPChannel::MyH323_ExternalRTPChannel(MyH323Connection & connection,
- const H323Capability & capability,
Directions direction,
unsigned id)
: H323_ExternalRTPChannel::H323_ExternalRTPChannel(connection, capability, direction, id)
{
-}
+ struct rtp_info *info;
-MyH323_ExternalRTPChannel::MyH323_ExternalRTPChannel(MyH323Connection & connection,
- const H323Capability & capability,
- Directions direction,
- unsigned id,
- const H323TransportAddress & data,
- const H323TransportAddress & control)
- : H323_ExternalRTPChannel::H323_ExternalRTPChannel(connection, capability, direction, id, data, control)
-{
+ /* Determine the Local (A side) IP Address and port */
+ info = on_external_rtp_create(connection.GetCallReference(), (const char *)connection.GetCallToken());
+ if (!info) {
+ cout << "\tERROR: on_external_rtp_create failure" << endl;
+ return;
+ } else {
+ localIpAddr = (PIPSocket::Address)info->addr;
+ localPort = (WORD)info->port;
+ /* tell the H.323 stack */
+ SetExternalAddress(H323TransportAddress(localIpAddr, localPort), H323TransportAddress(localIpAddr, localPort + 1));
+ /* clean up allocated memory */
+ free(info);
+ }
+
+ // Get the payload code
+ OpalMediaFormat format(capability.GetFormatName(), FALSE);
+ payloadCode = format.GetPayloadType();
}
-MyH323_ExternalRTPChannel::~MyH323_ExternalRTPChannel()
+MyH323_ExternalRTPChannel::~MyH323_ExternalRTPChannel()
{
+ if (h323debug) {
+ cout << "\tExternalRTPChannel Destroyed" << endl;
+ }
}
-BOOL MyH323_ExternalRTPChannel::OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param)
+BOOL MyH323_ExternalRTPChannel::Start(void)
{
- PIPSocket::Address remoteIpAddress;
- WORD remotePort;
- MyH323Connection* conn = (MyH323Connection*) &connection;
-
- if (h323debug)
- cout << "\t=-= In OnReceivedAckPDU for call " << connection.GetCallReference() << endl;
+ /* Call ancestor first */
+ if (!H323_ExternalRTPChannel::Start()) {
+ return FALSE;
+ }
- if (H323_ExternalRTPChannel::OnReceivedAckPDU(param)) {
- if (!connection.Lock()) {
- ast_log(LOG_ERROR,"chan_h323: OnReceivedAckPDU: Could not obtain connection lock");
- return FALSE;
- }
- /* if RTP hasn't been connected yet */
- if (!conn->AST_RTP_Connected) {
- H323_ExternalRTPChannel::GetRemoteAddress(remoteIpAddress, remotePort);
- if (h323debug) {
- cout << "\t\tRTP channel id " << sessionID << " parameters:" << endl;
- cout << "\t\t-- remoteIpAddress: " << remoteIpAddress << endl;
- cout << "\t\t-- remotePort: " << remotePort << endl;
- cout << "\t\t-- ExternalIpAddress: " << conn->externalIpAddress << endl;
- cout << "\t\t-- ExternalPort: " << conn->externalPort << endl;
- }
+ /* Collect the remote information */
+ GetRemoteAddress(remoteIpAddr, remotePort);
- /* Notify Asterisk of remote RTP information */
- on_start_logical_channel(connection.GetCallReference(), (const char *)remoteIpAddress.AsString(), remotePort,
- (const char *)conn->GetCallToken());
- conn->AST_RTP_Connected = TRUE;
- }
- connection.Unlock();
- return TRUE;
- }
- return FALSE;
+ if (h323debug) {
+ cout << "\t\tExternal RTP Session Starting" << endl;
+ cout << "\t\tRTP channel id " << sessionID << " parameters:" << endl;
+ cout << "\t\t-- remoteIpAddress: " << remoteIpAddr << endl;
+ cout << "\t\t-- remotePort: " << remotePort << endl;
+ cout << "\t\t-- ExternalIpAddress: " << localIpAddr << endl;
+ cout << "\t\t-- ExternalPort: " << localPort << endl;
+ }
+
+ /* Notify Asterisk of remote RTP information */
+ on_start_rtp_channel(connection.GetCallReference(), (const char *)remoteIpAddr.AsString(), remotePort,
+ (const char *)connection.GetCallToken());
+ return TRUE;
}
+
/** IMPLEMENTATION OF C FUNCTIONS */
/**
@@ -946,8 +845,8 @@
/** Installs the callback functions on behalf of the PBX application */
void h323_callback_register(setup_incoming_cb ifunc,
setup_outbound_cb sfunc,
- on_connection_cb confunc,
- start_logchan_cb lfunc,
+ on_rtp_cb rtpfunc,
+ start_rtp_cb lfunc,
clear_con_cb clfunc,
chan_ringing_cb rfunc,
con_established_cb efunc,
@@ -956,8 +855,8 @@
{
on_incoming_call = ifunc;
on_outgoing_call = sfunc;
- on_create_connection = confunc;
- on_start_logical_channel = lfunc;
+ on_external_rtp_create = rtpfunc;
+ on_start_rtp_channel = lfunc;
on_connection_cleared = clfunc;
on_chan_ringing = rfunc;
on_connection_established = efunc;
Index: ast_h323.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/ast_h323.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- ast_h323.h 21 Sep 2004 18:42:37 -0000 1.26
+++ ast_h323.h 10 Oct 2004 12:20:01 -0000 1.27
@@ -218,7 +218,8 @@
H323Channel * CreateRealTimeLogicalChannel(const H323Capability &,
H323Channel::Directions,
unsigned,
- const H245_H2250LogicalChannelParameters *);
+ const H245_H2250LogicalChannelParameters *,
+ RTP_QOS *);
H323Connection::AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
void OnReceivedReleaseComplete(const H323SignalPDU &);
BOOL OnAlerting(const H323SignalPDU &, const PString &);
@@ -237,12 +238,8 @@
PString sourceE164;
PString destE164;
- PIPSocket::Address externalIpAddress;
- WORD externalPort;
WORD sessionId;
BOOL bridging;
- BOOL AST_RTP_Connected;
- BOOL AST_Outgoing;
};
class MyH323_ExternalRTPChannel : public H323_ExternalRTPChannel {
@@ -251,35 +248,24 @@
public:
MyH323_ExternalRTPChannel(
- MyH323Connection & connection,
+ MyH323Connection & connection,
const H323Capability & capability,
Directions direction,
unsigned sessionID);
- MyH323_ExternalRTPChannel(
- MyH323Connection & connection,
- const H323Capability & capability,
- Directions direction,
- unsigned sessionID,
- const H323TransportAddress & data,
- const H323TransportAddress & control);
-
- /* Create a new channel. */
- MyH323_ExternalRTPChannel(
- MyH323Connection & connection,
- const H323Capability & capability,
- Directions direction,
- unsigned sessionID,
- const PIPSocket::Address & ip,
- WORD dataPort);
-
/* Destructor */
~MyH323_ExternalRTPChannel();
- BOOL OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param);
+ /* Overrides */
+ BOOL Start(void);
- PIPSocket::Address externalIpAddress;
- WORD externalPort;
+ protected:
+ BYTE payloadCode;
+
+ PIPSocket::Address localIpAddr;
+ PIPSocket::Address remoteIpAddr;
+ WORD localPort;
+ WORD remotePort;
};
/**
@@ -292,10 +278,7 @@
public:
MyProcess();
-
void Main();
-
-
};
#endif /* !defined AST_H323_H */
Index: chan_h323.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/chan_h323.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- chan_h323.h 4 Oct 2004 10:18:06 -0000 1.29
+++ chan_h323.h 10 Oct 2004 12:20:01 -0000 1.30
@@ -116,45 +116,45 @@
/* This is a callback prototype function, called pass
DTMF down the RTP. */
typedef int (*send_digit_cb)(unsigned, char, const char *);
-extern send_digit_cb on_send_digit;
+extern send_digit_cb on_send_digit;
/* This is a callback prototype function, called to collect
the external RTP port from Asterisk. */
-typedef rtp_info_t *(*on_connection_cb)(unsigned, const char *);
-extern on_connection_cb on_create_connection;
+typedef rtp_info_t *(*on_rtp_cb)(unsigned, const char *);
+extern on_rtp_cb on_external_rtp_create;
+
+/* This is a callback prototype function, called to send
+ the remote IP and RTP port from H.323 to Asterisk */
+typedef void (*start_rtp_cb)(unsigned int, const char *, int, const char *);
+extern start_rtp_cb on_start_rtp_channel;
/* This is a callback prototype function, called upon
an incoming call happens. */
typedef int (*setup_incoming_cb)(call_details_t);
-extern setup_incoming_cb on_incoming_call;
+extern setup_incoming_cb on_incoming_call;
/* This is a callback prototype function, called upon
an outbound call. */
typedef int (*setup_outbound_cb)(call_details_t);
-extern setup_outbound_cb on_outgoing_call;
-
-/* This is a callback prototype function, called when the openh323
- OnStartLogicalChannel is invoked. */
-typedef void (*start_logchan_cb)(unsigned int, const char *, int, const char *);
-extern start_logchan_cb on_start_logical_channel;
+extern setup_outbound_cb on_outgoing_call;
/* This is a callback prototype function, called when openh323
OnAlerting is invoked */
typedef void (*chan_ringing_cb)(unsigned, const char *);
-extern chan_ringing_cb on_chan_ringing;
+extern chan_ringing_cb on_chan_ringing;
/* This is a callback protoype function, called when the openh323
OnConnectionEstablished is inovked */
typedef void (*con_established_cb)(unsigned, const char *);
-extern con_established_cb on_connection_established;
+extern con_established_cb on_connection_established;
/* This is a callback prototype function, called when the openH323
OnConnectionCleared callback is invoked */
typedef void (*clear_con_cb)(call_details_t);
-extern clear_con_cb on_connection_cleared;
+extern clear_con_cb on_connection_cleared;
typedef int (*answer_call_cb)(unsigned, const char *);
-extern answer_call_cb on_answer_call;
+extern answer_call_cb on_answer_call;
/* debug flag */
extern int h323debug;
@@ -176,8 +176,8 @@
/* callback function handler*/
void h323_callback_register(setup_incoming_cb,
setup_outbound_cb,
- on_connection_cb,
- start_logchan_cb,
+ on_rtp_cb,
+ start_rtp_cb,
clear_con_cb,
chan_ringing_cb,
con_established_cb,
More information about the svn-commits
mailing list