[Freeswitch-svn] [commit] r8280 - in freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua: nta nta/sofia-sip nua nua/sofia-sip

Freeswitch SVN mikej at freeswitch.org
Tue May 6 18:28:21 EDT 2008


Author: mikej
Date: Tue May  6 18:28:20 2008
New Revision: 8280

Modified:
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua.h

Log:
add nua_handle_by_call_id

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c	Tue May  6 18:28:20 2008
@@ -4022,6 +4022,27 @@
   return leg;
 }
 
+/** Get dialog leg by @CallID.
+ *
+ * @since New in @VERSION_1_12_9.
+ */
+SOFIAPUBFUN
+nta_leg_t *nta_leg_by_call_id(nta_agent_t *sa, const char *call_id)
+{
+  nta_leg_t *leg = NULL;
+
+  if (call_id) {
+    sip_call_id_t id[1];
+    sip_call_id_init(id);
+
+    id->i_hash = msg_hash_string(id->i_id = call_id);
+
+    leg = leg_find(sa, NULL, NULL, id, NULL, NULL);
+  }
+
+  return leg;
+}
+
 /** Calculate a simple case-insensitive hash over a string */
 su_inline
 hash_value_t hash_istring(char const *s, char const *term, hash_value_t hash)

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta.h	Tue May  6 18:28:20 2008
@@ -253,6 +253,10 @@
 SOFIAPUBFUN
 nta_leg_t *nta_leg_by_replaces(nta_agent_t *, sip_replaces_t const *);
 
+/** Get dialog leg by CallID */
+SOFIAPUBFUN
+nta_leg_t *nta_leg_by_call_id(nta_agent_t *sa, const char *call_id);
+
 /* ----------------------------------------------------------------------
  * 6) Prototypes for incoming transactions 
  */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua.c	Tue May  6 18:28:20 2008
@@ -1005,6 +1005,21 @@
   return 0;
 }
 
+struct nua_stack_handle_by_call_id_args {
+  nua_handle_t *retval;
+  nua_t *nua;
+  const char *call_id;
+};
+
+static int nua_stack_handle_by_call_id_call(void *arg)
+{
+  struct nua_stack_handle_by_call_id_args *a = arg;
+
+  a->retval = nua_stack_handle_by_call_id(a->nua, a->call_id);
+
+  return 0;
+}
+
 /** Obtain a new reference to an existing handle based on @Replaces header.
  *
  * @since New in @VERSION_1_12_4.
@@ -1039,3 +1054,38 @@
   }
   return NULL;
 }
+
+/** Obtain a new reference to an existing handle based on @CallID.
+ *
+ * @since New in @VERSION_1_12_9.
+ *
+ * @note
+ * You should release the reference with nua_handle_unref() when you are
+ * done with the handle.
+ *
+ * @sa nua_handle_make_replaces(), @Replaces, @RFC3891, nua_refer(),
+ * #nua_i_refer, @ReferTo, nta_leg_by_replaces()
+ */
+nua_handle_t *nua_handle_by_call_id(nua_t *nua, const char *call_id)
+{
+  if (nua) {
+#if HAVE_OPEN_C
+    struct nua_stack_handle_by_call_id_args a;
+	a.retval = NULL;
+    a.nua = nua;
+    a.call_id = call_id;
+#else
+    struct nua_stack_handle_by_call_id_args a = { NULL, nua, call_id };
+#endif
+
+    if (su_task_execute(nua->nua_server,
+			nua_stack_handle_by_call_id_call, (void *)&a,
+			NULL) == 0) {
+      nua_handle_t *nh = a.retval;
+
+      if (nh && !NH_IS_DEFAULT(nh) && nh->nh_valid)
+	return nua_handle_ref(nh);
+    }
+  }
+  return NULL;
+}

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c	Tue May  6 18:28:20 2008
@@ -1115,6 +1115,15 @@
   return NULL;
 }
 
+nua_handle_t *nua_stack_handle_by_call_id(nua_t *nua, const char *call_id)
+{
+  if (nua) {
+    nta_leg_t *leg = nta_leg_by_call_id(nua->nua_nta, call_id);
+    if (leg)
+      return nta_leg_magic(leg, nua_stack_process_request);
+  }
+  return NULL;
+}
 
 /** @internal Add authorization data */
 int nh_authorize(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h	Tue May  6 18:28:20 2008
@@ -380,6 +380,9 @@
 nua_handle_t *nua_stack_handle_by_replaces(nua_t *nua,
 					   sip_replaces_t const *r);
 
+nua_handle_t *nua_stack_handle_by_call_id(nua_t *nua, const char *call_id);
+
+
 /* ---------------------------------------------------------------------- */
 
 int nua_stack_set_defaults(nua_handle_t *nh, nua_handle_preferences_t *nhp);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua.h	Tue May  6 18:28:20 2008
@@ -384,6 +384,7 @@
 SOFIAPUBFUN nua_handle_t *nua_handle_by_replaces(nua_t *nua,
 						 sip_replaces_t const *rp);
 
+nua_handle_t *nua_handle_by_call_id(nua_t *nua, const char *call_id);
 
 SOFIA_END_DECLS
 



More information about the Freeswitch-svn mailing list