Get GstStructure from GValue?

Eric Montellese eric.montellese at videon-central.com
Sun Nov 4 14:07:56 PST 2012


Unbelievable.  As soon as I send to the listserv, I find the answer...
which is simply this:

gst_value_get_structure()


I was looking at this documentation (gobject)
http://developer.gnome.org/gobject/stable/gobject-Standard-Parameter-and-Value-Types.html

and not this one (gstreamer):
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstValue.html#gst-value-get-structure


D'oh!






On Sun, Nov 4, 2012 at 5:02 PM, Eric Montellese
<eric.montellese at videon-central.com> wrote:
> I'm guessing this one has a very easy answer, but googling and
> trial-and-error hasn't done it for me yet...  so hoping this will be
> obvious to someone a bit more knowledgeable.
>
>
> I have a GValue which contains a GstStructure, but I'm not sure how to
> retrieve the GstStructure value.
>
>
>
> code looks something like below.  This happens in a bus message
> GST_MESSAGE_ELEMENT event:
>
> ...
> ...
> const GstStructure *s = gst_message_get_structure(msg)   //msg is the
> message passed in
>
> gchar *s_string = gst_structure_to_string(s);
> g_print("structure is \n%s\n", s_string);
> g_free(s_string);
>
> const GValue* tsid = gst_structure_get_value(s, "transport-stream-id");
> g_print("transport stream id: %u\n", g_value_get_uint(tsid));
>
> const GValue* progs = gst_structure_get_value(s, "programs");
> g_print("programs type is: %s\nlength is: %u\n",
> G_VALUE_TYPE_NAME(progs), gst_value_list_get_size(progs));
>
> for (i = 0; i < gst_value_list_get_size(progs); i++)
> {
>   const GValue *prog = gst_value_list_get_value(progs, i);
>   g_print("program type is: %s\n", G_VALUE_TYPE_NAME(prog));
>
>   //with this line in, it doesn't compile.
>   g_print("name: %s\n", gst_structure_get_name(s));
>   //error is:   unittest.cpp:112:70: error: cannot convert 'const
> GValue*' to 'const GstStructure*' for argument '1' to 'const gchar*
> gst_structure_get_name(const GstStructure*)'
> }
> ...
> ...
>
>
> The output (when the erroring line is removed) is this:
> structure is
> pat, transport-stream-id=(uint)0, programs=(structure){ "program-1\,\
> program-number\=\(uint\)1\,\ pid\=\(uint\)480\;" };
> transport stream id: 0
> programs type is: GstValueList
> length is: 1
> program type is: GstStructure
>
>
> I know that one would usually need to do a "g_value_get_int" sort of
> thing (as I did for the other value) to get the value in the GValue --
> but what do I do for a GstStructure?  (i've tried a few things and
> haven't had luck).
>
>
>
> Thanks!
> Eric


More information about the gstreamer-devel mailing list