<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 2, 2019 at 2:11 AM De Pauw jimmy <<a href="mailto:jimmy@dcode.eu">jimmy@dcode.eu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>Hello all,</p>
<p>I have a custom plugin that need to send message.<br>
The data for this message are an array of basic struct with only
simple numeric types in it.</p>
<p>I can store and retrieve any simple thing in GstStructure without
any issue but after more than 1 day of searching, i cannot manage
to make an array work.<br>
Even an array of int does not work at all.</p></div></blockquote><div><br></div><div>Hi, you can set a boxed type into a gvalue and put that into a GstStructure. I couldn't figure out how to do that directly from gst_structure_new (no time to read the source code now) but you can call gst_structure_set_value in the newly created structure and it works. Attached a modification of your snipped that works for me.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF">
<p>I tried with a small test program :</p>
<pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"DejaVu Sans Mono";font-size:10.5pt">GArray *garray = g_array_new(FALSE<span style="color:rgb(204,120,50)">, </span>FALSE<span style="color:rgb(204,120,50)">, sizeof</span>(cstruct))<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)">
</span>cstruct it = {}<span style="color:rgb(204,120,50)">;
</span>it.x = <span style="color:rgb(104,151,187)">10</span><span style="color:rgb(204,120,50)">;
</span>it.y = <span style="color:rgb(104,151,187)">20</span><span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)">
</span>cstruct it2 = {}<span style="color:rgb(204,120,50)">;
</span>it.x = <span style="color:rgb(104,151,187)">30</span><span style="color:rgb(204,120,50)">;
</span>it.y = <span style="color:rgb(104,151,187)">40</span><span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)">
</span>g_array_append_val(garray<span style="color:rgb(204,120,50)">, </span>it)<span style="color:rgb(204,120,50)">;
</span>g_array_append_val(garray<span style="color:rgb(204,120,50)">, </span>it2)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)">
</span>GstStructure *event_struct = gst_structure_new(
<span style="color:rgb(106,135,89)">"teststruct"</span><span style="color:rgb(204,120,50)">,
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(106,135,89)">"testint"</span><span style="color:rgb(204,120,50)">, </span>G_TYPE_UINT<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">1</span><span style="color:rgb(204,120,50)">,
</span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(106,135,89)">"testarr"</span><span style="color:rgb(204,120,50)">, </span>G_TYPE_ARRAY<span style="color:rgb(204,120,50)">, </span>garray<span style="color:rgb(204,120,50)">,
</span><span style="color:rgb(204,120,50)"> </span>NULL
)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)">
</span><span style="color:rgb(204,120,50)">const </span>GValue *arrval = gst_structure_get_value(event_struct<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"testarr"</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(128,128,128)">// No idea how to get my array back here
</span>GArray *structarr = (GArray *)arrval<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)">
</span>cstruct *t = &g_array_index(structarr<span style="color:rgb(204,120,50)">, </span>cstruct<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(104,151,187)">0</span>)<span style="color:rgb(204,120,50)">;
</span><span style="color:rgb(204,120,50)">
</span>printf(<span style="color:rgb(106,135,89)">"%u</span><span style="color:rgb(204,120,50)">\n</span><span style="color:rgb(106,135,89)">"</span><span style="color:rgb(204,120,50)">, </span>t->y)<span style="color:rgb(204,120,50)">;</span></pre>
<p>The way to get my GArray back is most likely not the right way
but i haven't found any leads on how to do it.<br>
I also don't know if i can build the GstStructure that way.</p>
<p>I tried using a boxed GValue to store my GArray but it doesn't
matter how i try to do it, it always segfault on
gst_structure_new.</p>
<p>GValueArray is deprecated so i tried to do without it, maybe it's
not currently possible with gstreamer.</p>
<p>Thanks<br>
</p>
</div>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a></blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">Thiago Sousa Santos</div></div>