Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
0
 def _registryFeatureAddedCb(self, registry, feature):
     # invalidate the cache
     log.warning("utils", "New feature added, invalidating cached factories")
     self._factories = None
Esempio n. 6
0
 def _registryFeatureAddedCb(self, registry, feature):
     # invalidate the cache
     log.warning("utils",
                 "New feature added, invalidating cached factories")
     self._factories = None
Esempio n. 7
0
        counter += 1

    def _wrapper(*args, **kwargs):
        local_func = func
        cProfile.runctx("result = local_func(*args, **kwargs)", globals(), locals(),
                        filename=output_filename)
        return locals()["result"]

    return _wrapper


def formatPercent(value):
    return "%3d%%" % (value * 100)


def quantize(input, interval):
    return (input // interval) * interval


def show_user_manual():
    time_now = int(time.time())
    for uri in (APPMANUALURL_OFFLINE, APPMANUALURL_ONLINE):
        try:
            gtk.show_uri(None, uri, time_now)
            return
        except Exception, e:
            log.debug("utils", "Failed loading URI %s: %s", uri, e)
            continue
    log.warning("utils", "Failed loading URIs")
    # TODO: Show an error message to the user.