<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><div>Hi Tim,</div><div>thanks for the help, I'll give it a try and see how that works.</div><div>Concerning the other problem, I've submitted the bug with a short extract of my file that still generates the problem: <span class="Apple-style-span" style="font-family: 'Bitstream Vera Sans', 'Luxi Sans', 'Lucida Grande', 'Trebuchet MS', helvetica, verdana, arial, sans-serif; font-size: small; color: rgb(51, 51, 51); font-weight: bold; "><i><a href="https://bugzilla.gnome.org/show_bug.cgi?id=623663" title="UNCONFIRMED - Cannot read MTS file with decodebin" style="color: rgb(0, 51, 153); ">Bug 623663</a></i></span></div><div><span class="Apple-style-span" style="font-family: 'Bitstream Vera Sans', 'Luxi Sans', 'Lucida Grande', 'Trebuchet MS', helvetica, verdana, arial, sans-serif; font-size:
small; color: rgb(51, 51, 51); font-weight: bold; ">Regards,</span></div><div><span class="Apple-style-span" style="font-family: 'Bitstream Vera Sans', 'Luxi Sans', 'Lucida Grande', 'Trebuchet MS', helvetica, verdana, arial, sans-serif; font-size: small; color: rgb(51, 51, 51); font-weight: bold; ">Al</span></div><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><br><div style="font-family:arial, helvetica, sans-serif;font-size:13px"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">De :</span></b> Tim-Philipp Müller <t.i.m@zen.co.uk><br><b><span style="font-weight: bold;">À :</span></b> gstreamer-devel@lists.sourceforge.net<br><b><span style="font-weight: bold;">Envoyé le :</span></b> Mar 6 juillet 2010, 10h 05min 22s<br><b><span style="font-weight: bold;">Objet :</span></b> Re: [gst-devel] Freeing application data from message<br></font><br>On Mon, 2010-07-05 at 12:11 +0000,
Albert Costa wrote:<br><br><br>> MyInfo* myinfo = new MyInfo;<br>> /* do stuff with myinfo, including allocating internal data */<br>><br>> structure = gst_structure_new("FILTERMESSAGE",<br>> "info", G_TYPE_POINTER, (gpointer)myinfo, <br>> NULL); <br><br>The problem here is that you're using G_TYPE_POINTER. If you use<br>G_TYPE_POINTER, the type system doesn't know how to copy or free your<br>data, so it's up to you to take care of this.<br><br>What you should do is register a 'boxed type' for your structure, like<br>this:<br><br>static MyInfo *<br>my_info_ref (MyInfo * info)<br>{<br> if (info != NULL)<br> g_atomic_int_inc (&info->refcount);<br><br> return info;<br>}<br><br>static void<br>my_info_unref (MyInfo * info)<br>{<br> /* if we ended up with the refcount at zero, free it */<br> if (g_atomic_int_dec_and_test (&info->refcount))
{<br> /* g_free (info->foo); */<br> /* g_free (info); */<br> }<br>}<br><br>#define MY_TYPE_INFO my_info_get_type()<br><br>static GType<br>my_info_get_type (void)<br>{<br> static volatile gsize type = 0;<br> if (g_once_init_enter (&type)) {<br> GType tmp;<br> tmp = g_boxed_type_register_static ("MyInfo",<br> (GBoxedCopyFunc) my_info_ref,<br> (GBoxedFreeFunc) my_info_unref);<br> g_once_init_leave (&type, tmp);<br> }<br> return type;<br>}<br><br>Then you can use:<br><br>> structure = gst_structure_new("FILTERMESSAGE",<br>> "info", MY_TYPE_INFO, myinfo, NULL);<br>> my_info_unref (myinfo);<br><br>and the info will be freed automatically with the message later (unless<br>you are still holding refs).<br><br><br>> gst_bus_post (bus, msg);<br><br>Use
gst_element_post_message().<br><br><br>> On the other side, I have my application that watches the bus<br>> messages, and gets my info:<br>> case GST_MESSAGE_APPLICATION:<br>> const GstStructure *structure =<br>> gst_message_get_structure(message);<br>> MyInfo* info;<br>> info =<br>> (MyInfo*)g_value_get_pointer(gst_structure_get_value(structure,<br>> "info"));<br><br>You can then use _get_boxed() here (to just get a pointer to your info<br>structure), or _dup_boxed() (to get a pointer and a reference).<br>> <br>Cheers<br> -Tim<br><br>PS: you still have not filed a bug about that MTS typefind problem from<br>a few days ago. Could you please do that and/or send me the (beginning<br>of the) file?<br><br><br><br><br>------------------------------------------------------------------------------<br>This SF.net email is sponsored by
Sprint<br>What will you do first with EVO, the first 4G phone?<br>Visit sprint.com/first -- <a href="http://p.sf.net/sfu/sprint-com-first" target="_blank">http://p.sf.net/sfu/sprint-com-first</a><br>_______________________________________________<br>gstreamer-devel mailing list<br><a ymailto="mailto:gstreamer-devel@lists.sourceforge.net" href="mailto:gstreamer-devel@lists.sourceforge.net">gstreamer-devel@lists.sourceforge.net</a><br><a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br></div></div><div style="position:fixed"></div>
</div><br>
</body></html>