gst/elements/gsttypefindelement.*: Set caps on first outgoing buffer when we've found the type.

Original commit message from CVS:
* 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.
This commit is contained in:
Tim-Philipp Müller 2005-08-01 09:10:01 +00:00
parent 102ef49110
commit 8ec43a5445
5 changed files with 67 additions and 2 deletions

View file

@ -1,3 +1,14 @@
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:

View file

@ -148,9 +148,20 @@ gst_type_find_element_have_type (GstTypeFindElement * typefind,
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)
{
@ -229,6 +240,7 @@ gst_type_find_element_init (GstTypeFindElement * typefind)
typefind->mode = MODE_TYPEFIND;
typefind->caps = NULL;
typefind->caps_changed = FALSE;
typefind->min_probability = 1;
typefind->max_probability = GST_TYPE_FIND_MAXIMUM;
@ -429,6 +441,7 @@ stop_typefinding (GstTypeFindElement * typefind)
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;
@ -499,6 +512,8 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
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);
@ -599,6 +614,7 @@ gst_type_find_element_chain (GstPad * pad, GstBuffer * buffer)
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;
@ -744,10 +760,20 @@ gst_type_find_element_getrange (GstPad * srcpad,
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

View file

@ -51,6 +51,7 @@ struct _GstTypeFindElement {
guint min_probability;
guint max_probability;
GstCaps * caps;
gboolean caps_changed;
guint mode;
GstBuffer * store;

View file

@ -148,9 +148,20 @@ gst_type_find_element_have_type (GstTypeFindElement * typefind,
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)
{
@ -229,6 +240,7 @@ gst_type_find_element_init (GstTypeFindElement * typefind)
typefind->mode = MODE_TYPEFIND;
typefind->caps = NULL;
typefind->caps_changed = FALSE;
typefind->min_probability = 1;
typefind->max_probability = GST_TYPE_FIND_MAXIMUM;
@ -429,6 +441,7 @@ stop_typefinding (GstTypeFindElement * typefind)
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;
@ -499,6 +512,8 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
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);
@ -599,6 +614,7 @@ gst_type_find_element_chain (GstPad * pad, GstBuffer * buffer)
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;
@ -744,10 +760,20 @@ gst_type_find_element_getrange (GstPad * srcpad,
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

View file

@ -51,6 +51,7 @@ struct _GstTypeFindElement {
guint min_probability;
guint max_probability;
GstCaps * caps;
gboolean caps_changed;
guint mode;
GstBuffer * store;