[farsight2/master] Create new local codecs from previously negotiated ones

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:22:41 PST 2008


---
 gst/fsrtpconference/fs-rtp-codec-negotiation.c |   53 ++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-codec-negotiation.c b/gst/fsrtpconference/fs-rtp-codec-negotiation.c
index 7515ac1..0a91c87 100644
--- a/gst/fsrtpconference/fs-rtp-codec-negotiation.c
+++ b/gst/fsrtpconference/fs-rtp-codec-negotiation.c
@@ -255,6 +255,24 @@ _is_disabled (GList *codec_prefs, CodecBlueprint *bp)
   return FALSE;
 }
 
+/*
+ * This function should return TRUE if the codec pref is a "base" of the
+ * negotiated codec, but %FALSE otherwise.
+ */
+
+static gboolean
+match_original_codec_and_codec_pref (CodecAssociation *ca, gpointer user_data)
+{
+  FsCodec *codec_pref = user_data;
+  FsCodec *tmpcodec = NULL;
+
+  tmpcodec = sdp_is_compat (codec_pref, ca->codec);
+
+  if (tmpcodec)
+    fs_codec_destroy (tmpcodec);
+
+  return (tmpcodec != NULL);
+}
 
 GList *
 create_local_codec_associations (
@@ -304,6 +322,41 @@ create_local_codec_associations (
       continue;
     }
 
+    /* Now lets see if there is an existing codec that matches this preference
+     */
+
+    {
+      CodecAssociation *oldca = NULL;
+
+      if (codec_pref->id == FS_CODEC_ID_ANY)
+      {
+        oldca = lookup_codec_association_custom_intern (
+            current_codec_associations, TRUE,
+            match_original_codec_and_codec_pref, codec_pref);
+      }
+      else
+      {
+        oldca = lookup_codec_association_by_pt_list (current_codec_associations,
+            codec_pref->id, FALSE);
+        if (oldca->reserved)
+          oldca = NULL;
+      }
+
+      /* In this case, we have a matching codec association, lets keep it */
+      if (oldca)
+      {
+        FsCodec *codec = sdp_is_compat (codec_pref, oldca->codec);
+        if (codec)
+        {
+          ca = g_slice_new (CodecAssociation);
+          memcpy (ca, oldca, sizeof (CodecAssociation));
+          ca->codec = codec;
+          codec_associations = g_list_append (codec_associations, ca);
+          continue;
+        }
+      }
+    }
+
     ca = g_slice_new0 (CodecAssociation);
     ca->blueprint = bp;
     ca->codec = fs_codec_copy (codec_pref);
-- 
1.5.6.5




More information about the farsight-commits mailing list