typefind: Handle the force-caps property more similar to all typefinding code flow

This makes sure that events happen in order and simplifies the code a bit.
This commit is contained in:
Sebastian Dröge 2013-05-15 13:22:04 +02:00
parent 516611bc33
commit 1d1946a321

View file

@ -849,12 +849,18 @@ gst_type_find_element_chain_do_typefinding (GstTypeFindElement * typefind,
gboolean check_avail)
{
GstTypeFindProbability probability;
GstCaps *caps;
GstCaps *caps = NULL;
gsize avail;
const guint8 *data;
gboolean have_min, have_max;
GST_OBJECT_LOCK (typefind);
if (typefind->force_caps) {
caps = gst_caps_ref (typefind->force_caps);
probability = GST_TYPE_FIND_MAXIMUM;
}
if (!caps) {
avail = gst_adapter_available (typefind->adapter);
if (check_avail) {
@ -882,6 +888,8 @@ gst_type_find_element_chain_do_typefinding (GstTypeFindElement * typefind,
/* found a type */
if (probability < typefind->min_probability)
goto low_probability;
}
GST_OBJECT_UNLOCK (typefind);
/* probability is good enough too, so let's make it known ... emiting this
@ -993,12 +1001,20 @@ gst_type_find_element_loop (GstPad * pad)
}
if (typefind->mode == MODE_TYPEFIND) {
GstPad *peer;
GstPad *peer = NULL;
GstCaps *found_caps = NULL;
GstTypeFindProbability probability = GST_TYPE_FIND_NONE;
GST_DEBUG_OBJECT (typefind, "find type in pull mode");
GST_OBJECT_LOCK (typefind);
if (typefind->force_caps) {
found_caps = gst_caps_ref (typefind->force_caps);
probability = GST_TYPE_FIND_MAXIMUM;
}
GST_OBJECT_UNLOCK (typefind);
if (!found_caps) {
peer = gst_pad_get_peer (pad);
if (peer) {
gint64 size;
@ -1034,6 +1050,7 @@ gst_type_find_element_loop (GstPad * pad)
gst_object_unref (peer);
}
}
if (!found_caps || probability < typefind->min_probability) {
GST_DEBUG ("Trying to guess using extension");
@ -1163,37 +1180,10 @@ gst_type_find_element_activate_sink_mode (GstPad * pad, GstObject * parent,
static gboolean
gst_type_find_element_activate_sink (GstPad * pad, GstObject * parent)
{
GstTypeFindElement *typefind;
GstQuery *query;
gboolean pull_mode;
GstCaps *found_caps = NULL;
GstTypeFindProbability probability = GST_TYPE_FIND_NONE;
GstSchedulingFlags sched_flags;
typefind = GST_TYPE_FIND_ELEMENT (parent);
/* if we have force caps, use those */
GST_OBJECT_LOCK (typefind);
if (typefind->force_caps) {
found_caps = gst_caps_ref (typefind->force_caps);
probability = GST_TYPE_FIND_MAXIMUM;
GST_OBJECT_UNLOCK (typefind);
GST_DEBUG ("Emiting found caps %" GST_PTR_FORMAT, found_caps);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
0, probability, found_caps);
gst_caps_unref (found_caps);
typefind->mode = MODE_NORMAL;
/* the signal above could have made a downstream element activate
* the pad in pull mode, we check if the pad is already active now and if
* so, we are done */
if (gst_pad_is_active (pad))
return TRUE;
goto typefind_push;
}
GST_OBJECT_UNLOCK (typefind);
query = gst_query_new_scheduling ();
if (!gst_pad_peer_query (pad, query)) {