Plugin Writing - Pad Caps Format Change

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Plugin Writing - Pad Caps Format Change

Emre Anıl Terzioglu
Hi,

I am trying to make filter element(based on videofilter class) which take
GRAY16_LE format on src pad and give RGB format on sink pad(code added
below). When i define pads in class_init function, other element on up or
down stream could not link with my plugin(in transform _ip function i change
frame data GRAY16_LE to RGB). What should i do in this situation?

Thanks,


GstCaps *in_caps = gst_caps_new_simple ("video/x-raw",
                                                                         "format", G_TYPE_STRING, "GRAY16_LE",
                                                                         "framerate", GST_TYPE_FRACTION, 25, 1,
                                                                         "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
                                                                         "width", G_TYPE_INT, 320,
                                                                         "height", G_TYPE_INT, 256,
                                                                         NULL);
GstCaps *out_caps = gst_caps_new_simple ("video/x-raw",
                                                                         "format", G_TYPE_STRING, "RGB",
                                                                         "framerate", GST_TYPE_FRACTION, 25, 1,
                                                                         "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
                                                                         "width", G_TYPE_INT, 320,
                                                                         "height", G_TYPE_INT, 256,
                                                                         NULL);
gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass),
      gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
         in_caps));

gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass),
      gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
          out_caps));





--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Writing - Pad Caps Format Change

j1432
I'm having the same problem I think with a very similar transformation.  I'm
going from YUY2 (but not really YUY2, it is just being called that and has
two bytes per pixel) into RGB, where I need three bytes per pixel.    

I can get everything to connect up by either using fakesink or videoconvert
and my caps appear to be as I set them.  Transform_caps is being called a
few times before the start function is called.  Things go south on the first
sink event after that.  

Here are the caps that are being set on my src pad:

video/x-raw, width=(int)1280, height=(int)960, framerate=(fraction)[ 0/1,
2147483647/1 ], format=(string)RGB

On the first sink event, it gives an error that there is an internal data
stream error then I get
streaming stopped, reason not-negotiated (-4)

On the second sink event, I get the same two errors and then it tells me
that execution ended.  

I feel that this is purely about the caps that I am specifying but am
stumbling in the dark.  My transform function where I am intending to copy
the input buffer over to the output buffer is never being called so the
issue isn't there.  

If you or anyone reading this can help, I'd appreciate it.  








--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Writing - Pad Caps Format Change

j1432
In reply to this post by Emre Anıl Terzioglu
<MODERATOR:   Why are my messages getting moderated?  I am a member of this
forum, which I understand means that I shouldn't get moderated.>

Here's a follow up on your message after my last reply:

  I see after re-reading that you are trying to use transform_ip.  My
understanding is that if have different caps on the input and output pads,
you need to use the transform function rather than transform_ip, which
stands for "transform in place".   With the transform function, you are
manually copying from one buffer into another.  With transform in place, you
just modify the buffer.

Another thing that I just tried that had some results was that if I set my
caps to RGBx instead of RGB, autovideosink now will connect to my element (I
think). Before that change, when connecting to autovideosink,  I would see
that my caps were EMPTY in the transform_caps function but now they are what
I expect.

I'm still getting the following debug messages though:

gst_ocamelement_sink_event

New clock: GstSystemClock
0:00:00.174752476  3517 0x55dfb07c9280 DEBUG            ocamelement
ocamelement.c:382:gst_ocamElement_transform_caps:<ocamelement0> transformed
video/x-raw, format=(string)RGBx, width=(int)1280, height=(int)960,
framerate=(fraction)[ 0/1, 2147483647/1 ] into video/x-raw,
format=(string)RGBx, width=(int)1280, height=(int)960
0:00:00.174780592  3517 0x55dfb07c9280 WARN                 basesrc
gstbasesrc.c:3055:gst_base_src_loop:<autovideosrc0-actual-src-v4l> error:
Internal data stream error.
0:00:00.174787494  3517 0x55dfb07c9280 WARN                 basesrc
gstbasesrc.c:3055:gst_base_src_loop:<autovideosrc0-actual-src-v4l> error:
streaming stopped, reason not-negotiated (-4)

gst_ocamelement_sink_event

ERROR: from element
/GstPipeline:pipeline0/GstAutoVideoSrc:autovideosrc0/GstV4l2Src:autovideosrc0-actual-src-v4l:
Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop ():
/GstPipeline:pipeline0/GstAutoVideoSrc:autovideosrc0/GstV4l2Src:autovideosrc0-actual-src-v4l:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.000186306




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Writing - Pad Caps Format Change

Emre Anıl Terzioglu
Hi there,

Thanks for reply, I switched normal Transform function and added
transform_caps function(Trying to convert GRAY16_LE to GRAY8. Transform_caps
added below), now i think i am doing things in true way but i am still
getting same errors.My debug output added below. Do you have any idea about
"GST_ELEMENT_PADS gstutils.c:1061:gst_element_get_compatible_pad: found
existing unlinked compatible pad mistherfilter0:sink".

