mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
caps: use the caps event
Use the caps event instead of gst_pad_set_caps() and the setcaps function
This commit is contained in:
parent
f48e7920da
commit
a767bf2bf9
7 changed files with 31 additions and 28 deletions
|
@ -159,16 +159,15 @@ debug_dump_pad (GstPad * pad, const gchar * color_name,
|
|||
}
|
||||
}
|
||||
if (details & GST_DEBUG_GRAPH_SHOW_STATES) {
|
||||
gchar pad_flags[6];
|
||||
gchar pad_flags[5];
|
||||
const gchar *activation_mode = "-><";
|
||||
|
||||
/* check if pad flags */
|
||||
pad_flags[0] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED) ? 'B' : 'b';
|
||||
pad_flags[1] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING) ? 'F' : 'f';
|
||||
pad_flags[2] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS) ? 'G' : 'g';
|
||||
pad_flags[3] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS) ? 'S' : 's';
|
||||
pad_flags[4] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING) ? 'B' : 'b';
|
||||
pad_flags[5] = '\0';
|
||||
pad_flags[3] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING) ? 'B' : 'b';
|
||||
pad_flags[4] = '\0';
|
||||
|
||||
fprintf (out,
|
||||
"%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s\\n[%c][%s]\", height=\"0.2\", style=\"%s\"];\n",
|
||||
|
|
|
@ -4248,7 +4248,8 @@ gst_base_sink_negotiate_pull (GstBaseSink * basesink)
|
|||
GST_DEBUG_OBJECT (basesink, "fixated to: %" GST_PTR_FORMAT, caps);
|
||||
|
||||
if (gst_caps_is_fixed (caps)) {
|
||||
if (!gst_pad_set_caps (GST_BASE_SINK_PAD (basesink), caps))
|
||||
if (!gst_pad_send_event (GST_BASE_SINK_PAD (basesink),
|
||||
gst_event_new_caps (caps)))
|
||||
goto could_not_set_caps;
|
||||
|
||||
GST_OBJECT_LOCK (basesink);
|
||||
|
|
|
@ -1159,11 +1159,6 @@ gst_base_transform_setcaps (GstBaseTransform * trans, GstPad * pad,
|
|||
otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad;
|
||||
otherpeer = gst_pad_get_peer (otherpad);
|
||||
|
||||
/* if we get called recursively, we bail out now to avoid an
|
||||
* infinite loop. */
|
||||
if (GST_PAD_IS_IN_SETCAPS (otherpad))
|
||||
goto done;
|
||||
|
||||
GST_DEBUG_OBJECT (pad, "have new caps %p %" GST_PTR_FORMAT, caps, caps);
|
||||
|
||||
/* find best possible caps for the other pad */
|
||||
|
|
|
@ -207,7 +207,8 @@ gst_check_setup_src_pad (GstElement * element,
|
|||
|
||||
srcpad = gst_check_setup_src_pad_by_name (element, tmpl, "sink");
|
||||
if (caps)
|
||||
fail_unless (gst_pad_set_caps (srcpad, caps), "could not set caps on pad");
|
||||
fail_unless (gst_pad_push_event (srcpad, gst_event_new_caps (caps)),
|
||||
"could not set caps on pad");
|
||||
return srcpad;
|
||||
}
|
||||
|
||||
|
@ -286,7 +287,8 @@ gst_check_setup_sink_pad (GstElement * element, GstStaticPadTemplate * tmpl,
|
|||
|
||||
sinkpad = gst_check_setup_sink_pad_by_name (element, tmpl, "src");
|
||||
if (caps)
|
||||
fail_unless (gst_pad_set_caps (sinkpad, caps), "Could not set pad caps");
|
||||
fail_unless (gst_pad_send_event (sinkpad, gst_event_new_caps (caps)),
|
||||
"Could not set pad caps");
|
||||
return sinkpad;
|
||||
}
|
||||
|
||||
|
|
|
@ -354,7 +354,7 @@ gst_capsfilter_prepare_buf (GstBaseTransform * trans, GstBuffer * input,
|
|||
GST_PTR_FORMAT " to apply to srcpad", out_caps);
|
||||
|
||||
if (!gst_pad_has_current_caps (trans->srcpad))
|
||||
gst_pad_set_caps (trans->srcpad, out_caps);
|
||||
gst_pad_push_event (trans->srcpad, gst_event_new_caps (out_caps));
|
||||
} else {
|
||||
gchar *caps_str = gst_caps_to_string (out_caps);
|
||||
|
||||
|
|
|
@ -144,9 +144,10 @@ static gboolean gst_type_find_element_src_event (GstPad * pad,
|
|||
GstEvent * event);
|
||||
static gboolean gst_type_find_handle_src_query (GstPad * pad, GstQuery * query);
|
||||
|
||||
static gboolean gst_type_find_element_handle_event (GstPad * pad,
|
||||
static gboolean gst_type_find_element_sink_event (GstPad * pad,
|
||||
GstEvent * event);
|
||||
static gboolean gst_type_find_element_setcaps (GstPad * pad, GstCaps * caps);
|
||||
static gboolean gst_type_find_element_setcaps (GstTypeFindElement * typefind,
|
||||
GstCaps * caps);
|
||||
static GstFlowReturn gst_type_find_element_chain (GstPad * sinkpad,
|
||||
GstBuffer * buffer);
|
||||
static GstFlowReturn gst_type_find_element_getrange (GstPad * srcpad,
|
||||
|
@ -184,7 +185,7 @@ gst_type_find_element_have_type (GstTypeFindElement * typefind,
|
|||
copy = gst_caps_ref (typefind->caps);
|
||||
GST_OBJECT_UNLOCK (typefind);
|
||||
|
||||
gst_pad_set_caps (typefind->src, copy);
|
||||
gst_pad_push_event (typefind->src, gst_event_new_caps (copy));
|
||||
gst_caps_unref (copy);
|
||||
}
|
||||
|
||||
|
@ -258,12 +259,10 @@ gst_type_find_element_init (GstTypeFindElement * typefind)
|
|||
|
||||
gst_pad_set_activate_function (typefind->sink,
|
||||
GST_DEBUG_FUNCPTR (gst_type_find_element_activate));
|
||||
gst_pad_set_setcaps_function (typefind->sink,
|
||||
GST_DEBUG_FUNCPTR (gst_type_find_element_setcaps));
|
||||
gst_pad_set_chain_function (typefind->sink,
|
||||
GST_DEBUG_FUNCPTR (gst_type_find_element_chain));
|
||||
gst_pad_set_event_function (typefind->sink,
|
||||
GST_DEBUG_FUNCPTR (gst_type_find_element_handle_event));
|
||||
GST_DEBUG_FUNCPTR (gst_type_find_element_sink_event));
|
||||
gst_element_add_pad (GST_ELEMENT (typefind), typefind->sink);
|
||||
|
||||
/* srcpad */
|
||||
|
@ -519,7 +518,7 @@ no_data:
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
|
||||
gst_type_find_element_sink_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
|
||||
|
@ -530,6 +529,20 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
|
|||
switch (typefind->mode) {
|
||||
case MODE_TYPEFIND:
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_CAPS:
|
||||
{
|
||||
GstCaps *caps;
|
||||
|
||||
/* first pass the caps event downstream */
|
||||
res = gst_pad_push_event (typefind->src, gst_event_ref (event));
|
||||
|
||||
/* then parse and push out our data */
|
||||
gst_event_parse_caps (event, &caps);
|
||||
res = gst_type_find_element_setcaps (typefind, caps);
|
||||
|
||||
gst_event_unref (event);
|
||||
break;
|
||||
}
|
||||
case GST_EVENT_EOS:
|
||||
{
|
||||
GST_INFO_OBJECT (typefind, "Got EOS and no type found yet");
|
||||
|
@ -593,12 +606,8 @@ gst_type_find_element_send_cached_events (GstTypeFindElement * typefind)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_type_find_element_setcaps (GstPad * pad, GstCaps * caps)
|
||||
gst_type_find_element_setcaps (GstTypeFindElement * typefind, GstCaps * caps)
|
||||
{
|
||||
GstTypeFindElement *typefind;
|
||||
|
||||
typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
|
||||
|
||||
/* don't operate on ANY caps */
|
||||
if (gst_caps_is_any (caps))
|
||||
return TRUE;
|
||||
|
|
|
@ -838,9 +838,6 @@ print_pad_info (GstElement * element)
|
|||
if (pad->getcapsfunc)
|
||||
n_print (" Has getcapsfunc(): %s\n",
|
||||
GST_DEBUG_FUNCPTR_NAME (pad->getcapsfunc));
|
||||
if (pad->setcapsfunc)
|
||||
n_print (" Has setcapsfunc(): %s\n",
|
||||
GST_DEBUG_FUNCPTR_NAME (pad->setcapsfunc));
|
||||
/* gst_pad_acceptcaps_default is static :/ */
|
||||
if (pad->acceptcapsfunc)
|
||||
n_print (" Has acceptcapsfunc(): %s\n",
|
||||
|
|
Loading…
Reference in a new issue