Discussion:
[gst-devel] assertion `GST_IS_CAPS (caps)' failed
bertrand haut
2006-05-15 20:28:51 UTC
Permalink
I'm trying to port a working plugin for gstreamer 0.8 to gstreamer
0.10. The caps of this plugin are
GST_STATIC_CAPS ("video/x-raw-yuv, "
"width=(int)720, "
"height=(int)576, "
"format=(fourcc){YUY2}"
)

At this moment the chain function is simply :

static GstFlowReturn
gst_undiscret_chain (GstPad *pad, GstBuffer *buf)
{
Gstundiscret *filter;

filter = GST_UNDISCRET (GST_OBJECT_PARENT (pad));
GstBuffer * out_buf;

out_buf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(buf));
GST_BUFFER_TIMESTAMP (out_buf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_DURATION (out_buf) = GST_BUFFER_DURATION (buf);
gst_buffer_set_caps (out_buf, GST_PAD_CAPS (filter->srcpad));

memcpy (GST_BUFFER_DATA (out_buf), GST_BUFFER_DATA(buf)
,GST_BUFFER_SIZE(buf) );
gst_buffer_unref (buf);
return gst_pad_push (filter->srcpad, out_buf);
}

If I launch this plugin with
gst-launch-0.10 v4l2src ! undiscret ! xvimagesink
I got the following error message :

***@neptune:~/code/canal1$ gst-launch-0.10 v4l2src ! undiscret ! xvimagesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

(gst-launch-0.10:30194): GStreamer-CRITICAL **:
gst_caps_get_structure: assertion `GST_IS_CAPS (caps)' failed

(gst-launch-0.10:30194): GStreamer-CRITICAL **: gst_structure_get_int:
assertion `structure != NULL' failed

(gst-launch-0.10:30194): GStreamer-CRITICAL **: gst_caps_intersect:
assertion `GST_IS_CAPS (caps1)' failed

(gst-launch-0.10:30194): GStreamer-CRITICAL **: gst_caps_is_empty:
assertion `GST_IS_CAPS (caps)' failed

(gst-launch-0.10:30194): GStreamer-CRITICAL **: gst_caps_unref:
assertion `caps != NULL' failed
ERROR: from element /pipeline0/xvimagesink0: Could not write to resource.
Additional debug info:
xvimagesink.c(518): gst_xvimagesink_xvimage_new (): /pipeline0/xvimagesink0:
could not get shared memory of 0 bytes
Execution ended after 327741000 ns.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
FREEING pipeline ...
***@neptune:~/code/canal1$


Why are there such errors ?

note that if I launch
gst-launch-0.10 v4l2src ! undiscret ! fakesink
or if I replace the two last line with
return gst_pad_push (filter->srcpad, buf);
it works.


I'm simply trying to copy the data from one buffer to a second in
order to insert my code which will be a function working on
unsigned char * g_out = (unsigned char *) (GST_BUFFER_DATA(out_buf))
I assume this should be simple.

Thanks for any help.
Jan Schmidt
2006-05-16 07:19:10 UTC
Permalink
Post by bertrand haut
I'm trying to port a working plugin for gstreamer 0.8 to gstreamer
0.10. The caps of this plugin are
GST_STATIC_CAPS ("video/x-raw-yuv, "
"width=(int)720, "
"height=(int)576, "
"format=(fourcc){YUY2}"
)
static GstFlowReturn
gst_undiscret_chain (GstPad *pad, GstBuffer *buf)
{
Gstundiscret *filter;
filter = GST_UNDISCRET (GST_OBJECT_PARENT (pad));
GstBuffer * out_buf;
out_buf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(buf));
GST_BUFFER_TIMESTAMP (out_buf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_DURATION (out_buf) = GST_BUFFER_DURATION (buf);
gst_buffer_set_caps (out_buf, GST_PAD_CAPS (filter->srcpad));
^ This line is the problem. GST_PAD_CAPS (pad) is NULL until the caps
are set, either by calling gst_pad_set_caps, or by pushing a buffer that
has caps on it. You're setting the caps on the buffer to NULL, and then
pushing it. You can use gst_static_caps_get or
gst_static_pad_template_get_caps to get the caps that you've defined as
your static caps for the pad template.

Even more simply, you can copy the caps from the incoming buffer.

Or, more simply again you can replace the whole lot with

out_buf = gst_buffer_make_writable (buf);

This will a) Take ownership of the buffer reference b) Copy the buffer
and all caps/flags/timestamps etc onto a new buffer only if necessary c)
Return the result as out_buf, which is a writable version of the input
buffer, avoiding any memory copying if the original was already
writable.

Cheers,
Jan.
--
Jan Schmidt ***@noraisin.net