Thanks.

DEBUG OUTPUT:

0:00:00.568450393 16427      0x24a5800 INFO                GST_PADS
gstutils.c:932:gst_pad_check_link: trying to link fakesrc0:src and
myfilter0:sink
0:00:00.568459077 16427      0x24a5800 DEBUG               GST_CAPS
gstutils.c:2840:gst_pad_query_caps:<fakesrc0:src> get pad caps with filter
(NULL)
0:00:00.568469537 16427      0x24a5800 DEBUG                  query
gstquery.c:674:gst_query_new_custom: creating new query 0x25d75e0 caps
0:00:00.568477304 16427      0x24a5800 DEBUG               GST_PADS
gstpad.c:3915:gst_pad_query:<fakesrc0:src> doing query 0x25d75e0 (caps)
0:00:00.568489201 16427      0x24a5800 DEBUG                basesrc
gstbasesrc.c:1296:gst_base_src_default_query:<fakesrc0> query caps returns 1
0:00:00.568496979 16427      0x24a5800 DEBUG               GST_PADS
gstpad.c:3938:gst_pad_query:<fakesrc0:src> sent query 0x25d75e0 (caps),
result 1
0:00:00.568505548 16427      0x24a5800 DEBUG               GST_CAPS
gstutils.c:2847:gst_pad_query_caps:<fakesrc0:src> query returned ANY
0:00:00.568516127 16427      0x24a5800 DEBUG               GST_CAPS
gstutils.c:2840:gst_pad_query_caps:<myfilter0:sink> get pad caps with filter
(NULL)
0:00:00.568523948 16427      0x24a5800 DEBUG                  query
gstquery.c:674:gst_query_new_custom: creating new query 0x25d7630 caps
0:00:00.568532111 16427      0x24a5800 DEBUG               GST_PADS
gstpad.c:3915:gst_pad_query:<myfilter0:sink> doing query 0x25d7630 (caps)
0:00:00.568541383 16427      0x24a5800 DEBUG          basetransform
gstbasetransform.c:730:gst_base_transform_query_caps:<myfilter0:sink> peer
filter caps (NULL)
0:00:00.568549557 16427      0x24a5800 DEBUG               GST_CAPS
gstutils.c:2886:gst_pad_peer_query_caps:<myfilter0:src> get pad peer caps
with filter (NULL)
0:00:00.568577106 16427      0x24a5800 DEBUG                  query
gstquery.c:674:gst_query_new_custom: creating new query 0x25d75e0 caps
0:00:00.568602805 16427      0x24a5800 DEBUG               GST_PADS
gstpad.c:4042:gst_pad_peer_query:<myfilter0:src> peer query 0x25d75e0 (caps)
0:00:00.568612816 16427      0x24a5800 INFO                GST_PADS
gstpad.c:4098:gst_pad_peer_query:<myfilter0:src> pad has no peer
0:00:00.568622454 16427      0x24a5800 DEBUG          basetransform
gstbasetransform.c:746:gst_base_transform_query_caps:<myfilter0:sink> peer
caps  ANY
0:00:00.568629926 16427      0x24a5800 DEBUG          basetransform
gstbasetransform.c:749:gst_base_transform_query_caps:<myfilter0:sink> our
template  video/x-raw, format=(string)GRAY16_LE, width=(int)[ 1, 2147483647
], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
0:00:00.568645714 16427      0x24a5800 DEBUG          basetransform
gstbasetransform.c:751:gst_base_transform_query_caps:<myfilter0:sink>
intersected video/x-raw, format=(string)GRAY16_LE, width=(int)[ 1,
2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1,
2147483647/1 ]
0:00:00.568656532 16427      0x24a5800 DEBUG          basetransform
gstbasetransform.c:533:gst_base_transform_transform_caps:<myfilter0>
transform caps (direction = 1)
0:00:00.568681582 16427      0x24a5800 DEBUG          basetransform
gstbasetransform.c:560:gst_base_transform_transform_caps:<myfilter0> to:
video/x-raw, format=(string)GRAY8, width=(int)[ 1, 2147483647 ],
height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
0:00:00.568697034 16427      0x24a5800 DEBUG          basetransform
gstbasetransform.c:759:gst_base_transform_query_caps:<myfilter0:sink>
transformed  video/x-raw, format=(string)GRAY8, width=(int)[ 1, 2147483647
], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
0:00:00.568707124 16427      0x24a5800 DEBUG          basetransform
gstbasetransform.c:766:gst_base_transform_query_caps:<myfilter0:sink> our
template  video/x-raw, format=(string)GRAY8, width=(int)[ 1, 2147483647 ],
height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
0:00:00.568719317 16427      0x24a5800 DEBUG          basetransform
gstbasetransform.c:769:gst_base_transform_query_caps:<myfilter0:sink>
intersected video/x-raw, format=(string)GRAY8, width=(int)[ 1, 2147483647 ],
height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
0:00:00.568729287 16427      0x24a5800 DEBUG          basetransform
gstbasetransform.c:793:gst_base_transform_query_caps:<myfilter0> returning
video/x-raw, format=(string)GRAY8, width=(int)[ 1, 2147483647 ],
height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
0:00:00.568739245 16427      0x24a5800 DEBUG               GST_PADS
gstpad.c:3938:gst_pad_query:<myfilter0:sink> sent query 0x25d7630 (caps),
result 1
0:00:00.568747548 16427      0x24a5800 DEBUG               GST_CAPS
gstutils.c:2847:gst_pad_query_caps:<myfilter0:sink> query returned
video/x-raw, format=(string)GRAY8, width=(int)[ 1, 2147483647 ],
height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
0:00:00.568759369 16427      0x24a5800 DEBUG       GST_ELEMENT_PADS
gstutils.c:1061:gst_element_get_compatible_pad: found existing unlinked
compatible pad myfilter0:sink
0:00:00.568768671 16427      0x24a5800 INFO                GST_PADS
gstutils.c:1446:prepare_link_maybe_ghosting: fakesrc0 and myfilter0 in same
bin, no need for ghost pads

