Пример #1
0
def element_make_from_uri(uri, type_=Gst.URIType.SRC):
    """Creates Gst element from URI locator
    """
    if not Gst.uri_is_valid(uri):
        raise Exception("Invalid URI {}".format(uri))

    proto = Gst.uri_get_protocol(uri)

    if proto == "tcp":
        u = Gst.uri_from_string(uri)
        return elmake("tcpserversrc", host=u.get_host(), port=u.get_port())

    if not Gst.uri_protocol_is_supported(type_, proto):
        raise Exception("Protocol {} not supported, URI {}".format(proto, uri))

    return Gst.Element.make_from_uri(type_, uri, None)