From e3e1ead1a3722bff1daa3a6dd74e09dfbb5af2a3 Mon Sep 17 00:00:00 2001 From: Jose Tiago Macara Coutinho Date: Thu, 22 Aug 2024 08:22:02 +0200 Subject: [PATCH 1/2] Remove term coverage report --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f1e8856..01218ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,7 +88,7 @@ show-slowest = 3 [tool.ward.plugins.coverage] branch = true omit = ["*test*"] -report_type = ["term", "html", "json", "xml"] +report_type = ["html", "json", "xml"] report = {skip_empty = true, show_missing = true} From fbe57d06e86b78f4f0351f1c6e9b3b2fce9cbdae Mon Sep 17 00:00:00 2001 From: Jose Tiago Macara Coutinho Date: Thu, 22 Aug 2024 17:28:34 +0200 Subject: [PATCH 2/2] Add video_standards info --- linuxpy/video/device.py | 5 +++ tests/test_video.py | 75 ++++++++++++++++++++++++++++------------- 2 files changed, 57 insertions(+), 23 deletions(-) diff --git a/linuxpy/video/device.py b/linuxpy/video/device.py index c82ecbc..5bdc0fa 100644 --- a/linuxpy/video/device.py +++ b/linuxpy/video/device.py @@ -1539,6 +1539,11 @@ def outputs(self): def controls(self): return list(iter_read_controls(self.device)) + @property + def video_standards(self) -> list[Standard]: + """List of video standards for the active input""" + return list(iter_read_video_standards(self.device)) + class BufferManager(DeviceHelper): def __init__(self, device: Device, buffer_type: BufferType, size: int = 2): diff --git a/tests/test_video.py b/tests/test_video.py index 807e24c..b5c5011 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -30,6 +30,7 @@ Capability, ControlClass, Device, + InputCapabilities, Memory, PixelFormat, Priority, @@ -565,6 +566,7 @@ def _(display=hardware): VIVID_TEST_DEVICES = [Path(f"/dev/video{i}") for i in range(190, 194)] +VIVID_CAPTURE_DEVICE, VIVID_OUTPUT_DEVICE, VIVID_META_CAPTURE_DEVICE, VIVID_META_OUTPUT_DEVICE = VIVID_TEST_DEVICES @cache @@ -597,7 +599,7 @@ def _(): @test_vivid_only("list vivid capture files") def _(): video_files = list(iter_video_capture_files()) - assert VIVID_TEST_DEVICES[0] in video_files + assert VIVID_CAPTURE_DEVICE in video_files for video_file in VIVID_TEST_DEVICES[1:]: assert video_file not in video_files @@ -605,8 +607,8 @@ def _(): @test_vivid_only("list vivid output files") def _(): video_files = list(iter_video_output_files()) - assert VIVID_TEST_DEVICES[1] in video_files - assert VIVID_TEST_DEVICES[0] not in video_files + assert VIVID_OUTPUT_DEVICE in video_files + assert VIVID_CAPTURE_DEVICE not in video_files for video_file in VIVID_TEST_DEVICES[2:]: assert video_file not in video_files @@ -623,7 +625,7 @@ def _(): def _(): devices = list(iter_video_capture_devices()) device_names = [dev.filename for dev in devices] - assert VIVID_TEST_DEVICES[0] in device_names + assert VIVID_CAPTURE_DEVICE in device_names for video_file in VIVID_TEST_DEVICES[1:]: assert video_file not in device_names @@ -632,35 +634,36 @@ def _(): def _(): devices = list(iter_video_output_devices()) device_names = [dev.filename for dev in devices] - assert VIVID_TEST_DEVICES[1] in device_names - assert VIVID_TEST_DEVICES[0] not in device_names + assert VIVID_OUTPUT_DEVICE in device_names + assert VIVID_CAPTURE_DEVICE not in device_names for video_file in VIVID_TEST_DEVICES[2:]: assert video_file not in device_names @test_vivid_only("controls with vivid") def _(): - with Device(VIVID_TEST_DEVICES[0]) as device: + with Device(VIVID_CAPTURE_DEVICE) as device: controls = device.controls # Brightness - assert controls.brightness is controls["brightness"] - current_value = controls.brightness.value - assert 0 <= current_value < 250 + brightness = controls.brightness + assert brightness is controls["brightness"] + current_value = brightness.value + assert brightness.minimum <= current_value <= brightness.maximum try: - controls.brightness.value = 100 - assert controls.brightness.value == 100 + brightness.value = 100 + assert brightness.value == 100 finally: - controls.brightness.value = current_value + brightness.value = current_value with raises(AttributeError): _ = controls.unknown_field assert ControlClass.USER in {ctrl.id - 1 for ctrl in controls.used_classes()} - assert controls.brightness in controls.with_class("user") - assert controls.brightness in controls.with_class(ControlClass.USER) + assert brightness in controls.with_class("user") + assert brightness in controls.with_class(ControlClass.USER) - assert " 0 active_input = capture_dev.get_input() @@ -780,7 +809,7 @@ def test_frame(frame, width, height, pixel_format, source): @test_vivid_only(f"vivid capture ({iname})") def _(source=input_type): - with Device(VIVID_TEST_DEVICES[0]) as capture_dev: + with Device(VIVID_CAPTURE_DEVICE) as capture_dev: capture_dev.set_input(0) width, height, pixel_format = 640, 480, PixelFormat.RGB24 capture = VideoCapture(capture_dev, source=source) @@ -802,7 +831,7 @@ def _(source=input_type): @test_vivid_only(f"vivid async capture ({iname})") async def _(source=input_type): - with Device(VIVID_TEST_DEVICES[0]) as capture_dev: + with Device(VIVID_CAPTURE_DEVICE) as capture_dev: capture_dev.set_input(0) width, height, pixel_format = 640, 480, PixelFormat.RGB24 capture = VideoCapture(capture_dev, source=source) @@ -827,7 +856,7 @@ async def _(source=input_type): @test_vivid_only("vivid capture no capability") def _(): - with Device(VIVID_TEST_DEVICES[1]) as output_dev: + with Device(VIVID_OUTPUT_DEVICE) as output_dev: stream = iter(output_dev) with raises(V4L2Error): next(stream) @@ -835,7 +864,7 @@ def _(): @test_vivid_only("vivid output") def _(): - with Device(VIVID_TEST_DEVICES[1]) as output_dev: + with Device(VIVID_OUTPUT_DEVICE) as output_dev: width, height, pixel_format = 640, 480, PixelFormat.RGB24 size = width * height * 3 out = VideoOutput(output_dev)