[Asterisk-code-review] app queue.c: Factor out a connected line update routine. (asterisk[13])
Richard Mudgett
asteriskteam at digium.com
Fri Sep 25 12:43:31 CDT 2015
Richard Mudgett has uploaded a new change for review.
https://gerrit.asterisk.org/1318
Change subject: app_queue.c: Factor out a connected line update routine.
......................................................................
app_queue.c: Factor out a connected line update routine.
Replace inlined code with update_connected_line_from_peer().
ASTERISK-25423
Reported by: John Hardin
Change-Id: I33bbd033596fcb0208d41d8970369b4e87b806f3
---
M apps/app_queue.c
1 file changed, 30 insertions(+), 21 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/18/1318/1
diff --git a/apps/app_queue.c b/apps/app_queue.c
index dbaa167..2ca3a9e 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -4561,6 +4561,34 @@
return;
}
+/*!
+ * \internal
+ * \brief Update connected line on chan from peer.
+ * \since 13.6.0
+ *
+ * \param chan Channel to get connected line updated.
+ * \param peer Channel providing connected line information.
+ * \param is_caller Non-zero if chan is the calling channel.
+ *
+ * \return Nothing
+ */
+static void update_connected_line_from_peer(struct ast_channel *chan, struct ast_channel *peer, int is_caller)
+{
+ struct ast_party_connected_line connected_caller;
+
+ ast_party_connected_line_init(&connected_caller);
+
+ ast_channel_lock(peer);
+ ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(peer));
+ ast_channel_unlock(peer);
+ connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+ if (ast_channel_connected_line_sub(peer, chan, &connected_caller, 0)
+ && ast_channel_connected_line_macro(peer, chan, &connected_caller, is_caller, 0)) {
+ ast_channel_update_connected_line(chan, &connected_caller, NULL);
+ }
+ ast_party_connected_line_free(&connected_caller);
+}
+
#define AST_MAX_WATCHERS 256
/*!
* \brief Wait for a member to answer the call
@@ -4595,11 +4623,8 @@
#ifdef HAVE_EPOLL
struct callattempt *epollo;
#endif
- struct ast_party_connected_line connected_caller;
char *inchan_name;
struct timeval start_time_tv = ast_tvnow();
-
- ast_party_connected_line_init(&connected_caller);
ast_channel_lock(qe->chan);
inchan_name = ast_strdupa(ast_channel_name(qe->chan));
@@ -4685,15 +4710,7 @@
ast_channel_update_connected_line(in, &o->connected, NULL);
}
} else if (!o->dial_callerid_absent) {
- ast_channel_lock(o->chan);
- ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(o->chan));
- ast_channel_unlock(o->chan);
- connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- if (ast_channel_connected_line_sub(o->chan, in, &connected_caller, 0) &&
- ast_channel_connected_line_macro(o->chan, in, &connected_caller, 1, 0)) {
- ast_channel_update_connected_line(in, &connected_caller, NULL);
- }
- ast_party_connected_line_free(&connected_caller);
+ update_connected_line_from_peer(in, o->chan, 1);
}
}
if (o->aoc_s_rate_list) {
@@ -4856,15 +4873,7 @@
ast_channel_update_connected_line(in, &o->connected, NULL);
}
} else if (!o->dial_callerid_absent) {
- ast_channel_lock(o->chan);
- ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(o->chan));
- ast_channel_unlock(o->chan);
- connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- if (ast_channel_connected_line_sub(o->chan, in, &connected_caller, 0) &&
- ast_channel_connected_line_macro(o->chan, in, &connected_caller, 1, 0)) {
- ast_channel_update_connected_line(in, &connected_caller, NULL);
- }
- ast_party_connected_line_free(&connected_caller);
+ update_connected_line_from_peer(in, o->chan, 1);
}
}
if (o->aoc_s_rate_list) {
--
To view, visit https://gerrit.asterisk.org/1318
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I33bbd033596fcb0208d41d8970369b4e87b806f3
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-code-review
mailing list