mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
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:
parent
102ef49110
commit
8ec43a5445
5 changed files with 67 additions and 2 deletions
11
ChangeLog
11
ChangeLog
|
@ -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>
|
2005-08-01 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* docs/gst/gstreamer-docs.sgml:
|
* docs/gst/gstreamer-docs.sgml:
|
||||||
|
|
|
@ -148,9 +148,20 @@ gst_type_find_element_have_type (GstTypeFindElement * typefind,
|
||||||
|
|
||||||
GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT, caps);
|
GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT, caps);
|
||||||
typefind->caps = gst_caps_copy (caps);
|
typefind->caps = gst_caps_copy (caps);
|
||||||
|
typefind->caps_changed = TRUE;
|
||||||
gst_pad_set_caps (typefind->src, (GstCaps *) caps);
|
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
|
static void
|
||||||
gst_type_find_element_base_init (gpointer g_class)
|
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->mode = MODE_TYPEFIND;
|
||||||
typefind->caps = NULL;
|
typefind->caps = NULL;
|
||||||
|
typefind->caps_changed = FALSE;
|
||||||
typefind->min_probability = 1;
|
typefind->min_probability = 1;
|
||||||
typefind->max_probability = GST_TYPE_FIND_MAXIMUM;
|
typefind->max_probability = GST_TYPE_FIND_MAXIMUM;
|
||||||
|
|
||||||
|
@ -429,6 +441,7 @@ stop_typefinding (GstTypeFindElement * typefind)
|
||||||
gst_buffer_unref (typefind->store);
|
gst_buffer_unref (typefind->store);
|
||||||
} else {
|
} else {
|
||||||
typefind->mode = MODE_NORMAL;
|
typefind->mode = MODE_NORMAL;
|
||||||
|
gst_type_find_element_check_set_buffer_caps (typefind, typefind->store);
|
||||||
gst_pad_push (typefind->src, typefind->store);
|
gst_pad_push (typefind->src, typefind->store);
|
||||||
}
|
}
|
||||||
typefind->store = NULL;
|
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],
|
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
|
||||||
0, entry->probability, entry->caps);
|
0, entry->probability, entry->caps);
|
||||||
stop_typefinding (typefind);
|
stop_typefinding (typefind);
|
||||||
|
gst_type_find_element_check_set_buffer_caps (typefind,
|
||||||
|
typefind->store);
|
||||||
gst_pad_push (typefind->src, typefind->store);
|
gst_pad_push (typefind->src, typefind->store);
|
||||||
typefind->store = NULL;
|
typefind->store = NULL;
|
||||||
res = gst_pad_event_default (pad, event);
|
res = gst_pad_event_default (pad, event);
|
||||||
|
@ -599,6 +614,7 @@ gst_type_find_element_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
|
|
||||||
switch (typefind->mode) {
|
switch (typefind->mode) {
|
||||||
case MODE_NORMAL:
|
case MODE_NORMAL:
|
||||||
|
gst_type_find_element_check_set_buffer_caps (typefind, buffer);
|
||||||
return gst_pad_push (typefind->src, buffer);
|
return gst_pad_push (typefind->src, buffer);
|
||||||
case MODE_TYPEFIND:{
|
case MODE_TYPEFIND:{
|
||||||
gboolean done = TRUE;
|
gboolean done = TRUE;
|
||||||
|
@ -744,10 +760,20 @@ gst_type_find_element_getrange (GstPad * srcpad,
|
||||||
guint64 offset, guint length, GstBuffer ** buffer)
|
guint64 offset, guint length, GstBuffer ** buffer)
|
||||||
{
|
{
|
||||||
GstTypeFindElement *typefind;
|
GstTypeFindElement *typefind;
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (srcpad));
|
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
|
static gboolean
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct _GstTypeFindElement {
|
||||||
guint min_probability;
|
guint min_probability;
|
||||||
guint max_probability;
|
guint max_probability;
|
||||||
GstCaps * caps;
|
GstCaps * caps;
|
||||||
|
gboolean caps_changed;
|
||||||
|
|
||||||
guint mode;
|
guint mode;
|
||||||
GstBuffer * store;
|
GstBuffer * store;
|
||||||
|
|
|
@ -148,9 +148,20 @@ gst_type_find_element_have_type (GstTypeFindElement * typefind,
|
||||||
|
|
||||||
GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT, caps);
|
GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT, caps);
|
||||||
typefind->caps = gst_caps_copy (caps);
|
typefind->caps = gst_caps_copy (caps);
|
||||||
|
typefind->caps_changed = TRUE;
|
||||||
gst_pad_set_caps (typefind->src, (GstCaps *) caps);
|
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
|
static void
|
||||||
gst_type_find_element_base_init (gpointer g_class)
|
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->mode = MODE_TYPEFIND;
|
||||||
typefind->caps = NULL;
|
typefind->caps = NULL;
|
||||||
|
typefind->caps_changed = FALSE;
|
||||||
typefind->min_probability = 1;
|
typefind->min_probability = 1;
|
||||||
typefind->max_probability = GST_TYPE_FIND_MAXIMUM;
|
typefind->max_probability = GST_TYPE_FIND_MAXIMUM;
|
||||||
|
|
||||||
|
@ -429,6 +441,7 @@ stop_typefinding (GstTypeFindElement * typefind)
|
||||||
gst_buffer_unref (typefind->store);
|
gst_buffer_unref (typefind->store);
|
||||||
} else {
|
} else {
|
||||||
typefind->mode = MODE_NORMAL;
|
typefind->mode = MODE_NORMAL;
|
||||||
|
gst_type_find_element_check_set_buffer_caps (typefind, typefind->store);
|
||||||
gst_pad_push (typefind->src, typefind->store);
|
gst_pad_push (typefind->src, typefind->store);
|
||||||
}
|
}
|
||||||
typefind->store = NULL;
|
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],
|
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
|
||||||
0, entry->probability, entry->caps);
|
0, entry->probability, entry->caps);
|
||||||
stop_typefinding (typefind);
|
stop_typefinding (typefind);
|
||||||
|
gst_type_find_element_check_set_buffer_caps (typefind,
|
||||||
|
typefind->store);
|
||||||
gst_pad_push (typefind->src, typefind->store);
|
gst_pad_push (typefind->src, typefind->store);
|
||||||
typefind->store = NULL;
|
typefind->store = NULL;
|
||||||
res = gst_pad_event_default (pad, event);
|
res = gst_pad_event_default (pad, event);
|
||||||
|
@ -599,6 +614,7 @@ gst_type_find_element_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
|
|
||||||
switch (typefind->mode) {
|
switch (typefind->mode) {
|
||||||
case MODE_NORMAL:
|
case MODE_NORMAL:
|
||||||
|
gst_type_find_element_check_set_buffer_caps (typefind, buffer);
|
||||||
return gst_pad_push (typefind->src, buffer);
|
return gst_pad_push (typefind->src, buffer);
|
||||||
case MODE_TYPEFIND:{
|
case MODE_TYPEFIND:{
|
||||||
gboolean done = TRUE;
|
gboolean done = TRUE;
|
||||||
|
@ -744,10 +760,20 @@ gst_type_find_element_getrange (GstPad * srcpad,
|
||||||
guint64 offset, guint length, GstBuffer ** buffer)
|
guint64 offset, guint length, GstBuffer ** buffer)
|
||||||
{
|
{
|
||||||
GstTypeFindElement *typefind;
|
GstTypeFindElement *typefind;
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (srcpad));
|
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
|
static gboolean
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct _GstTypeFindElement {
|
||||||
guint min_probability;
|
guint min_probability;
|
||||||
guint max_probability;
|
guint max_probability;
|
||||||
GstCaps * caps;
|
GstCaps * caps;
|
||||||
|
gboolean caps_changed;
|
||||||
|
|
||||||
guint mode;
|
guint mode;
|
||||||
GstBuffer * store;
|
GstBuffer * store;
|
||||||
|
|
Loading…
Reference in a new issue