def get_all_video_devices(capture_only=True): contents = os.listdir("/dev") devices = {} device_paths = set() try: from xpra.codecs.v4l2.pusher import query_video_device except ImportError: def query_video_device(device): return {} for f in contents: if not f.startswith("video"): continue dev_file = "/dev/%s" % f try: dev_file = os.readlink(dev_file) except OSError: pass if dev_file in device_paths: continue device_paths.add(dev_file) try: no = int(f[len("video"):]) assert no>=0 except: continue dev_info = query_video_device(dev_file) if capture_only and not _can_capture_video(dev_file, dev_info): continue info = {"device" : dev_file} info.update(dev_info) devices[no] = info return devices
def get_all_video_devices(capture_only=True): contents = os.listdir("/dev") devices = {} device_paths = set() try: from xpra.codecs.v4l2.pusher import query_video_device except ImportError: def query_video_device(device): return {} for f in contents: if not f.startswith("video"): continue dev_file = "/dev/%s" % f try: dev_file = os.readlink(dev_file) except OSError: pass if dev_file in device_paths: continue device_paths.add(dev_file) try: no = int(f[len("video"):]) assert no >= 0 except: continue dev_info = query_video_device(dev_file) if capture_only and not _can_capture_video(dev_file, dev_info): continue info = {"device": dev_file} info.update(dev_info) devices[no] = info return devices
def get_virtual_video_devices(capture_only=True): log("get_virtual_video_devices") if not check_virtual_dir(False): return [] contents = os.listdir(v4l2_virtual_dir) devices = {} try: from xpra.codecs.v4l2.pusher import query_video_device except ImportError: def query_video_device(device): return {} for f in contents: if not f.startswith("video"): continue try: no = int(f[len("video"):]) assert no >= 0 except: continue dev_file = "/dev/%s" % f dev_info = query_video_device(dev_file) if capture_only and not _can_capture_video(dev_file, dev_info): continue info = {"device": dev_file} info.update(dev_info) if "card" not in dev_info: #look up the name from the v4l2 virtual dir: dev_dir = os.path.join(v4l2_virtual_dir, f) if not os.path.isdir(dev_dir): continue dev_name = os.path.join(dev_dir, "name") try: name = open(dev_name).read().replace("\n", "") info["card"] = name except: pass devices[no] = info log("devices: %s", devices) log("found %i virtual video device%s", len(devices), engs(devices)) return devices
def get_virtual_video_devices(capture_only=True): log("get_virtual_video_devices") if not check_virtual_dir(False): return [] contents = os.listdir(v4l2_virtual_dir) devices = {} try: from xpra.codecs.v4l2.pusher import query_video_device except ImportError: def query_video_device(device): return {} for f in contents: if not f.startswith("video"): continue try: no = int(f[len("video"):]) assert no>=0 except: continue dev_file = "/dev/%s" % f dev_info = query_video_device(dev_file) if capture_only and not _can_capture_video(dev_file, dev_info): continue info = {"device" : dev_file} info.update(dev_info) if "card" not in dev_info: #look up the name from the v4l2 virtual dir: dev_dir = os.path.join(v4l2_virtual_dir, f) if not os.path.isdir(dev_dir): continue dev_name = os.path.join(dev_dir, "name") try: name = open(dev_name).read().replace("\n", "") info["card"] = name except: pass devices[no] = info log("devices: %s", devices) log("found %i virtual video device%s", len(devices), engs(devices)) return devices