summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2012-03-21 19:03:18 (GMT)
committerOlivier CrĂȘte <olivier.crete@collabora.com>2012-03-21 19:03:18 (GMT)
commit7d26b23ce613498f86ddb0723e929c9868ac17de (patch)
treee936dfbe7b01e89f5d3cd99da41ecdf6d6ec1358
parent56d3f36341d9f6a6eeff38db22f7cb25ee46fb7c (diff)
downloadfarstream-7d26b23ce613498f86ddb0723e929c9868ac17de.tar.gz
farstream-7d26b23ce613498f86ddb0723e929c9868ac17de.tar.xz
rtpdiscovercodecs: Remove duplicate codecs
Only keep the first codec if there is more than one way to produce the same RTP codec
-rw-r--r--gst/fsrtpconference/fs-rtp-discover-codecs.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gst/fsrtpconference/fs-rtp-discover-codecs.c b/gst/fsrtpconference/fs-rtp-discover-codecs.c
index 6f65860..5b26cd9 100644
--- a/gst/fsrtpconference/fs-rtp-discover-codecs.c
+++ b/gst/fsrtpconference/fs-rtp-discover-codecs.c
@@ -68,6 +68,7 @@ typedef gboolean (FilterFunc) (GstElementFactory *factory);
static gboolean create_codec_lists (FsMediaType media_type,
GList *recv_list, GList *send_list);
static GList *remove_dynamic_duplicates (GList *list);
+static GList *remove_duplicates (GList *list);
static void parse_codec_cap_list (GList *list, FsMediaType media_type);
static GList *detect_send_codecs (GstCaps *caps);
static GList *detect_recv_codecs (GstCaps *caps);
@@ -309,6 +310,7 @@ create_codec_lists (FsMediaType media_type,
debug_codec_cap_list (duplex_list);
duplex_list = remove_dynamic_duplicates (duplex_list);
+ duplex_list = remove_duplicates (duplex_list);
if (!duplex_list) {
GST_WARNING ("Dynamic duplicate removal left us with nothing");
@@ -516,6 +518,33 @@ remove_dynamic_duplicates (GList *list)
return list;
}
+/* Removes duplicate codecs that have the same RTP expression */
+static GList *
+remove_duplicates (GList *list)
+{
+ GList *walk1, *walk2;
+
+ for (walk1 = list; walk1; walk1 = g_list_next (walk1))
+ {
+ CodecCap *codec_cap1 = walk1->data;
+
+ again:
+ for (walk2 = walk1->next; walk2; walk2 = g_list_next (walk2))
+ {
+ CodecCap *codec_cap2 = walk2->data;
+
+ if (gst_caps_is_equal (codec_cap1->rtp_caps, codec_cap2->rtp_caps))
+ {
+ codec_cap_free (codec_cap2);
+ walk1 = g_list_remove_link (walk1, walk2);
+ goto again;
+ }
+ }
+ }
+
+ return list;
+}
+
static GList *
copy_element_list (GList *inlist)
{