#include <gst/pbutils/pbutils.h>
#include "gstplaybackelements.h"
+#include "gstplaybackutils.h"
#include "gstrawcaps.h"
/**
GstStream *stream =
gst_stream_collection_get_stream (input->collection, i);
/* Only add if not already present in the list */
- if (!g_list_find (unsorted_streams, stream))
+ if (!gst_playback_utils_stream_in_list (unsorted_streams, stream))
unsorted_streams = g_list_append (unsorted_streams, stream);
}
}
* and then by factory name */
return gst_plugin_feature_rank_compare_func (p1, p2);
}
+
+/* gst_playback_utils_stream_in_list:
+ * @streams: A list of #GstStream
+ * @stream: A #GstStream
+ *
+ * Searchs whether the given @stream is present in @streams. This also handles
+ * the case where the actual @stream was rewritten but contains the same
+ * stream-id and type.
+ *
+ * Returns: TRUE if @stream is in @streams.
+ *
+ **/
+gboolean
+gst_playback_utils_stream_in_list (GList * streams, GstStream * stream)
+{
+ GList *iter;
+ const gchar *stream_id = gst_stream_get_stream_id (stream);
+ GstStreamType stream_type = gst_stream_get_stream_type (stream);
+
+ for (iter = streams; iter; iter = iter->next) {
+ GstStream *cand = iter->data;
+
+ if (iter->data == stream)
+ return TRUE;
+ /* Compare the stream type */
+ if (gst_stream_get_stream_type (cand) != stream_type)
+ continue;
+ /* Compare the stream-id */
+ if (!g_strcmp0 (stream_id, gst_stream_get_stream_id (cand)))
+ return TRUE;
+ }
+
+ return FALSE;
+}
GstPlayFlags flags,
gboolean isaudioelement);
G_GNUC_INTERNAL
-gint
-gst_playback_utils_compare_factories_func (gconstpointer p1, gconstpointer p2);
+gint gst_playback_utils_compare_factories_func(gconstpointer p1,
+ gconstpointer p2);
+
+G_GNUC_INTERNAL
+gboolean gst_playback_utils_stream_in_list(GList *streams, GstStream *stream);
+
G_END_DECLS
#endif /* __GST_PLAYBACK_UTILS_H__ */
for (iter = info->outputs; iter; iter = iter->next) {
OutputSlotInfo *output = iter->data;
- if (output->stream && !g_list_find (streams, output->stream)) {
+ if (output->stream
+ && !gst_playback_utils_stream_in_list (streams, output->stream)) {
GST_DEBUG_OBJECT (output->originating_pad,
"No longer used in new collection");
unused_slots = g_list_append (unused_slots, output);
for (i = 0; i < len; i++) {
GstStream *stream =
gst_stream_collection_get_stream (info->collection, i);
- if (!g_list_find (streams, stream)) {
+ if (!gst_playback_utils_stream_in_list (streams, stream)) {
streams = g_list_append (streams, stream);
}
}