X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=chan_lcr.c;h=b28965a877c02c321f1fbe6c46bae835b5877fe6;hp=de9d788c11d43414ae3262afe92729475001bf9b;hb=ee848d3a9e333b3b91c0e40679c9d0512d511fc2;hpb=a9c1ce57ba87ed4f83ce2ead103e9b6891e921c2 diff --git a/chan_lcr.c b/chan_lcr.c index de9d788..b28965a 100644 --- a/chan_lcr.c +++ b/chan_lcr.c @@ -477,7 +477,7 @@ void apply_opt(struct chan_call *call, char *data) bchannel_pipeline(call->bchannel, call->pipeline); break; case 'r': - if (opt[1] == '\0') { + if (opt[1] != '\0') { CERROR(call, call->ast, "Option 'r' (re-buffer 160 bytes) expects no parameter.\n", opt); break; } @@ -1428,7 +1428,6 @@ int handle_socket(void) int open_socket(void) { int ret; - char *socket_name = SOCKET_NAME; int conn; struct sockaddr_un sock_address; unsigned int on = 1; @@ -1444,7 +1443,7 @@ int open_socket(void) /* set socket address and name */ memset(&sock_address, 0, sizeof(sock_address)); sock_address.sun_family = PF_UNIX; - strcpy(sock_address.sun_path, socket_name); + sprintf(sock_address.sun_path, SOCKET_NAME, options.lock); /* connect socket */ if ((conn = connect(lcr_sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0) @@ -2070,6 +2069,7 @@ static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz /*start music onhold*/ ast_moh_start(ast,data,ast->musicclass); + call->on_hold = 1; break; case AST_CONTROL_UNHOLD: CDEBUG(call, ast, "Received indicate AST_CONTROL_UNHOLD from Asterisk.\n"); @@ -2080,8 +2080,14 @@ static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz /*stop moh*/ ast_moh_stop(ast); + call->on_hold = 0; break; - +#ifdef AST_CONTROL_SRCUPDATE + case AST_CONTROL_SRCUPDATE: + CDEBUG(call, ast, "Received indicate AST_CONTROL_SRCUPDATE from Asterisk.\n"); + res = -1; + break; +#endif default: CERROR(call, ast, "Received indicate from Asterisk with unknown condition %d.\n", cond); res = -1; @@ -2096,21 +2102,25 @@ static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz /* * fixup asterisk */ -static int lcr_fixup(struct ast_channel *oldast, struct ast_channel *newast) +static int lcr_fixup(struct ast_channel *oldast, struct ast_channel *ast) { struct chan_call *call; + if (!ast) { + return -1; + } + ast_mutex_lock(&chan_lock); - call = oldast->tech_pvt; + call = ast->tech_pvt; if (!call) { - CERROR(NULL, oldast, "Received fixup from Asterisk, but no call instance exists.\n"); + CERROR(NULL, ast, "Received fixup from Asterisk, but no call instance exists.\n"); ast_mutex_unlock(&chan_lock); return -1; } - CDEBUG(call, oldast, "Received fixup from Asterisk.\n"); - call->ast = newast; - ast_mutex_lock(&chan_lock); + CDEBUG(call, ast, "Received fixup from Asterisk.\n"); + call->ast = ast; + ast_mutex_unlock(&chan_lock); return 0; } @@ -2204,6 +2214,30 @@ enum ast_bridge_result lcr_bridge(struct ast_channel *ast1, CDEBUG(call2, ast2, "Bridge established before lcr_answer, so we call it ourself: Calling lcr_answer...\n"); lcr_answer(ast2); } + + /* sometimes SIP phones forget to send RETRIEVE before TRANSFER + so let's do it for them. Hmpf. + */ + + if (call1->on_hold) { + union parameter newparam; + + memset(&newparam, 0, sizeof(union parameter)); + newparam.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL; + send_message(MESSAGE_NOTIFY, call1->ref, &newparam); + + call1->on_hold = 0; + } + + if (call2->on_hold) { + union parameter newparam; + + memset(&newparam, 0, sizeof(union parameter)); + newparam.notifyinfo.notify = INFO_NOTIFY_REMOTE_RETRIEVAL; + send_message(MESSAGE_NOTIFY, call2->ref, &newparam); + + call2->on_hold = 0; + } ast_mutex_unlock(&chan_lock);