projects
/
lcr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adding forwarding of DTMF and keypad between peers
[lcr.git]
/
chan_lcr.c
diff --git
a/chan_lcr.c
b/chan_lcr.c
index
ca6b026
..
25515d0
100644
(file)
--- a/
chan_lcr.c
+++ b/
chan_lcr.c
@@
-245,8
+245,9
@@
void chan_lcr_log(int type, const char *file, int line, const char *function, st
if (ast)
strncpy(ast_text, ast->name, sizeof(ast_text)-1);
ast_text[sizeof(ast_text)-1] = '\0';
if (ast)
strncpy(ast_text, ast->name, sizeof(ast_text)-1);
ast_text[sizeof(ast_text)-1] = '\0';
-
- ast_log(type, file, line, function, "[call=%s ast=%s] %s", call_text, ast_text, buffer);
+
+// ast_log(type, file, line, function, "[call=%s ast=%s] %s", call_text, ast_text, buffer);
+ printf("[call=%s ast=%s] %s", call_text, ast_text, buffer);
ast_mutex_unlock(&log_lock);
}
ast_mutex_unlock(&log_lock);
}
@@
-612,7
+613,7
@@
static void send_setup_to_lcr(struct chan_call *call)
{
union parameter newparam;
struct ast_channel *ast = call->ast;
{
union parameter newparam;
struct ast_channel *ast = call->ast;
-
const char *tmp;
+
//
const char *tmp;
if (!call->ast || !call->ref)
return;
if (!call->ast || !call->ref)
return;
@@
-665,9
+666,10
@@
static void send_setup_to_lcr(struct chan_call *call)
default:
newparam.setup.callerinfo.ntype = INFO_NTYPE_UNKNOWN;
}
default:
newparam.setup.callerinfo.ntype = INFO_NTYPE_UNKNOWN;
}
- tmp = pbx_builtin_getvar_helper(ast, "LCR_TRANSFERCAPABILITY");
- if (tmp && *tmp)
- ast->transfercapability = atoi(tmp);
+#warning DISABLED DUE TO DOUBLE LOCKING PROBLEM
+// tmp = pbx_builtin_getvar_helper(ast, "LCR_TRANSFERCAPABILITY");
+// if (tmp && *tmp)
+// ast->transfercapability = atoi(tmp);
newparam.setup.capainfo.bearer_capa = ast->transfercapability;
newparam.setup.capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
if (call->hdlc)
newparam.setup.capainfo.bearer_capa = ast->transfercapability;
newparam.setup.capainfo.bearer_mode = INFO_BMODE_CIRCUIT;
if (call->hdlc)
@@
-879,8
+881,11
@@
static void lcr_in_setup(struct chan_call *call, int message_type, union paramet
strncpy(ast->context, param->setup.context, AST_MAX_CONTEXT-1);
else
strncpy(ast->context, param->setup.callerinfo.interface, AST_MAX_CONTEXT-1);
strncpy(ast->context, param->setup.context, AST_MAX_CONTEXT-1);
else
strncpy(ast->context, param->setup.callerinfo.interface, AST_MAX_CONTEXT-1);
+ memset(&ast->cid, 0, sizeof(ast->cid));
if (param->setup.callerinfo.id[0])
ast->cid.cid_num = strdup(param->setup.callerinfo.id);
if (param->setup.callerinfo.id[0])
ast->cid.cid_num = strdup(param->setup.callerinfo.id);
+ if (param->setup.callerinfo.id2[0])
+ ast->cid.cid_ani = strdup(param->setup.callerinfo.id2);
if (param->setup.callerinfo.name[0])
ast->cid.cid_name = strdup(param->setup.callerinfo.name);
if (param->setup.redirinfo.id[0])
if (param->setup.callerinfo.name[0])
ast->cid.cid_name = strdup(param->setup.callerinfo.name);
if (param->setup.redirinfo.id[0])
@@
-1659,12
+1664,18
@@
static void handle_queue()
struct ast_frame fr;
char *p;
struct ast_frame fr;
char *p;
+again:
call = call_first;
while(call) {
p = call->queue_string;
ast = call->ast;
if (*p && ast) {
call = call_first;
while(call) {
p = call->queue_string;
ast = call->ast;
if (*p && ast) {
- ast_channel_lock(ast);
+ if (ast_channel_trylock(ast)) {
+ ast_mutex_unlock(&chan_lock);
+ usleep(1);
+ ast_mutex_lock(&chan_lock);
+ goto again;
+ }
while(*p) {
switch (*p) {
case 'T':
while(*p) {
switch (*p) {
case 'T':
@@
-1969,7
+1980,7
@@
static void send_digit_to_chan(struct ast_channel * ast, char digit )
ast_playtones_start(ast,0,dtmf_tones[15], 0);
else {
/* not handled */
ast_playtones_start(ast,0,dtmf_tones[15], 0);
else {
/* not handled */
-
ast_log(LOG_DEBUG
, "Unable to handle DTMF tone "
+
CDEBUG(NULL, ast
, "Unable to handle DTMF tone "
"'%c' for '%s'\n", digit, ast->name);
}
}
"'%c' for '%s'\n", digit, ast->name);
}
}
@@
-2109,13
+2120,15
@@
static int lcr_hangup(struct ast_channel *ast)
struct chan_call *call;
pthread_t tid = pthread_self();
struct chan_call *call;
pthread_t tid = pthread_self();
- if (!pthread_equal(tid, chan_tid))
+ if (!pthread_equal(tid, chan_tid))
{
ast_mutex_lock(&chan_lock);
ast_mutex_lock(&chan_lock);
+ }
call = ast->tech_pvt;
if (!call) {
CERROR(NULL, ast, "Received hangup from Asterisk, but no call instance exists.\n");
call = ast->tech_pvt;
if (!call) {
CERROR(NULL, ast, "Received hangup from Asterisk, but no call instance exists.\n");
- if (!pthread_equal(tid, chan_tid))
+ if (!pthread_equal(tid, chan_tid))
{
ast_mutex_unlock(&chan_lock);
ast_mutex_unlock(&chan_lock);
+ }
return -1;
}
return -1;
}
@@
-2136,8
+2149,9
@@
static int lcr_hangup(struct ast_channel *ast)
send_release_and_import(call, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL);
/* remove call */
free_call(call);
send_release_and_import(call, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL);
/* remove call */
free_call(call);
- if (!pthread_equal(tid, chan_tid))
+ if (!pthread_equal(tid, chan_tid))
{
ast_mutex_unlock(&chan_lock);
ast_mutex_unlock(&chan_lock);
+ }
return 0;
} else {
/* ref is not set, due to prepare setup or release */
return 0;
} else {
/* ref is not set, due to prepare setup or release */
@@
-2152,8
+2166,9
@@
static int lcr_hangup(struct ast_channel *ast)
call->ast = NULL;
}
}
call->ast = NULL;
}
}
- if (!pthread_equal(tid, chan_tid))
+ if (!pthread_equal(tid, chan_tid))
{
ast_mutex_unlock(&chan_lock);
ast_mutex_unlock(&chan_lock);
+ }
return 0;
}
return 0;
}
@@
-2182,7
+2197,7
@@
static int lcr_write(struct ast_channel *ast, struct ast_frame *f)
static struct ast_frame *lcr_read(struct ast_channel *ast)
{
struct chan_call *call;
static struct ast_frame *lcr_read(struct ast_channel *ast)
{
struct chan_call *call;
- int len;
+ int len
= 0
;
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
@@
-2247,6
+2262,7
@@
static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz
union parameter newparam;
int res = 0;
struct chan_call *call;
union parameter newparam;
int res = 0;
struct chan_call *call;
+ const struct tone_zone_sound *ts = NULL;
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
@@
-2268,6
+2284,9
@@
static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz
send_message(MESSAGE_DISCONNECT, call->ref, &newparam);
/* change state */
call->state = CHAN_LCR_STATE_OUT_DISCONNECT;
send_message(MESSAGE_DISCONNECT, call->ref, &newparam);
/* change state */
call->state = CHAN_LCR_STATE_OUT_DISCONNECT;
+ } else {
+ CDEBUG(call, ast, "Using Asterisk 'busy' indication\n");
+ ts = ast_get_indication_tone(ast->zone, "busy");
}
break;
case AST_CONTROL_CONGESTION:
}
break;
case AST_CONTROL_CONGESTION:
@@
-2280,6
+2299,9
@@
static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz
send_message(MESSAGE_DISCONNECT, call->ref, &newparam);
/* change state */
call->state = CHAN_LCR_STATE_OUT_DISCONNECT;
send_message(MESSAGE_DISCONNECT, call->ref, &newparam);
/* change state */
call->state = CHAN_LCR_STATE_OUT_DISCONNECT;
+ } else {
+ CDEBUG(call, ast, "Using Asterisk 'congestion' indication\n");
+ ts = ast_get_indication_tone(ast->zone, "congestion");
}
break;
case AST_CONTROL_PROCEEDING:
}
break;
case AST_CONTROL_PROCEEDING:
@@
-2304,6
+2326,9
@@
static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz
send_message(MESSAGE_ALERTING, call->ref, &newparam);
/* change state */
call->state = CHAN_LCR_STATE_IN_ALERTING;
send_message(MESSAGE_ALERTING, call->ref, &newparam);
/* change state */
call->state = CHAN_LCR_STATE_IN_ALERTING;
+ } else {
+ CDEBUG(call, ast, "Using Asterisk 'ring' indication\n");
+ ts = ast_get_indication_tone(ast->zone, "ring");
}
break;
case AST_CONTROL_PROGRESS:
}
break;
case AST_CONTROL_PROGRESS:
@@
-2318,6
+2343,7
@@
static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz
break;
case -1:
CDEBUG(call, ast, "Received indicate -1.\n");
break;
case -1:
CDEBUG(call, ast, "Received indicate -1.\n");
+ ast_playtones_stop(ast);
res = -1;
break;
res = -1;
break;
@@
-2367,6
+2393,10
@@
static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz
break;
}
break;
}
+ if (ts && ts->data[0]) {
+ ast_playtones_start(ast, 0, ts->data, 1);
+ }
+
/* return */
ast_mutex_unlock(&chan_lock);
return res;
/* return */
ast_mutex_unlock(&chan_lock);
return res;