problems with caps-negotiating of self-made element
Andreas GST DEV
abue.gst.dev at googlemail.com
Tue Dec 20 23:59:28 PST 2011
When I start the application with the caps between the elements than I
get the following debug-logs (gst-debug-level=3):
---------------------------------------------------------------------------------
0:00:00.000445198 GST_INIT gstquery.c:105:_gst_query_initialize: init
queries
0:00:00.001508551 GST_INIT gstmessage.c:73:_gst_message_initialize: init
messages
0:00:00.001991775 GST_PLUGIN_LOADING
gstplugin.c:348:_gst_plugin_initialize: registering 0 static plugins
0:00:00.002144702 GST_PLUGIN_LOADING
gstplugin.c:254:gst_plugin_register_static: registered static plugin
"staticelements"
0:00:00.002159226 GST_PLUGIN_LOADING
gstplugin.c:256:gst_plugin_register_static: added static plugin
"staticelements", result: 1
0:00:00.002932162 GST_REGISTRY
gstregistry.c:1586:ensure_current_registry: reading registry cache:
/home/user/.gstreamer-0.10/registry.i686.bin
0:00:00.027116310 GST_REGISTRY
gstregistrybinary.c:601:gst_registry_binary_read_cache: loaded
/home/user/.gstreamer-0.10/registry.i686.bin in 0,024146 seconds
0:00:00.027257629 GST_REGISTRY
gstregistry.c:1446:scan_and_update_registry: Validating plugins from
registry cache: /home/user/.gstreamer-0.10/registry.i686.bin
0:00:00.028646209 GST_REGISTRY
gstregistry.c:1548:scan_and_update_registry: Registry cache has not changed
0:00:00.034925158 GST_REGISTRY
gstregistry.c:1615:ensure_current_registry: registry reading and
updating done, result = 1
0:00:00.034943575 GST_INIT gst.c:786:init_post: GLib runtime version: 2.26.1
0:00:00.034955608 GST_INIT gst.c:788:init_post: GLib headers version:
2.25.13
0:00:00.035028469 GST_INIT gst.c:450:gst_init_check: initialized
GStreamer successfully
0:00:00.035073102 GST_ELEMENT_FACTORY
gstelementfactory.c:363:gst_element_factory_create: creating element
"pipeline"
0:00:00.036862692 GST_PLUGIN_LOADING
gstplugin.c:800:gst_plugin_load_file: plugin
"/usr/lib/gstreamer-0.10/libgstvideotestsrc.so" loaded
0:00:00.036891665 GST_ELEMENT_FACTORY
gstelementfactory.c:361:gst_element_factory_create: creating element
"videotestsrc" named "vsrc"
0:00:00.038311922 GST_ELEMENT_PADS
gstelement.c:711:gst_element_add_pad:<GstBaseSrc at 0x93dc138> adding pad 'src'
0:00:00.039015245 GST_PLUGIN_LOADING
gstplugin.c:800:gst_plugin_load_file: plugin
"/usr/local/lib/gstreamer-0.10/libgstvicimgconv.so" loaded
0:00:00.039037244 GST_ELEMENT_FACTORY
gstelementfactory.c:361:gst_element_factory_create: creating element
"vicimgconv" named "vicimgconv"
0:00:00.039232178 GST_ELEMENT_PADS
gstelement.c:711:gst_element_add_pad:<Gstvicimgconv at 0x93c3120> adding
pad 'sink'
0:00:00.039255306 GST_ELEMENT_PADS
gstelement.c:711:gst_element_add_pad:<Gstvicimgconv at 0x93c3120> adding
pad 'src'
0:00:00.041852367 GST_PLUGIN_LOADING
gstplugin.c:800:gst_plugin_load_file: plugin
"/usr/lib/gstreamer-0.10/libgstxvimagesink.so" loaded
0:00:00.041877406 GST_ELEMENT_FACTORY
gstelementfactory.c:361:gst_element_factory_create: creating element
"xvimagesink" named "vsink"
0:00:00.042213095 GST_ELEMENT_PADS
gstelement.c:711:gst_element_add_pad:<GstBaseSink at 0x93e0058> adding pad
'sink'
** are created.
0:00:00.043184661 GST_PLUGIN_LOADING
gstplugin.c:800:gst_plugin_load_file: plugin
"/usr/lib/gstreamer-0.10/libgstcoreelements.so" loaded
0:00:00.043215233 GST_ELEMENT_FACTORY
gstelementfactory.c:363:gst_element_factory_create: creating element
"capsfilter"
0:00:00.043388083 GST_ELEMENT_PADS
gstelement.c:711:gst_element_add_pad:<GstBaseTransform at 0x93e4000> adding
pad 'sink'
0:00:00.043420564 GST_ELEMENT_PADS
gstelement.c:711:gst_element_add_pad:<GstBaseTransform at 0x93e4000> adding
pad 'src'
0:00:00.043517879 GST_STATES
gstbin.c:1710:gst_bin_get_state_func:<pipeline0> getting state
0:00:00.043542863 GST_STATES
gstelement.c:2236:gst_element_continue_state:<capsfilter0> completed
state change to NULL
0:00:00.043573274 GST_ELEMENT_PADS
gstutils.c:1592:gst_element_link_pads_full: trying to link element
vsrc:(any) to element capsfilter0:sink
0:00:00.043592727 GST_ELEMENT_PADS
gstelement.c:958:gst_element_get_static_pad: found pad capsfilter0:sink
0:00:00.043635880 GST_PADS gstutils.c:1493:prepare_link_maybe_ghosting:
vsrc and capsfilter0 in same bin, no need for ghost pads
0:00:00.043745171 GST_PADS gstpad.c:1906:gst_pad_link_prepare: trying to
link vsrc:src and capsfilter0:sink
0:00:00.046164279 GST_PADS gstpad.c:2089:gst_pad_link_full: linked
vsrc:src and capsfilter0:sink, successful
0:00:00.046227063 GST_ELEMENT_PADS
gstutils.c:1592:gst_element_link_pads_full: trying to link element
capsfilter0:src to element vicimgconv:(any)
0:00:00.046243878 GST_ELEMENT_PADS
gstelement.c:958:gst_element_get_static_pad: found pad capsfilter0:src
0:00:00.046263171 GST_PADS gstutils.c:1046:gst_pad_check_link: trying to
link capsfilter0:src and vicimgconv:src
0:00:00.046290464 GST_PADS gstutils.c:1066:gst_pad_check_link: Sink pad
vicimgconv:src is not sink pad, failed
0:00:00.046314513 GST_PADS gstutils.c:1046:gst_pad_check_link: trying to
link capsfilter0:src and vicimgconv:sink
0:00:00.048781008 GST_PADS gstutils.c:1493:prepare_link_maybe_ghosting:
capsfilter0 and vicimgconv in same bin, no need for ghost pads
0:00:00.048822541 GST_PADS gstpad.c:1906:gst_pad_link_prepare: trying to
link capsfilter0:src and vicimgconv:sink
0:00:00.051211198 GST_PADS gstpad.c:2089:gst_pad_link_full: linked
capsfilter0:src and vicimgconv:sink, successful
0:00:00.051243958 GST_ELEMENT_FACTORY
gstelementfactory.c:363:gst_element_factory_create: creating element
"capsfilter"
0:00:00.051280818 GST_ELEMENT_PADS
gstelement.c:711:gst_element_add_pad:<GstBaseTransform at 0x93e41b8> adding
pad 'sink'
0:00:00.051304837 GST_ELEMENT_PADS
gstelement.c:711:gst_element_add_pad:<GstBaseTransform at 0x93e41b8> adding
pad 'src'
0:00:00.051324316 GST_STATES
gstbin.c:1710:gst_bin_get_state_func:<pipeline0> getting state
0:00:00.051345462 GST_STATES
gstelement.c:2236:gst_element_continue_state:<capsfilter1> completed
state change to NULL
0:00:00.051363172 GST_ELEMENT_PADS
gstutils.c:1592:gst_element_link_pads_full: trying to link element
vicimgconv:(any) to element capsfilter1:sink
0:00:00.051374404 GST_ELEMENT_PADS
gstelement.c:958:gst_element_get_static_pad: found pad capsfilter1:sink
0:00:00.051384124 GST_PADS gstutils.c:1493:prepare_link_maybe_ghosting:
vicimgconv and capsfilter1 in same bin, no need for ghost pads
0:00:00.051397778 GST_PADS gstpad.c:1906:gst_pad_link_prepare: trying to
link vicimgconv:src and capsfilter1:sink
0:00:00.051409581 GST_PADS gstpad.c:2089:gst_pad_link_full: linked
vicimgconv:src and capsfilter1:sink, successful
0:00:00.051424359 GST_ELEMENT_PADS
gstutils.c:1592:gst_element_link_pads_full: trying to link element
capsfilter1:src to element vsink:(any)
0:00:00.051434610 GST_ELEMENT_PADS
gstelement.c:958:gst_element_get_static_pad: found pad capsfilter1:src
0:00:00.051464091 GST_PADS gstutils.c:1046:gst_pad_check_link: trying to
link capsfilter1:src and vsink:sink
0:00:00.051498966 GST_PADS gstutils.c:1493:prepare_link_maybe_ghosting:
capsfilter1 and vsink in same bin, no need for ghost pads
0:00:00.051513246 GST_PADS gstpad.c:1906:gst_pad_link_prepare: trying to
link capsfilter1:src and vsink:sink
0:00:00.051544270 GST_PADS gstpad.c:2089:gst_pad_link_full: linked
capsfilter1:src and vsink:sink, successful
** pipeline
0:00:00.100312737 GST_STATES
gstelement.c:2236:gst_element_continue_state:<vsink> completed state
change to READY
0:00:00.100375076 GST_STATES
gstelement.c:2249:gst_element_continue_state:<vsink> posting
state-changed NULL to READY
0:00:00.100440872 GST_STATES
gstbin.c:2443:gst_bin_change_state_func:<pipeline0> child 'vsink'
changed state to 2(READY) successfully
0:00:00.100466020 GST_STATES
gstelement.c:2236:gst_element_continue_state:<capsfilter1> completed
state change to READY
0:00:00.100477455 GST_STATES
gstelement.c:2249:gst_element_continue_state:<capsfilter1> posting
state-changed NULL to READY
0:00:00.100491420 GST_STATES
gstbin.c:2443:gst_bin_change_state_func:<pipeline0> child 'capsfilter1'
changed state to 2(READY) successfully
0:00:00.100504917 GST_STATES
gstelement.c:2236:gst_element_continue_state:<vicimgconv> completed
state change to READY
0:00:00.100515329 GST_STATES
gstelement.c:2249:gst_element_continue_state:<vicimgconv> posting
state-changed NULL to READY
0:00:00.100530224 GST_STATES
gstbin.c:2443:gst_bin_change_state_func:<pipeline0> child 'vicimgconv'
changed state to 2(READY) successfully
0:00:00.100545885 GST_STATES
gstelement.c:2236:gst_element_continue_state:<capsfilter0> completed
state change to READY
0:00:00.100556338 GST_STATES
gstelement.c:2249:gst_element_continue_state:<capsfilter0> posting
state-changed NULL to READY
0:00:00.100570527 GST_STATES
gstbin.c:2443:gst_bin_change_state_func:<pipeline0> child 'capsfilter0'
changed state to 2(READY) successfully
0:00:00.100594857 GST_STATES
gstelement.c:2236:gst_element_continue_state:<vsrc> completed state
change to READY
0:00:00.100606706 GST_STATES
gstelement.c:2249:gst_element_continue_state:<vsrc> posting
state-changed NULL to READY
0:00:00.100633460 GST_STATES
gstbin.c:2443:gst_bin_change_state_func:<pipeline0> child 'vsrc' changed
state to 2(READY) successfully
0:00:00.100661746 GST_STATES
gstelement.c:2209:gst_element_continue_state:<pipeline0> committing
state from NULL to READY, pending PLAYING, next PAUSED
0:00:00.100677021 GST_STATES
gstelement.c:2218:gst_element_continue_state:<pipeline0> continue state
change READY to PAUSED, final PLAYING
0:00:00.100732435 GST_STATES
gstbin.c:2449:gst_bin_change_state_func:<pipeline0> child 'vsink' is
changing state asynchronously to PAUSED
0:00:00.100758410 GST_STATES
gstelement.c:2236:gst_element_continue_state:<capsfilter1> completed
state change to PAUSED
0:00:00.100769505 GST_STATES
gstelement.c:2249:gst_element_continue_state:<capsfilter1> posting
state-changed READY to PAUSED
0:00:00.100787096 GST_STATES
gstbin.c:2443:gst_bin_change_state_func:<pipeline0> child 'capsfilter1'
changed state to 3(PAUSED) successfully
0:00:00.100827595 GST_STATES
gstelement.c:2236:gst_element_continue_state:<vicimgconv> completed
state change to PAUSED
0:00:00.100839283 GST_STATES
gstelement.c:2249:gst_element_continue_state:<vicimgconv> posting
state-changed READY to PAUSED
0:00:00.100852861 GST_STATES
gstbin.c:2443:gst_bin_change_state_func:<pipeline0> child 'vicimgconv'
changed state to 3(PAUSED) successfully
0:00:00.100867906 GST_STATES
gstelement.c:2236:gst_element_continue_state:<capsfilter0> completed
state change to PAUSED
0:00:00.100878319 GST_STATES
gstelement.c:2249:gst_element_continue_state:<capsfilter0> posting
state-changed READY to PAUSED
0:00:00.100891357 GST_STATES
gstbin.c:2443:gst_bin_change_state_func:<pipeline0> child 'capsfilter0'
changed state to 3(PAUSED) successfully
0:00:00.103298788 basesrc gstbasesrc.c:2755:gst_base_src_start:<vsrc>
error: Could not negotiate format
0:00:00.103323856 basesrc gstbasesrc.c:2755:gst_base_src_start:<vsrc>
error: Check your filtered caps, if any
0:00:00.103346670 GST_ERROR_SYSTEM
gstelement.c:1761:gst_element_message_full:<vsrc> posting message: Could
not negotiate format
0:00:00.103366670 GST_ERROR_SYSTEM
gstelement.c:1784:gst_element_message_full:<vsrc> posted error message:
Could not negotiate format
0:00:00.103387067 basesrc
gstbasesrc.c:2951:gst_base_src_activate_push:<vsrc> Failed to start in
push mode
0:00:00.103397239 GST_PADS gstpad.c:960:gst_pad_activate_push:<vsrc:src>
failed to activate in push mode
0:00:00.103407095 GST_PADS gstpad.c:712:gst_pad_set_active:<vsrc:src>
Failed to activate pad
0:00:00.103417170 GST_STATES
gstelement.c:2553:gst_element_change_state:<vsrc> have FAILURE
change_state return
0:00:00.103426664 GST_STATES
gstelement.c:2130:gst_element_abort_state:<vsrc> aborting state from
READY to PAUSED
0:00:00.103436307 GST_STATES
gstbin.c:2459:gst_bin_change_state_func:<pipeline0> child 'vsrc' failed
to go to state 3(PAUSED)
0:00:00.103448091 GST_STATES
gstelement.c:2553:gst_element_change_state:<pipeline0> have FAILURE
change_state return
---------------------------------------------------------------------------------
When I analyze the messages., I think this:
0:00:00.046290464 GST_PADS gstutils.c:1066:gst_pad_check_link: Sink pad
vicimgconv:src is not sink pad, failed
should be the problem. But I can't interpret it correctly.
Thanks in advance,
Andreas
Am 20.12.2011 16:36, schrieb Thiago Sousa Santos:
> On Tue, 2011-12-20 at 10:30 +0100, Andreas GST DEV wrote:
>> Hello,
>>
>> I am working on a image converter, converting images from YUY2 to UYVY.
>> Well, I have some problems with the negotiating of the pads. Without
>> filter-elements between the elements it is working (doing something, but
>> the wrong) and with some filter to force the right media-type it is not
>> working.
> You should post the error you are getting. Have you tried looking at
> GST_DEBUG yet?
>
> I guess the problem is in using gst_pad_proxy_getcaps, it will get
> downstream caps and return that as what your sink pad supports. Which
> seems to be false for your case.
>
>> Here is the source-code of my Gst-Element vicimgconv:
>> ----------------------------------------------------------------------------------------------------------
>> /* GStreamer plugin for converting Images (VICImageConverter)
>> * Copyright (C) 2011 Andreas Buettner
>> *
>> * SECTION:element-vicimgconv
>> *
>> * FIXME:Describe vicimgconv here.
>> *
>> *<refsect2>
>> *<title>Example launch line</title>
>> * |[
>> * gst-launch -v -m fakesrc ! vicimgconv ! fakesink silent=TRUE
>> * ]|
>> *</refsect2>
>> */
>>
>> #ifdef HAVE_CONFIG_H
>> # include<config.h>
>> #endif
>>
>> #include<gst/gst.h>
>> #include<gst/video/video.h>
>>
>> #include "gstvicimgconv.h"
>>
>> GST_DEBUG_CATEGORY_STATIC (gst_vicimgconv_debug);
>> #define GST_CAT_DEFAULT gst_vicimgconv_debug
>>
>> static const GstElementDetails vicimgconv_details =
>> GST_ELEMENT_DETAILS ("Video Image converter",
>> "Filter/Converter/Video",
>> "Converts the colorspace of a videostream",
>> "ABUE GMBH");
>>
>>
>> /* Filter signals and args */
>> enum
>> {
>> /* FILL ME */
>> LAST_SIGNAL
>> };
>>
>> enum
>> {
>> PROP_0,
>> PROP_SILENT
>> };
>>
>> /* the capabilities of the inputs and outputs.
>> *
>> * describe the real formats here.
>> */
>> static GstStaticPadTemplate vicimgconv_sink_template =
>> GST_STATIC_PAD_TEMPLATE ("sink",
>> GST_PAD_SINK,
>> GST_PAD_ALWAYS,
>> GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YUY2"))
>> //GST_STATIC_CAPS ("ANY")
>> //GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("UYVY"))
>> );
>>
>> static GstStaticPadTemplate vicimgconv_src_template =
>> GST_STATIC_PAD_TEMPLATE ("src",
>> GST_PAD_SRC,
>> GST_PAD_ALWAYS,
>> //GST_STATIC_CAPS ("ANY")
>> //GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("YUY2"))
>> GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("UYVY"))
>> );
>>
>> GST_BOILERPLATE (Gstvicimgconv, gst_vicimgconv, GstElement,
>> GST_TYPE_ELEMENT);
>>
>> /*
>> * FUNCTION FORWARD DECLARATION
>> */
>>
>> static void gst_vicimgconv_set_property (GObject * object, guint prop_id,
>> const GValue * value, GParamSpec * pspec);
>> static void gst_vicimgconv_get_property (GObject * object, guint prop_id,
>> GValue * value, GParamSpec * pspec);
>>
>> static gboolean gst_vicimgconv_set_caps (GstPad * pad, GstCaps * caps);
>> static GstFlowReturn gst_vicimgconv_chain (GstPad * pad, GstBuffer * buf);
>>
>> /* GObject vmethod implementations */
>>
>> static void
>> gst_vicimgconv_base_init (gpointer gclass)
>> {
>> GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
>>
>> /* set the details of the Element Class */
>> gst_element_class_set_details (element_class,&vicimgconv_details);
>>
>> gst_element_class_add_pad_template (element_class,
>> gst_static_pad_template_get (&vicimgconv_src_template));
>> gst_element_class_add_pad_template (element_class,
>> gst_static_pad_template_get (&vicimgconv_sink_template));
>> }
>>
>> /* initialize the vicimgconv's class */
>> static void
>> gst_vicimgconv_class_init (GstvicimgconvClass * klass)
>> {
>> GObjectClass *gobject_class;
>> GstElementClass *gstelement_class;
>>
>> gobject_class = (GObjectClass *) klass;
>> gstelement_class = (GstElementClass *) klass;
>>
>> gobject_class->set_property = gst_vicimgconv_set_property;
>> gobject_class->get_property = gst_vicimgconv_get_property;
>>
>> g_object_class_install_property (gobject_class, PROP_SILENT,
>> g_param_spec_boolean ("silent", "Silent", "Produce verbose
>> output ?",
>> FALSE, G_PARAM_READWRITE));
>>
>> }
>>
>> /* initialize the new element
>> * instantiate pads and add them to element
>> * set pad calback functions
>> * initialize instance structure
>> */
>> static void
>> gst_vicimgconv_init (Gstvicimgconv * filter, GstvicimgconvClass * gclass)
>> {
>> /* local variables */
>> GstElementClass *klass = GST_ELEMENT_CLASS (gclass);
>>
>> /* pad through which data comes in to the element */
>> //filter->sinkpad = gst_pad_new_from_template
>> (gst_element_class_get_pad_template (klass, "sink"), "sink");
>>
>> filter->sinkpad = gst_pad_new_from_static_template
>> (&vicimgconv_sink_template, "sink");
>>
>> /* set the pointer to the _setcaps() function */
>> //gst_pad_set_setcaps_function (filter->sinkpad,
>> GST_DEBUG_FUNCPTR(gst_vicimgconv_set_caps));
>>
>> /* set the pointer to the _getcaps() function */
>> gst_pad_set_getcaps_function (filter->sinkpad,
>> GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));
>>
>> /* set the pointer to the _chain() function */
>> gst_pad_set_chain_function (filter->sinkpad,
>> GST_DEBUG_FUNCPTR(gst_vicimgconv_chain));
>>
>>
>> /* pad through which data goes out of the element */
>> //filter->srcpad = gst_pad_new_from_template
>> (gst_element_class_get_pad_template (klass, "src"), "src");
>>
>> filter->srcpad = gst_pad_new_from_static_template
>> (&vicimgconv_src_template, "src");
>>
>> //gst_pad_set_getcaps_function (filter->srcpad,
>> GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));
>>
>> /* add the pads to the element */
>> gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
>> gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
>> /* properties initial value */
>> filter->silent = FALSE;
>> }
>>
>> static void
>> gst_vicimgconv_set_property (GObject * object, guint prop_id,
>> const GValue * value, GParamSpec * pspec)
>> {
>> Gstvicimgconv *filter = GST_VICIMGCONV (object);
>>
>> /* set the Properties of the Element */
>> switch (prop_id) {
>> case PROP_SILENT:
>> filter->silent = g_value_get_boolean (value);
>> break;
>> default:
>> G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
>> break;
>> }
>> }
>>
>> static void
>> gst_vicimgconv_get_property (GObject * object, guint prop_id,
>> GValue * value, GParamSpec * pspec)
>> {
>> Gstvicimgconv *filter = GST_VICIMGCONV (object);
>>
>> /* get the Properties of the Element */
>> switch (prop_id) {
>> case PROP_SILENT:
>> g_value_set_boolean (value, filter->silent);
>> break;
>> default:
>> G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
>> break;
>> }
>> }
>>
>> /* GstElement vmethod implementations */
>>
>> /* this function handles the link with other elements */
>> static gboolean gst_vicimgconv_set_caps (GstPad * pad, GstCaps * caps)
>> {
>> Gstvicimgconv *filter;
>> //GstPad *otherpad;
>> const GstStructure *structure;
>> const gchar *mime;
>>
>> /* get the strings of the given cap */
>> structure = gst_caps_get_structure(caps, 0);
>>
>> g_return_val_if_fail (structure, FALSE);
>>
>> mime = gst_structure_get_name (structure);
>>
>> /* check if we can handle this mime-type */
>> if (g_strcmp0(mime, "video/x-raw-yuv") != 0)
>> {
>> GST_WARNING("Wrong Mime-Type %s is provided, we only support
>> %s", mime, "video/x-raw-yuv");
>> return FALSE;
>> }
>>
>> /* set the caps of the srcpad of the filter */
>> if (!gst_pad_set_caps (filter->srcpad, caps))
>> {
>> GST_WARNING("Capsnego not successfull");
>> return FALSE;
>> }
>>
>>
>> filter = GST_VICIMGCONV (gst_pad_get_parent (pad));
>> //otherpad = (pad == filter->srcpad) ? filter->sinkpad :
>> filter->srcpad;
>>
>>
>> //gst_object_unref (filter);
>>
>> g_print("gst_vicimgconv_set_caps:return TRUE");
>> //return gst_pad_set_caps (otherpad, caps);
>> return TRUE;
>> }
>>
>> /* chain function
>> * this function does the actual processing
>> */
>> static GstFlowReturn gst_vicimgconv_chain (GstPad * pad, GstBuffer * buf)
>> {
>> Gstvicimgconv *filter;
>> GstBuffer *out_buf;
>> guint8 *ptr_in, *ptr_out;
>> guint size;
>> gint i;
>>
>> filter = GST_VICIMGCONV (GST_OBJECT_PARENT (pad));
>> out_buf = gst_buffer_copy (buf); /* copy the
>> input buffer */
>>
>> /* call the image conversion function */
>> if(convYUY2toUYVY(GST_BUFFER_DATA(buf), GST_BUFFER_DATA(out_buf),
>> GST_BUFFER_SIZE(buf))< 0)
>> g_print("Fehler bei der Konvertierung\n");
>>
>>
>> /* add here debug-messages */
>> if (filter->silent == FALSE)
>> //g_print("Have Data of size %u bytes with start-adress %d!\n",
>> size, ptr);
>>
>> /* just push out the incoming buffer without touching it */
>> return gst_pad_push (filter->srcpad, out_buf);
>> //return GST_FLOW_OK;
>> }
>>
>>
>> /* entry point to initialize the plug-in
>> * initialize the plug-in itself
>> * register the element factories and other features
>> * load here other dependencies
>> * return: TRUE or FALSE
>> */
>> static gboolean
>> vicimgconv_init (GstPlugin * vicimgconv)
>> {
>> /* debug category for fltering log messages
>> *
>> * exchange the string 'Template vicimgconv' with your description
>> */
>> GST_DEBUG_CATEGORY_INIT (gst_vicimgconv_debug, "vicimgconv",
>> 0, "Converter for video images");
>>
>> return gst_element_register (vicimgconv, "vicimgconv", GST_RANK_NONE,
>> GST_TYPE_VICIMGCONV);
>> }
>>
>> /* PACKAGE: this is usually set by autotools depending on some _INIT macro
>> * in configure.ac and then written into and defined in config.h, but
>> we can
>> * just set it ourselves here in case someone doesn't use autotools to
>> * compile this code. GST_PLUGIN_DEFINE needs PACKAGE to be defined.
>> */
>> #ifndef PACKAGE
>> #define PACKAGE "myfirstvicimgconv"
>> #endif
>>
>> /* gstreamer looks for this structure to register vicimgconvs
>> *
>> * exchange the string 'Template vicimgconv' with your vicimgconv
>> description
>> */
>> GST_PLUGIN_DEFINE (
>> GST_VERSION_MAJOR,
>> GST_VERSION_MINOR,
>> "vicimgconv",
>> "Converter for video images",
>> vicimgconv_init,
>> VERSION,
>> "LGPL",
>> "GStreamer",
>> "http://gstreamer.net/"
>> )
>>
>>
>>
>> /* Konvertierung vom YUY2 ins UYVY Format --> ByteSwapping */
>> int convYUY2toUYVY(unsigned char *source_ptr, unsigned char *result_ptr,
>> unsigned int size)
>> {
>> int i;
>>
>> /* Verarbeitung */
>> for (i = 0; i< size; i = i+2)
>> {
>> //printf("Wert %d: 0x%02X\n", i, *source_ptr);
>> *(result_ptr) = *(source_ptr + 1);
>> *(result_ptr + 1) = *(source_ptr);
>> result_ptr = result_ptr + 2;
>> source_ptr = source_ptr + 2;
>> }
>>
>> return 1;
>> }
>> ----------------------------------------------------------------------------------------------------------
>>
>>
>> This is the working application-code:
>> ----------------------------------------------------------------------------------------------------------
>> /*
>> * vicimgconv_app.c
>> *
>> * Created on: 20.12.2011
>> * Author: user
>> */
>>
>> /* modules */
>> #include<string.h>
>> #include<math.h>
>> #include<gst/gst.h>
>> #include<glib.h>
>> #include<glib-object.h>
>>
>> /* function declaration */
>>
>>
>>
>> /* main */
>> int main (int argc, char *argv[])
>> {
>> g_debug(G_STRFUNC);
>>
>> /* variables */
>> GstElement *vsrc, *vconv, *vsink;
>> GstElement *pipeline;
>> GMainLoop *loop;
>> gboolean res;
>>
>> /* always init first */
>> gst_init (&argc,&argv);
>>
>> /* the pipeline to hold everything */
>> pipeline = gst_pipeline_new (NULL);
>> g_assert (pipeline);
>>
>> /* creating all videoelements */
>> vsrc = gst_element_factory_make ("videotestsrc","vsrc");
>> g_assert(vsrc);
>> vconv = gst_element_factory_make ("vicimgconv","vicimgconv");
>> g_assert(vconv);
>> vsink = gst_element_factory_make ("xvimagesink","vsink");
>> g_assert(vsink);
>>
>> /* check if all elements are created */
>> if (!pipeline || !vsrc || !vconv || !vsink) {
>> g_printerr ("One element could not be created. Exiting.\n");
>> return -1;
>> }
>> else
>> { g_message("All elements are created.");}
>>
>> /* add all elements to the pipeline */
>> gst_bin_add_many (GST_BIN (pipeline), vsrc, vconv, vsink, NULL);
>>
>> res = gst_element_link_many(vsrc, vconv, vsink,NULL);
>> if (res == FALSE)
>> g_debug("linking error");
>>
>> /* set the pipeline to playing */
>> g_message ("starting sender pipeline\n");
>> gst_element_set_state (pipeline, GST_STATE_PLAYING);
>>
>> /* we need to run a GLib main loop to get the messages */
>> loop = g_main_loop_new (NULL, FALSE);
>> g_main_loop_run (loop);
>>
>> /* set to the pipeline to ending */
>> g_print ("stopping sender pipeline\n");
>> gst_element_set_state (pipeline, GST_STATE_NULL);
>>
>> return 0;
>> }
>> ----------------------------------------------------------------------------------------------------------
>>
>> But If I try to use filters between the elements, it is not working:
>> ----------------------------------------------------------------------------------------------------------
>>
>> /* modules */
>> #include<string.h>
>> #include<math.h>
>> #include<gst/gst.h>
>> #include<glib.h>
>> #include<glib-object.h>
>>
>> /* function declaration */
>>
>>
>>
>> /* main */
>> int main (int argc, char *argv[])
>> {
>> g_debug(G_STRFUNC);
>>
>> /* variables */
>> GstElement *vsrc, *vconv, *vsink;
>> GstElement *pipeline;
>> GMainLoop *loop;
>> gboolean res;
>> GstCaps *caps, *caps2;
>>
>> /* always init first */
>> gst_init (&argc,&argv);
>>
>> /* the pipeline to hold everything */
>> pipeline = gst_pipeline_new (NULL);
>> g_assert (pipeline);
>>
>> /* creating all videoelements */
>> vsrc = gst_element_factory_make ("videotestsrc","vsrc");
>> g_assert(vsrc);
>> vconv = gst_element_factory_make ("vicimgconv","vicimgconv");
>> g_assert(vconv);
>> vsink = gst_element_factory_make ("xvimagesink","vsink");
>> g_assert(vsink);
>>
>> /* check if all elements are created */
>> if (!pipeline || !vsrc || !vconv || !vsink) {
>> g_printerr ("One element could not be created. Exiting.\n");
>> return -1;
>> }
>> else
>> { g_message("All elements are created.");}
>>
>>
>> caps = gst_caps_new_simple ("video/x-raw-yuv" ,
>> "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
>> "width", G_TYPE_INT, 320,
>> "height", G_TYPE_INT, 240,
>> "bpp", G_TYPE_INT, 24,
>> NULL );
>>
>> caps2 = gst_caps_new_simple ("video/x-raw-yuv" ,
>> "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('U', 'Y',
>> 'V', 'Y'),
>> NULL );
>>
>>
>> /* add all elements to the pipeline */
>> gst_bin_add_many (GST_BIN (pipeline), vsrc, vconv, vsink, NULL);
>>
>> if(!gst_element_link_filtered(vsrc,vconv,caps))
>> {
>> g_print ("1 Failed to link one or more elements!\n");
>> return -1;
>> }
>>
>> if(!gst_element_link_filtered(vconv,vsink,caps2))
>> {
>> g_print ("1 Failed to link one or more elements!\n");
>> return -1;
>> }
>>
>> /* set the pipeline to playing */
>> g_message ("starting sender pipeline\n");
>> gst_element_set_state (pipeline, GST_STATE_PLAYING);
>>
>> /* we need to run a GLib main loop to get the messages */
>> loop = g_main_loop_new (NULL, FALSE);
>> g_main_loop_run (loop);
>>
>> /* set to the pipeline to ending */
>> g_print ("stopping sender pipeline\n");
>> gst_element_set_state (pipeline, GST_STATE_NULL);
>>
>> return 0;
>> }
>> ----------------------------------------------------------------------------------------------------------
>>
>> Maybe anybody has a hint for me. I suppose that I have to change
>> something in the Gst-Element vicimgconv or?
>>
>> Thanks in advance.
>>
>> Andreas
> --
> Thiago
>
>>
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list