From 70525a33c92587a03b0e7ae683d9434c0693c3b8 Mon Sep 17 00:00:00 2001 From: Jan Luebbe Date: Mon, 26 Aug 2024 16:43:14 +0200 Subject: [PATCH 1/2] driver/usbvideodriver: use elif if a sequence of conditions Only one of these can match anyway, so using 'if' is just confusing. Signed-off-by: Jan Luebbe --- labgrid/driver/usbvideodriver.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/labgrid/driver/usbvideodriver.py b/labgrid/driver/usbvideodriver.py index 5a604d570..613c8b66d 100644 --- a/labgrid/driver/usbvideodriver.py +++ b/labgrid/driver/usbvideodriver.py @@ -27,43 +27,43 @@ def get_qualities(self): ("mid", "video/x-h264,width=1280,height=720,framerate=15/2"), ("high", "video/x-h264,width=1920,height=1080,framerate=10/1"), ]) - if match == (0x046d, 0x0892): + elif match == (0x046d, 0x0892): return ("mid", [ ("low", "image/jpeg,width=640,height=360,framerate=5/1"), ("mid", "image/jpeg,width=1280,height=720,framerate=15/2"), ("high", "image/jpeg,width=1920,height=1080,framerate=10/1"), ]) - if match == (0x046d, 0x08e5): # Logitech HD Pro Webcam C920 + elif match == (0x046d, 0x08e5): # Logitech HD Pro Webcam C920 return ("mid", [ ("low", "image/jpeg,width=640,height=360,framerate=5/1"), ("mid", "image/jpeg,width=1280,height=720,framerate=15/2"), ("high", "image/jpeg,width=1920,height=1080,framerate=10/1"), ]) - if match == (0x1224, 0x2825): # LogiLink UA0371 + elif match == (0x1224, 0x2825): # LogiLink UA0371 return ("mid", [ ("low", "image/jpeg,width=640,height=480,framerate=30/1"), ("mid", "image/jpeg,width=1280,height=720,framerate=30/1"), ("high", "image/jpeg,width=1920,height=1080,framerate=30/1"), ]) - if match == (0x05a3, 0x9331): # WansView Webcam 102 + elif match == (0x05a3, 0x9331): # WansView Webcam 102 return ("mid", [ ("low","video/x-h264,width=640,height=360,framerate=30/1"), ("mid","video/x-h264,width=1280,height=720,framerate=30/1"), ("high","video/x-h264,width=1920,height=1080,framerate=30/1"), ]) - if match == (0x534d, 0x2109): # MacroSilicon + elif match == (0x534d, 0x2109): # MacroSilicon return ("mid", [ ("low", "image/jpeg,width=720,height=480,framerate=10/1"), ("mid", "image/jpeg,width=1280,height=720,framerate=10/1"), ("high", "image/jpeg,width=1920,height=1080,framerate=10/1"), ]) - if match == (0x1d6c, 0x0103): # HD 2MP WEBCAM + elif match == (0x1d6c, 0x0103): # HD 2MP WEBCAM return ("mid", [ ("low", "video/x-h264,width=640,height=480,framerate=25/1"), ("mid", "video/x-h264,width=1280,height=720,framerate=25/1"), ("high", "video/x-h264,width=1920,height=1080,framerate=25/1"), ]) - if match == (0x0c45, 0x636d): # AUKEY PC-LM1E + elif match == (0x0c45, 0x636d): # AUKEY PC-LM1E return ("mid", [ ("low", "image/jpeg,width=640,height=480,pixel-aspect-ratio=1/1,framerate=30/1"), ("mid", "image/jpeg,width=864,height=480,pixel-aspect-ratio=1/1,framerate=30/1"), @@ -130,8 +130,7 @@ def stream(self, caps_hint=None, controls=None): tx_cmd = self.video.command_prefix + ["gst-launch-1.0", "-q"] tx_cmd += pipeline.split() - rx_cmd = ["gst-launch-1.0"] - rx_cmd += "playbin3 buffer-duration=0 uri=fd://0".split() + rx_cmd = ["gst-launch-1.0", "playbin3", "buffer-duration=0", "uri=fd://0"] tx = subprocess.Popen( tx_cmd, From 87cc17503e1a38ca9fd86ca54b829ffb8299e4d4 Mon Sep 17 00:00:00 2001 From: Jan Luebbe Date: Mon, 26 Aug 2024 16:51:14 +0200 Subject: [PATCH 2/2] driver/usbvideodriver: add support for LogiLink UA0379 / Microdia camera Signed-off-by: Jan Luebbe --- labgrid/driver/usbvideodriver.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/labgrid/driver/usbvideodriver.py b/labgrid/driver/usbvideodriver.py index 613c8b66d..391dd709d 100644 --- a/labgrid/driver/usbvideodriver.py +++ b/labgrid/driver/usbvideodriver.py @@ -63,6 +63,12 @@ def get_qualities(self): ("mid", "video/x-h264,width=1280,height=720,framerate=25/1"), ("high", "video/x-h264,width=1920,height=1080,framerate=25/1"), ]) + elif match == (0x0c45, 0x636b): # LogiLink UA0379 / Microdia + return ("mid", [ + ("low", "image/jpeg,width=640,height=480,pixel-aspect-ratio=1/1,framerate=30/1"), + ("mid", "image/jpeg,width=1280,height=720,pixel-aspect-ratio=1/1,framerate=30/1"), + ("high", "image/jpeg,width=1920,height=1080,pixel-aspect-ratio=1/1,framerate=30/1"), + ]) elif match == (0x0c45, 0x636d): # AUKEY PC-LM1E return ("mid", [ ("low", "image/jpeg,width=640,height=480,pixel-aspect-ratio=1/1,framerate=30/1"), @@ -108,6 +114,9 @@ def get_pipeline(self, path, caps, controls=None): elif match == (0x1d6c, 0x0103): controls = controls or "focus_auto=1" inner = "h264parse" + elif match == (0x0c54, 0x636b): + controls = controls or "focus_auto=1" + inner = None # just forward the jpeg frames elif match == (0x0c54, 0x636d): controls = controls or "focus_auto=1" inner = None # just forward the jpeg frames