[Asterisk-cvs] asterisk/channels/h323 ast_h323.h,1.20,1.21 chan_h323.h,1.19,1.20 ast_h323.cpp,1.45,1.46
jeremy at lists.digium.com
jeremy at lists.digium.com
Thu May 20 02:52:47 CDT 2004
Update of /usr/cvsroot/asterisk/channels/h323
In directory mongoose.digium.com:/tmp/cvs-serv3451
Modified Files:
ast_h323.h chan_h323.h ast_h323.cpp
Log Message:
properly send call progress and alerting PDUs, re-fix one-way audio on call manager, and hopefully add call progress (N+101) support (not tested)
Index: ast_h323.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/ast_h323.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- ast_h323.h 20 Mar 2004 14:29:36 -0000 1.20
+++ ast_h323.h 20 May 2004 07:05:26 -0000 1.21
@@ -198,7 +198,7 @@
public:
- int MakeCall(const PString &, PString &, unsigned int *, unsigned int, char *);
+ int MakeCall(const PString &, PString &, unsigned int *, unsigned int, char *, char *s);
BOOL ClearCall(const PString &);
void OnClosedLogicalChannel(H323Connection &, const H323Channel &);
@@ -225,8 +225,10 @@
MyH323Connection(MyH323EndPoint &, unsigned, unsigned);
~MyH323Connection();
- H323Channel * CreateRealTimeLogicalChannel(const H323Capability &, H323Channel::Directions, unsigned,
- const H245_H2250LogicalChannelParameters *);
+ H323Channel * CreateRealTimeLogicalChannel(const H323Capability &,
+ H323Channel::Directions,
+ unsigned,
+ const H245_H2250LogicalChannelParameters *);
H323Connection::AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
void OnReceivedReleaseComplete(const H323SignalPDU &);
BOOL OnAlerting(const H323SignalPDU &, const PString &);
@@ -245,33 +247,53 @@
PString sourceE164;
PString destE164;
- PIPSocket::Address externalIpAddress; // IP address of media server
- PIPSocket::Address remoteIpAddress; // IP Address of remote endpoint
- WORD externalPort; // local media server Data port (control is dataPort+1)
- WORD remotePort; // remote endpoint Data port (control is dataPort+1)
- WORD sessionId;
- BOOL bridging; // Used to help determine which IP to use
+ PIPSocket::Address externalIpAddress;
+ PIPSocket::Address remoteIpAddress;
+ WORD externalPort;
+ WORD remotePort;
+ WORD sessionId;
+ BOOL bridging;
};
class MyH323_ExternalRTPChannel : public H323_ExternalRTPChannel {
- PCLASSINFO(MyH323_ExternalRTPChannel, H323_ExternalRTPChannel);
+ PCLASSINFO(MyH323_ExternalRTPChannel, H323_ExternalRTPChannel);
- public:
+ public:
+ MyH323_ExternalRTPChannel(
+ MyH323Connection & connection,
+ const H323Capability & capability,
+ Directions direction,
+ unsigned sessionID);
- MyH323_ExternalRTPChannel(MyH323Connection &, const H323Capability &, Directions,
- unsigned, const PIPSocket::Address &, WORD);
+ 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 OnReceivedPDU(
- const H245_H2250LogicalChannelParameters & param, /// Acknowledgement PDU
- unsigned & errorCode /// Error on failure
- );
-
- BOOL OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param);
+
+ BOOL OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param);
-};
+ PIPSocket::Address externalIpAddress;
+ PIPSocket::Address remoteIpAddress;
+ WORD externalPort;
+ WORD remotePort;
+};
/**
* The MyProcess is a necessary descendant PProcess class so that the H323EndPoint
Index: chan_h323.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/chan_h323.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- chan_h323.h 4 Mar 2004 01:57:32 -0000 1.19
+++ chan_h323.h 20 May 2004 07:05:26 -0000 1.20
@@ -85,10 +85,11 @@
PBX application and passed through make_call
function*/
typedef struct call_options {
- char *callerid;
- int noFastStart;
- int noH245Tunnelling;
- int noSilenceSuppression;
+ char *callerid;
+ char *callername;
+ int noFastStart;
+ int noH245Tunnelling;
+ int noSilenceSuppression;
unsigned int port;
} call_options_t;
@@ -101,6 +102,7 @@
const char *call_token;
const char *call_source_aliases;
const char *call_dest_alias;
+ const char *call_source_name;
const char *call_source_e164;
const char *call_dest_e164;
const char *sourceIp;
@@ -136,6 +138,11 @@
typedef void (*start_logchan_cb)(unsigned int, const char *, int);
start_logchan_cb on_start_logical_channel;
+/* This is a callback prototype function, called when openh323
+ OnAlerting is invoked */
+typedef void (*chan_ringing_cb)(unsigned);
+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);
@@ -164,13 +171,14 @@
void h323_debug(int, unsigned);
/* callback function handler*/
- void h323_callback_register(setup_incoming_cb,
- setup_outbound_cb,
- on_connection_cb,
- start_logchan_cb,
- clear_con_cb,
- con_established_cb,
- send_digit_cb);
+ void h323_callback_register(setup_incoming_cb,
+ setup_outbound_cb,
+ on_connection_cb,
+ start_logchan_cb,
+ clear_con_cb,
+ chan_ringing_cb,
+ con_established_cb,
+ send_digit_cb);
int h323_set_capability(int, int);
@@ -191,9 +199,13 @@
/* H323 create and destroy sessions */
int h323_make_call(char *host, call_details_t *cd, call_options_t);
int h323_clear_call(const char *);
+
+ /* 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_soft_hangup(const char *data);
int h323_show_codec(int fd, int argc, char *argv[]);
Index: ast_h323.cpp
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/ast_h323.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- ast_h323.cpp 18 May 2004 10:32:34 -0000 1.45
+++ ast_h323.cpp 20 May 2004 07:05:26 -0000 1.46
@@ -218,8 +218,7 @@
* transport = ip.
* port = 1720.
*/
-int MyH323EndPoint::MakeCall(const PString & dest, PString & token,
- unsigned int *callReference, unsigned int port, char *callerid)
+int MyH323EndPoint::MakeCall(const PString & dest, PString & token, unsigned int *callReference, unsigned int port, char *callerid, char *callername)
{
PString fullAddress;
MyH323Connection * connection;
@@ -245,6 +244,15 @@
if (callerid)
connection->SetLocalPartyName(PString(callerid));
+ if (callername) {
+ localAliasNames.RemoveAll();
+ connection->SetLocalPartyName(PString(callername));
+ if (callerid)
+ localAliasNames.AppendString(PString(callerid));
+ } else if (callerid) {
+ localAliasNames.RemoveAll();
+ connection->SetLocalPartyName(PString(callerid));
+ }
connection->Unlock();
@@ -486,7 +494,7 @@
{
/* The call will be answered later with "AnsweringCall()" function.
*/
- return H323Connection::AnswerCallAlertWithMedia;
+ return H323Connection::AnswerCallDeferred;
}
BOOL MyH323Connection::OnAlerting(const H323SignalPDU & /*alertingPDU*/, const PString & username)
@@ -495,6 +503,7 @@
if (h323debug) {
cout << " -- Ringing phone for \"" << username << "\"" << endl;
}
+ on_chan_ringing(GetCallReference());
return TRUE;
}
@@ -508,6 +517,7 @@
call_details_t cd;
PString sourceE164;
PString destE164;
+ PString sourceName;
PString sourceAliases;
PString destAliases;
PIPSocket::Address Ip;
@@ -519,6 +529,8 @@
sourceE164 = "";
setupPDU.GetSourceE164(sourceE164);
+ sourceName = "";
+ sourceName=setupPDU.GetQ931().GetDisplayName();
destE164 = "";
setupPDU.GetDestinationE164(destE164);
@@ -540,6 +552,7 @@
cd.call_dest_alias = (const char *)destAliases;
cd.call_source_e164 = (const char *)sourceE164;
cd.call_dest_e164 = (const char *)destE164;
+ cd.call_source_name = (const char *)sourceName;
GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort);
cd.sourceIp = (const char *)Ip.AsString();
@@ -727,11 +740,11 @@
/* MyH323_ExternalRTPChannel */
MyH323_ExternalRTPChannel::MyH323_ExternalRTPChannel(MyH323Connection & connection,
- const H323Capability & capability,
- Directions direction,
- unsigned sessionID,
- const PIPSocket::Address & ip,
- WORD dataPort)
+ const H323Capability & capability,
+ Directions direction,
+ unsigned sessionID,
+ const PIPSocket::Address & ip,
+ WORD dataPort)
: H323_ExternalRTPChannel(connection, capability, direction, sessionID, ip, dataPort)
{
if (h323debug) {
@@ -740,6 +753,24 @@
return;
}
+MyH323_ExternalRTPChannel::MyH323_ExternalRTPChannel(MyH323Connection & connection,
+ const H323Capability & capability,
+ Directions direction,
+ unsigned id)
+ : H323_ExternalRTPChannel::H323_ExternalRTPChannel(connection, capability, direction, id)
+{
+}
+
+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)
+{
+}
+
MyH323_ExternalRTPChannel::~MyH323_ExternalRTPChannel()
{
if (h323debug) {
@@ -748,29 +779,17 @@
return;
}
-BOOL MyH323_ExternalRTPChannel::OnReceivedPDU(
- const H245_H2250LogicalChannelParameters & param,
- unsigned & errorCode)
-{
- if (h323debug) {
- cout << " MyH323_ExternalRTPChannel::OnReceivedPDU " << endl;
- }
- return H323_ExternalRTPChannel::OnReceivedPDU( param, errorCode );
-}
-
-BOOL MyH323_ExternalRTPChannel::OnReceivedAckPDU(
- const H245_H2250LogicalChannelAckParameters & param)
+BOOL MyH323_ExternalRTPChannel::OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param)
{
-
- PIPSocket::Address remoteIpAddress; // IP Address of remote endpoint
- WORD remotePort; // remote endpoint Data port (control is dataPort+1)
+ PIPSocket::Address remoteIpAddress;
+ WORD remotePort;
if (h323debug) {
cout << " MyH323_ExternalRTPChannel::OnReceivedAckPDU " << endl;
}
- if (H323_ExternalRTPChannel::OnReceivedAckPDU( param )) {
- GetRemoteAddress(remoteIpAddress, remotePort);
+ if (H323_ExternalRTPChannel::OnReceivedAckPDU(param)) {
+ H323_ExternalRTPChannel::GetRemoteAddress(remoteIpAddress, remotePort);
if (h323debug) {
cout << " -- remoteIpAddress: " << remoteIpAddress << endl;
cout << " -- remotePort: " << remotePort << endl;
@@ -838,7 +857,8 @@
on_connection_cb confunc,
start_logchan_cb lfunc,
clear_con_cb clfunc,
- con_established_cb efunc,
+ chan_ringing_cb rfunc,
+ con_established_cb efunc,
send_digit_cb dfunc)
{
on_incoming_call = ifunc;
@@ -846,6 +866,7 @@
on_create_connection = confunc;
on_start_logical_channel = lfunc;
on_connection_cleared = clfunc;
+ on_chan_ringing = rfunc;
on_connection_established = efunc;
on_send_digit = dfunc;
}
@@ -1085,7 +1106,7 @@
PString dest(host);
- res = endPoint->MakeCall(dest, token, &cd->call_reference, call_options.port, call_options.callerid);
+ res = endPoint->MakeCall(dest, token, &cd->call_reference, call_options.port, call_options.callerid, call_options.callername);
memcpy((char *)(cd->call_token), (const unsigned char *)token, token.GetLength());
return res;
@@ -1101,6 +1122,45 @@
return 0;
};
+/* Send Alerting PDU to H.323 caller */
+int h323_send_alerting(const char *token)
+{
+ const PString currentToken(token);
+ H323Connection * connection;
+
+ connection = endPoint->FindConnectionWithLock(currentToken);
+
+ if (!connection) {
+ cout << "No connection found for " << token << endl;
+ return -1;
+ }
+
+ connection->AnsweringCall(H323Connection::AnswerCallPending);
+ connection->Unlock();
+
+ return 0;
+
+}
+
+/* Send Progress PDU to H.323 caller */
+int h323_send_progress(const char *token)
+{
+ const PString currentToken(token);
+ 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;
+}
+
/** This function tells the h.323 stack to either
answer or deny an incoming call */
int h323_answering_call(const char *token, int busy)
More information about the svn-commits
mailing list