*_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_
*
Transform_caps Function:


static GstCaps *
gst_myfilter_transform_caps (GstBaseTransform * trans,
    GstPadDirection direction, GstCaps * caps, GstCaps * filter)
{
        GstCaps *to, *ret;
  GstCaps *templ;
  GstStructure *structure;
  GstPad *other;
  gint i;
        printf("DEBUG 1 %s \n",__func__);
  to = gst_caps_new_empty ();

  for (i = 0; i < gst_caps_get_size (caps); i++) {
    const GValue *v;
    GValue list = { 0, };
    GValue val = { 0, };
                printf("DEBUG 2 %s \n",__func__);
    structure = gst_structure_copy (gst_caps_get_structure (caps, i));

    g_value_init (&list, GST_TYPE_LIST);

    g_value_init (&val, G_TYPE_STRING);
    g_value_set_string (&val, "GRAY8");
    gst_value_list_append_value (&list, &val);
    g_value_unset (&val);
                printf("DEBUG 3 %s \n",__func__);
    g_value_init (&val, G_TYPE_STRING);
/*
#if G_BYTE_ORDER == G_BIG_ENDIAN
    g_value_set_string (&val, "GRAY16_BE");
#else
    g_value_set_string (&val, "GRAY16_LE");
#endif
*/
                g_value_set_string (&val, "GRAY16_LE");
    gst_value_list_append_value (&list, &val);
    g_value_unset (&val);
                printf("DEBUG 4 %s \n",__func__);
    v = gst_structure_get_value (structure, "format");

    gst_value_list_merge (&val, v, &list);
    gst_structure_set_value (structure, "format", &val);
    g_value_unset (&val);
    g_value_unset (&list);

    gst_structure_remove_field (structure, "colorimetry");
    gst_structure_remove_field (structure, "chroma-site");
                printf("DEBUG 5 %s \n",__func__);
    gst_caps_append_structure (to, structure);

  }
  /* filter against set allowed caps on the pad */
  other = (direction == GST_PAD_SINK) ?  trans->srcpad : trans->sinkpad;
  templ = gst_pad_get_pad_template_caps (other);
  ret = gst_caps_intersect (to, templ);
  gst_caps_unref (to);
  gst_caps_unref (templ);
        printf("DEBUG 6 %s \n",__func__);
  if (ret && filter) {
    GstCaps *intersection;
                printf("DEBUG 7 %s \n",__func__);
    intersection =
        gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST);
    gst_caps_unref (ret);
    ret = intersection;
  }
        printf("DEBUG 8 %s \n",__func__);
  return ret;
}



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Writing - Pad Caps Format Change

Emre Anıl Terzioglu
I SOLVED the problem with:
-Switching Transform_ip to Transform function,
-Adding Transform_caps function(functionally same as my previous post),
-Using set_info function,

Now it's working. Thanks for help

Have a nice day.
Emre Anıl Terzioglu



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Writing - Pad Caps Format Change

j1432
In reply to this post by Emre Anıl Terzioglu
I have it too now.  I wasn't clear about what the transform_caps function was
supposed to do.  I assumed that if I was given a direction of GST_PAD_SINK
that I needed to change the caps to what worked on a sink pad otherwise,
change them to what is needed on a src pad.   None of the elements that I
was referencing had any comments.  Eventually I looked at the base class's
code and there was a comment saying that I should be doing exactly the
opposite thing.   :(

I'm glad I have it now though.  



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel