go-gst icon indicating copy to clipboard operation
go-gst copied to clipboard

Handle up- and downcasting safely

Open RSWilli opened this issue 10 months ago • 11 comments

This takes #79 and generalizes it.

We need to add some methods to convert the objects safely between the type hierarchie. E.g. a call to gst_element_get_static_pad always returns a GstPad aka *gst.Pad, but in some cases (e.g. bins) these pads are actually a GstGhostPad, and currently there is no safe way to convert them for the go application.

Similarly, gst_parse_launch returns a GstElement, but oftentimes a pipeline or bin is needed.

This is also be relevant for glib signals (see https://github.com/go-gst/go-gst/discussions/77#discussioncomment-9099011) where we unmarshal elements and sometimes do not have unmarshaler for every plugin, e.g. GstMpegAudioParse, but in other times we need to downcast an unmarshaled *gst.Element to a *gst.Object because the signal handler expects it that way.

RSWilli avatar Apr 14 '24 13:04 RSWilli