[farsight2/master] rtp: Lookup codec with config is always for sending, so make it explicit

Olivier Crête olivier.crete at collabora.co.uk
Mon Nov 9 12:33:52 PST 2009


Also, the dtmf sound will always get a valid codec now.
---
 gst/fsrtpconference/fs-rtp-codec-negotiation.c |   15 ++++++++++-----
 gst/fsrtpconference/fs-rtp-codec-negotiation.h |    2 +-
 gst/fsrtpconference/fs-rtp-dtmf-sound-source.c |    2 +-
 gst/fsrtpconference/fs-rtp-session.c           |   20 ++++----------------
 4 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-codec-negotiation.c b/gst/fsrtpconference/fs-rtp-codec-negotiation.c
index 4c30595..2561d79 100644
--- a/gst/fsrtpconference/fs-rtp-codec-negotiation.c
+++ b/gst/fsrtpconference/fs-rtp-codec-negotiation.c
@@ -1245,18 +1245,18 @@ codec_associations_list_are_equal (GList *list1, GList *list2)
 
 
 /**
- * lookup_codec_association_by_codec_without_config:
+ * lookup_codec_association_by_codec_for_sending
  * @codec_associations: a #GList of #CodecAssociation
  * @codec: The #FsCodec to look for
  *
- * Finds the first #CodecAssociation that matches the #FsCodec, the config data
- * inside both are removed.
+ * Finds the first #CodecAssociation that matches the #FsCodec and that is
+ * valid for sending, the config data inside both are ignored.
  *
  * Returns: a #CodecAssociation
  */
 
 CodecAssociation *
-lookup_codec_association_by_codec_without_config (GList *codec_associations,
+lookup_codec_association_by_codec_for_sending (GList *codec_associations,
     FsCodec *codec)
 {
   FsCodec *lookup_codec = codec_copy_without_config (codec);
@@ -1265,7 +1265,12 @@ lookup_codec_association_by_codec_without_config (GList *codec_associations,
   while (codec_associations)
   {
     CodecAssociation *tmpca = codec_associations->data;
-    FsCodec *tmpcodec = codec_copy_without_config (tmpca->codec);
+    FsCodec *tmpcodec;
+
+    if (!codec_association_is_valid_for_sending (tmpca, FALSE))
+      continue;
+
+    tmpcodec = codec_copy_without_config (tmpca->codec);
 
     if (fs_codec_are_equal (tmpcodec, lookup_codec))
       ca = tmpca;
diff --git a/gst/fsrtpconference/fs-rtp-codec-negotiation.h b/gst/fsrtpconference/fs-rtp-codec-negotiation.h
index 55e45c7..e12c203 100644
--- a/gst/fsrtpconference/fs-rtp-codec-negotiation.h
+++ b/gst/fsrtpconference/fs-rtp-codec-negotiation.h
@@ -92,7 +92,7 @@ CodecAssociation *
 lookup_codec_association_by_codec (GList *codec_associations, FsCodec *codec);
 
 CodecAssociation *
-lookup_codec_association_by_codec_without_config (GList *codec_associations,
+lookup_codec_association_by_codec_for_sending (GList *codec_associations,
     FsCodec *codec);
 
 gboolean
diff --git a/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c b/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c
index 7bd56f2..bce405c 100644
--- a/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c
+++ b/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c
@@ -157,7 +157,7 @@ _check_element_factory (gchar *name)
 static CodecAssociation *
 _get_main_codec_association (GList *codec_associations, FsCodec *codec)
 {
-  CodecAssociation *ca = lookup_codec_association_by_codec_without_config (
+  CodecAssociation *ca = lookup_codec_association_by_codec_for_sending (
       codec_associations, codec);
 
   if (ca && codec_association_is_valid_for_sending (ca, TRUE) &&
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 1cc7ab5..eda0545 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -1690,7 +1690,7 @@ fs_rtp_session_set_send_codec (FsSession *session, FsCodec *send_codec,
 
   FS_RTP_SESSION_LOCK (self);
 
-  if (lookup_codec_association_by_codec_without_config (
+  if (lookup_codec_association_by_codec_for_sending (
           self->priv->codec_associations, send_codec))
   {
     if (self->priv->requested_send_codec)
@@ -2896,25 +2896,13 @@ fs_rtp_session_select_send_codec_locked (FsRtpSession *session,
 
   if (session->priv->requested_send_codec)
   {
-    ca = lookup_codec_association_by_codec_without_config (
+    ca = lookup_codec_association_by_codec_for_sending (
         session->priv->codec_associations,
         session->priv->requested_send_codec);
     if (ca)
     {
-      if (!codec_association_is_valid_for_sending (ca, TRUE))
-      {
-        fs_codec_destroy (session->priv->requested_send_codec);
-        session->priv->requested_send_codec = NULL;
-        ca = NULL;
-        GST_DEBUG_OBJECT (session->priv->conference,
-            "The current requested codec is not a valid main send codec,"
-            " ignoring");
-      }
-      else
-      {
-        /* We have a valid codec, lets use it */
-        goto out;
-      }
+      /* We have a valid codec, lets use it */
+      goto out;
     }
     else
     {
-- 
1.5.6.5




More information about the farsight-commits mailing list