mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
plugins/elements/gsttypefindelement.*: Cleanup properties.
Original commit message from CVS: * plugins/elements/gsttypefindelement.c: (gst_type_find_element_class_init), (gst_type_find_element_set_property), (gst_type_find_element_get_property), (gst_type_find_element_activate): * plugins/elements/gsttypefindelement.h: Cleanup properties. Fix pad leak when peer query fails. We can still typefind when the peer returns -1. Add property to force caps and bypass typefinding. This will be used in uridecodebin. API::force-caps
This commit is contained in:
parent
1e0128c47e
commit
9825935d6d
3 changed files with 65 additions and 19 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2008-04-02 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||
|
||||
* plugins/elements/gsttypefindelement.c:
|
||||
(gst_type_find_element_class_init),
|
||||
(gst_type_find_element_set_property),
|
||||
(gst_type_find_element_get_property),
|
||||
(gst_type_find_element_activate):
|
||||
* plugins/elements/gsttypefindelement.h:
|
||||
Cleanup properties.
|
||||
Fix pad leak when peer query fails.
|
||||
We can still typefind when the peer returns -1.
|
||||
Add property to force caps and bypass typefinding. This will be used in
|
||||
uridecodebin.
|
||||
API::force-caps
|
||||
|
||||
2008-04-01 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* configure.ac:
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
* 1) get a list of all typefind functions sorted best to worst
|
||||
* 2) if all elements have been called with all requested data goto 8
|
||||
* 3) call all functions once with all available data
|
||||
* 4) if a function returns a value >= ARG_MAXIMUM goto 8
|
||||
* 5) all functions with a result > ARG_MINIMUM or functions that did not get
|
||||
* 4) if a function returns a value >= PROP_MAXIMUM goto 8
|
||||
* 5) all functions with a result > PROP_MINIMUM or functions that did not get
|
||||
* all requested data (where peek returned NULL) stay in list
|
||||
* 6) seek to requested offset of best function that still has open data
|
||||
* requests
|
||||
|
@ -89,10 +89,12 @@ enum
|
|||
};
|
||||
enum
|
||||
{
|
||||
ARG_0,
|
||||
ARG_CAPS,
|
||||
ARG_MINIMUM,
|
||||
ARG_MAXIMUM
|
||||
PROP_0,
|
||||
PROP_CAPS,
|
||||
PROP_MINIMUM,
|
||||
PROP_MAXIMUM,
|
||||
PROP_FORCE_CAPS,
|
||||
PROP_LAST
|
||||
};
|
||||
enum
|
||||
{
|
||||
|
@ -188,20 +190,24 @@ gst_type_find_element_class_init (GstTypeFindElementClass * typefind_class)
|
|||
|
||||
typefind_class->have_type = gst_type_find_element_have_type;
|
||||
|
||||
g_object_class_install_property (gobject_class, ARG_CAPS,
|
||||
g_object_class_install_property (gobject_class, PROP_CAPS,
|
||||
g_param_spec_boxed ("caps", _("caps"),
|
||||
_("detected capabilities in stream"), gst_caps_get_type (),
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (gobject_class, ARG_MINIMUM,
|
||||
g_object_class_install_property (gobject_class, PROP_MINIMUM,
|
||||
g_param_spec_uint ("minimum", _("minimum"),
|
||||
"minimum probability required to accept caps", GST_TYPE_FIND_MINIMUM,
|
||||
GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (gobject_class, ARG_MAXIMUM,
|
||||
g_object_class_install_property (gobject_class, PROP_MAXIMUM,
|
||||
g_param_spec_uint ("maximum", _("maximum"),
|
||||
"probability to stop typefinding (deprecated; non-functional)",
|
||||
GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (gobject_class, PROP_FORCE_CAPS,
|
||||
g_param_spec_boxed ("force-caps", _("force caps"),
|
||||
_("force caps without doing a typefind"), gst_caps_get_type (),
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
/**
|
||||
* GstTypeFindElement::have-type:
|
||||
* @typefind: the typefind instance
|
||||
|
@ -284,12 +290,19 @@ gst_type_find_element_set_property (GObject * object, guint prop_id,
|
|||
typefind = GST_TYPE_FIND_ELEMENT (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case ARG_MINIMUM:
|
||||
case PROP_MINIMUM:
|
||||
typefind->min_probability = g_value_get_uint (value);
|
||||
break;
|
||||
case ARG_MAXIMUM:
|
||||
case PROP_MAXIMUM:
|
||||
typefind->max_probability = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_FORCE_CAPS:
|
||||
GST_OBJECT_LOCK (typefind);
|
||||
if (typefind->force_caps)
|
||||
gst_caps_unref (typefind->force_caps);
|
||||
typefind->force_caps = g_value_dup_boxed (value);
|
||||
GST_OBJECT_UNLOCK (typefind);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -304,15 +317,20 @@ gst_type_find_element_get_property (GObject * object, guint prop_id,
|
|||
typefind = GST_TYPE_FIND_ELEMENT (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case ARG_CAPS:
|
||||
case PROP_CAPS:
|
||||
g_value_set_boxed (value, typefind->caps);
|
||||
break;
|
||||
case ARG_MINIMUM:
|
||||
case PROP_MINIMUM:
|
||||
g_value_set_uint (value, typefind->min_probability);
|
||||
break;
|
||||
case ARG_MAXIMUM:
|
||||
case PROP_MAXIMUM:
|
||||
g_value_set_uint (value, typefind->max_probability);
|
||||
break;
|
||||
case PROP_FORCE_CAPS:
|
||||
GST_OBJECT_LOCK (typefind);
|
||||
g_value_set_boxed (value, typefind->force_caps);
|
||||
GST_OBJECT_UNLOCK (typefind);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -703,6 +721,13 @@ gst_type_find_element_activate (GstPad * pad)
|
|||
|
||||
typefind = GST_TYPE_FIND_ELEMENT (GST_OBJECT_PARENT (pad));
|
||||
|
||||
/* if we have force caps, use those */
|
||||
if (typefind->force_caps) {
|
||||
found_caps = gst_caps_ref (typefind->force_caps);
|
||||
probability = GST_TYPE_FIND_MAXIMUM;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* 1. try to activate in pull mode. if not, switch to push and succeed.
|
||||
2. try to pull type find.
|
||||
3. deactivate pull mode.
|
||||
|
@ -730,19 +755,23 @@ gst_type_find_element_activate (GstPad * pad)
|
|||
|
||||
if (!gst_pad_query_duration (peer, &format, &size)) {
|
||||
GST_WARNING_OBJECT (typefind, "Could not query upstream length!");
|
||||
gst_object_unref (peer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (size > 0) {
|
||||
found_caps = gst_type_find_helper_get_range (GST_OBJECT_CAST (peer),
|
||||
(GstTypeFindHelperGetRangeFunction) (GST_PAD_GETRANGEFUNC (peer)),
|
||||
(guint64) size, &probability);
|
||||
} else {
|
||||
/* the size if 0, we cannot continue */
|
||||
if (size == 0) {
|
||||
/* keep message in sync with message in sink event handler */
|
||||
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND,
|
||||
(_("Stream contains no data.")), ("Can't typefind empty stream"));
|
||||
gst_object_unref (peer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
found_caps = gst_type_find_helper_get_range (GST_OBJECT_CAST (peer),
|
||||
(GstTypeFindHelperGetRangeFunction) (GST_PAD_GETRANGEFUNC (peer)),
|
||||
(guint64) size, &probability);
|
||||
|
||||
gst_object_unref (peer);
|
||||
}
|
||||
}
|
||||
|
@ -760,6 +789,7 @@ gst_type_find_element_activate (GstPad * pad)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
done:
|
||||
/* 6 */
|
||||
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
|
||||
0, probability, found_caps);
|
||||
|
|
|
@ -59,6 +59,7 @@ struct _GstTypeFindElement {
|
|||
GstBuffer * store;
|
||||
|
||||
GList * cached_events;
|
||||
GstCaps * force_caps;
|
||||
};
|
||||
|
||||
struct _GstTypeFindElementClass {
|
||||
|
|
Loading…
Reference in a new issue