2005-08-01 Tim-Philipp Müller <tim at centricular dot net>
+ * gst/elements/gsttypefindelement.c:
+ (gst_type_find_element_have_type),
+ (gst_type_find_element_check_set_buffer_caps),
+ (gst_type_find_element_init), (stop_typefinding),
+ (gst_type_find_element_handle_event),
+ (gst_type_find_element_chain), (gst_type_find_element_getrange):
+ * gst/elements/gsttypefindelement.h:
+ Set caps on first outgoing buffer when we've found the type.
+
+2005-08-01 Tim-Philipp Müller <tim at centricular dot net>
+
* docs/gst/gstreamer-docs.sgml:
* docs/gst/gstreamer-sections.txt:
* docs/gst/tmpl/gstscheduler.sgml:
GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT, caps);
typefind->caps = gst_caps_copy (caps);
+ typefind->caps_changed = TRUE;
gst_pad_set_caps (typefind->src, (GstCaps *) caps);
}
+static inline void
+gst_type_find_element_check_set_buffer_caps (GstTypeFindElement * typefind,
+ GstBuffer * buffer)
+{
+ if (typefind->caps_changed && buffer != NULL) {
+ gst_buffer_set_caps (buffer, typefind->caps);
+ typefind->caps_changed = FALSE;
+ }
+}
+
static void
gst_type_find_element_base_init (gpointer g_class)
{
typefind->mode = MODE_TYPEFIND;
typefind->caps = NULL;
+ typefind->caps_changed = FALSE;
typefind->min_probability = 1;
typefind->max_probability = GST_TYPE_FIND_MAXIMUM;
gst_buffer_unref (typefind->store);
} else {
typefind->mode = MODE_NORMAL;
+ gst_type_find_element_check_set_buffer_caps (typefind, typefind->store);
gst_pad_push (typefind->src, typefind->store);
}
typefind->store = NULL;
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
0, entry->probability, entry->caps);
stop_typefinding (typefind);
+ gst_type_find_element_check_set_buffer_caps (typefind,
+ typefind->store);
gst_pad_push (typefind->src, typefind->store);
typefind->store = NULL;
res = gst_pad_event_default (pad, event);
switch (typefind->mode) {
case MODE_NORMAL:
+ gst_type_find_element_check_set_buffer_caps (typefind, buffer);
return gst_pad_push (typefind->src, buffer);
case MODE_TYPEFIND:{
gboolean done = TRUE;
guint64 offset, guint length, GstBuffer ** buffer)
{
GstTypeFindElement *typefind;
+ GstFlowReturn ret;
typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (srcpad));
- return gst_pad_pull_range (typefind->sink, offset, length, buffer);
+ ret = gst_pad_pull_range (typefind->sink, offset, length, buffer);
+
+ if (typefind->caps_changed) {
+ if (ret == GST_FLOW_OK && buffer && *buffer) {
+ gst_buffer_set_caps (*buffer, typefind->caps);
+ typefind->caps_changed = FALSE;
+ }
+ }
+
+ return ret;
}
static gboolean
guint min_probability;
guint max_probability;
GstCaps * caps;
+ gboolean caps_changed;
guint mode;
GstBuffer * store;
GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT, caps);
typefind->caps = gst_caps_copy (caps);
+ typefind->caps_changed = TRUE;
gst_pad_set_caps (typefind->src, (GstCaps *) caps);
}
+static inline void
+gst_type_find_element_check_set_buffer_caps (GstTypeFindElement * typefind,
+ GstBuffer * buffer)
+{
+ if (typefind->caps_changed && buffer != NULL) {
+ gst_buffer_set_caps (buffer, typefind->caps);
+ typefind->caps_changed = FALSE;
+ }
+}
+
static void
gst_type_find_element_base_init (gpointer g_class)
{
typefind->mode = MODE_TYPEFIND;
typefind->caps = NULL;
+ typefind->caps_changed = FALSE;
typefind->min_probability = 1;
typefind->max_probability = GST_TYPE_FIND_MAXIMUM;
gst_buffer_unref (typefind->store);
} else {
typefind->mode = MODE_NORMAL;
+ gst_type_find_element_check_set_buffer_caps (typefind, typefind->store);
gst_pad_push (typefind->src, typefind->store);
}
typefind->store = NULL;
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
0, entry->probability, entry->caps);
stop_typefinding (typefind);
+ gst_type_find_element_check_set_buffer_caps (typefind,
+ typefind->store);
gst_pad_push (typefind->src, typefind->store);
typefind->store = NULL;
res = gst_pad_event_default (pad, event);
switch (typefind->mode) {
case MODE_NORMAL:
+ gst_type_find_element_check_set_buffer_caps (typefind, buffer);
return gst_pad_push (typefind->src, buffer);
case MODE_TYPEFIND:{
gboolean done = TRUE;
guint64 offset, guint length, GstBuffer ** buffer)
{
GstTypeFindElement *typefind;
+ GstFlowReturn ret;
typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (srcpad));
- return gst_pad_pull_range (typefind->sink, offset, length, buffer);
+ ret = gst_pad_pull_range (typefind->sink, offset, length, buffer);
+
+ if (typefind->caps_changed) {
+ if (ret == GST_FLOW_OK && buffer && *buffer) {
+ gst_buffer_set_caps (*buffer, typefind->caps);
+ typefind->caps_changed = FALSE;
+ }
+ }
+
+ return ret;
}
static gboolean
guint min_probability;
guint max_probability;
GstCaps * caps;
+ gboolean caps_changed;
guint mode;
GstBuffer * store;