[calls] sip: origin: Explicitly include contact header for sofia > 1.13
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] sip: origin: Explicitly include contact header for sofia > 1.13
- Date: Fri, 16 Jul 2021 09:48:55 +0000 (UTC)
commit 864a15d79957c2dc395f4161b773dd5c258b9bc5
Author: Evangelos Ribeiro Tzaras <evangelos tzaras puri sm>
Date: Mon Jul 12 19:08:38 2021 +0200
sip: origin: Explicitly include contact header for sofia > 1.13
Fixes #304
plugins/sip/calls-sip-origin.c | 56 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
---
diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c
index 847317bc..091383cb 100644
--- a/plugins/sip/calls-sip-origin.c
+++ b/plugins/sip/calls-sip-origin.c
@@ -40,6 +40,7 @@
#include <glib/gi18n.h>
#include <glib-object.h>
+#include <sofia-sip/sofia_features.h>
#include <sofia-sip/nua.h>
#include <sofia-sip/su_tag.h>
#include <sofia-sip/su_tag_io.h>
@@ -70,6 +71,8 @@ enum {
};
static GParamSpec *props[PROP_LAST_PROP];
+static gboolean set_contact_header = FALSE;
+
struct _CallsSipOrigin
{
GObject parent_instance;
@@ -77,6 +80,7 @@ struct _CallsSipOrigin
CallsSipContext *ctx;
nua_t *nua;
CallsSipHandles *oper;
+ char *contact_header; /* Needed for sofia SIP >= 1.13 */
/* Direct connection mode is useful for debugging purposes */
gboolean use_direct_connection;
@@ -231,6 +235,7 @@ add_call (CallsSipOrigin *self,
SOATAG_AF (SOA_AF_IP4_IP6),
SOATAG_USER_SDP_STR (local_sdp),
SIPTAG_TO_STR (address),
+ TAG_IF (!!self->contact_header, SIPTAG_CONTACT_STR (self->contact_header)),
SOATAG_RTP_SORT (SOA_RTP_SORT_REMOTE),
SOATAG_RTP_SELECT (SOA_RTP_SELECT_ALL),
TAG_END ());
@@ -457,6 +462,7 @@ sip_r_register (int status,
if (status == 200) {
g_debug ("REGISTER successful");
origin->state = CALLS_ACCOUNT_ONLINE;
+ nua_get_params (nua, TAG_ANY (), TAG_END());
} else if (status == 401 || status == 407) {
sip_authenticate (origin, nh, sip);
@@ -598,6 +604,35 @@ sip_i_state (int status,
}
+static void
+sip_r_get_params (int status,
+ char const *phrase,
+ nua_t *nua,
+ CallsSipOrigin *origin,
+ nua_handle_t *nh,
+ CallsSipHandles *op,
+ sip_t const *sip,
+ tagi_t tags[])
+{
+ tagi_t *from = NULL;
+ const char *from_str = NULL;
+
+ g_debug ("response to get_params: %03d %s", status, phrase);
+
+ if (!set_contact_header)
+ return;
+
+ if ((status != 200) || ((from = tl_find (tags, siptag_from_str)) == NULL)) {
+ g_warning ("Could not find 'siptag_from_tag' among the tags");
+ return;
+ }
+
+ from_str = (const char *) from->t_value;
+ g_free (origin->contact_header);
+ origin->contact_header = g_strdup (from_str);
+}
+
+
static void
sip_callback (nua_event_t event,
int status,
@@ -694,6 +729,17 @@ sip_callback (nua_event_t event,
tags);
break;
+ case nua_r_get_params:
+ sip_r_get_params (status,
+ phrase,
+ nua,
+ origin,
+ nh,
+ op,
+ sip,
+ tags);
+ break;
+
case nua_r_set_params:
g_debug ("response to set_params: %03d %s", status, phrase);
break;
@@ -1134,6 +1180,16 @@ calls_sip_origin_constructed (GObject *object)
{
CallsSipOrigin *self = CALLS_SIP_ORIGIN (object);
g_autoptr (GError) error = NULL;
+ int major = 0;
+ int minor = 0;
+ int patch = 0;
+
+ if (sscanf (SOFIA_SIP_VERSION, "%d.%d.%d", &major, &minor, &patch) == 3) {
+ if (major > 2 || (major == 1 && minor >= 13)) {
+ /* Sofia 1.13 does no longer include the contact header by default, see #304 */
+ set_contact_header = TRUE;
+ }
+ }
if (!init_sip_account (self, &error)) {
g_warning ("Error initializing the SIP account: %s", error->message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]