From 3acba5ac9bfdd677ac6c6e6bfaff779dedfc9483 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Mon, 22 Sep 2008 20:35:37 +0200 Subject: work around broken HOLD/UNHOLD handling on some SIP phones Some SIP phones don't send RETRIEVE before they send TRANSFER. So we RETRIEVE if we bridge two channels, if calls are still on hold. Also: handle CONTROL_SRCUPDATE with a debug message in recent versions of asterisk. --- chan_lcr.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'chan_lcr.c') diff --git a/chan_lcr.c b/chan_lcr.c index 52c2a31..b28965a 100644 --- a/chan_lcr.c +++ b/chan_lcr.c @@ -2069,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"); @@ -2079,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; @@ -2207,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); -- cgit v1.2.3-55-g7522