From 22160f9a3a7ce2760f695b651bde40747e2694e3 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sun, 27 Jul 2014 09:28:07 +0000 Subject: [PATCH] #614 * let the users choose the decoders enabled via the command line or config file * add "all" and "none" special keywords git-svn-id: https://xpra.org/svn/Xpra/trunk@6966 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/etc/xpra/xpra.conf.in | 19 +++++++++++++ src/xpra/client/ui_client_base.py | 4 +-- src/xpra/scripts/config.py | 6 +++-- src/xpra/scripts/main.py | 45 ++++++++++++++++++++++--------- 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/etc/xpra/xpra.conf.in b/src/etc/xpra/xpra.conf.in index 2829bc114a..ff4a2d14ad 100644 --- a/src/etc/xpra/xpra.conf.in +++ b/src/etc/xpra/xpra.conf.in @@ -52,6 +52,25 @@ pings = no #encoding = rgb #encoding = webp +# Used by the server to encode video: +# video-encoders = x264, vpx, nvenc +# video-encoders = none +# video-encoders = all +video-encoders = all + +# Used by both the client and server for colourspace conversion: +# csc-modules = swscale, cython, opencl +# csc-modules = none +# csc-modules = all +video-encoders = all + +# Used the client for decoding: +# video-decoders = avcodec2, vpx +# video-decoders = avcodec, vpx +# video-decoders = none +# video-decoders = all +video-decoders = all + # Use fixed quality # (value is a percentage or "auto"): #quality = 80 diff --git a/src/xpra/client/ui_client_base.py b/src/xpra/client/ui_client_base.py index 1cb6af7dc9..6d29071156 100644 --- a/src/xpra/client/ui_client_base.py +++ b/src/xpra/client/ui_client_base.py @@ -33,7 +33,7 @@ from xpra.platform.gui import init as gui_init, ready as gui_ready, get_native_notifier_classes, get_native_tray_classes, get_native_system_tray_classes, get_native_tray_menu_helper_classes, ClientExtras from xpra.codecs.codec_constants import get_PIL_decodings from xpra.codecs.loader import codec_versions, has_codec, get_codec, PREFERED_ENCODING_ORDER, ALL_NEW_ENCODING_NAMES_TO_OLD, OLD_ENCODING_NAMES_TO_NEW -from xpra.codecs.video_helper import getVideoHelper, ALL_VIDEO_DECODER_OPTIONS, NO_GFX_CSC_OPTIONS +from xpra.codecs.video_helper import getVideoHelper, NO_GFX_CSC_OPTIONS from xpra.simple_stats import std_unit from xpra.net import compression, packet_encoding from xpra.daemon_thread import make_daemon_thread @@ -250,7 +250,7 @@ def init(self, opts): #until we add the ability to choose decoders, use all of them: #(and default to non grahics card csc modules if not specified) vh = getVideoHelper() - vh.set_modules(video_decoders=ALL_VIDEO_DECODER_OPTIONS, csc_modules=opts.csc_modules or NO_GFX_CSC_OPTIONS) + vh.set_modules(video_decoders=opts.video_decoders, csc_modules=opts.csc_modules or NO_GFX_CSC_OPTIONS) vh.init() diff --git a/src/xpra/scripts/config.py b/src/xpra/scripts/config.py index cf8844b938..9080619e44 100644 --- a/src/xpra/scripts/config.py +++ b/src/xpra/scripts/config.py @@ -293,6 +293,7 @@ def read_xpra_defaults(conf_dir=DEFAULT_XPRA_CONF_DIR): #arrays of strings (default value, allowed options): "video-encoders" : list, "csc-modules" : list, + "video-decoders" : list, "speaker-codec" : list, "microphone-codec" : list, "compressors" : list, @@ -385,8 +386,9 @@ def get_defaults(): "opengl" : OPENGL_DEFAULT, "mdns" : os.name=="posix" and not sys.platform.startswith("darwin"), "swap-keys" : sys.platform.startswith("darwin"), #only used on osx - "video-encoders" : [], - "csc-modules" : [], + "video-encoders" : ["all"], + "csc-modules" : ["all"], + "video-decoders" : ["all"], "speaker-codec" : [], "microphone-codec" : [], "compressors" : [], diff --git a/src/xpra/scripts/main.py b/src/xpra/scripts/main.py index e15ca31ceb..0cc9e03fb3 100755 --- a/src/xpra/scripts/main.py +++ b/src/xpra/scripts/main.py @@ -346,6 +346,9 @@ def parse_cmdline(cmdline): group.add_option("--csc-modules", action="store", dest="csc_modules", default=defaults.csc_modules, help="Specify which colourspace conversion modules to enable, to get a list of all the options specify 'help' (default: %default)") + group.add_option("--video-decoders", action="store", + dest="video_decoders", default=defaults.video_decoders, + help="Specify which video decoders to enable, to get a list of all the options specify 'help'") group.add_option("--min-quality", action="store", metavar="MIN-LEVEL", dest="min_quality", type="int", default=defaults.min_quality, @@ -547,26 +550,42 @@ def parse_cmdline(cmdline): if not [x for x in pe_map.keys() if getattr(packet_encoding, "use_%s" % x)]: parser.error("at least one valid packet encoder must be enabled") - #special case for video encoders and csc, stored as lists, but command line option is a CSV string: + #special case for video encoders/decoders and csc, stored as lists, but command line option is a CSV string: + from xpra.codecs.video_helper import ALL_VIDEO_ENCODER_OPTIONS as aveco + from xpra.codecs.video_helper import ALL_CSC_MODULE_OPTIONS as acsco + from xpra.codecs.video_helper import ALL_VIDEO_DECODER_OPTIONS as avedo if (supports_server or supports_shadow): if type(options.video_encoders)==str: - if options.video_encoders=="help": - from xpra.codecs.video_helper import ALL_VIDEO_ENCODER_OPTIONS as aveco + vestr = options.video_encoders.strip().lower() + if vestr=="help": print("the following video encoders may be available: %s" % ", ".join(aveco)) sys.exit(0) - elif options.video_encoders=="none": - options.video_encoders = [] - else: - options.video_encoders = [x.strip() for x in options.video_encoders.split(",")] + options.video_encoders = [x.strip() for x in vestr.split(",")] if type(options.csc_modules)==str: - if options.csc_modules=="help": - from xpra.codecs.video_helper import ALL_CSC_MODULE_OPTIONS as acsco + cscstr = options.csc_modules.strip().lower() + if cscstr=="help": print("the following csc modules may be available: %s" % ", ".join(acsco)) sys.exit(0) - elif options.csc_modules=="none": - options.csc_modules = [] - else: - options.csc_modules = [x.strip() for x in options.csc_modules.split(",")] + options.csc_modules = [x.strip() for x in cscstr.split(",")] + if type(options.video_decoders)==str: + vdstr = options.video_decoders.strip().lower() + if vdstr=="help": + print("the following video decoders may be available: %s" % ", ".join(avedo)) + sys.exit(0) + options.video_decoders = [x.strip() for x in vdstr.split(",")] + + if options.video_encoders==["none"]: + options.video_encoders = [] + elif options.video_encoders==["all"]: + options.video_encoders = aveco + if options.csc_modules==["none"]: + options.csc_modules = [] + elif options.csc_modules==["all"]: + options.csc_modules = acsco + if options.video_decoders==["none"]: + options.video_decoders = [] + elif options.video_decoders==["all"]: + options.video_decoders = avedo #special handling for URL mode: #xpra attach xpra://[mode:]host:port/?param1=value1¶m2=value2