How to use the xpra.codecs.video_helper.getVideoHelper function in xpra

To help you get started, we’ve selected a few xpra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dscho / Xpra / src / xpra / server / proxy_instance_process.py View on Github external
def filter_client_caps(self, caps):
        fc = self.filter_caps(caps, ("cipher", "digest", "aliases", "compression", "lz4"))
        #update with options provided via config if any:
        fc.update(self.session_options)
        if self.video_encoder_types:
            #pass list of encoding specs to client:
            from xpra.codecs.video_helper import getVideoHelper
            self.video_helper = getVideoHelper()
            self.video_helper.init()
            #serialize encodings defs into a dict:
            encoding_defs = {}
            e_found = []
            #encoding: "h264" or "vp8", etc
            for encoding in self.video_helper.get_encodings():
                #ie: colorspace_specs = {"BGRX" : [codec_spec("x264"), codec_spec("nvenc")], "YUV422P" : ...
                colorspace_specs = self.video_helper.get_encoder_specs(encoding)
                #ie: colorspace="BGRX", especs=[codec_spec("x264"), codec_spec("nvenc")]
                for colorspace, especs in colorspace_specs.items():
                    if colorspace not in ("BGRX", "BGRA", "RGBX", "RGBA"):
                        #don't bother with formats that require a CSC step for now
                        continue
                    for spec in especs:                             #ie: codec_spec("x264")
                        if spec.codec_type not in self.video_encoder_types:
                            debug("skipping encoder %s", spec.codec_type)
github dscho / Xpra / tags / v0.13.x / src / xpra / server / server_base.py View on Github external
def cleanup(self, *args):
        if self.notifications_forwarder:
            thread.start_new_thread(self.notifications_forwarder.release, ())
            self.notifications_forwarder = None
        ServerCore.cleanup(self)
        getVideoHelper().cleanup()
github dscho / Xpra / tags / v0.13.x / src / xpra / server / server_base.py View on Github external
def init_encodings(self):
        def add_encodings(encodings):
            for ce in encodings:
                e = {"rgb32" : "rgb", "rgb24" : "rgb"}.get(ce, ce)
                if e not in self.encodings:
                    self.encodings.append(e)
                if ce not in self.core_encodings:
                    self.core_encodings.append(ce)

        add_encodings(["rgb24", "rgb32"])

        #video encoders (empty when first called - see threaded_init)
        add_encodings(getVideoHelper().get_encodings())  #ie: ["vp8", "h264"]
        #Pithon Imaging Libary:
        PIL = get_codec("PIL")
        if PIL:
            add_encodings(get_PIL_encodings(PIL))
        #webp: only check for "enc_webm" because "enc_webp" needs a fallback (either "PIL" or "enc_webm")
        if has_codec("enc_webm"):
            add_encodings(["webp"])

        self.lossless_encodings = [x for x in self.core_encodings if (x.startswith("png") or x.startswith("rgb"))]
        self.lossless_mode_encodings = []
        if has_codec("enc_webm_lossless"):
            self.lossless_mode_encodings.append("webp")
            self.lossless_encodings.append("webp")

        self.default_encoding = [x for x in PREFERED_ENCODING_ORDER if x in self.encodings][0]
github dscho / Xpra / trunk / src / xpra / server / server_base.py View on Github external
info.update(self.get_encoding_info())
        for k,v in codec_versions.items():
            info["encoding.%s.version" % k] = v
        info["windows"] = len([window for window in list(self._id_to_window.values()) if window.is_managed()])
        info.update({
             "keyboard.sync"            : self.keyboard_sync,
             "keyboard.repeat.delay"    : self.key_repeat_delay,
             "keyboard.repeat.interval" : self.key_repeat_interval,
             "keyboard.keys_pressed"    : self.keys_pressed.values(),
             "keyboard.modifiers"       : self.xkbmap_mod_meanings})
        if self.keyboard_config:
            for k,v in self.keyboard_config.get_info().items():
                if v is not None:
                    info["keyboard."+k] = v
        # csc and video encoders:
        info.update(getVideoHelper().get_info())

        # other clients:
        info["clients"] = len([p for p in self._server_sources.keys() if p!=proto])
        info["clients.unauthenticated"] = len([p for p in self._potential_protocols if ((p is not proto) and (p not in self._server_sources.keys()))])
        #find the source to report on:
        n = len(server_sources)
        if n==1:
            ss = server_sources[0]
            ss.add_info(info)
            ss.add_stats(info, window_ids)
        elif n>1:
            i = 0
            for ss in server_sources:
                ss.add_info(info, suffix="{%s}" % i)
                ss.add_stats(info, window_ids, suffix="{%s}" % i)
                i += 1
