예제 #1
0
def get_compatible_sink_pad(factoryname, caps):
    """
    Returns the pad name of a (request) pad from factoryname which is
    compatible with the given caps.
    """
    factory = gst.registry_get_default().lookup_feature(factoryname)
    if factory == None:
        log.warning("encode", "%s is not a valid factoryname", factoryname)
        return None

    res = []
    sinkpads = [
        x for x in factory.get_static_pad_templates()
        if x.direction == gst.PAD_SINK
    ]
    for p in sinkpads:
        c = p.get_caps()
        log.log("encode", "sinkcaps %s", c.to_string())
        inter = caps.intersect(c)
        log.log("encode", "intersection %s", inter.to_string())
        if inter:
            res.append(p.name_template)
    if len(res) > 0:
        return res[0]
    return None
예제 #2
0
def get_compatible_sink_caps(factoryname, caps):
    """
    Returns the compatible caps between 'caps' and the sink pad caps of 'factoryname'
    """
    log.log("encode", "factoryname : %s , caps : %s", factoryname,
            caps.to_string())
    factory = gst.registry_get_default().lookup_feature(factoryname)
    if factory == None:
        log.warning("encode", "%s is not a valid factoryname", factoryname)
        return None

    res = []
    sinkcaps = [
        x.get_caps() for x in factory.get_static_pad_templates()
        if x.direction == gst.PAD_SINK
    ]
    for c in sinkcaps:
        log.log("encode", "sinkcaps %s", c.to_string())
        inter = caps.intersect(c)
        log.log("encode", "intersection %s", inter.to_string())
        if inter:
            res.append(inter)

    if len(res) > 0:
        return res[0]
    return None
예제 #3
0
파일: encode.py 프로젝트: dparker18/Pitivi
def get_compatible_sink_pad(factoryname, caps):
    """
    Returns the pad name of a (request) pad from factoryname which is
    compatible with the given caps.
    """
    factory = gst.registry_get_default().lookup_feature(factoryname)
    if factory == None:
        log.warning("encode", "%s is not a valid factoryname", factoryname)
        return None

    res = []
    sinkpads = [x for x in factory.get_static_pad_templates() if x.direction == gst.PAD_SINK]
    for p in sinkpads:
        c = p.get_caps()
        log.log("encode", "sinkcaps %s", c.to_string())
        inter = caps.intersect(c)
        log.log("encode", "intersection %s", inter.to_string())
        if inter:
            res.append(p.name_template)
    if len(res) > 0:
        return res[0]
    return None
예제 #4
0
파일: encode.py 프로젝트: dparker18/Pitivi
def get_compatible_sink_caps(factoryname, caps):
    """
    Returns the compatible caps between 'caps' and the sink pad caps of 'factoryname'
    """
    log.log("encode", "factoryname : %s , caps : %s", factoryname, caps.to_string())
    factory = gst.registry_get_default().lookup_feature(factoryname)
    if factory == None:
        log.warning("encode", "%s is not a valid factoryname", factoryname)
        return None

    res = []
    sinkcaps = [x.get_caps() for x in factory.get_static_pad_templates() if x.direction == gst.PAD_SINK]
    for c in sinkcaps:
        log.log("encode", "sinkcaps %s", c.to_string())
        inter = caps.intersect(c)
        log.log("encode", "intersection %s", inter.to_string())
        if inter:
            res.append(inter)

    if len(res) > 0:
        return res[0]
    return None
