From 6fd8940d4c62c2ab052a3a7877278bee1eea5563 Mon Sep 17 00:00:00 2001
From: Kinsey Moore <kmoore@digium.com>
Date: Thu, 5 Jun 2014 11:59:09 +0000
Subject: [PATCH] PJSIP: Send initial connected line information

This makes chan_pjsip send connected line information when it is called
so that connected line information is available on the connected
channel.

(closes issue DPMA-442)
Reported by: John Bigelow
Review: https://reviewboard.asterisk.org/r/3584/
........

Merged revisions 415191 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415192 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_pjsip.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 26dda4ae2e..fcf2a4c1d9 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1467,6 +1467,38 @@ static int chan_pjsip_digit_end(struct ast_channel *ast, char digit, unsigned in
 	return res;
 }
 
+static void update_initial_connected_line(struct ast_sip_session *session)
+{
+	struct ast_party_connected_line connected;
+	struct ast_set_party_connected_line update_connected;
+	struct ast_sip_endpoint_id_configuration *id = &session->endpoint->id;
+
+	if (!id->self.number.valid && !id->self.name.valid) {
+		return;
+	}
+
+	/* Supply initial connected line information if available. */
+	memset(&update_connected, 0, sizeof(update_connected));
+	ast_party_connected_line_init(&connected);
+	connected.id.number = id->self.number;
+	connected.id.name = id->self.name;
+	connected.id.tag = id->self.tag;
+	connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+
+	if (connected.id.number.valid) {
+		update_connected.id.number = 1;
+	}
+
+	if (connected.id.name.valid) {
+		update_connected.id.name = 1;
+	}
+
+	/* Invalidate any earlier private connected id representation */
+	ast_set_party_id_all(&update_connected.priv);
+
+	ast_channel_queue_connected_line_update(session->channel, &connected, &update_connected);
+}
+
 static int call(void *data)
 {
 	struct ast_sip_session *session = data;
@@ -1477,6 +1509,7 @@ static int call(void *data)
 	if (res) {
 		ast_queue_hangup(session->channel);
 	} else {
+		update_initial_connected_line(session);
 		ast_sip_session_send_request(session, tdata);
 	}
 	ao2_ref(session, -1);
-- 
GitLab