Skip to content

Commit

Permalink
#1613 honour the device specified
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@16677 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 10, 2017
1 parent c6e0590 commit 311449e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def init(self, opts):
self.desktop_fullscreen = opts.desktop_fullscreen

self.webcam_option = opts.webcam
self.webcam_forwarding = self.webcam_option.lower() not in ("no", "false")
self.webcam_forwarding = self.webcam_option.lower() not in FALSE_OPTIONS
self.server_supports_webcam = False
self.server_virtual_video_devices = 0
if self.webcam_forwarding:
Expand Down
41 changes: 28 additions & 13 deletions src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def __init__(self):
self.pings = 0
self.scaling_control = False
self.rpc_handlers = {}
self.webcam_option = ""
self.webcam_forwarding = False
self.webcam_encodings = []
self.webcam_forwarding_device = None
Expand Down Expand Up @@ -262,6 +263,7 @@ def set_reaper_callback():
self.notifications_forwarder = None
self.notifications = opts.notifications
self.scaling_control = parse_bool_or_int("video-scaling", opts.video_scaling)
self.webcam_option = opts.webcam
self.webcam_forwarding = opts.webcam.lower() not in FALSE_OPTIONS
self.input_devices = opts.input_devices or "auto"

Expand Down Expand Up @@ -427,9 +429,12 @@ def init_webcam(self):
webcamlog.error("Error: webcam forwarding disabled:")
webcamlog.error(" %s", e)
self.webcam_forwarding = False
self.virtual_video_devices = self.init_virtual_video_devices()
if self.virtual_video_devices==0:
self.webcam_forwarding = False
if self.webcam_option.startswith("/dev/video"):
self.virtual_video_devices = 1
else:
self.virtual_video_devices = self.init_virtual_video_devices()
if self.virtual_video_devices==0:
self.webcam_forwarding = False

def init_virtual_video_devices(self):
webcamlog("init_virtual_video_devices")
Expand Down Expand Up @@ -2218,8 +2223,10 @@ def get_clipboard_info(self):
def get_webcam_info(self):
webcam_info = {
"" : self.webcam_forwarding,
"virtual-video-devices" : self.virtual_video_devices,
}
if self.webcam_option.startswith("/dev/video"):
webcam_info["device"] = self.webcam_option
webcam_info["virtual-video-devices"] = self.virtual_video_devices
d = self.webcam_forwarding_device
if d:
webcam_info.update(d.get_info())
Expand Down Expand Up @@ -3146,15 +3153,23 @@ def _process_webcam_start(self, proto, packet):

def start_virtual_webcam(self, ss, device, w, h):
assert w>0 and h>0
from xpra.platform.xposix.webcam import get_virtual_video_devices
devices = get_virtual_video_devices()
if len(devices)==0:
webcamlog.warn("Warning: cannot start webcam forwarding, no virtual devices found")
ss.send_webcam_stop(device)
return
if self.webcam_forwarding_device:
self.stop_virtual_webcam()
webcamlog("start_virtual_webcam%s virtual video devices=%s", (ss, device, w, h), devices)
if self.webcam_option.startswith("/dev/video"):
#use the device specified:
devices = {
0 : {
"device" : self.webcam_option,
}
}
else:
from xpra.platform.xposix.webcam import get_virtual_video_devices
devices = get_virtual_video_devices()
if len(devices)==0:
webcamlog.warn("Warning: cannot start webcam forwarding, no virtual devices found")
ss.send_webcam_stop(device)
return
if self.webcam_forwarding_device:
self.stop_virtual_webcam()
webcamlog("start_virtual_webcam%s virtual video devices=%s", (ss, device, w, h), devices)
errs = {}
for device_id, device_info in devices.items():
webcamlog("trying device %s: %s", device_id, device_info)
Expand Down

0 comments on commit 311449e

Please sign in to comment.