Store/Retrieve array of struct in GstStructure

Thiago Sousa Santos thiagossantos at gmail.com
Tue Apr 2 18:34:43 UTC 2019


On Tue, Apr 2, 2019 at 2:11 AM De Pauw jimmy <jimmy at dcode.eu> wrote:

> Hello all,
>
> I have a custom plugin that need to send message.
> The data for this message are an array of basic struct with only simple
> numeric types in it.
>
> 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.
> Even an array of int does not work at all.
>

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.


> I tried with a small test program :
>
> GArray *garray = g_array_new(FALSE, FALSE, sizeof(cstruct));cstruct it = {};it.x = 10;it.y = 20;cstruct it2 = {};it.x = 30;it.y = 40;g_array_append_val(garray, it);g_array_append_val(garray, it2);GstStructure *event_struct = gst_structure_new(
>         "teststruct",        "testint", G_TYPE_UINT, 1,        "testarr", G_TYPE_ARRAY, garray,        NULL
> );const GValue *arrval = gst_structure_get_value(event_struct, "testarr");// No idea how to get my array back hereGArray *structarr = (GArray *)arrval;cstruct *t = &g_array_index(structarr, cstruct, 0);printf("%u\n", t->y);
>
> 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.
> I also don't know if i can build the GstStructure that way.
>
> 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.
>
> GValueArray is deprecated so i tried to do without it, maybe it's not
> currently possible with gstreamer.
>
> Thanks
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



-- 
Thiago Sousa Santos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190402/5badc606/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 989 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190402/5badc606/attachment.c>


More information about the gstreamer-devel mailing list