[calls] sip: origin: Honor preferred codecs for incoming calls



commit fec3451cd02dea596c141309e576b166834a3778
Author: eladyn <eladyn protonmail com>
Date:   Sun May 29 17:32:55 2022 +0200

    sip: origin: Honor preferred codecs for incoming calls
    
    This enables proper negotiation of the codec when answering calls, which
    previously also responded with codecs that were not part of the users
    preferred ones.
    
    Fixes: #413

 plugins/sip/calls-sip-origin.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c
index 9ac719c5..d475a738 100644
--- a/plugins/sip/calls-sip-origin.c
+++ b/plugins/sip/calls-sip-origin.c
@@ -590,9 +590,21 @@ sip_i_state (int              status,
   }
 
   if (r_sdp) {
-    g_autoptr (GList) codecs =
+    g_autoptr (GList) remote_codecs =
       calls_sip_media_manager_get_codecs_from_sdp (origin->media_manager,
                                                    r_sdp->sdp_media);
+    GList *preferred_codecs = calls_sip_media_manager_codec_candidates (origin->media_manager);
+    g_autoptr (GList) codecs = NULL;
+    GList *node;
+
+    for (node = remote_codecs; node != NULL; node = node->next) {
+      MediaCodecInfo *codec = node->data;
+      if (g_list_find (preferred_codecs, codec)) {
+        g_debug ("Found common codec: %s", codec->name);
+        codecs = g_list_append (codecs, codec);
+      }
+    }
+
     g_autoptr (CallsSdpCryptoContext) ctx = NULL;
     const char *session_ip = NULL;
     const char *media_ip = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]