mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 16:21:01 +00:00
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)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3023 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -393,7 +393,7 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
|
|||||||
int res;
|
int res;
|
||||||
struct oh323_pvt *p = c->pvt->pvt;
|
struct oh323_pvt *p = c->pvt->pvt;
|
||||||
char called_addr[256];
|
char called_addr[256];
|
||||||
char *tmp;
|
char *tmp, *cid, *cidname, oldcid[256];
|
||||||
|
|
||||||
strtok_r(dest, "/", &(tmp));
|
strtok_r(dest, "/", &(tmp));
|
||||||
|
|
||||||
@@ -424,13 +424,44 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
|
|||||||
|
|
||||||
/* Copy callerid, if there is any */
|
/* Copy callerid, if there is any */
|
||||||
if (c->callerid) {
|
if (c->callerid) {
|
||||||
char *tmp = strchr(c->callerid, '"');
|
memset(oldcid, 0, sizeof(oldcid));
|
||||||
if (!tmp) {
|
memcpy(oldcid, c->callerid, strlen(c->callerid));
|
||||||
p->calloptions.callerid = malloc(80); // evil
|
oldcid[sizeof(oldcid)-1] = '\0';
|
||||||
// sprintf(p->calloptions.callerid, "\"%s\"", c->callerid);
|
ast_callerid_parse(oldcid, &cidname, &cid);
|
||||||
sprintf(p->calloptions.callerid, "\"\" <%s>", c->callerid);
|
if (p->calloptions.callerid) {
|
||||||
|
free(p->calloptions.callerid);
|
||||||
|
p->calloptions.callerid = NULL;
|
||||||
|
}
|
||||||
|
if (p->calloptions.callername) {
|
||||||
|
free(p->calloptions.callername);
|
||||||
|
p->calloptions.callername = NULL;
|
||||||
|
}
|
||||||
|
p->calloptions.callerid = (char*)malloc(256);
|
||||||
|
if (p->calloptions.callerid == NULL) {
|
||||||
|
ast_log(LOG_ERROR, "Not enough memory.\n");
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
memset(p->calloptions.callerid, 0, 256);
|
||||||
|
if ((cid != NULL)&&(strlen(cid) > 0))
|
||||||
|
strncpy(p->calloptions.callerid, cid, 255);
|
||||||
|
|
||||||
|
p->calloptions.callername = (char*)malloc(256);
|
||||||
|
if (p->calloptions.callername == NULL) {
|
||||||
|
ast_log(LOG_ERROR, "Not enough memory.\n");
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
memset(p->calloptions.callername, 0, 256);
|
||||||
|
if ((cidname != NULL)&&(strlen(cidname) > 0))
|
||||||
|
strncpy(p->calloptions.callername, cidname, 255);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
p->calloptions.callerid = strdup(c->callerid);
|
if (p->calloptions.callerid) {
|
||||||
|
free(p->calloptions.callerid);
|
||||||
|
p->calloptions.callerid = NULL;
|
||||||
|
}
|
||||||
|
if (p->calloptions.callername) {
|
||||||
|
free(p->calloptions.callername);
|
||||||
|
p->calloptions.callername = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,12 +471,9 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
|
|||||||
ast_log(LOG_NOTICE, "h323_make_call failed(%s)\n", c->name);
|
ast_log(LOG_NOTICE, "h323_make_call failed(%s)\n", c->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_setstate(c, AST_STATE_RINGING);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int oh323_answer(struct ast_channel *c)
|
static int oh323_answer(struct ast_channel *c)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
@@ -597,24 +625,34 @@ static int oh323_indicate(struct ast_channel *c, int condition)
|
|||||||
|
|
||||||
switch(condition) {
|
switch(condition) {
|
||||||
case AST_CONTROL_RINGING:
|
case AST_CONTROL_RINGING:
|
||||||
if (c->_state == AST_STATE_RING) {
|
if (c->_state == AST_STATE_RING || c->_state == AST_STATE_RINGING) {
|
||||||
return -1;
|
h323_send_alerting(p->cd.call_token);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
|
case AST_CONTROL_PROGRESS:
|
||||||
|
if (c->_state != AST_STATE_UP) {
|
||||||
|
h323_send_progress(p->cd.call_token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
|
||||||
case AST_CONTROL_BUSY:
|
case AST_CONTROL_BUSY:
|
||||||
if (c->_state != AST_STATE_UP) {
|
if (c->_state != AST_STATE_UP) {
|
||||||
|
h323_answering_call(p->cd.call_token, 1);
|
||||||
p->alreadygone = 1;
|
p->alreadygone = 1;
|
||||||
ast_softhangup(c, AST_SOFTHANGUP_DEV);
|
ast_softhangup_nolock(c, AST_SOFTHANGUP_DEV);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
case AST_CONTROL_CONGESTION:
|
case AST_CONTROL_CONGESTION:
|
||||||
if (c->_state != AST_STATE_UP) {
|
if (c->_state != AST_STATE_UP) {
|
||||||
|
h323_answering_call(p->cd.call_token, 1);
|
||||||
p->alreadygone = 1;
|
p->alreadygone = 1;
|
||||||
ast_softhangup(c, AST_SOFTHANGUP_DEV);
|
ast_softhangup_nolock(c, AST_SOFTHANGUP_DEV);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
case -1:
|
case -1:
|
||||||
return -1;
|
return -1;
|
||||||
default:
|
default:
|
||||||
@@ -986,13 +1024,14 @@ int setup_incoming_call(call_details_t cd)
|
|||||||
p->cd.call_token = cd.call_token;
|
p->cd.call_token = cd.call_token;
|
||||||
p->cd.call_source_aliases = cd.call_source_aliases;
|
p->cd.call_source_aliases = cd.call_source_aliases;
|
||||||
p->cd.call_dest_alias = cd.call_dest_alias;
|
p->cd.call_dest_alias = cd.call_dest_alias;
|
||||||
|
p->cd.call_source_name = cd.call_source_name;
|
||||||
p->cd.call_source_e164 = cd.call_source_e164;
|
p->cd.call_source_e164 = cd.call_source_e164;
|
||||||
p->cd.call_dest_e164 = cd.call_dest_e164;
|
p->cd.call_dest_e164 = cd.call_dest_e164;
|
||||||
|
|
||||||
if (h323debug) {
|
if (h323debug) {
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Setting up Call\n");
|
ast_verbose(VERBOSE_PREFIX_3 "Setting up Call\n");
|
||||||
ast_verbose(VERBOSE_PREFIX_3 " Call token: [%s]\n", p->cd.call_token);
|
ast_verbose(VERBOSE_PREFIX_3 " Call token: [%s]\n", p->cd.call_token);
|
||||||
ast_verbose(VERBOSE_PREFIX_3 " Calling party name: [%s]\n", p->cd.call_source_aliases);
|
ast_verbose(VERBOSE_PREFIX_3 " Calling party name: [%s]\n", p->cd.call_source_name);
|
||||||
ast_verbose(VERBOSE_PREFIX_3 " Calling party number: [%s]\n", p->cd.call_source_e164);
|
ast_verbose(VERBOSE_PREFIX_3 " Calling party number: [%s]\n", p->cd.call_source_e164);
|
||||||
ast_verbose(VERBOSE_PREFIX_3 " Called party name: [%s]\n", p->cd.call_dest_alias);
|
ast_verbose(VERBOSE_PREFIX_3 " Called party name: [%s]\n", p->cd.call_dest_alias);
|
||||||
ast_verbose(VERBOSE_PREFIX_3 " Called party number: [%s]\n", p->cd.call_dest_e164);
|
ast_verbose(VERBOSE_PREFIX_3 " Called party number: [%s]\n", p->cd.call_dest_e164);
|
||||||
@@ -1014,17 +1053,14 @@ int setup_incoming_call(call_details_t cd)
|
|||||||
strncpy(p->exten, alias->name, sizeof(p->exten)-1);
|
strncpy(p->exten, alias->name, sizeof(p->exten)-1);
|
||||||
strncpy(p->context, alias->context, sizeof(p->context)-1);
|
strncpy(p->context, alias->context, sizeof(p->context)-1);
|
||||||
}
|
}
|
||||||
|
sprintf(p->callerid, "%s <%s>", p->cd.call_source_name, p->cd.call_source_e164);
|
||||||
|
|
||||||
sprintf(p->callerid, "%s <%s>", p->cd.call_source_aliases, p->cd.call_source_e164);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Either this call is not from the Gatekeeper
|
/* Either this call is not from the Gatekeeper
|
||||||
or we are not allowing gk routed calls */
|
or we are not allowing gk routed calls */
|
||||||
user = find_user(cd);
|
user = find_user(cd);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
sprintf(p->callerid, "%s <%s>", p->cd.call_source_aliases, p->cd.call_source_e164);
|
sprintf(p->callerid, "%s <%s>", p->cd.call_source_name, p->cd.call_source_e164);
|
||||||
if (!ast_strlen_zero(p->cd.call_dest_e164)) {
|
if (!ast_strlen_zero(p->cd.call_dest_e164)) {
|
||||||
strncpy(p->exten, cd.call_dest_e164, sizeof(p->exten)-1);
|
strncpy(p->exten, cd.call_dest_e164, sizeof(p->exten)-1);
|
||||||
} else {
|
} else {
|
||||||
@@ -1061,11 +1097,11 @@ int setup_incoming_call(call_details_t cd)
|
|||||||
p->bridge = user->bridge;
|
p->bridge = user->bridge;
|
||||||
p->nat = user->nat;
|
p->nat = user->nat;
|
||||||
|
|
||||||
if (!ast_strlen_zero(user->callerid))
|
if (!ast_strlen_zero(user->callerid)) {
|
||||||
strncpy(p->callerid, user->callerid, sizeof(p->callerid) - 1);
|
strncpy(p->callerid, user->callerid, sizeof(p->callerid) - 1);
|
||||||
else
|
} else {
|
||||||
sprintf(p->callerid, "%s <%s>", p->cd.call_source_aliases, p->cd.call_source_e164);
|
sprintf(p->callerid, "%s <%s>", p->cd.call_source_name, p->cd.call_source_e164);
|
||||||
|
}
|
||||||
if (!ast_strlen_zero(p->cd.call_dest_e164)) {
|
if (!ast_strlen_zero(p->cd.call_dest_e164)) {
|
||||||
strncpy(p->exten, cd.call_dest_e164, sizeof(p->exten)-1);
|
strncpy(p->exten, cd.call_dest_e164, sizeof(p->exten)-1);
|
||||||
} else {
|
} else {
|
||||||
@@ -1161,6 +1197,32 @@ void connection_made(unsigned call_reference)
|
|||||||
c = p->owner;
|
c = p->owner;
|
||||||
|
|
||||||
ast_setstate(c, AST_STATE_UP);
|
ast_setstate(c, AST_STATE_UP);
|
||||||
|
ast_queue_control(c, AST_CONTROL_ANSWER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call-back function to signal asterisk that the channel is ringing
|
||||||
|
* Returns nothing
|
||||||
|
*/
|
||||||
|
void chan_ringing(unsigned call_reference)
|
||||||
|
{
|
||||||
|
struct ast_channel *c = NULL;
|
||||||
|
struct oh323_pvt *p = NULL;
|
||||||
|
|
||||||
|
p = find_call(call_reference);
|
||||||
|
|
||||||
|
if (!p) {
|
||||||
|
ast_log(LOG_ERROR, "Something is wrong: ringing\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!p->owner) {
|
||||||
|
ast_log(LOG_ERROR, "Channel has no owner\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
c = p->owner;
|
||||||
|
ast_setstate(c, AST_STATE_RINGING);
|
||||||
|
ast_queue_control(c, AST_CONTROL_RINGING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1171,7 +1233,7 @@ void connection_made(unsigned call_reference)
|
|||||||
void cleanup_connection(call_details_t cd)
|
void cleanup_connection(call_details_t cd)
|
||||||
{
|
{
|
||||||
struct oh323_pvt *p = NULL;
|
struct oh323_pvt *p = NULL;
|
||||||
// struct oh323_peer *peer = NULL;
|
/* struct oh323_peer *peer = NULL; */
|
||||||
struct oh323_user *user = NULL;
|
struct oh323_user *user = NULL;
|
||||||
struct ast_rtp *rtp = NULL;
|
struct ast_rtp *rtp = NULL;
|
||||||
|
|
||||||
@@ -1793,6 +1855,7 @@ int load_module()
|
|||||||
create_connection,
|
create_connection,
|
||||||
setup_rtp_connection,
|
setup_rtp_connection,
|
||||||
cleanup_connection,
|
cleanup_connection,
|
||||||
|
chan_ringing,
|
||||||
connection_made,
|
connection_made,
|
||||||
send_digit);
|
send_digit);
|
||||||
|
|
||||||
@@ -1800,7 +1863,6 @@ int load_module()
|
|||||||
/* start the h.323 listener */
|
/* start the h.323 listener */
|
||||||
if (h323_start_listener(port, bindaddr)) {
|
if (h323_start_listener(port, bindaddr)) {
|
||||||
ast_log(LOG_ERROR, "Unable to create H323 listener.\n");
|
ast_log(LOG_ERROR, "Unable to create H323 listener.\n");
|
||||||
// h323_end_process();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1808,7 +1870,6 @@ int load_module()
|
|||||||
if (gatekeeper_disable == 0) {
|
if (gatekeeper_disable == 0) {
|
||||||
if (h323_set_gk(gatekeeper_discover, gatekeeper, secret)) {
|
if (h323_set_gk(gatekeeper_discover, gatekeeper, secret)) {
|
||||||
ast_log(LOG_ERROR, "Gatekeeper registration failed.\n");
|
ast_log(LOG_ERROR, "Gatekeeper registration failed.\n");
|
||||||
// h323_end_process();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -218,8 +218,7 @@ H323Codec * AST_G729ACapability::CreateCodec(H323Codec::Direction direction) con
|
|||||||
* transport = ip.
|
* transport = ip.
|
||||||
* port = 1720.
|
* port = 1720.
|
||||||
*/
|
*/
|
||||||
int MyH323EndPoint::MakeCall(const PString & dest, PString & token,
|
int MyH323EndPoint::MakeCall(const PString & dest, PString & token, unsigned int *callReference, unsigned int port, char *callerid, char *callername)
|
||||||
unsigned int *callReference, unsigned int port, char *callerid)
|
|
||||||
{
|
{
|
||||||
PString fullAddress;
|
PString fullAddress;
|
||||||
MyH323Connection * connection;
|
MyH323Connection * connection;
|
||||||
@@ -245,6 +244,15 @@ int MyH323EndPoint::MakeCall(const PString & dest, PString & token,
|
|||||||
|
|
||||||
if (callerid)
|
if (callerid)
|
||||||
connection->SetLocalPartyName(PString(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();
|
connection->Unlock();
|
||||||
|
|
||||||
@@ -486,7 +494,7 @@ H323Connection::AnswerCallResponse MyH323Connection::OnAnswerCall(const PString
|
|||||||
{
|
{
|
||||||
/* The call will be answered later with "AnsweringCall()" function.
|
/* The call will be answered later with "AnsweringCall()" function.
|
||||||
*/
|
*/
|
||||||
return H323Connection::AnswerCallAlertWithMedia;
|
return H323Connection::AnswerCallDeferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL MyH323Connection::OnAlerting(const H323SignalPDU & /*alertingPDU*/, const PString & username)
|
BOOL MyH323Connection::OnAlerting(const H323SignalPDU & /*alertingPDU*/, const PString & username)
|
||||||
@@ -495,6 +503,7 @@ BOOL MyH323Connection::OnAlerting(const H323SignalPDU & /*alertingPDU*/, const
|
|||||||
if (h323debug) {
|
if (h323debug) {
|
||||||
cout << " -- Ringing phone for \"" << username << "\"" << endl;
|
cout << " -- Ringing phone for \"" << username << "\"" << endl;
|
||||||
}
|
}
|
||||||
|
on_chan_ringing(GetCallReference());
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,6 +517,7 @@ BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
|
|||||||
call_details_t cd;
|
call_details_t cd;
|
||||||
PString sourceE164;
|
PString sourceE164;
|
||||||
PString destE164;
|
PString destE164;
|
||||||
|
PString sourceName;
|
||||||
PString sourceAliases;
|
PString sourceAliases;
|
||||||
PString destAliases;
|
PString destAliases;
|
||||||
PIPSocket::Address Ip;
|
PIPSocket::Address Ip;
|
||||||
@@ -519,6 +529,8 @@ BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
|
|||||||
|
|
||||||
sourceE164 = "";
|
sourceE164 = "";
|
||||||
setupPDU.GetSourceE164(sourceE164);
|
setupPDU.GetSourceE164(sourceE164);
|
||||||
|
sourceName = "";
|
||||||
|
sourceName=setupPDU.GetQ931().GetDisplayName();
|
||||||
destE164 = "";
|
destE164 = "";
|
||||||
setupPDU.GetDestinationE164(destE164);
|
setupPDU.GetDestinationE164(destE164);
|
||||||
|
|
||||||
@@ -540,6 +552,7 @@ BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
|
|||||||
cd.call_dest_alias = (const char *)destAliases;
|
cd.call_dest_alias = (const char *)destAliases;
|
||||||
cd.call_source_e164 = (const char *)sourceE164;
|
cd.call_source_e164 = (const char *)sourceE164;
|
||||||
cd.call_dest_e164 = (const char *)destE164;
|
cd.call_dest_e164 = (const char *)destE164;
|
||||||
|
cd.call_source_name = (const char *)sourceName;
|
||||||
|
|
||||||
GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort);
|
GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort);
|
||||||
cd.sourceIp = (const char *)Ip.AsString();
|
cd.sourceIp = (const char *)Ip.AsString();
|
||||||
@@ -740,6 +753,24 @@ MyH323_ExternalRTPChannel::MyH323_ExternalRTPChannel(MyH323Connection & connecti
|
|||||||
return;
|
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()
|
MyH323_ExternalRTPChannel::~MyH323_ExternalRTPChannel()
|
||||||
{
|
{
|
||||||
if (h323debug) {
|
if (h323debug) {
|
||||||
@@ -748,29 +779,17 @@ MyH323_ExternalRTPChannel::~MyH323_ExternalRTPChannel()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL MyH323_ExternalRTPChannel::OnReceivedPDU(
|
BOOL MyH323_ExternalRTPChannel::OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param)
|
||||||
const H245_H2250LogicalChannelParameters & param,
|
|
||||||
unsigned & errorCode)
|
|
||||||
{
|
{
|
||||||
if (h323debug) {
|
PIPSocket::Address remoteIpAddress;
|
||||||
cout << " MyH323_ExternalRTPChannel::OnReceivedPDU " << endl;
|
WORD remotePort;
|
||||||
}
|
|
||||||
return H323_ExternalRTPChannel::OnReceivedPDU( param, errorCode );
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
if (h323debug) {
|
if (h323debug) {
|
||||||
cout << " MyH323_ExternalRTPChannel::OnReceivedAckPDU " << endl;
|
cout << " MyH323_ExternalRTPChannel::OnReceivedAckPDU " << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (H323_ExternalRTPChannel::OnReceivedAckPDU(param)) {
|
if (H323_ExternalRTPChannel::OnReceivedAckPDU(param)) {
|
||||||
GetRemoteAddress(remoteIpAddress, remotePort);
|
H323_ExternalRTPChannel::GetRemoteAddress(remoteIpAddress, remotePort);
|
||||||
if (h323debug) {
|
if (h323debug) {
|
||||||
cout << " -- remoteIpAddress: " << remoteIpAddress << endl;
|
cout << " -- remoteIpAddress: " << remoteIpAddress << endl;
|
||||||
cout << " -- remotePort: " << remotePort << endl;
|
cout << " -- remotePort: " << remotePort << endl;
|
||||||
@@ -838,6 +857,7 @@ void h323_callback_register(setup_incoming_cb ifunc,
|
|||||||
on_connection_cb confunc,
|
on_connection_cb confunc,
|
||||||
start_logchan_cb lfunc,
|
start_logchan_cb lfunc,
|
||||||
clear_con_cb clfunc,
|
clear_con_cb clfunc,
|
||||||
|
chan_ringing_cb rfunc,
|
||||||
con_established_cb efunc,
|
con_established_cb efunc,
|
||||||
send_digit_cb dfunc)
|
send_digit_cb dfunc)
|
||||||
{
|
{
|
||||||
@@ -846,6 +866,7 @@ void h323_callback_register(setup_incoming_cb ifunc,
|
|||||||
on_create_connection = confunc;
|
on_create_connection = confunc;
|
||||||
on_start_logical_channel = lfunc;
|
on_start_logical_channel = lfunc;
|
||||||
on_connection_cleared = clfunc;
|
on_connection_cleared = clfunc;
|
||||||
|
on_chan_ringing = rfunc;
|
||||||
on_connection_established = efunc;
|
on_connection_established = efunc;
|
||||||
on_send_digit = dfunc;
|
on_send_digit = dfunc;
|
||||||
}
|
}
|
||||||
@@ -1085,7 +1106,7 @@ int h323_make_call(char *host, call_details_t *cd, call_options_t call_options)
|
|||||||
|
|
||||||
PString dest(host);
|
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());
|
memcpy((char *)(cd->call_token), (const unsigned char *)token, token.GetLength());
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -1101,6 +1122,45 @@ int h323_clear_call(const char *call_token)
|
|||||||
return 0;
|
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
|
/** This function tells the h.323 stack to either
|
||||||
answer or deny an incoming call */
|
answer or deny an incoming call */
|
||||||
int h323_answering_call(const char *token, int busy)
|
int h323_answering_call(const char *token, int busy)
|
||||||
|
@@ -198,7 +198,7 @@ class MyH323EndPoint : public H323EndPoint {
|
|||||||
|
|
||||||
public:
|
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 &);
|
BOOL ClearCall(const PString &);
|
||||||
|
|
||||||
void OnClosedLogicalChannel(H323Connection &, const H323Channel &);
|
void OnClosedLogicalChannel(H323Connection &, const H323Channel &);
|
||||||
@@ -225,7 +225,9 @@ class MyH323Connection : public H323Connection {
|
|||||||
MyH323Connection(MyH323EndPoint &, unsigned, unsigned);
|
MyH323Connection(MyH323EndPoint &, unsigned, unsigned);
|
||||||
~MyH323Connection();
|
~MyH323Connection();
|
||||||
|
|
||||||
H323Channel * CreateRealTimeLogicalChannel(const H323Capability &, H323Channel::Directions, unsigned,
|
H323Channel * CreateRealTimeLogicalChannel(const H323Capability &,
|
||||||
|
H323Channel::Directions,
|
||||||
|
unsigned,
|
||||||
const H245_H2250LogicalChannelParameters *);
|
const H245_H2250LogicalChannelParameters *);
|
||||||
H323Connection::AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
|
H323Connection::AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
|
||||||
void OnReceivedReleaseComplete(const H323SignalPDU &);
|
void OnReceivedReleaseComplete(const H323SignalPDU &);
|
||||||
@@ -245,12 +247,12 @@ class MyH323Connection : public H323Connection {
|
|||||||
PString sourceE164;
|
PString sourceE164;
|
||||||
PString destE164;
|
PString destE164;
|
||||||
|
|
||||||
PIPSocket::Address externalIpAddress; // IP address of media server
|
PIPSocket::Address externalIpAddress;
|
||||||
PIPSocket::Address remoteIpAddress; // IP Address of remote endpoint
|
PIPSocket::Address remoteIpAddress;
|
||||||
WORD externalPort; // local media server Data port (control is dataPort+1)
|
WORD externalPort;
|
||||||
WORD remotePort; // remote endpoint Data port (control is dataPort+1)
|
WORD remotePort;
|
||||||
WORD sessionId;
|
WORD sessionId;
|
||||||
BOOL bridging; // Used to help determine which IP to use
|
BOOL bridging;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyH323_ExternalRTPChannel : public H323_ExternalRTPChannel {
|
class MyH323_ExternalRTPChannel : public H323_ExternalRTPChannel {
|
||||||
@@ -258,19 +260,39 @@ 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,
|
MyH323_ExternalRTPChannel(
|
||||||
unsigned, const PIPSocket::Address &, WORD);
|
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();
|
~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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -86,6 +86,7 @@ struct oh323_alias {
|
|||||||
function*/
|
function*/
|
||||||
typedef struct call_options {
|
typedef struct call_options {
|
||||||
char *callerid;
|
char *callerid;
|
||||||
|
char *callername;
|
||||||
int noFastStart;
|
int noFastStart;
|
||||||
int noH245Tunnelling;
|
int noH245Tunnelling;
|
||||||
int noSilenceSuppression;
|
int noSilenceSuppression;
|
||||||
@@ -101,6 +102,7 @@ typedef struct call_details {
|
|||||||
const char *call_token;
|
const char *call_token;
|
||||||
const char *call_source_aliases;
|
const char *call_source_aliases;
|
||||||
const char *call_dest_alias;
|
const char *call_dest_alias;
|
||||||
|
const char *call_source_name;
|
||||||
const char *call_source_e164;
|
const char *call_source_e164;
|
||||||
const char *call_dest_e164;
|
const char *call_dest_e164;
|
||||||
const char *sourceIp;
|
const char *sourceIp;
|
||||||
@@ -136,6 +138,11 @@ setup_outbound_cb on_outgoing_call;
|
|||||||
typedef void (*start_logchan_cb)(unsigned int, const char *, int);
|
typedef void (*start_logchan_cb)(unsigned int, const char *, int);
|
||||||
start_logchan_cb on_start_logical_channel;
|
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
|
/* This is a callback protoype function, called when the openh323
|
||||||
OnConnectionEstablished is inovked */
|
OnConnectionEstablished is inovked */
|
||||||
typedef void (*con_established_cb)(unsigned);
|
typedef void (*con_established_cb)(unsigned);
|
||||||
@@ -169,6 +176,7 @@ extern "C" {
|
|||||||
on_connection_cb,
|
on_connection_cb,
|
||||||
start_logchan_cb,
|
start_logchan_cb,
|
||||||
clear_con_cb,
|
clear_con_cb,
|
||||||
|
chan_ringing_cb,
|
||||||
con_established_cb,
|
con_established_cb,
|
||||||
send_digit_cb);
|
send_digit_cb);
|
||||||
|
|
||||||
@@ -191,9 +199,13 @@ extern "C" {
|
|||||||
/* H323 create and destroy sessions */
|
/* H323 create and destroy sessions */
|
||||||
int h323_make_call(char *host, call_details_t *cd, call_options_t);
|
int h323_make_call(char *host, call_details_t *cd, call_options_t);
|
||||||
int h323_clear_call(const char *);
|
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_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[]);
|
int h323_show_codec(int fd, int argc, char *argv[]);
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user