[calls] sip: origin: Pass telephone number to the call object



commit e2acfd37948163279f8cee9f0fb1e91eead085a8
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Fri Dec 10 05:16:58 2021 +0100

    sip: origin: Pass telephone number to the call object
    
    If the origin is used for PSTN telephony extract the number from the
    SIP dialstring (i.e. sip:+49160123456789 my-sip-host de) and pass that
    to call object for contact matching.

 plugins/sip/calls-sip-origin.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c
index 04a823d3..2a8cf54d 100644
--- a/plugins/sip/calls-sip-origin.c
+++ b/plugins/sip/calls-sip-origin.c
@@ -215,11 +215,21 @@ add_call (CallsSipOrigin *self,
   CallsSipCall *sip_call;
   CallsCall *call;
   g_autofree gchar *local_sdp = NULL;
+  g_auto (GStrv)  address_split = NULL;
+  const char *call_address = address;
 
   /* TODO get free port by creating GSocket and passing that to the pipeline */
   guint local_port = get_port_for_rtp ();
 
-  sip_call = calls_sip_call_new (address, inbound, handle);
+  if (self->can_tel) {
+    address_split = g_strsplit_set (address, ":@;", -1);
+
+    if (g_strv_length (address_split) >=2 &&
+        g_strcmp0 (address_split[2], self->host) == 0)
+      call_address = address_split[2];
+  }
+
+  sip_call = calls_sip_call_new (call_address, inbound, handle);
   g_assert (sip_call != NULL);
 
   if (self->oper->call_handle)
@@ -248,8 +258,6 @@ add_call (CallsSipOrigin *self,
 
     g_debug ("Setting local SDP for outgoing call to %s:\n%s", address, local_sdp);
 
-    /* TODO transform tel URI according to https://tools.ietf.org/html/rfc3261#section-19.1.6 */
-
     /* TODO handle IPv4 vs IPv6 for nua_invite (SOATAG_TAG) */
     nua_invite (self->oper->call_handle,
                 SOATAG_AF (SOA_AF_IP4_IP6),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]