예제 #5
0
def make_property_widget(unused_element, prop, value=None):
    """ Creates a Widget for the given element property """
    # FIXME : implement the case for flags
    type_name = gobject.type_name(prop.value_type.fundamental)

    if value == None:
        value = prop.default_value
    if (type_name == 'gchararray'):
        widget = gtk.Entry()
        widget.set_text(str(value))
    elif (type_name in [
            'guint64', 'gint64', 'guint', 'gint', 'gfloat', 'gdouble', 'gulong'
    ]):
        widget = gtk.SpinButton()
        if type_name == 'gint':
            minimum, maximum = (-(2**31), 2**31 - 1)
            widget.set_increments(1.0, 10.0)
        elif type_name == 'guint':
            minimum, maximum = (0, 2**32 - 1)
            widget.set_increments(1.0, 10.0)
        elif type_name == 'gint64':
            minimum, maximum = (-(2**63), 2**63 - 1)
            widget.set_increments(1.0, 10.0)
        elif type_name in ['gulong', 'guint64']:
            minimum, maximum = (0, 2**64 - 1)
            widget.set_increments(1.0, 10.0)
        elif type_name == 'gfloat' or type_name == 'gdouble':
            minimum, maximum = (float("-Infinity"), float("Infinity"))
            widget.set_increments(0.00001, 0.01)
            widget.set_digits(5)
        if hasattr(prop, "minimum"):
            minimum = prop.minimum
        if hasattr(prop, "maximum"):
            maximum = prop.maximum
        widget.set_range(minimum, maximum)
        widget.props.climb_rate = 0.01 * abs(
            min(maximum, 1000) - max(minimum, -1000))
        widget.set_value(float(value))
    elif (type_name == 'gboolean'):
        widget = gtk.CheckButton()
        if value:
            widget.set_active(True)
    elif (type_name == 'GEnum'):
        model = gtk.ListStore(gobject.TYPE_STRING, prop.value_type)
        widget = gtk.ComboBox(model)
        cell = gtk.CellRendererText()
        widget.pack_start(cell, True)
        widget.add_attribute(cell, 'text', 0)

        idx = 0
        for key, val in prop.enum_class.__enum_values__.iteritems():
            log.log("gstwidget", "adding %s / %s", val.value_name, val)
            model.append([val.value_name, val])
            if val == value or key == value:
                selected = idx
            idx = idx + 1
        widget.set_active(selected)
    else:
        widget = gtk.Label(type_name)
        widget.set_alignment(1.0, 0.5)

    if not prop.flags & gobject.PARAM_WRITABLE:
        widget.set_sensitive(False)
    return widget
예제 #6
0
def make_property_widget(unused_element, prop, value=None):
    """ Creates a Widget for the given element property """
    # FIXME : implement the case for flags
    type_name = gobject.type_name(prop.value_type.fundamental)

    if value == None:
        value = prop.default_value
    if (type_name == 'gchararray'):
        widget = gtk.Entry()
        widget.set_text(str(value))
    elif (type_name in ['guint64', 'gint64', 'guint', 'gint', 'gfloat',
        'gdouble', 'gulong']):
        widget = gtk.SpinButton()
        if type_name == 'gint':
            minimum, maximum = (-(2**31), 2**31 - 1)
            widget.set_increments(1.0, 10.0)
        elif type_name == 'guint':
            minimum, maximum = (0, 2**32 - 1)
            widget.set_increments(1.0, 10.0)
        elif type_name == 'gint64':
            minimum, maximum = (-(2**63), 2**63 - 1)
            widget.set_increments(1.0, 10.0)
        elif type_name in ['gulong', 'guint64']:
            minimum, maximum = (0, 2**64 - 1)
            widget.set_increments(1.0, 10.0)
        elif type_name == 'gfloat' or type_name == 'gdouble':
            minimum, maximum = (float("-Infinity"), float("Infinity"))
            widget.set_increments(0.00001, 0.01)
            widget.set_digits(5)
        if hasattr(prop, "minimum"):
            minimum = prop.minimum
        if hasattr(prop, "maximum"):
            maximum = prop.maximum
        widget.set_range(minimum, maximum)
        widget.props.climb_rate = 0.01 * abs(min(maximum, 1000) -
            max(minimum, -1000))
        widget.set_value(float(value))
    elif (type_name == 'gboolean'):
        widget = gtk.CheckButton()
        if value:
            widget.set_active(True)
    elif (type_name == 'GEnum'):
        model = gtk.ListStore(gobject.TYPE_STRING, prop.value_type)
        widget = gtk.ComboBox(model)
        cell = gtk.CellRendererText()
        widget.pack_start(cell, True)
        widget.add_attribute(cell, 'text', 0)

        idx = 0
        for key, val in prop.enum_class.__enum_values__.iteritems():
            log.log("gstwidget", "adding %s / %s", val.value_name, val)
            model.append([val.value_name, val])
            if val == value or key == value:
                selected = idx
            idx = idx + 1
        widget.set_active(selected)
    else:
        widget = gtk.Label(type_name)
        widget.set_alignment(1.0, 0.5)

    if not prop.flags & gobject.PARAM_WRITABLE:
        widget.set_sensitive(False)
    return widget