<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hello,<br>
I am trying to build an element that is a video transformer. It will
transform in a way that depends on downstream<br>
elements (external dependencies). The sink pad has voxelVideo as caps
and the two src pads have video/x-raw-rgb and video/x-raw-short
respectively. The video/x-raw-short is just a 16bit/pixel 1 channel
video used for a disparity map.<br>
<br>
<br>
When I try to get negotiated caps in the chain function, this fails.<br>
<br>
Code:<br>
-----<br>
<small><font face="Courier New, Courier, monospace">static
GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",<br>
GST_PAD_SINK,<br>
GST_PAD_ALWAYS,<br>
GST_STATIC_CAPS ("videoVoxel/x-raw-gray, "<br>
"width = (int) [ 16, 4096 ], "<br>
"height = (int) [ 16, 4096 ], "<br>
"voxelDepth = (int) [ 1, 4096 ], "<br>
"framerate = (fraction) [ 0/1,
2147483647/1 ]"));<br>
<br>
<br>
static GstStaticPadTemplate src_factory_rgb =
GST_STATIC_PAD_TEMPLATE("src_rgb",<br>
GST_PAD_SRC,<br>
GST_PAD_REQUEST,<br>
GST_STATIC_CAPS ("video/x-raw-rgb, "<br>
"width = (int) [ 16, 4096 ], "<br>
"bpp = (int) 24, "<br>
"height = (int) [ 16, 4096 ], "<br>
"framerate = (fraction) [ 0/1,
2147483647/1 ]"));<br>
<br>
static GstStaticPadTemplate src_factory_short =
GST_STATIC_PAD_TEMPLATE("src_short",<br>
GST_PAD_SRC,<br>
GST_PAD_REQUEST,<br>
GST_STATIC_CAPS ("video/x-raw-short, "<br>
"width = (int) [ 16, 4096 ], "<br>
"bpp = (int) 16, "<br>
"height = (int) [ 16, 4096 ], "<br>
"framerate = (fraction) [ 0/1,
2147483647/1 ]"));<br>
-----<br>
<br>
/* initialize the plugin's class */<br>
static void<br>
gst_tidvoxelrend_class_init (GsttidvoxelrendClass * klass) {<br>
...<br>
gstelement_class->request_new_pad = gst_vrender_request_new_pad;<br>
....<br>
}<br>
---------<br>
static void gst_tidvoxelrend_base_init (gpointer gclass)<br>
{<br>
...<br>
<br>
gst_element_class_add_pad_template(element_class,
gst_static_pad_template_get (&sink_factory));<br>
gst_element_class_add_pad_template(element_class,
gst_static_pad_template_get (&src_factory_rgb));<br>
gst_element_class_add_pad_template(element_class,
gst_static_pad_template_get (&src_factory_short));<br>
gst_element_class_set_details(element_class, &element_details);<br>
...<br>
<br>
}<br>
------------<br>
static GstPad *<br>
gst_vrender_request_new_pad (GstElement * element,<br>
GstPadTemplate * templ, const gchar * req_name)<br>
{<br>
Gsttidvoxelrend *vrender = GST_TIDVOXELREND (element);<br>
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);<br>
GstPad *pad;<br>
<br>
GST_DEBUG("RENDER :::::::::: new pad");<br>
<br>
g_return_val_if_fail (templ != NULL, NULL);<br>
<br>
if (templ->direction != GST_PAD_SRC) {<br>
GST_WARNING_OBJECT (vrender, "request pad is not a SRC pad");<br>
return NULL;<br>
}<br>
<br>
<br>
<br>
if (templ == gst_element_class_get_pad_template (klass, "src_rgb"))
{<br>
if (vrender->srcpad_rgb)<br>
return NULL;<br>
<br>
vrender->srcpad_rgb = gst_pad_new_from_template (templ,
"src_rgb");<br>
<br>
gst_pad_set_setcaps_function (vrender->srcpad_rgb,<br>
GST_DEBUG_FUNCPTR
(gst_tidvoxelrend_set_caps_rgb));<br>
<br>
pad = vrender->srcpad_rgb;<br>
<br>
} else if (templ == gst_element_class_get_pad_template (klass,
"src_short")) {<br>
if (vrender->srcpad_short)<br>
return NULL;<br>
<br>
vrender->srcpad_short = gst_pad_new_from_template (templ,
"src_short");<br>
<br>
gst_pad_set_setcaps_function (vrender->srcpad_short,<br>
GST_DEBUG_FUNCPTR
(gst_tidvoxelrend_set_caps_short));<br>
<br>
pad = vrender->srcpad_short;<br>
<br>
} else {<br>
g_return_val_if_reached (NULL);<br>
}<br>
<br>
gst_element_add_pad (element, pad);<br>
return pad;<br>
}<br>
-----<br>
static void gst_tidvoxelrend_init(Gsttidvoxelrend * filter,
GsttidvoxelrendClass * gclass)<br>
{<br>
GstElementClass *klass = GST_ELEMENT_GET_CLASS (filter);<br>
<br>
GST_DEBUG("In gst_tidvoxelrend_init");<br>
<br>
goodtimestamp = GOODTIMESTAMP;<br>
goodduration = GOODDURATION;<br>
gst_tidvoxelrend_pad_id = GST_TIDVOXELREND_PAD_ID;<br>
<br>
<br>
/* Src pad config */<br>
filter->sinkpad = gst_pad_new_from_template
(gst_element_class_get_pad_template (klass, "sink"), "sink");<br>
<br>
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);<br>
gst_pad_set_chain_function (filter->sinkpad,
gst_tidvoxelrend_chain);<br>
....<br>
}<br>
---------------<br>
static GstFlowReturn gst_tidvoxelrend_chain (GstPad * pad, GstBuffer *
buf)<br>
{<br>
GstCaps *debugcaps = NULL;<br>
GstStructure *structure;<br>
GList *pads;<br>
GstBuffer *outbuf = NULL;<br>
size_t outsize = 0;<br>
int rgb = 0;<br>
Gsttidvoxelrend *vrender = (Gsttidvoxelrend *) gst_pad_get_parent
(pad);<br>
<br>
<br>
<br>
pads = GST_ELEMENT_CAST (vrender)->srcpads;<br>
<br>
<br>
while (pads) {<br>
GstPad *pad;<br>
<br>
pad = GST_PAD_CAST (pads->data);<br>
<br>
GST_DEBUG("RENDER :::::::::: pad name = %s", GST_PAD_NAME(pad));<br>
<br>
/* We get the already negotiated caps to reapply them on the src
pad */<br>
debugcaps = gst_pad_get_negotiated_caps(pad);<br>
<br>
GST_DEBUG("RENDER :::::::::: after get_negotiated_caps");<br>
<br>
/* Get output buffer size */<br>
<br>
structure = gst_caps_get_structure (debugcaps, 0);<br>
<br>
GST_DEBUG("RENDER :::::::::: after caps_get_structure");<br>
<br>
<br>
if (strstr (GST_PAD_NAME(pad), "src_rgb")) {<br>
outsize = vrender->out_width * vrender->out_height * 3;<br>
rgb = 1;<br>
}<br>
else {<br>
outsize = vrender->out_width * vrender->out_height * 2;<br>
rgb = 0;<br>
}<br>
<br>
if( gst_pad_alloc_buffer_and_set_caps (pad,<br>
GST_BUFFER_OFFSET_NONE,<br>
outsize,<br>
debugcaps,<br>
&outbuf) !=
GST_FLOW_OK )<br>
<br>
................<br>
<br>
}<br>
----------------<br>
<br>
</font><br>
<font face="Courier New, Courier, monospace"><br>
</font></small>When I try to run this element with one fakesink
afterwards:<br>
<br>
<small><font face="Courier New, Courier, monospace">gstlaunch
someplugins ! tidvoxelrend name=rend rend. ! fakesink dump=true<br>
<br>
</font></small>I get:<br>
<br>
<br>
<small><font face="Courier New, Courier, monospace">0:00:01.427001861
25832 0x7fd6b0002f00 DEBUG tidvoxelrend
voxelRenderer/gsttidvoxelrend.c:606:gst_tidvoxelrend_chain: RENDER
:::::::::: pad name = src_rgb<br>
0:00:01.427033240 25832 0x7fd6b0002f00 DEBUG tidvoxelrend
voxelRenderer/gsttidvoxelrend.c:611:gst_tidvoxelrend_chain: RENDER
:::::::::: after get_negotiated_caps<br>
<br>
(gst-launch-0.10:25832): GStreamer-CRITICAL **: gst_caps_get_structure:
assertion `GST_IS_CAPS (caps)' failed<br>
0:00:01.427112209 25832 0x7fd6b0002f00 DEBUG tidvoxelrend
voxelRenderer/gsttidvoxelrend.c:617:gst_tidvoxelrend_chain: RENDER
:::::::::: after caps_get_structure<br>
<br>
<br>
<br>
</font></small>What could be wrong here, please?<br>
<br>
<br>
Thanks in advance,<br>
<br>
<br>
Mattias<br>
<small><font face="Courier New, Courier, monospace"><br>
<br>
<br>
</font></small>
<pre class="moz-signature" cols="72">--
Mattias Frank Barthel
Vía Augusta 177 08021 Barcelona (Spain)
Video & Multimedia technologies
TELEFÓNICA R&D
T. 0034-93-365-3309
</pre>
</body>
</html>