1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-07-07 09:29:30 +00:00
Purism-Calls/plugins/sip/calls-sip-media-manager.c
Evangelos Ribeiro Tzaras 967f30d688 sip: Add media manager and sipify origin
* pipeline: we should bind the used socket of our udpsink to the socket udpsrc
2021-04-03 00:08:31 +02:00

128 lines
3.3 KiB
C

/*
* 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
*
*/
#define G_LOG_DOMAIN "CallsCallsSipMediaManager"
#include "calls-sip-media-pipeline.h"
#include "gst-rfc3551.h"
#include "calls-sip-media-manager.h"
#include <gst/gst.h>
typedef struct _CallsSipMediaManager
{
GObject parent;
} CallsSipMediaManager;
G_DEFINE_TYPE (CallsSipMediaManager, calls_sip_media_manager, G_TYPE_OBJECT);
MediaCodecInfo*
get_best_codec (CallsSipMediaManager *self)
{
return media_codec_by_name ("PCMU");
}
static void
calls_sip_media_manager_finalize (GObject *object)
{
gst_deinit ();
G_OBJECT_CLASS (calls_sip_media_manager_parent_class)->finalize (object);
}
static void
calls_sip_media_manager_class_init (CallsSipMediaManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = calls_sip_media_manager_finalize;
}
static void
calls_sip_media_manager_init (CallsSipMediaManager *self)
{
gst_init (NULL, NULL);
}
/* Public functions */
CallsSipMediaManager *
calls_sip_media_manager_default ()
{
static CallsSipMediaManager *instance = NULL;
if (instance == NULL) {
g_debug ("Creating CallsSipMediaManager");
instance = g_object_new (CALLS_TYPE_SIP_MEDIA_MANAGER, NULL);
g_object_add_weak_pointer (G_OBJECT (instance), (gpointer *) &instance);
}
return instance;
}
/* calls_sip_media_manager_static_capabilities:
*
* @port: Should eventually come from the ICE stack
* @use_srtp: Whether to use srtp (not really handled)
*
* Returns: (full-control) string describing capabilities
* to be used in the session description (SDP)
*/
char *
calls_sip_media_manager_static_capabilities (CallsSipMediaManager *self,
guint port,
gboolean use_srtp)
{
char *attribute_line = "rtpmap:0 PCMU/8000";
char *payload_type = use_srtp ? "SAVP" : "AVP";
g_autofree char *media_line = NULL;
g_return_val_if_fail (CALLS_IS_SIP_MEDIA_MANAGER (self), NULL);
media_line = g_strdup_printf ("audio %d RTP/%s 0", port, payload_type);
/* TODO we can have multiple attribute lines (or media lines for that matter) */
/* TODO add attribute describing RTCP stream */
return g_strdup_printf ("v=0\r\n"
"m=%s\r\n"
"a=%s\r\n",
media_line,
attribute_line);
}
/* TODO lookup plugins in GStreamer */
gboolean
calls_sip_media_manager_supports_media (CallsSipMediaManager *self,
const char *media_type)
{
return TRUE;
}