From 58f9f5cb62aaf96c89e1a59a40c47b51c96e8347 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Thu, 7 Apr 2022 11:42:18 +0200 Subject: [PATCH] sip: media: Allow specifying SRTP for GStreamer capabilities When using SRTP the GstCaps must be set accordingly. --- plugins/sip/calls-sip-media-pipeline.c | 2 +- plugins/sip/gst-rfc3551.c | 7 +++++-- plugins/sip/gst-rfc3551.h | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/sip/calls-sip-media-pipeline.c b/plugins/sip/calls-sip-media-pipeline.c index 0eefa57..476dda5 100644 --- a/plugins/sip/calls-sip-media-pipeline.c +++ b/plugins/sip/calls-sip-media-pipeline.c @@ -656,7 +656,7 @@ pipeline_setup_codecs (CallsSipMediaPipeline *self, } /* UDP src capabilities */ - caps_string = media_codec_get_gst_capabilities (codec); + caps_string = media_codec_get_gst_capabilities (codec, FALSE); g_debug ("Capabilities:\n%s", caps_string); caps = gst_caps_from_string (caps_string); diff --git a/plugins/sip/gst-rfc3551.c b/plugins/sip/gst-rfc3551.c index a72b297..d052b01 100644 --- a/plugins/sip/gst-rfc3551.c +++ b/plugins/sip/gst-rfc3551.c @@ -106,15 +106,18 @@ media_codec_by_payload_id (guint payload_id) /* media_codec_get_gst_capabilities: * * @codec: A #MediaCodecInfo + * @use_srtp: Whether to use SRTP * * Returns: (transfer full): The capability string describing GstCaps. * Used for the RTP source element. */ gchar * -media_codec_get_gst_capabilities (MediaCodecInfo *codec) +media_codec_get_gst_capabilities (MediaCodecInfo *codec, + gboolean use_srtp) { - return g_strdup_printf ("application/x-rtp,media=(string)audio,clock-rate=(int)%u" + return g_strdup_printf ("application/%s,media=(string)audio,clock-rate=(int)%u" ",encoding-name=(string)%s,payload=(int)%u", + use_srtp ? "x-srtp" : "x-rtp", codec->clock_rate, codec->name, codec->payload_id); diff --git a/plugins/sip/gst-rfc3551.h b/plugins/sip/gst-rfc3551.h index 36d571a..9e42d20 100644 --- a/plugins/sip/gst-rfc3551.h +++ b/plugins/sip/gst-rfc3551.h @@ -47,5 +47,6 @@ typedef struct { gboolean media_codec_available_in_gst (MediaCodecInfo *codec); MediaCodecInfo *media_codec_by_name (const char *name); MediaCodecInfo *media_codec_by_payload_id (uint payload_id); -gchar *media_codec_get_gst_capabilities (MediaCodecInfo *codec); +gchar *media_codec_get_gst_capabilities (MediaCodecInfo *codec, + gboolean use_srtp); GList *media_codecs_get_candidates (void);