[farsight2/master] Check if there are src/sink pads in the profiles that match the codec
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:25:46 PST 2008
---
gst/fsrtpconference/fs-rtp-codec-negotiation.c | 53 ++++++++++++++++++++++--
tests/check/rtp/codecs.c | 2 +-
2 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/gst/fsrtpconference/fs-rtp-codec-negotiation.c b/gst/fsrtpconference/fs-rtp-codec-negotiation.c
index 3d5db51..7119e2f 100644
--- a/gst/fsrtpconference/fs-rtp-codec-negotiation.c
+++ b/gst/fsrtpconference/fs-rtp-codec-negotiation.c
@@ -121,13 +121,38 @@ parse_bin_from_description_all_linked (const gchar *bin_description,
return NULL;
}
+static gint
+find_matching_pad (gconstpointer a, gconstpointer b)
+{
+ GstPad *pad = GST_PAD (a);
+ GstCaps *caps = GST_CAPS (b);
+ GstCaps *padcaps = NULL;
+ GstCaps *intersect = NULL;
+ gint ret = 1;
+
+ padcaps = gst_pad_get_caps (pad);
+ intersect = gst_caps_intersect (caps, padcaps);
+
+ if (intersect && !gst_caps_is_empty (intersect))
+ ret = 0;
+
+ gst_caps_unref (intersect);
+ gst_caps_unref (padcaps);
+ gst_object_unref (pad);
+
+ return ret;
+}
+
static gboolean
-validate_codec_profile (const gchar *bin_description, gboolean is_send)
+validate_codec_profile (FsCodec *codec,const gchar *bin_description,
+ gboolean is_send)
{
GError *error = NULL;
GstElement *bin = NULL;
guint src_pad_count = 0, sink_pad_count = 0;
-
+ GstCaps *caps;
+ gpointer matching_pad = NULL;;
+ GstIterator *iter;
bin = parse_bin_from_description_all_linked (bin_description,
&src_pad_count, &sink_pad_count, &error);
@@ -142,6 +167,26 @@ validate_codec_profile (const gchar *bin_description, gboolean is_send)
}
g_clear_error (&error);
+ caps = fs_codec_to_gst_caps (codec);
+
+ if (is_send)
+ iter = gst_element_iterate_src_pads (bin);
+ else
+ iter = gst_element_iterate_sink_pads (bin);
+
+ matching_pad = gst_iterator_find_custom (iter, find_matching_pad, caps);
+ gst_iterator_free (iter);
+
+ if (!matching_pad)
+ {
+ GST_WARNING ("Invalid profile (%s), has no %s pad that matches the codec"
+ " details", is_send ? "src" : "sink", bin_description);
+ gst_caps_unref (caps);
+ gst_object_unref (bin);
+ return FALSE;
+ }
+
+ gst_caps_unref (caps);
gst_object_unref (bin);
if (is_send)
@@ -257,11 +302,11 @@ validate_codecs_configuration (FsMediaType media_type, GList *blueprints,
/* If there are send and/or recv profiles, lets test them */
param = fs_codec_get_optional_parameter (codec, RECV_PROFILE_ARG, NULL);
- if (param && !validate_codec_profile (param->value, FALSE))
+ if (param && !validate_codec_profile (codec, param->value, FALSE))
goto remove_this_codec;
param = fs_codec_get_optional_parameter (codec, SEND_PROFILE_ARG, NULL);
- if (param && !validate_codec_profile (param->value, TRUE))
+ if (param && !validate_codec_profile (codec, param->value, TRUE))
goto remove_this_codec;
/* If no blueprint was found */
diff --git a/tests/check/rtp/codecs.c b/tests/check/rtp/codecs.c
index 8ef6359..ff11fc1 100644
--- a/tests/check/rtp/codecs.c
+++ b/tests/check/rtp/codecs.c
@@ -780,7 +780,7 @@ profile_test (const gchar *send_profile, const gchar *recv_profile,
GstElement *conf;
FsSession *session;
GList *codecs;
- FsCodec *base_codec = fs_codec_new (120, "test-codec", FS_MEDIA_TYPE_AUDIO,
+ FsCodec *base_codec = fs_codec_new (120, "PCMA", FS_MEDIA_TYPE_AUDIO,
8000);
FsCodec *pref_codec = fs_codec_copy (base_codec);
GList *prefs = g_list_append (NULL, pref_codec);
--
1.5.6.5
More information about the farsight-commits
mailing list