Help with Gst.Iterator.find_custom() in python

Marianna S. Buschle msb at qtec.com
Tue May 25 12:09:15 UTC 2021


I did manage to make it work like this:

def gst_bin_get_by_gtype(bin, type_name):
    factory = Gst.ElementFactory.find(type_name)
    if factory is None:
        print("No factory found for " + type_name)
        return None
    type = factory.get_element_type()
    print("[" + bin.get_name() + "]: looking up child element of type " +
type.name)
    
    children = bin.iterate_recurse()        
    if children is None:
        print("Iterate Error")
        return None
        
    elem = children.next().elem
    while elem:
        #print(elem.name)
        #print(elem.__gtype__)
        if elem.__gtype__ == type:
            return elem
        elem = children.next().elem
        
    return None

And found out that since gstreamer 1.18 I can also use:

    #from gst 1.18
    children = bin.iterate_all_by_element_factory_name(type_name)
    if children is None:
        print("Iterate Error")
        return None
    res = []
    elem = children.next().elem
    while elem:
        print(elem.name)
        #print(elem.__gtype__)
        res.append(elem)
        elem = children.next().elem
    return res



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list