Repository navigation
refactor(camera): move the lores encoder hooks into StreamingCameraBackend - #60
Merged
Merged
Conversation
…ckend - Move start_lores_encoder and stop_lores_encoder from CameraBackend to StreamingCameraBackend, so a core-only backend no longer has to stub them. - Move StreamingNotSupportedError next to the protocols. The manager still imports it from there. - The preview pipeline narrows to StreamingCameraBackend and raises StreamingNotSupportedError instead of an AttributeError. - The preview sleeper and thermal governor skip a backend without the hooks. - Give the worker and pipeline test mocks a StreamingCameraBackend spec and add tests for the core-only backend path.
Merging this PR will not alter performance1 warning
Comparing |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This moves the H264 lores encoder methods out of the core
CameraBackendprotocol and intoStreamingCameraBackend. Before this, every backend had to implement them, even a stills-only sensor with no preview stream. A backend without them crashed the preview pipeline with anAttributeError.CameraBackenddeclaredstart_lores_encoderandstop_lores_encoder. They now live onStreamingCameraBackend.StreamingNotSupportedErrormoved next to the protocols, and the manager imports it from there.CameraBackend. It now narrows toStreamingCameraBackendand raisesStreamingNotSupportedErrorfor a backend without them.MagicMocks, which fail a runtime protocol check. They now use aStreamingCameraBackendspec. I also updated the backend paragraph in ARCHITECTURE.md.No test runs
Picamera2Backendon a Pi, so the hardware path is unchecked.Picamera2Backendalready subclassesStreamingCameraBackendand keeps both methods unchanged.Tests:
just check: exit 0ty checkboth reported "All checks passed!".! sed -n '/^class CameraBackend/,/^class StreamingCameraBackend/p' app/camera/services/backend.py | grep -q 'lores_encoder': exit 0, no output.I ran the two new tests on the code before the change and both failed.
test_start_raises_streaming_not_supportedfailed withAttributeError: '_StillOnlyBackend' object has no attribute 'start_lores_encoder'.test_tick_is_noop_for_backend_without_lores_encoderfailed withExpected 'start' to not have been called. Called 1 times.