[asterisk-commits] pcadach: branch pcadach/chan_h323-live r41613 -
in /team/pcadach/chan_h323-li...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Aug 31 12:11:28 MST 2006
Author: pcadach
Date: Thu Aug 31 14:11:28 2006
New Revision: 41613
URL: http://svn.digium.com/view/asterisk?rev=41613&view=rev
Log:
VLDTMF and realtime stuff
Modified:
team/pcadach/chan_h323-live/channels/chan_h323.c
team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp
team/pcadach/chan_h323-live/channels/h323/ast_h323.h
team/pcadach/chan_h323-live/channels/h323/chan_h323.h
Modified: team/pcadach/chan_h323-live/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/chan_h323.c?rev=41613&r1=41612&r2=41613&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_h323.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_h323.c Thu Aug 31 14:11:28 2006
@@ -102,7 +102,7 @@
#include "h323/chan_h323.h"
-send_digit_cb on_send_digit;
+receive_digit_cb on_receive_digit;
on_rtp_cb on_external_rtp_create;
start_rtp_cb on_start_rtp_channel;
setup_incoming_cb on_incoming_call;
@@ -180,10 +180,12 @@
int newstate; /* Pending state change */
int newcontrol; /* Pending control to send */
int newdigit; /* Pending DTMF digit to send */
+ int newduration; /* Pending DTMF digit duration to send */
int pref_codec; /* Preferred codec */
int peercapability; /* Capabilities learned from peer */
int jointcapability; /* Common capabilities for local and remote side */
int dtmf_pt; /* Payload code used for RFC2833 messages */
+ int curDTMF; /* DTMF tone being generated */
struct oh323_pvt *next; /* Next channel in list */
} *iflist = NULL;
@@ -307,12 +309,18 @@
}
if (pvt->newdigit >= 0) {
struct ast_frame f = {
- .frametype = AST_FRAME_DTMF,
+ .frametype = AST_FRAME_DTMF_END,
.subclass = pvt->newdigit,
- .samples = 800,
+ .samples = pvt->newduration * 8,
.src = "UPDATE_INFO",
};
-
+ if (pvt->newdigit == ' ') { /* signalUpdate message */
+ f.subclass = pvt->curDTMF;
+ } else { /* Regular input or signal message */
+ if (pvt->newduration) /* This is a signal, signalUpdate follows */
+ f.frametype = AST_FRAME_DTMF_BEGIN;
+ pvt->curDTMF = pvt->newdigit;
+ }
ast_queue_frame(c, &f);
pvt->newdigit = -1;
}
@@ -413,9 +421,36 @@
ast_mutex_unlock(&iflock);
}
-static int oh323_digit_begin(struct ast_channel *chan, char digit)
-{
- /* XXX Implement me, plz, kthx */
+static int oh323_digit_begin(struct ast_channel *c, char digit)
+{
+ struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
+ char *token;
+
+ if (!pvt) {
+ ast_log(LOG_ERROR, "No private structure?! This is bad\n");
+ return -1;
+ }
+ ast_mutex_lock(&pvt->lock);
+ if (pvt->rtp && (pvt->options.dtmfmode & H323_DTMF_RFC2833) && (pvt->dtmf_pt > 0)) {
+ /* out-of-band DTMF */
+ if (h323debug) {
+ ast_log(LOG_DEBUG, "Begin sending out-of-band digit %c on %s\n", digit, c->name);
+ }
+ ast_rtp_senddigit_begin(pvt->rtp, digit);
+ ast_mutex_unlock(&pvt->lock);
+ } else {
+ /* in-band DTMF */
+ if (h323debug) {
+ ast_log(LOG_DEBUG, "Begin sending inband digit %c on %s\n", digit, c->name);
+ }
+ token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
+ ast_mutex_unlock(&pvt->lock);
+ h323_send_tone(token, digit);
+ if (token) {
+ free(token);
+ }
+ }
+ oh323_update_info(c);
return 0;
}
@@ -436,18 +471,18 @@
if (pvt->rtp && (pvt->options.dtmfmode & H323_DTMF_RFC2833) && (pvt->dtmf_pt > 0)) {
/* out-of-band DTMF */
if (h323debug) {
- ast_log(LOG_DEBUG, "Sending out-of-band digit %c on %s\n", digit, c->name);
- }
- ast_rtp_senddigit(pvt->rtp, digit);
+ ast_log(LOG_DEBUG, "End sending out-of-band digit %c on %s\n", digit, c->name);
+ }
+ ast_rtp_senddigit_end(pvt->rtp, digit);
ast_mutex_unlock(&pvt->lock);
} else {
/* in-band DTMF */
if (h323debug) {
- ast_log(LOG_DEBUG, "Sending inband digit %c on %s\n", digit, c->name);
+ ast_log(LOG_DEBUG, "End sending inband digit %c on %s\n", digit, c->name);
}
token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
ast_mutex_unlock(&pvt->lock);
- h323_send_tone(token, digit);
+ h323_send_tone(token, ' ');
if (token) {
free(token);
}
@@ -638,7 +673,7 @@
/* Do in-band DTMF detection */
if ((pvt->options.dtmfmode & H323_DTMF_INBAND) && pvt->vad) {
if (!ast_channel_trylock(pvt->owner)) {
- f = ast_dsp_process(pvt->owner,pvt->vad,f);
+ f = ast_dsp_process(pvt->owner, pvt->vad, f);
ast_channel_unlock(pvt->owner);
}
else
@@ -979,7 +1014,7 @@
}
}
-static struct oh323_alias *build_alias(char *name, struct ast_variable *v)
+static struct oh323_alias *build_alias(const char *name, struct ast_variable *v, int realtime)
{
struct oh323_alias *alias;
int found = 0;
@@ -1012,6 +1047,31 @@
}
ASTOBJ_UNMARK(alias);
return alias;
+}
+
+static struct oh323_alias *realtime_alias(const char *alias)
+{
+ struct ast_variable *var, *tmp;
+ struct oh323_alias *a;
+
+ var = ast_load_realtime("h323", "name", alias, NULL);
+
+ if (!var)
+ return NULL;
+
+ for (tmp = var; tmp; tmp = tmp->next) {
+ if (!strcasecmp(tmp->name, "type") &&
+ !(!strcasecmp(tmp->value, "alias") || !strcasecmp(tmp->value, "h323"))) {
+ ast_variables_destroy(var);
+ return NULL;
+ }
+ }
+
+ a = build_alias(alias, var, 1);
+
+ ast_variables_destroy(var);
+
+ return a;
}
static int update_common_options(struct ast_variable *v, struct call_options *options)
@@ -1206,6 +1266,8 @@
peer->chanvars = NULL;
}
#endif
+ /* Default settings for mailbox */
+ peer->mailbox[0] = '\0';
for (; v; v = v->next) {
if (!update_common_options(v, &peer->options))
@@ -1226,6 +1288,8 @@
} else if (!strcasecmp(v->name, "permit") ||
!strcasecmp(v->name, "deny")) {
peer->ha = ast_append_ha(v->name, v->value, peer->ha);
+ } else if (!strcasecmp(v->name, "mailbox")) {
+ ast_copy_string(peer->mailbox, v->value, sizeof(peer->mailbox));
}
}
ASTOBJ_UNMARK(peer);
@@ -1347,7 +1411,7 @@
port++;
}
pvt->sa.sin_family = AF_INET;
- p = find_peer(peer, NULL, 0);
+ p = find_peer(peer, NULL, 1);
if (p) {
found++;
memcpy(&pvt->options, &p->options, sizeof(pvt->options));
@@ -1381,7 +1445,7 @@
memcpy(&pvt->sa.sin_addr, hp->h_addr, sizeof(pvt->sa.sin_addr));
pvt->sa.sin_port = htons(portno);
/* Look peer by address */
- p = find_peer(NULL, &pvt->sa, 0);
+ p = find_peer(NULL, &pvt->sa, 1);
memcpy(&pvt->options, (p ? &p->options : &global_options), sizeof(pvt->options));
pvt->jointcapability = pvt->options.capability;
if (p) {
@@ -1490,16 +1554,14 @@
}
/** Find a call by alias */
-static struct oh323_alias *find_alias(const char *source_aliases)
+static struct oh323_alias *find_alias(const char *source_aliases, int realtime)
{
struct oh323_alias *a;
a = ASTOBJ_CONTAINER_FIND(&aliasl, source_aliases);
-#if 0 /* XXX REALTIME XXX */
if (!a && realtime)
a = realtime_alias(source_aliases);
-#endif
return a;
}
@@ -1508,17 +1570,17 @@
* Callback for sending digits from H.323 up to asterisk
*
*/
-static int send_digit(unsigned call_reference, char digit, const char *token)
+static int receive_digit(unsigned call_reference, char digit, const char *token, int duration)
{
struct oh323_pvt *pvt;
int res;
- if (digit == ' ') /* DTMF tone update -- ignore */
- return 0;
- ast_log(LOG_DEBUG, "Received Digit: %c\n", digit);
+ if (h323debug)
+ ast_log(LOG_DEBUG, "Received digit '%c' (%u ms) for call %s\n", digit, duration, token);
+
pvt = find_call_locked(call_reference, token);
if (!pvt) {
- ast_log(LOG_ERROR, "Private structure not found in send_digit.\n");
+ ast_log(LOG_ERROR, "Private structure not found in receive_digit.\n");
return -1;
}
if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
@@ -1526,19 +1588,28 @@
res = ast_queue_control(pvt->owner, AST_CONTROL_FLASH);
else {
struct ast_frame f = {
- .frametype = AST_FRAME_DTMF,
+ .frametype = AST_FRAME_DTMF_END,
.subclass = digit,
- .samples = 800,
+ .samples = duration * 8,
.src = "SEND_DIGIT",
};
+ if (digit == ' ') { /* signalUpdate message */
+ f.subclass = pvt->curDTMF;
+ } else { /* Regular input or signal message */
+ if (duration) /* This is a signal, signalUpdate follows */
+ f.frametype = AST_FRAME_DTMF_BEGIN;
+ pvt->curDTMF = digit;
+ }
res = ast_queue_frame(pvt->owner, &f);
}
ast_channel_unlock(pvt->owner);
} else {
if (digit == '!')
pvt->newcontrol = AST_CONTROL_FLASH;
- else
+ else {
+ pvt->newduration = duration;
pvt->newdigit = digit;
+ }
res = 0;
}
ast_mutex_unlock(&pvt->lock);
@@ -1735,7 +1806,7 @@
strncpy(pvt->exten, cd->call_dest_e164, sizeof(pvt->exten) - 1);
strncpy(pvt->context, default_context, sizeof(pvt->context) - 1);
} else {
- alias = find_alias(cd->call_dest_alias);
+ alias = find_alias(cd->call_dest_alias, 1);
if (!alias) {
ast_log(LOG_ERROR, "Call for %s rejected, alias not found\n", cd->call_dest_alias);
oh323_destroy(pvt);
@@ -1747,7 +1818,7 @@
} else {
/* Either this call is not from the Gatekeeper
or we are not allowing gk routed calls */
- user = find_user(cd, 0);
+ user = find_user(cd, 1);
if (!user) {
if (!ast_strlen_zero(pvt->cd.call_dest_e164)) {
strncpy(pvt->exten, cd->call_dest_e164, sizeof(pvt->exten) - 1);
@@ -2383,7 +2454,7 @@
}
}
if (is_alias) {
- alias = build_alias(cat, ast_variable_browse(cfg, cat));
+ alias = build_alias(cat, ast_variable_browse(cfg, cat), 0);
if (alias) {
ASTOBJ_CONTAINER_LINK(&aliasl, alias);
ASTOBJ_UNREF(alias, oh323_destroy_alias);
@@ -2626,7 +2697,7 @@
cleanup_connection,
chan_ringing,
connection_made,
- send_digit,
+ receive_digit,
answer_call,
progress,
set_dtmf_payload,
Modified: team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp?rev=41613&r1=41612&r2=41613&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp (original)
+++ team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp Thu Aug 31 14:11:28 2006
@@ -987,13 +987,17 @@
return H323Connection::OnClosingLogicalChannel(channel);
}
-void MyH323Connection::SendUserInputTone(char tone, unsigned duration)
-{
- if (h323debug) {
- cout << "\t-- Sending user input tone (" << tone << ") to remote" << endl;
- }
- on_send_digit(GetCallReference(), tone, (const char *)GetCallToken());
- H323Connection::SendUserInputTone(tone, duration);
+void MyH323Connection::SendUserInputTone(char tone, unsigned duration, unsigned logicalChannel, unsigned rtpTimestamp)
+{
+ SendUserInputModes mode = GetRealSendUserInputMode();
+// That is recursive call... Why?
+// on_receive_digit(GetCallReference(), tone, (const char *)GetCallToken());
+ if ((tone != ' ') || (mode == SendUserInputAsTone) || (mode == SendUserInputAsInlineRFC2833)) {
+ if (h323debug) {
+ cout << "\t-- Sending user input tone (" << tone << ") to remote" << endl;
+ }
+ H323Connection::SendUserInputTone(tone, duration);
+ }
}
void MyH323Connection::OnUserInputTone(char tone, unsigned duration, unsigned logicalChannel, unsigned rtpTimestamp)
@@ -1002,7 +1006,7 @@
if (h323debug) {
cout << "\t-- Received user input tone (" << tone << ") from remote" << endl;
}
- on_send_digit(GetCallReference(), tone, (const char *)GetCallToken());
+ on_receive_digit(GetCallReference(), tone, (const char *)GetCallToken(), duration);
}
}
@@ -1011,7 +1015,7 @@
if (h323debug) {
cout << "\t-- Received user input string (" << value << ") from remote." << endl;
}
- on_send_digit(GetCallReference(), value[0], (const char *)GetCallToken());
+ on_receive_digit(GetCallReference(), value[0], (const char *)GetCallToken(), 0);
}
void MyH323Connection::OnSendCapabilitySet(H245_TerminalCapabilitySet & pdu)
@@ -1458,7 +1462,7 @@
clear_con_cb clfunc,
chan_ringing_cb rfunc,
con_established_cb efunc,
- send_digit_cb dfunc,
+ receive_digit_cb dfunc,
answer_call_cb acfunc,
progress_cb pgfunc,
rfc2833_cb dtmffunc,
@@ -1473,7 +1477,7 @@
on_connection_cleared = clfunc;
on_chan_ringing = rfunc;
on_connection_established = efunc;
- on_send_digit = dfunc;
+ on_receive_digit = dfunc;
on_answer_call = acfunc;
on_progress = pgfunc;
on_set_rfc2833_payload = dtmffunc;
Modified: team/pcadach/chan_h323-live/channels/h323/ast_h323.h
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/ast_h323.h?rev=41613&r1=41612&r2=41613&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/ast_h323.h (original)
+++ team/pcadach/chan_h323-live/channels/h323/ast_h323.h Thu Aug 31 14:11:28 2006
@@ -204,9 +204,9 @@
BOOL OnSendSignalSetup(H323SignalPDU &);
BOOL OnStartLogicalChannel(H323Channel &);
BOOL OnClosingLogicalChannel(H323Channel &);
- void SendUserInputTone(char, unsigned);
- void OnUserInputTone(char, unsigned, unsigned, unsigned);
- void OnUserInputString(const PString &value);
+ virtual void SendUserInputTone(char tone, unsigned duration = 0, unsigned logicalChannel = 0, unsigned rtpTimestamp = 0);
+ virtual void OnUserInputTone(char, unsigned, unsigned, unsigned);
+ virtual void OnUserInputString(const PString &value);
BOOL OnReceivedProgress(const H323SignalPDU &);
void OnSendCapabilitySet(H245_TerminalCapabilitySet &);
void OnSetLocalCapabilities();
Modified: team/pcadach/chan_h323-live/channels/h323/chan_h323.h
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/chan_h323.h?rev=41613&r1=41612&r2=41613&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/chan_h323.h (original)
+++ team/pcadach/chan_h323-live/channels/h323/chan_h323.h Thu Aug 31 14:11:28 2006
@@ -109,8 +109,8 @@
/* 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;
+typedef int (*receive_digit_cb)(unsigned, char, const char *, int);
+extern receive_digit_cb on_receive_digit;
/* This is a callback prototype function, called to collect
the external RTP port from Asterisk. */
@@ -201,7 +201,7 @@
clear_con_cb,
chan_ringing_cb,
con_established_cb,
- send_digit_cb,
+ receive_digit_cb,
answer_call_cb,
progress_cb,
rfc2833_cb,
More information about the asterisk-commits
mailing list