X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fdebugutils%2Fgstcapssetter.c;h=6b3db76d8311d8a124d5dde45637f82e1663add7;hb=2cb6bb425384ac1187bb4317cb3425e8797285fb;hp=977a502b403a5d661143117fb65750a146ff111c;hpb=95f39873327d789b7b4d929cf9a498f2eb1143ce;p=platform%2Fupstream%2Fgst-plugins-good.git diff --git a/gst/debugutils/gstcapssetter.c b/gst/debugutils/gstcapssetter.c index 977a502..6b3db76 100644 --- a/gst/debugutils/gstcapssetter.c +++ b/gst/debugutils/gstcapssetter.c @@ -20,34 +20,24 @@ /** * SECTION:element-capssetter * - * - * - * Sets or merges caps on a stream's buffers. - * That is, a buffer's caps are updated using (fields of) - * caps. Note that this may - * contain multiple structures (though not likely recommended), but each - * of these must be fixed (or will otherwise be rejected). - * - * - * If join - * is TRUE, then the incoming caps' mime-type is compared to the mime-type(s) - * of provided caps and only matching structure(s) are considered for updating. - * - * - * If replace - * is TRUE, then any caps update is preceded by clearing existing fields, - * making provided fields (as a whole) replace incoming ones. - * Otherwise, no clearing is performed, in which case provided fields are - * added/merged onto incoming caps - * - * + * Sets or merges caps on a stream's buffers. That is, a buffer's caps are + * updated using (fields of) #GstCapsSetter:caps. Note that this may contain + * multiple structures (though not likely recommended), but each of these must + * be fixed (or will otherwise be rejected). + * + * If #GstCapsSetter:join is %TRUE, then the incoming caps' mime-type is + * compared to the mime-type(s) of provided caps and only matching structure(s) + * are considered for updating. + * + * If #GstCapsSetter:replace is %TRUE, then any caps update is preceded by + * clearing existing fields, making provided fields (as a whole) replace + * incoming ones. Otherwise, no clearing is performed, in which case provided + * fields are added/merged onto incoming caps + * * Although this element might mainly serve as debug helper, * it can also practically be used to correct a faulty pixel-aspect-ratio, * or to modify a yuv fourcc value to effectively swap chroma components or such * alike. - * - * - * */ @@ -141,15 +131,15 @@ gst_caps_setter_class_init (GstCapsSetterClass * g_class) "Drop fields of incoming caps", DEFAULT_REPLACE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - gst_element_class_set_details_simple (element_class, "CapsSetter", + gst_element_class_set_static_metadata (element_class, "CapsSetter", "Generic", "Set/merge caps on stream", "Mark Nauwelaerts "); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_caps_setter_sink_template)); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_caps_setter_src_template)); + gst_element_class_add_static_pad_template (element_class, + &gst_caps_setter_sink_template); + gst_element_class_add_static_pad_template (element_class, + &gst_caps_setter_src_template); trans_class->transform_size = GST_DEBUG_FUNCPTR (gst_caps_setter_transform_size); @@ -192,42 +182,51 @@ gst_caps_setter_transform_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps, GstCaps * cfilter) { GstCapsSetter *filter = GST_CAPS_SETTER (trans); - GstCaps *ret, *filter_caps; + GstCaps *ret = NULL, *filter_caps = NULL; GstStructure *structure, *merge; const gchar *name; - gint i, j; - - GST_DEBUG_OBJECT (trans, "receiving caps: %" GST_PTR_FORMAT, caps); + gint i, j, k; + + GST_DEBUG_OBJECT (trans, + "receiving caps: %" GST_PTR_FORMAT ", with filter: %" GST_PTR_FORMAT, + caps, cfilter); + + /* pass filter caps upstream, or any if no filter */ + if (direction != GST_PAD_SINK) { + if (!cfilter || gst_caps_is_empty (cfilter)) { + return gst_caps_ref (GST_CAPS_ANY); + } else { + return gst_caps_ref (cfilter); + } + } ret = gst_caps_copy (caps); - /* this function is always called with a simple caps */ - if (!GST_CAPS_IS_SIMPLE (ret) || direction != GST_PAD_SINK) - return ret; - - structure = gst_caps_get_structure (ret, 0); - name = gst_structure_get_name (structure); - GST_OBJECT_LOCK (filter); filter_caps = gst_caps_ref (filter->caps); GST_OBJECT_UNLOCK (filter); - for (i = 0; i < gst_caps_get_size (filter_caps); ++i) { - merge = gst_caps_get_structure (filter_caps, i); - if (gst_structure_has_name (merge, name) || !filter->join) { + for (k = 0; k < gst_caps_get_size (ret); k++) { + structure = gst_caps_get_structure (ret, k); + name = gst_structure_get_name (structure); - if (!filter->join) - gst_structure_set_name (structure, gst_structure_get_name (merge)); + for (i = 0; i < gst_caps_get_size (filter_caps); ++i) { + merge = gst_caps_get_structure (filter_caps, i); + if (gst_structure_has_name (merge, name) || !filter->join) { - if (filter->replace) - gst_structure_remove_all_fields (structure); + if (!filter->join) + gst_structure_set_name (structure, gst_structure_get_name (merge)); - for (j = 0; j < gst_structure_n_fields (merge); ++j) { - const gchar *fname; + if (filter->replace) + gst_structure_remove_all_fields (structure); - fname = gst_structure_nth_field_name (merge, j); - gst_structure_set_value (structure, fname, - gst_structure_get_value (merge, fname)); + for (j = 0; j < gst_structure_n_fields (merge); ++j) { + const gchar *fname; + + fname = gst_structure_nth_field_name (merge, j); + gst_structure_set_value (structure, fname, + gst_structure_get_value (merge, fname)); + } } } } @@ -294,7 +293,7 @@ gst_caps_setter_set_property (GObject * object, guint prop_id, } /* try to activate these new caps next time around */ - gst_base_transform_reconfigure (GST_BASE_TRANSFORM (filter)); + gst_base_transform_reconfigure_src (GST_BASE_TRANSFORM (filter)); break; } case PROP_JOIN: