#include "gst/glib-compat-private.h"
#include <string.h>
+#include <stdio.h>
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
{
GstPad parent;
+ guint index;
gboolean pushed;
GstFlowReturn result;
gboolean removed;
tee = GST_TEE (object);
+ g_hash_table_unref (tee->pad_indexes);
+
g_free (tee->last_message);
G_OBJECT_CLASS (parent_class)->finalize (object);
GST_OBJECT_FLAG_SET (tee->sinkpad, GST_PAD_FLAG_PROXY_CAPS);
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
+ tee->pad_indexes = g_hash_table_new (NULL, NULL);
+
tee->last_message = NULL;
}
static GstPad *
gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ,
- const gchar * unused, const GstCaps * caps)
+ const gchar * name_templ, const GstCaps * caps)
{
gchar *name;
GstPad *srcpad;
GstTee *tee;
GstPadMode mode;
gboolean res;
+ guint index = 0;
tee = GST_TEE (element);
GST_DEBUG_OBJECT (tee, "requesting pad");
GST_OBJECT_LOCK (tee);
- name = g_strdup_printf ("src_%u", tee->pad_counter++);
+
+ if (name_templ) {
+ sscanf (name_templ, "src_%u", &index);
+ GST_LOG_OBJECT (element, "name: %s (index %d)", name_templ, index);
+ if (g_hash_table_contains (tee->pad_indexes, GUINT_TO_POINTER (index))) {
+ GST_ERROR_OBJECT (element, "pad name %s is not unique", name_templ);
+ GST_OBJECT_UNLOCK (tee);
+ return NULL;
+ }
+ if (index >= tee->next_pad_index)
+ tee->next_pad_index = index + 1;
+ } else {
+ index = tee->next_pad_index;
+
+ while (g_hash_table_contains (tee->pad_indexes, GUINT_TO_POINTER (index)))
+ index++;
+
+ tee->next_pad_index = index + 1;
+ }
+
+ g_hash_table_insert (tee->pad_indexes, GUINT_TO_POINTER (index), NULL);
+
+ name = g_strdup_printf ("src_%u", index);
srcpad = GST_PAD_CAST (g_object_new (GST_TYPE_TEE_PAD,
"name", name, "direction", templ->direction, "template", templ,
NULL));
+ GST_TEE_PAD_CAST (srcpad)->index = index;
g_free (name);
mode = tee->sink_mode;
{
GstTee *tee;
gboolean changed = FALSE;
+ guint index;
tee = GST_TEE (element);
GST_DEBUG_OBJECT (tee, "releasing pad");
GST_OBJECT_LOCK (tee);
+ index = GST_TEE_PAD_CAST (pad)->index;
/* mark the pad as removed so that future pad_alloc fails with NOT_LINKED. */
GST_TEE_PAD_CAST (pad)->removed = TRUE;
if (tee->allocpad == pad) {
if (changed) {
gst_tee_notify_alloc_pad (tee);
}
+
+ GST_OBJECT_LOCK (tee);
+ g_hash_table_remove (tee->pad_indexes, GUINT_TO_POINTER (index));
+ GST_OBJECT_UNLOCK (tee);
}
static void