GstFormat format;
gboolean block;
gchar *uri;
+ gboolean new_caps;
gboolean flushing;
gboolean started;
g_mutex_lock (priv->mutex);
GST_DEBUG_OBJECT (appsrc, "starting");
+ priv->new_caps = FALSE;
priv->started = TRUE;
/* set the offset to -1 so that we always do a first seek. This is only used
* in random-access mode. */
}
static gboolean
-gst_app_src_negotiate (GstBaseSrc * basesrc)
+gst_app_src_do_negotiate (GstBaseSrc * basesrc)
{
GstAppSrc *appsrc = GST_APP_SRC_CAST (basesrc);
GstAppSrcPrivate *priv = appsrc->priv;
- GstCaps *caps;
gboolean result;
+ GstCaps *caps;
- GST_OBJECT_LOCK (appsrc);
- if ((caps = priv->caps))
- gst_caps_ref (caps);
- GST_OBJECT_UNLOCK (appsrc);
+ GST_OBJECT_LOCK (basesrc);
+ caps = priv->caps ? gst_caps_ref (priv->caps) : NULL;
+ GST_OBJECT_UNLOCK (basesrc);
if (caps) {
result = gst_base_src_set_caps (basesrc, caps);
} else {
result = GST_BASE_SRC_CLASS (parent_class)->negotiate (basesrc);
}
+
+ return result;
+}
+
+static gboolean
+gst_app_src_negotiate (GstBaseSrc * basesrc)
+{
+ GstAppSrc *appsrc = GST_APP_SRC_CAST (basesrc);
+ GstAppSrcPrivate *priv = appsrc->priv;
+ gboolean result;
+
+ g_mutex_lock (priv->mutex);
+ result = gst_app_src_do_negotiate (basesrc);
+ priv->new_caps = FALSE;
+ g_mutex_unlock (priv->mutex);
return result;
}
buf_size = gst_buffer_get_size (*buf);
GST_DEBUG_OBJECT (appsrc, "we have buffer %p of size %u", *buf, buf_size);
+ if (priv->new_caps) {
+ gst_app_src_do_negotiate (bsrc);
+ priv->new_caps = FALSE;
+ }
priv->queued_bytes -= buf_size;
priv->caps = NULL;
if (old)
gst_caps_unref (old);
+ g_mutex_lock (priv->mutex);
+ priv->new_caps = TRUE;
+ g_mutex_unlock (priv->mutex);
}
GST_OBJECT_UNLOCK (appsrc);
}