mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-05 19:15:32 +00:00
sip: Gather public IP from REGISTER response and use it in SDP
Fixes #335
This commit is contained in:
parent
b8efaf1f66
commit
36880c3d34
3 changed files with 76 additions and 6 deletions
|
@ -39,22 +39,52 @@
|
|||
* shall also manage the #CallsSipMediaPipeline objects that are in use.
|
||||
*/
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SESSION_IP,
|
||||
PROP_LAST_PROP
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
||||
typedef struct _CallsSipMediaManager
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
char *session_ip;
|
||||
GList *supported_codecs;
|
||||
} CallsSipMediaManager;
|
||||
|
||||
G_DEFINE_TYPE (CallsSipMediaManager, calls_sip_media_manager, G_TYPE_OBJECT);
|
||||
|
||||
|
||||
static void
|
||||
calls_sip_media_manager_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CallsSipMediaManager *self = CALLS_SIP_MEDIA_MANAGER (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_SESSION_IP:
|
||||
calls_sip_media_manager_set_session_ip (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_sip_media_manager_finalize (GObject *object)
|
||||
{
|
||||
CallsSipMediaManager *self = CALLS_SIP_MEDIA_MANAGER (object);
|
||||
gst_deinit ();
|
||||
|
||||
g_list_free (CALLS_SIP_MEDIA_MANAGER (object)->supported_codecs);
|
||||
g_list_free (self->supported_codecs);
|
||||
g_free (self->session_ip);
|
||||
|
||||
G_OBJECT_CLASS (calls_sip_media_manager_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -65,7 +95,17 @@ calls_sip_media_manager_class_init (CallsSipMediaManagerClass *klass)
|
|||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = calls_sip_media_manager_set_property;
|
||||
object_class->finalize = calls_sip_media_manager_finalize;
|
||||
|
||||
props[PROP_SESSION_IP] =
|
||||
g_param_spec_string ("session-ip",
|
||||
"Session IP",
|
||||
"The public IP used as the session line in SDP",
|
||||
NULL,
|
||||
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,11 +185,21 @@ calls_sip_media_manager_get_capabilities (CallsSipMediaManager *self,
|
|||
g_string_append_printf (attribute_lines, "a=rtcp:%d\r\n", port + 1);
|
||||
|
||||
done:
|
||||
return g_strdup_printf ("v=0\r\n"
|
||||
"%s\r\n"
|
||||
"%s\r\n",
|
||||
media_line->str,
|
||||
attribute_lines->str);
|
||||
if (self->session_ip && *self->session_ip)
|
||||
return g_strdup_printf ("v=0\r\n"
|
||||
"s=%s\r\n"
|
||||
"%s\r\n"
|
||||
"%s\r\n",
|
||||
self->session_ip,
|
||||
media_line->str,
|
||||
attribute_lines->str);
|
||||
else
|
||||
return g_strdup_printf ("v=0\r\n"
|
||||
"%s\r\n"
|
||||
"%s\r\n",
|
||||
media_line->str,
|
||||
attribute_lines->str);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -236,3 +286,17 @@ calls_sip_media_manager_get_codecs_from_sdp (CallsSipMediaManager *self,
|
|||
|
||||
return codecs;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
calls_sip_media_manager_set_session_ip (CallsSipMediaManager *self,
|
||||
const char *session_ip)
|
||||
{
|
||||
g_return_if_fail (CALLS_IS_SIP_MEDIA_MANAGER (self));
|
||||
|
||||
g_clear_pointer (&self->session_ip, g_free);
|
||||
if (session_ip && *session_ip) {
|
||||
g_debug ("Setting session IP to %s", session_ip);
|
||||
self->session_ip = g_strdup (session_ip);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,5 +51,7 @@ MediaCodecInfo* get_best_codec (Cal
|
|||
GList * calls_sip_media_manager_codec_candidates (CallsSipMediaManager *self);
|
||||
GList * calls_sip_media_manager_get_codecs_from_sdp (CallsSipMediaManager *self,
|
||||
sdp_media_t *sdp_media);
|
||||
void calls_sip_media_manager_set_session_ip (CallsSipMediaManager *self,
|
||||
const char *session_ip);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -402,6 +402,10 @@ sip_r_register (int status,
|
|||
g_debug ("REGISTER successful");
|
||||
origin->state = CALLS_ACCOUNT_ONLINE;
|
||||
nua_get_params (nua, TAG_ANY (), TAG_END());
|
||||
if (sip->sip_contact && sip->sip_contact->m_url && sip->sip_contact->m_url->url_host) {
|
||||
calls_sip_media_manager_set_session_ip (origin->media_manager,
|
||||
sip->sip_contact->m_url->url_host);
|
||||
}
|
||||
|
||||
} else if (status == 401 || status == 407) {
|
||||
sip_authenticate (origin, nh, sip);
|
||||
|
|
Loading…
Reference in a new issue