From e739888d99bc4f4ef250e9c775814f4252335726 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Fri, 15 Jul 2016 20:44:52 -0500 Subject: res_pjsip: Add fax_detect_timeout endpoint option. The new endpoint option allows the PJSIP channel driver's fax_detect endpoint option to timeout on a call after the specified number of seconds into a call. The new feature is disabled if the timeout is set to zero. The option is disabled by default. ASTERISK-26214 Reported by: Richard Mudgett Change-Id: Id5a87375fb2c4f9dc1d4b44c78ec8735ba65453d --- main/channel.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'main') diff --git a/main/channel.c b/main/channel.c index f654e4d25..911c26955 100644 --- a/main/channel.c +++ b/main/channel.c @@ -2692,10 +2692,28 @@ void ast_hangup(struct ast_channel *chan) ast_channel_unref(chan); } +/*! + * \internal + * \brief Set channel answered time if not already set. + * \since 13.11.0 + * + * \param chan Channel to set answered time. + * + * \return Nothing + */ +static void set_channel_answer_time(struct ast_channel *chan) +{ + if (ast_tvzero(ast_channel_answertime(chan))) { + struct timeval answertime; + + answertime = ast_tvnow(); + ast_channel_answertime_set(chan, &answertime); + } +} + int ast_raw_answer(struct ast_channel *chan) { int res = 0; - struct timeval answertime; ast_channel_lock(chan); @@ -2711,8 +2729,11 @@ int ast_raw_answer(struct ast_channel *chan) return -1; } - answertime = ast_tvnow(); - ast_channel_answertime_set(chan, &answertime); + /* + * Mark when incoming channel answered so we can know how + * long the channel has been up. + */ + set_channel_answer_time(chan); ast_channel_unlock(chan); @@ -3911,6 +3932,12 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) ast_frfree(f); f = &ast_null_frame; } else { + /* + * Mark when outgoing channel answered so we can know how + * long the channel has been up. + */ + set_channel_answer_time(chan); + ast_setstate(chan, AST_STATE_UP); } } else if (f->subclass.integer == AST_CONTROL_READ_ACTION) { -- cgit v1.2.3