It all works, but it limits Linux processes to a mere 512GB of virtual
address space. Such limits are irksome to the kernel developers when the
hardware can do more, and, besides, somebody is likely to release a web
browser or office suite which runs into that limit in the near future.
- http://lwn.net/Articles/106177/
bertrand haut
2006-05-16 13:54:07 UTC
Permalink
Post by Jan Schmidt
Post by bertrand haut
I'm trying to port a working plugin for gstreamer 0.8 to gstreamer
0.10. The caps of this plugin are
GST_STATIC_CAPS ("video/x-raw-yuv, "
"width=(int)720, "
"height=(int)576, "
"format=(fourcc){YUY2}"
)
static GstFlowReturn
gst_undiscret_chain (GstPad *pad, GstBuffer *buf)
{
Gstundiscret *filter;
filter = GST_UNDISCRET (GST_OBJECT_PARENT (pad));
GstBuffer * out_buf;
out_buf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(buf));
GST_BUFFER_TIMESTAMP (out_buf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_DURATION (out_buf) = GST_BUFFER_DURATION (buf);
gst_buffer_set_caps (out_buf, GST_PAD_CAPS (filter->srcpad));
^ This line is the problem. GST_PAD_CAPS (pad) is NULL until the caps
are set, either by calling gst_pad_set_caps, or by pushing a buffer that
has caps on it. You're setting the caps on the buffer to NULL, and then
pushing it. You can use gst_static_caps_get or
gst_static_pad_template_get_caps to get the caps that you've defined as
your static caps for the pad template.
Even more simply, you can copy the caps from the incoming buffer.
Or, more simply again you can replace the whole lot with
out_buf = gst_buffer_make_writable (buf);
I've tried this proposition. My code of the chain function is for the moment

GstBuffer * out_buf;
out_buf = gst_buffer_make_writable (buf);

unsigned char * g_out = (unsigned char *) (GST_BUFFER_DATA(out_buf));

int i,j;
for(i=0 ; i < filter->height ; ++i)
for(j=0 ; j< filter->width ; ++j)
g_out[(i*filter->width+j)*2 ]=0;
return gst_pad_push (filter->srcpad, out_buf);

So gst-launch-0.10 v4l2src ! undiscret ! xvimagesink must produce a
constant image. But it does not work... I still see the tv (
/dev/video0 is a tv captur
Jan Schmidt
2006-05-16 15:00:12 UTC
Permalink
Post by bertrand haut
Post by Jan Schmidt
Or, more simply again you can replace the whole lot with
out_buf = gst_buffer_make_writable (buf);
I've tried this proposition. My code of the chain function is for the moment
GstBuffer * out_buf;
out_buf = gst_buffer_make_writable (buf);
unsigned char * g_out = (unsigned char *) (GST_BUFFER_DATA(out_buf));
int i,j;
for(i=0 ; i < filter->height ; ++i)
for(j=0 ; j< filter->width ; ++j)
g_out[(i*filter->width+j)*2 ]=0;
return gst_pad_push (filter->srcpad, out_buf);
So gst-launch-0.10 v4l2src ! undiscret ! xvimagesink must produce a
constant image. But it does not work... I still see the tv (
/dev/video0 is a tv capture card)
Are you sure that filter->height and filter->width are being set to the
right values? That's the only thing I can think of.

J.
--
Jan Schmidt ***@noraisin.net

"Stoke me a clipper, I'll be back for Christmas"
-- Arnold 'Ace' Rimmer, Red Dwarf
bertrand haut
2006-05-16 15:40:07 UTC
Permalink
Post by Jan Schmidt
Post by bertrand haut
Post by Jan Schmidt
Or, more simply again you can replace the whole lot with
out_buf = gst_buffer_make_writable (buf);
I've tried this proposition. My code of the chain function is for the moment
GstBuffer * out_buf;
out_buf = gst_buffer_make_writable (buf);
unsigned char * g_out = (unsigned char *) (GST_BUFFER_DATA(out_buf));
int i,j;
for(i=0 ; i < filter->height ; ++i)
for(j=0 ; j< filter->width ; ++j)
g_out[(i*filter->width+j)*2 ]=0;
return gst_pad_push (filter->srcpad, out_buf);
So gst-launch-0.10 v4l2src ! undiscret ! xvimagesink must produce a
constant image. But it does not work... I still see the tv (
/dev/video0 is a tv capture card)
Are you sure that filter->height and filter->width are being set to the
right values? That's the only thing I can think of.
Indeed, shame on me... I"ve cut & paste the code and I must have made
an error somewhere. Thanks for your help
--
Bertrand Haut
pgp key:B9514013C02E33F
Loading...