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:
Wim Taymans 2008-04-02 17:21:40 +00:00
parent 1e0128c47e
commit 9825935d6d
3 changed files with 65 additions and 19 deletions

View file

@ -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> 2008-04-01 Sebastian Dröge <slomo@circular-chaos.org>
* configure.ac: * configure.ac:

View file

@ -25,8 +25,8 @@
* 1) get a list of all typefind functions sorted best to worst * 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 * 2) if all elements have been called with all requested data goto 8
* 3) call all functions once with all available data * 3) call all functions once with all available data
* 4) if a function returns a value >= ARG_MAXIMUM goto 8 * 4) if a function returns a value >= PROP_MAXIMUM goto 8
* 5) all functions with a result > ARG_MINIMUM or functions that did not get * 5) all functions with a result > PROP_MINIMUM or functions that did not get
* all requested data (where peek returned NULL) stay in list * all requested data (where peek returned NULL) stay in list
* 6) seek to requested offset of best function that still has open data * 6) seek to requested offset of best function that still has open data
* requests * requests
@ -89,10 +89,12 @@ enum
}; };
enum enum
{ {
ARG_0, PROP_0,
ARG_CAPS, PROP_CAPS,
ARG_MINIMUM, PROP_MINIMUM,
ARG_MAXIMUM PROP_MAXIMUM,
PROP_FORCE_CAPS,
PROP_LAST
}; };
enum enum
{ {
@ -188,20 +190,24 @@ gst_type_find_element_class_init (GstTypeFindElementClass * typefind_class)
typefind_class->have_type = gst_type_find_element_have_type; 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"), g_param_spec_boxed ("caps", _("caps"),
_("detected capabilities in stream"), gst_caps_get_type (), _("detected capabilities in stream"), gst_caps_get_type (),
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 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"), g_param_spec_uint ("minimum", _("minimum"),
"minimum probability required to accept caps", GST_TYPE_FIND_MINIMUM, "minimum probability required to accept caps", GST_TYPE_FIND_MINIMUM,
GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 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"), g_param_spec_uint ("maximum", _("maximum"),
"probability to stop typefinding (deprecated; non-functional)", "probability to stop typefinding (deprecated; non-functional)",
GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 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: * GstTypeFindElement::have-type:
* @typefind: the typefind instance * @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); typefind = GST_TYPE_FIND_ELEMENT (object);
switch (prop_id) { switch (prop_id) {
case ARG_MINIMUM: case PROP_MINIMUM:
typefind->min_probability = g_value_get_uint (value); typefind->min_probability = g_value_get_uint (value);
break; break;
case ARG_MAXIMUM: case PROP_MAXIMUM:
typefind->max_probability = g_value_get_uint (value); typefind->max_probability = g_value_get_uint (value);
break; 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: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -304,15 +317,20 @@ gst_type_find_element_get_property (GObject * object, guint prop_id,
typefind = GST_TYPE_FIND_ELEMENT (object); typefind = GST_TYPE_FIND_ELEMENT (object);
switch (prop_id) { switch (prop_id) {
case ARG_CAPS: case PROP_CAPS:
g_value_set_boxed (value, typefind->caps); g_value_set_boxed (value, typefind->caps);
break; break;
case ARG_MINIMUM: case PROP_MINIMUM:
g_value_set_uint (value, typefind->min_probability); g_value_set_uint (value, typefind->min_probability);
break; break;
case ARG_MAXIMUM: case PROP_MAXIMUM:
g_value_set_uint (value, typefind->max_probability); g_value_set_uint (value, typefind->max_probability);
break; break;
case PROP_FORCE_CAPS:
GST_OBJECT_LOCK (typefind);
g_value_set_boxed (value, typefind->force_caps);
GST_OBJECT_UNLOCK (typefind);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -703,6 +721,13 @@ gst_type_find_element_activate (GstPad * pad)
typefind = GST_TYPE_FIND_ELEMENT (GST_OBJECT_PARENT (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. /* 1. try to activate in pull mode. if not, switch to push and succeed.
2. try to pull type find. 2. try to pull type find.
3. deactivate pull mode. 3. deactivate pull mode.
@ -730,19 +755,23 @@ gst_type_find_element_activate (GstPad * pad)
if (!gst_pad_query_duration (peer, &format, &size)) { if (!gst_pad_query_duration (peer, &format, &size)) {
GST_WARNING_OBJECT (typefind, "Could not query upstream length!"); GST_WARNING_OBJECT (typefind, "Could not query upstream length!");
gst_object_unref (peer);
return FALSE; return FALSE;
} }
if (size > 0) { /* the size if 0, we cannot continue */
found_caps = gst_type_find_helper_get_range (GST_OBJECT_CAST (peer), if (size == 0) {
(GstTypeFindHelperGetRangeFunction) (GST_PAD_GETRANGEFUNC (peer)),
(guint64) size, &probability);
} else {
/* keep message in sync with message in sink event handler */ /* keep message in sync with message in sink event handler */
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND,
(_("Stream contains no data.")), ("Can't typefind empty stream")); (_("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); gst_object_unref (peer);
} }
} }
@ -760,6 +789,7 @@ gst_type_find_element_activate (GstPad * pad)
return FALSE; return FALSE;
} }
done:
/* 6 */ /* 6 */
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
0, probability, found_caps); 0, probability, found_caps);

View file

@ -59,6 +59,7 @@ struct _GstTypeFindElement {
GstBuffer * store; GstBuffer * store;
GList * cached_events; GList * cached_events;
GstCaps * force_caps;
}; };
struct _GstTypeFindElementClass { struct _GstTypeFindElementClass {