Skip to content

Commit

Permalink
#1838: make it possible to run without any codecs, which also means w…
Browse files Browse the repository at this point in the history
…ithout webcam or window forwarding

git-svn-id: https://xpra.org/svn/Xpra/trunk@19726 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 26, 2018
1 parent 49e8257 commit 11c6a95
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 22 deletions.
5 changes: 4 additions & 1 deletion src/xpra/net/bytestreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,17 +404,20 @@ def do_get_socket_info(self):
def get_socket_options(sock, level, options):
opts = {}
try:
errs = []
for k in options:
opt = getattr(socket, k, None)
if opt is None:
continue
try:
v = sock.getsockopt(level, opt)
except Exception as e:
log.warn("Warning: cannot query %s: %s", k, e)
errs.append(k)
else:
if v is not None:
opts[k] = v
if errs:
log.warn("Warning: failed to query %s", csv(errs))
except:
log.error("Error querying socket options:")
log.error(" %s", e)
Expand Down
14 changes: 10 additions & 4 deletions src/xpra/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,9 +1201,12 @@ def _nodupes(s):
return remove_dupes(x.strip().lower() for x in s.split(","))

def fixup_video_all_or_none(options):
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
try:
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
except ImportError:
return
vestr = _csvstr(options.video_encoders)
cscstr = _csvstr(options.csc_modules)
vdstr = _csvstr(options.video_decoders)
Expand Down Expand Up @@ -1248,7 +1251,10 @@ def fixup_pings(options):
options.pings = 5

def fixup_encodings(options):
from xpra.codecs.loader import PREFERED_ENCODING_ORDER
try:
from xpra.codecs.loader import PREFERED_ENCODING_ORDER
except ImportError:
return
RENAME = {"jpg" : "jpeg"}
if options.encoding:
options.encoding = RENAME.get(options.encoding, options.encoding)
Expand Down
5 changes: 4 additions & 1 deletion src/xpra/scripts/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,10 @@ def ignore(defaults):
return options, args

def validated_encodings(encodings):
from xpra.codecs.loader import PREFERED_ENCODING_ORDER
try:
from xpra.codecs.loader import PREFERED_ENCODING_ORDER
except ImportError:
return []
lower_encodings = [x.lower() for x in encodings]
validated = [x for x in PREFERED_ENCODING_ORDER if x.lower() in lower_encodings]
if not validated:
Expand Down
15 changes: 9 additions & 6 deletions src/xpra/scripts/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,30 +913,33 @@ def b(v):
return str(v).lower() not in FALSE_OPTIONS
#turn off some server mixins:
from xpra.server import server_features
impwarned = []
def impcheck(*modules):
for mod in modules:
try:
__import__("xpra.%s" % mod, {}, {}, [])
except ImportError as e:
log = get_util_logger()
log.warn("Warning: missing %s module", mod)
if mod not in impwarned:
impwarned.append(mod)
log = get_util_logger()
log.warn("Warning: missing %s module", mod)
return False
return True
server_features.notifications = opts.notifications and impcheck("notifications")
server_features.webcam = b(opts.webcam)
server_features.webcam = b(opts.webcam) and impcheck("codecs")
server_features.clipboard = b(opts.clipboard) and impcheck("clipboard")
server_features.audio = (b(opts.speaker) or b(opts.microphone)) and impcheck("sound")
server_features.av_sync = server_features.audio and b(opts.av_sync)
server_features.fileprint = b(opts.printing) or b(opts.file_transfer)
server_features.mmap = b(opts.mmap)
server_features.input_devices = not opts.readonly and impcheck("keyboard")
#server_features.commands = ??
server_features.commands = impcheck("server.control_command")
server_features.dbus = opts.dbus_proxy and impcheck("dbus")
#server_features.encoding = ??
server_features.encoding = impcheck("codecs")
server_features.logging = b(opts.remote_logging)
#server_features.network_state = ??
server_features.display = opts.windows
server_features.windows = opts.windows
server_features.windows = opts.windows and impcheck("codecs")

kill_dbus = None
if shadowing:
Expand Down
20 changes: 12 additions & 8 deletions src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
SERVER_EXIT, SERVER_ERROR, SERVER_SHUTDOWN, DETACH_REQUEST, NEW_CLIENT, DONE, SESSION_BUSY
from xpra.net.bytestreams import set_socket_timeout
from xpra.server import EXITING_CODE
from xpra.codecs.loader import codec_versions


CLIENT_CAN_SHUTDOWN = envbool("XPRA_CLIENT_CAN_SHUTDOWN", True)
Expand Down Expand Up @@ -445,13 +444,18 @@ def make_hello(self, source):
def send_hello(self, server_source, root_w, root_h, server_cipher):
capabilities = self.make_hello(server_source)
if server_source.wants_encodings:
updict(capabilities, "encoding", codec_versions, "version")
for k,v in self.get_encoding_info().items():
if k=="":
k = "encodings"
else:
k = "encodings.%s" % k
capabilities[k] = v
try:
from xpra.codecs.loader import codec_versions
except ImportError:
log("no codecs", exc_info=True)
else:
updict(capabilities, "encoding", codec_versions, "version")
for k,v in self.get_encoding_info().items():
if k=="":
k = "encodings"
else:
k = "encodings.%s" % k
capabilities[k] = v
if server_source.wants_display:
capabilities.update({
"actual_desktop_size" : (root_w, root_h),
Expand Down
7 changes: 5 additions & 2 deletions src/xpra/x11/prop_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
log = Logger("x11", "window")

from xpra.os_util import hexstr, StringIOClass, PYTHON3
from xpra.codecs.argb.argb import premultiply_argb_in_place #@UnresolvedImport
from xpra.x11.bindings.window_bindings import constants #@UnresolvedImport
from xpra.x11.bindings.window_bindings import X11WindowBindings #@UnresolvedImport
X11Window = X11WindowBindings()
Expand Down Expand Up @@ -209,7 +208,11 @@ def _read_image(_disp, stream):
# Cairo uses premultiplied alpha. EWMH actually doesn't specify what it
# uses, but apparently the de-facto standard is non-premultiplied. (At
# least that's what Compiz's sources say.)
premultiply_argb_in_place(surf.get_data())
try:
from xpra.codecs.argb.argb import premultiply_argb_in_place #@UnresolvedImport
premultiply_argb_in_place(surf.get_data())
except ImportError:
log("no argb premultiply", exc_info=True)
return (width * height, surf)

# This returns a cairo ImageSurface which contains the largest icon defined in
Expand Down

0 comments on commit 11c6a95

Please sign in to comment.