/* 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_delete_link (walk1, walk2); goto again; } } } return list; }
static void codec_cap_list_free (GList *list) { GList *mwalk; for (mwalk = list; mwalk; mwalk = g_list_next (mwalk)) { codec_cap_free ((CodecCap *)mwalk->data); } g_list_free (list); }
/* Removes all dynamic pts that already have a static pt in the list */ static GList * remove_dynamic_duplicates (GList *list) { GList *walk1, *walk2; CodecCap *codec_cap, *cur_codec_cap; GstStructure *rtp_struct, *cur_rtp_struct; const gchar *encoding_name, *cur_encoding_name; GList *remove_us = NULL; for (walk1 = list; walk1; walk1 = g_list_next (walk1)) { const GValue *value; GType type; codec_cap = (CodecCap *)(walk1->data); rtp_struct = gst_caps_get_structure (codec_cap->rtp_caps, 0); encoding_name = gst_structure_get_string (rtp_struct, "encoding-name"); if (!encoding_name) continue; /* let's skip all non static payload types */ value = gst_structure_get_value (rtp_struct, "payload"); type = G_VALUE_TYPE (value); if (type != G_TYPE_INT) { continue; } else { gint payload_type; payload_type = g_value_get_int (value); if (payload_type >= 96) { continue; } } for (walk2 = list; walk2; walk2 = g_list_next (walk2)) { cur_codec_cap = (CodecCap *)(walk2->data); cur_rtp_struct = gst_caps_get_structure (cur_codec_cap->rtp_caps, 0); cur_encoding_name = gst_structure_get_string (cur_rtp_struct, "encoding-name"); if (!cur_encoding_name) continue; if (g_ascii_strcasecmp (encoding_name, cur_encoding_name) == 0) { const GValue *value = gst_structure_get_value (cur_rtp_struct, "payload"); GType type = G_VALUE_TYPE (value); /* this is a dynamic pt that has a static one , let's remove it */ if (type == GST_TYPE_INT_RANGE) remove_us = g_list_prepend (remove_us, cur_codec_cap); } } } for (walk1 = remove_us; walk1; walk1 = g_list_next (walk1)) { list = g_list_remove_all (list, walk1->data); codec_cap_free (walk1->data); } g_list_free (remove_us); return list; }