Gst.Object.Replace doesn't seem to work
Hello
I'm trying to create a player, similar to (https://github.com/GStreamer/gst-plugins-base/blob/master/tools/gst-play.c)
In the handler for GST_MESSAGE_STREAM_COLLECTION
(line 534) there's a call to gst_object_replace
. If I understand correctly, it's supposed to replace an old collection with the new by replacing the pointers.
I try to use Gst.Object.Replace
, but it doesn't seem to work and there's an error:
(GstPlayer.exe:19812): GStreamer-CRITICAL **: gst_object_replace: assertion 'oldobj != NULL' failed
When I look at the code for the Replace
method it seems that there are a few errors.
- The
gst_object_replace
takes a **, so the import should probably be
static extern bool gst_object_replace(ref IntPtr oldobj, IntPtr newobj);
// note the ref oldobj - Also, the
Replace
method should also take aref Gst.Object oldobj
parameter. - In the case when the oldptr==null , the IntPtr value sent to the
gst_object_replace
is not anOwnedHandle
of theoldobj
, so theoldobj
doesn't change. - However, since handles in Gst.Object cannot just be replaced, when
gst_object_replace
returns true, a new value for theoldobj
needs to be created with the replaced handle.
Attached are the test and the patch. There are two versions of Replace, a generic and non-generic. Test shows the usage for both of them.
Hope it's OK, Tom
TestStreamCollection.cs 0001-A-fix-for-a-Gst.Object.Replace-in-Object.cs.patch