github dscho / Xpra / tags / v0.12.x / src / xpra / server / server_base.py View on Github external
info = {
             "features.randr"           : self.randr,
             "features.cursors"         : self.cursors,
             "features.bell"            : self.bell,
             "features.notifications"   : self.notifications_forwarder is not None,
             "features.pulseaudio"      : self.pulseaudio,
             "features.dbus_proxy"      : self.supports_dbus_proxy,
             "features.clipboard"       : self.supports_clipboard}
        if self._clipboard_helper is not None:
            for k,v in self._clipboard_helper.get_info().items():
                info["clipboard.%s" % k] = v
        info.update(self.get_encoding_info())
        for k,v in codec_versions.items():
            info["encoding.%s.version" % k] = v

        vh = getVideoHelper()
        def modstatus(x, def_list, active_list):
            #the module is present
            if x in active_list:
                return "active"
            elif x in def_list:
                return "disabled"
            else:
                return "not found"
        for x in ALL_VIDEO_ENCODER_OPTIONS:
            info["encoding.video-encoder.%s" % x] = modstatus(x, get_DEFAULT_VIDEO_ENCODERS(), vh.video_encoders)
        for x in ALL_CSC_MODULE_OPTIONS:
            info["encoding.csc-module.%s" % x] = modstatus(x, get_DEFAULT_CSC_MODULES(), vh.csc_modules)

        info["windows"] = len([window for window in list(self._id_to_window.values()) if window.is_managed()])
        info.update({
             "keyboard.sync"            : self.keyboard_sync,
github dscho / Xpra / tags / v0.12.x / src / xpra / client / window_backing_base.py View on Github external
def load_video_decoders():
    global VIDEO_DECODERS
    if VIDEO_DECODERS is None:
        VIDEO_DECODERS = {}
        vh = getVideoHelper()
        for encoding in vh.get_decodings():
            specs = vh.get_decoder_specs(encoding)
            for colorspace, decoders in specs.items():
                log("%s decoders for %s: %s", encoding, colorspace, decoders)
                assert len(decoders)>0
                #use the first one:
                _, decoder_module = decoders[0]
                VIDEO_DECODERS[encoding] = decoder_module
        log("video decoders: %s", VIDEO_DECODERS)
    return VIDEO_DECODERS
github dscho / Xpra / tags / v0.13.x / src / xpra / client / ui_client_base.py View on Github external
"""
            This method returns the actual encodings supported.
            ie: ["rgb24", "vp8", "webp", "png", "png/L", "png/P", "jpeg", "h264", "vpx"]
            It is often overriden in the actual client class implementations,
            where extra encodings can be added (generally just 'rgb32' for transparency),
            or removed if the toolkit implementation class is more limited.
        """
        #we always support rgb24:
        core_encodings = ["rgb24"]
        #PIL:
        core_encodings += get_PIL_decodings(get_codec("PIL"))
        if (has_codec("dec_webm") or has_codec("dec_webp")) and "webp" not in core_encodings:
            core_encodings.append("webp")
        #we enable all the video decoders we know about,
        #what will actually get used by the server will still depend on the csc modes supported
        video_decodings = getVideoHelper().get_decodings()
        log("video_decodings=%s", video_decodings)
        for encoding in video_decodings:
            if encoding not in core_encodings:
                core_encodings.append(encoding)
        #remove duplicates and use prefered encoding order:
        core_encodings = [x for x in PREFERED_ENCODING_ORDER if x in set(core_encodings)]
        log("do_get_core_encodings()=%s", core_encodings)
        return core_encodings
github dscho / Xpra / tags / v0.13.x / src / xpra / client / ui_client_base.py View on Github external
capabilities["speed"] = self.speed
            capabilities["encoding.speed"] = self.speed
        if self.min_speed>=0:
            capabilities["encoding.min-speed"] = self.min_speed

        #note: this is mostly for old servers, with newer ones we send the properties
        #again (and more accurately) once the window is instantiated.
        #figure out the CSC modes supported:
        #these are the RGB modes we want (the ones we can paint with):
        rgb_formats = ["RGB", "RGBX"]
        if not sys.platform.startswith("win") and not sys.platform.startswith("darwin"):
            #only win32 and osx cannot handle transparency
            rgb_formats.append("RGBA")
        capabilities["encodings.rgb_formats"] = rgb_formats
        #figure out which CSC modes (usually YUV) can give us those RGB modes:
        full_csc_modes = getVideoHelper().get_server_full_csc_modes_for_rgb(*rgb_formats)
        log("supported full csc_modes=%s", full_csc_modes)
        capabilities["encoding.full_csc_modes"] = full_csc_modes
        #for older servers (remove per-encoding and hope for the best..):
        csc_modes = []
        for modes in full_csc_modes.values():
            csc_modes += modes
        capabilities["encoding.csc_modes"] = list(set(csc_modes))

        log("encoding capabilities: %s", [(k,v) for k,v in capabilities.items() if k.startswith("encoding")])
        capabilities["encoding.uses_swscale"] = True
        if "h264" in self.get_core_encodings():
            # some profile options: "baseline", "main", "high", "high10", ...
            # set the default to "high10" for I420/YUV420P
            # as the python client always supports all the profiles
            # whereas on the server side, the default is baseline to accomodate less capable clients.
            # I422/YUV422P requires high422, and