2021-02-02 14:48:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 Purism SPC
|
|
|
|
*
|
|
|
|
* This file is part of Calls.
|
|
|
|
*
|
|
|
|
* Calls is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calls is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calls. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-02-19 16:34:57 +00:00
|
|
|
#define G_LOG_DOMAIN "CallsSipCall"
|
|
|
|
|
2021-02-02 14:48:12 +00:00
|
|
|
|
2021-04-10 22:25:13 +00:00
|
|
|
#include "calls-call.h"
|
2021-02-02 14:48:12 +00:00
|
|
|
#include "calls-message-source.h"
|
2022-05-05 23:21:27 +00:00
|
|
|
#include "calls-sdp-crypto-context.h"
|
2021-04-10 22:25:13 +00:00
|
|
|
#include "calls-sip-call.h"
|
2022-05-05 23:21:27 +00:00
|
|
|
#include "calls-sip-enums.h"
|
2021-02-17 22:48:33 +00:00
|
|
|
#include "calls-sip-media-manager.h"
|
|
|
|
#include "calls-sip-media-pipeline.h"
|
2021-02-26 16:29:21 +00:00
|
|
|
#include "calls-sip-util.h"
|
2021-04-26 10:00:02 +00:00
|
|
|
#include "util.h"
|
2021-02-02 14:48:12 +00:00
|
|
|
|
|
|
|
#include <glib/gi18n.h>
|
2021-04-10 22:25:13 +00:00
|
|
|
|
2021-02-17 22:48:33 +00:00
|
|
|
#include <sofia-sip/nua.h>
|
2021-02-02 14:48:12 +00:00
|
|
|
|
2021-04-10 22:25:13 +00:00
|
|
|
/**
|
|
|
|
* SECTION:sip-call
|
|
|
|
* @short_description: A #CallsCall for the SIP protocol
|
|
|
|
* @Title: CallsSipCall
|
|
|
|
*
|
|
|
|
* #CallsSipCall derives from #CallsCall. Apart from allowing call control
|
|
|
|
* like answering and hanging up it also coordinates with #CallsSipMediaManager
|
|
|
|
* to prepare and control appropriate #CallsSipMediaPipeline objects.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_CALL_HANDLE,
|
2021-11-22 23:58:08 +00:00
|
|
|
PROP_IP,
|
2022-02-28 17:17:53 +00:00
|
|
|
PROP_PIPELINE,
|
2022-05-05 23:21:27 +00:00
|
|
|
PROP_MEDIA_ENCRYPTION,
|
2021-04-10 22:25:13 +00:00
|
|
|
PROP_LAST_PROP
|
|
|
|
};
|
|
|
|
static GParamSpec *props[PROP_LAST_PROP];
|
2021-02-02 14:48:12 +00:00
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
struct _CallsSipCall {
|
|
|
|
GObject parent_instance;
|
2021-02-17 22:48:33 +00:00
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
CallsSipMediaManager *manager;
|
2021-02-17 22:48:33 +00:00
|
|
|
CallsSipMediaPipeline *pipeline;
|
2021-04-08 15:57:10 +00:00
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
char *ip;
|
2021-11-22 23:58:08 +00:00
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
guint rport_rtp;
|
|
|
|
guint rport_rtcp;
|
|
|
|
gchar *remote;
|
2021-04-08 15:57:10 +00:00
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
nua_handle_t *nh;
|
|
|
|
GList *codecs;
|
2022-05-05 23:21:27 +00:00
|
|
|
|
|
|
|
CallsSdpCryptoContext *sdp_crypto_context;
|
|
|
|
SipMediaEncryption media_encryption;
|
2021-02-02 14:48:12 +00:00
|
|
|
};
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
static void calls_sip_call_message_source_interface_init (CallsMessageSourceInterface *iface);
|
2021-02-02 14:48:12 +00:00
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (CallsSipCall, calls_sip_call, CALLS_TYPE_CALL,
|
2021-02-02 14:48:12 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (CALLS_TYPE_MESSAGE_SOURCE,
|
2021-04-05 04:00:10 +00:00
|
|
|
calls_sip_call_message_source_interface_init))
|
2021-02-02 14:48:12 +00:00
|
|
|
|
|
|
|
static void
|
2021-04-05 04:00:10 +00:00
|
|
|
calls_sip_call_answer (CallsCall *call)
|
2021-02-02 14:48:12 +00:00
|
|
|
{
|
|
|
|
CallsSipCall *self;
|
2021-02-19 16:34:57 +00:00
|
|
|
g_autofree gchar *local_sdp = NULL;
|
2022-02-28 10:38:06 +00:00
|
|
|
guint rtp_port, rtcp_port;
|
2022-05-05 23:21:27 +00:00
|
|
|
g_autoptr (GList) local_crypto = NULL;
|
|
|
|
gboolean got_crypto_offer;
|
2021-02-02 14:48:12 +00:00
|
|
|
|
|
|
|
g_assert (CALLS_IS_CALL (call));
|
|
|
|
g_assert (CALLS_IS_SIP_CALL (call));
|
|
|
|
|
|
|
|
self = CALLS_SIP_CALL (call);
|
|
|
|
|
2021-02-19 16:34:57 +00:00
|
|
|
g_assert (self->nh);
|
|
|
|
|
2021-12-10 08:02:39 +00:00
|
|
|
if (calls_call_get_state (CALLS_CALL (self)) != CALLS_CALL_STATE_INCOMING) {
|
2021-02-02 14:48:12 +00:00
|
|
|
g_warning ("Call must be in 'incoming' state in order to answer");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-28 10:38:06 +00:00
|
|
|
rtp_port = calls_sip_media_pipeline_get_rtp_port (self->pipeline);
|
|
|
|
rtcp_port = calls_sip_media_pipeline_get_rtcp_port (self->pipeline);
|
|
|
|
|
2022-05-05 23:21:27 +00:00
|
|
|
got_crypto_offer =
|
|
|
|
calls_sdp_crypto_context_get_state (self->sdp_crypto_context) ==
|
|
|
|
CALLS_CRYPTO_CONTEXT_STATE_OFFER_REMOTE;
|
|
|
|
|
|
|
|
if (got_crypto_offer) {
|
|
|
|
if (self->media_encryption == SIP_MEDIA_ENCRYPTION_NONE) {
|
|
|
|
g_warning ("Encryption disabled, but got offer. Call should have already been declined!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!calls_sdp_crypto_context_generate_answer (self->sdp_crypto_context)) {
|
|
|
|
g_warning ("Could not generate answer for crypto key exchange. Aborting!");
|
2022-05-26 11:45:07 +00:00
|
|
|
CALLS_EMIT_MESSAGE(self, _("Cryptographic key exchange unsuccessful"), GTK_MESSAGE_WARNING);
|
2022-05-05 23:21:27 +00:00
|
|
|
/* XXX this should (probably) never be reached */
|
|
|
|
nua_respond (self->nh, 488, "Not acceptable here", TAG_END ());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
local_crypto = calls_sdp_crypto_context_get_crypto_candidates (self->sdp_crypto_context, FALSE);
|
|
|
|
} else {
|
|
|
|
if (self->media_encryption == SIP_MEDIA_ENCRYPTION_FORCED) {
|
|
|
|
g_warning ("Encryption forced, but got no offer. Call should have already been declined!");
|
|
|
|
return;
|
|
|
|
} else if (self->media_encryption == SIP_MEDIA_ENCRYPTION_PREFERRED) {
|
|
|
|
g_debug ("Encryption optional, got no offer. Continuing unencrypted");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-08 14:43:13 +00:00
|
|
|
local_sdp = calls_sip_media_manager_get_capabilities (self->manager,
|
2021-11-22 23:58:08 +00:00
|
|
|
self->ip,
|
2022-02-28 10:38:06 +00:00
|
|
|
rtp_port,
|
|
|
|
rtcp_port,
|
2022-05-05 23:21:27 +00:00
|
|
|
local_crypto,
|
2021-04-08 14:43:13 +00:00
|
|
|
self->codecs);
|
2021-02-19 16:34:57 +00:00
|
|
|
|
|
|
|
g_assert (local_sdp);
|
|
|
|
g_debug ("Setting local SDP to string:\n%s", local_sdp);
|
|
|
|
|
|
|
|
nua_respond (self->nh, 200, NULL,
|
|
|
|
SOATAG_USER_SDP_STR (local_sdp),
|
|
|
|
SOATAG_AF (SOA_AF_IP4_IP6),
|
|
|
|
TAG_END ());
|
2021-02-17 22:48:33 +00:00
|
|
|
|
2021-12-10 08:02:39 +00:00
|
|
|
calls_call_set_state (CALLS_CALL (self), CALLS_CALL_STATE_ACTIVE);
|
2021-02-02 14:48:12 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 22:25:13 +00:00
|
|
|
|
2021-02-02 14:48:12 +00:00
|
|
|
static void
|
2021-04-05 04:00:10 +00:00
|
|
|
calls_sip_call_hang_up (CallsCall *call)
|
2021-02-02 14:48:12 +00:00
|
|
|
{
|
|
|
|
CallsSipCall *self;
|
|
|
|
|
|
|
|
g_assert (CALLS_IS_CALL (call));
|
|
|
|
g_assert (CALLS_IS_SIP_CALL (call));
|
|
|
|
|
|
|
|
self = CALLS_SIP_CALL (call);
|
|
|
|
|
2021-12-10 08:02:39 +00:00
|
|
|
switch (calls_call_get_state (call)) {
|
2021-02-19 16:34:57 +00:00
|
|
|
case CALLS_CALL_STATE_DIALING:
|
|
|
|
nua_cancel (self->nh, TAG_END ());
|
|
|
|
g_debug ("Hanging up on outgoing ringing call");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CALLS_CALL_STATE_ACTIVE:
|
|
|
|
nua_bye (self->nh, TAG_END ());
|
|
|
|
|
|
|
|
g_debug ("Hanging up ongoing call");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CALLS_CALL_STATE_INCOMING:
|
|
|
|
nua_respond (self->nh, 480, NULL, TAG_END ());
|
|
|
|
g_debug ("Hanging up incoming call");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CALLS_CALL_STATE_DISCONNECTED:
|
|
|
|
g_warning ("Tried hanging up already disconnected call");
|
2021-02-25 13:26:11 +00:00
|
|
|
break;
|
2021-02-19 16:34:57 +00:00
|
|
|
|
|
|
|
default:
|
2021-12-10 08:02:39 +00:00
|
|
|
g_warning ("Hanging up not possible in state %d",
|
|
|
|
calls_call_get_state (call));
|
2021-02-19 16:34:57 +00:00
|
|
|
}
|
2021-02-02 14:48:12 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 22:25:13 +00:00
|
|
|
|
2021-02-02 14:48:12 +00:00
|
|
|
static void
|
|
|
|
calls_sip_call_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
CallsSipCall *self = CALLS_SIP_CALL (object);
|
|
|
|
|
|
|
|
switch (property_id) {
|
2021-02-17 22:48:33 +00:00
|
|
|
case PROP_CALL_HANDLE:
|
|
|
|
self->nh = g_value_get_pointer (value);
|
|
|
|
break;
|
|
|
|
|
2021-11-22 23:58:08 +00:00
|
|
|
case PROP_IP:
|
|
|
|
g_free (self->ip);
|
|
|
|
self->ip = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
|
2022-02-28 17:17:53 +00:00
|
|
|
case PROP_PIPELINE:
|
|
|
|
self->pipeline = g_value_dup_object (value);
|
|
|
|
break;
|
|
|
|
|
2022-05-05 23:21:27 +00:00
|
|
|
case PROP_MEDIA_ENCRYPTION:
|
|
|
|
self->media_encryption = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
|
2021-02-02 14:48:12 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2022-04-24 10:24:55 +00:00
|
|
|
calls_sip_call_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2021-02-02 14:48:12 +00:00
|
|
|
{
|
|
|
|
CallsSipCall *self = CALLS_SIP_CALL (object);
|
|
|
|
|
|
|
|
switch (property_id) {
|
2021-02-17 22:48:33 +00:00
|
|
|
case PROP_CALL_HANDLE:
|
|
|
|
g_value_set_pointer (value, self->nh);
|
|
|
|
break;
|
|
|
|
|
2021-02-02 14:48:12 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
calls_sip_call_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
CallsSipCall *self = CALLS_SIP_CALL (object);
|
|
|
|
|
2022-02-28 17:17:53 +00:00
|
|
|
calls_sip_media_pipeline_stop (self->pipeline);
|
|
|
|
|
|
|
|
g_clear_object (&self->pipeline);
|
2021-04-08 14:43:13 +00:00
|
|
|
g_clear_pointer (&self->codecs, g_list_free);
|
2021-04-08 15:57:10 +00:00
|
|
|
g_clear_pointer (&self->remote, g_free);
|
2021-11-22 23:58:08 +00:00
|
|
|
g_clear_pointer (&self->ip, g_free);
|
2021-04-08 14:43:13 +00:00
|
|
|
|
2021-02-02 14:48:12 +00:00
|
|
|
G_OBJECT_CLASS (calls_sip_call_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
calls_sip_call_class_init (CallsSipCallClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2021-04-05 04:00:10 +00:00
|
|
|
CallsCallClass *call_class = CALLS_CALL_CLASS (klass);
|
2021-02-02 14:48:12 +00:00
|
|
|
|
|
|
|
object_class->get_property = calls_sip_call_get_property;
|
|
|
|
object_class->set_property = calls_sip_call_set_property;
|
|
|
|
object_class->finalize = calls_sip_call_finalize;
|
|
|
|
|
2021-04-05 04:00:10 +00:00
|
|
|
call_class->answer = calls_sip_call_answer;
|
|
|
|
call_class->hang_up = calls_sip_call_hang_up;
|
|
|
|
|
2021-02-17 22:48:33 +00:00
|
|
|
props[PROP_CALL_HANDLE] =
|
|
|
|
g_param_spec_pointer ("nua-handle",
|
|
|
|
"NUA handle",
|
|
|
|
"The used NUA handler",
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
2021-11-22 23:58:08 +00:00
|
|
|
|
|
|
|
props[PROP_IP] =
|
|
|
|
g_param_spec_string ("own-ip",
|
|
|
|
"Own IP",
|
|
|
|
"Own IP for media and SDP",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT);
|
2022-02-28 17:17:53 +00:00
|
|
|
|
|
|
|
props[PROP_PIPELINE] =
|
|
|
|
g_param_spec_object ("pipeline",
|
|
|
|
"Pipeline",
|
|
|
|
"Media pipeline for this call",
|
|
|
|
CALLS_TYPE_SIP_MEDIA_PIPELINE,
|
|
|
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
2022-05-05 23:21:27 +00:00
|
|
|
props[PROP_MEDIA_ENCRYPTION] =
|
|
|
|
g_param_spec_enum ("media-encryption",
|
|
|
|
"Media encryption",
|
|
|
|
"The media encryption mode",
|
|
|
|
SIP_TYPE_MEDIA_ENCRYPTION,
|
|
|
|
SIP_MEDIA_ENCRYPTION_NONE,
|
|
|
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
2021-11-22 23:58:08 +00:00
|
|
|
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
2021-02-02 14:48:12 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 22:25:13 +00:00
|
|
|
|
2021-02-02 14:48:12 +00:00
|
|
|
static void
|
2021-04-05 04:00:10 +00:00
|
|
|
calls_sip_call_message_source_interface_init (CallsMessageSourceInterface *iface)
|
2021-02-02 14:48:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
calls_sip_call_init (CallsSipCall *self)
|
|
|
|
{
|
2021-02-17 22:48:33 +00:00
|
|
|
self->manager = calls_sip_media_manager_default ();
|
2022-05-05 23:21:27 +00:00
|
|
|
self->sdp_crypto_context = calls_sdp_crypto_context_new ();
|
2021-02-17 22:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-11 00:28:01 +00:00
|
|
|
/**
|
|
|
|
* calls_sip_call_setup_remote_media_connection:
|
|
|
|
* @self: A #CallsSipCall
|
|
|
|
* @remote: The remote host
|
|
|
|
* @port_rtp: The RTP port on the remote host
|
|
|
|
* @port_rtcp: The RTCP port on the remote host
|
|
|
|
*/
|
2021-02-17 22:48:33 +00:00
|
|
|
void
|
2021-04-08 12:16:35 +00:00
|
|
|
calls_sip_call_setup_remote_media_connection (CallsSipCall *self,
|
|
|
|
const char *remote,
|
|
|
|
guint port_rtp,
|
|
|
|
guint port_rtcp)
|
2021-02-17 22:48:33 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (CALLS_IS_SIP_CALL (self));
|
|
|
|
|
2021-04-08 15:57:10 +00:00
|
|
|
g_free (self->remote);
|
|
|
|
self->remote = g_strdup (remote);
|
|
|
|
self->rport_rtp = port_rtp;
|
|
|
|
self->rport_rtcp = port_rtcp;
|
|
|
|
|
2022-05-05 22:55:39 +00:00
|
|
|
g_debug ("Setting remote ports: RTP/RTCP %u/%u",
|
|
|
|
self->rport_rtp, self->rport_rtcp);
|
|
|
|
|
|
|
|
g_object_set (self->pipeline,
|
|
|
|
"remote", self->remote,
|
|
|
|
"rport-rtp", self->rport_rtp,
|
|
|
|
"rport-rtcp", self->rport_rtcp,
|
|
|
|
NULL);
|
2021-02-17 22:48:33 +00:00
|
|
|
}
|
|
|
|
|
2021-04-11 00:28:01 +00:00
|
|
|
/**
|
|
|
|
* calls_sip_call_activate_media:
|
|
|
|
* @self: A #CallsSipCall
|
|
|
|
* @enabled: %TRUE to enable the media pipeline, %FALSE to disable
|
|
|
|
*
|
|
|
|
* Controls the state of the #CallsSipMediaPipeline
|
|
|
|
*/
|
2021-02-17 22:48:33 +00:00
|
|
|
void
|
|
|
|
calls_sip_call_activate_media (CallsSipCall *self,
|
2021-02-19 16:34:57 +00:00
|
|
|
gboolean enabled)
|
2021-02-17 22:48:33 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (CALLS_IS_SIP_CALL (self));
|
2021-04-12 13:21:48 +00:00
|
|
|
|
|
|
|
/* when hanging up an incoming call the pipeline has not yet been setup */
|
|
|
|
if (self->pipeline == NULL && !enabled)
|
|
|
|
return;
|
2021-02-19 16:34:57 +00:00
|
|
|
g_return_if_fail (CALLS_IS_SIP_MEDIA_PIPELINE (self->pipeline));
|
2021-02-17 22:48:33 +00:00
|
|
|
|
|
|
|
if (enabled) {
|
2022-05-05 23:21:27 +00:00
|
|
|
gboolean negotiated = calls_sdp_crypto_context_get_is_negotiated (self->sdp_crypto_context);
|
|
|
|
|
|
|
|
if (negotiated) {
|
|
|
|
calls_srtp_crypto_attribute *remote_crypto =
|
|
|
|
calls_sdp_crypto_context_get_remote_crypto (self->sdp_crypto_context);
|
|
|
|
calls_srtp_crypto_attribute *local_crypto =
|
|
|
|
calls_sdp_crypto_context_get_local_crypto (self->sdp_crypto_context);
|
|
|
|
|
|
|
|
calls_sip_media_pipeline_set_crypto (self->pipeline, local_crypto, remote_crypto);
|
|
|
|
} else {
|
|
|
|
if (self->media_encryption == SIP_MEDIA_ENCRYPTION_FORCED) {
|
|
|
|
g_warning ("Encryption is forced, but parameters were not negotiated! Aborting");
|
|
|
|
return;
|
|
|
|
} else if (self->media_encryption == SIP_MEDIA_ENCRYPTION_PREFERRED) {
|
|
|
|
g_debug ("No encryption parameters negotiated, continuing unencrypted");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-05 22:55:39 +00:00
|
|
|
if (calls_sip_media_pipeline_get_state (self->pipeline) ==
|
|
|
|
CALLS_MEDIA_PIPELINE_STATE_NEED_CODEC) {
|
|
|
|
MediaCodecInfo *codec = (MediaCodecInfo *) self->codecs->data;
|
|
|
|
|
|
|
|
g_debug ("Setting codec '%s' for pipeline", codec->name);
|
|
|
|
calls_sip_media_pipeline_set_codec (self->pipeline, codec);
|
|
|
|
}
|
|
|
|
|
2021-02-19 16:34:57 +00:00
|
|
|
calls_sip_media_pipeline_start (self->pipeline);
|
2021-02-17 22:48:33 +00:00
|
|
|
} else {
|
2021-02-19 16:34:57 +00:00
|
|
|
calls_sip_media_pipeline_stop (self->pipeline);
|
2021-02-17 22:48:33 +00:00
|
|
|
}
|
2021-02-02 14:48:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CallsSipCall *
|
2022-02-28 17:17:53 +00:00
|
|
|
calls_sip_call_new (const gchar *id,
|
|
|
|
gboolean inbound,
|
|
|
|
const char *own_ip,
|
|
|
|
CallsSipMediaPipeline *pipeline,
|
2022-05-05 23:21:27 +00:00
|
|
|
SipMediaEncryption media_encryption,
|
2022-02-28 17:17:53 +00:00
|
|
|
nua_handle_t *handle)
|
2021-02-02 14:48:12 +00:00
|
|
|
{
|
2021-12-10 08:46:32 +00:00
|
|
|
g_return_val_if_fail (id, NULL);
|
2021-02-02 14:48:12 +00:00
|
|
|
|
2021-12-10 08:46:32 +00:00
|
|
|
return g_object_new (CALLS_TYPE_SIP_CALL,
|
|
|
|
"id", id,
|
2021-12-10 07:00:11 +00:00
|
|
|
"inbound", inbound,
|
2021-11-22 23:58:08 +00:00
|
|
|
"own-ip", own_ip,
|
2022-02-28 17:17:53 +00:00
|
|
|
"pipeline", pipeline,
|
2022-05-05 23:21:27 +00:00
|
|
|
"media-encryption", media_encryption,
|
2021-11-22 23:58:08 +00:00
|
|
|
"nua-handle", handle,
|
2022-02-12 13:37:28 +00:00
|
|
|
"call-type", CALLS_CALL_TYPE_SIP_VOICE,
|
2021-02-17 22:48:33 +00:00
|
|
|
NULL);
|
2021-02-02 14:48:12 +00:00
|
|
|
}
|
2021-02-19 16:34:57 +00:00
|
|
|
|
2021-04-11 00:28:01 +00:00
|
|
|
/**
|
|
|
|
* calls_sip_call_set_codecs:
|
|
|
|
* @self: A #CallsSipCall
|
|
|
|
* @codecs: A #GList of #MediaCodecInfo elements
|
|
|
|
*
|
|
|
|
* Set the supported codecs. This is used when answering the call
|
|
|
|
*/
|
2021-04-08 14:43:13 +00:00
|
|
|
void
|
|
|
|
calls_sip_call_set_codecs (CallsSipCall *self,
|
|
|
|
GList *codecs)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CALLS_IS_SIP_CALL (self));
|
|
|
|
g_return_if_fail (codecs);
|
|
|
|
|
|
|
|
g_list_free (self->codecs);
|
2021-09-17 14:56:47 +00:00
|
|
|
self->codecs = g_list_copy (codecs);
|
2021-04-08 14:43:13 +00:00
|
|
|
}
|
2022-05-05 23:21:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* calls_sip_call_get_sdp_crypto_context:
|
|
|
|
* @self: A #CallsSipCall
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): The #CallsSdpCryptoContext of this call
|
|
|
|
*/
|
|
|
|
CallsSdpCryptoContext *
|
|
|
|
calls_sip_call_get_sdp_crypto_context (CallsSipCall *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CALLS_IS_CALL (self), NULL);
|
|
|
|
|
|
|
|
return g_object_ref (self->sdp_crypto_context);
|
|
|
|
}
|