-
Couldn't load subscription status.
- Fork 3.5k
[camera_android_camerax] use MediaSettings::fps for image preview, streaming, and video recording #10301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
6707def to
3404a0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thank you so much for taking this on. This will be a huge improvement to the plugin!
I think we need to add a Dart test, but otherwise LGTM. Let's get a second review.
|
|
||
| @RunWith(RobolectricTestRunner.class) | ||
| public class ImageAnalysisTest { | ||
| @SuppressWarnings({"unchecked", "rawtypes"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: where you added this annotation, can you leave a comment as to why this is safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a test to make sure that if the fps media setting is passed, we actually set it as expected. I know these test are a bit daunting to write so let me know if you need help 😅
Just in case you need help getting started: The hardest part is mocking the pigeon calls. There are several other createCamera tests you can copy or modify to handle the mocks, though. But there are some helper methods at the top of the file that can help with that. I think you could end up doing something like
packages/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart
Lines 4649 to 4662 in 3404a0b
| newCameraSelector: | |
| ({ | |
| LensFacing? requireLensFacing, | |
| CameraInfo? cameraInfoForFilter, | |
| // ignore: non_constant_identifier_names | |
| BinaryMessenger? pigeon_binaryMessenger, | |
| // ignore: non_constant_identifier_names | |
| PigeonInstanceManager? pigeon_instanceManager, | |
| }) { | |
| if (cameraInfoForFilter == mockFrontCameraInfo) { | |
| return mockFrontCameraSelector; | |
| } | |
| return mockBackCameraSelector; | |
| }, |
camera.videoCapture) equals your mock object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending unit tests and updating the lint-baseline.xml.
| class ImageAnalysisProxyApi extends PigeonApiImageAnalysis { | ||
| static final long CLEAR_FINALIZED_WEAK_REFERENCES_INTERVAL_FOR_IMAGE_ANALYSIS = 1000; | ||
|
|
||
| @OptIn(markerClass = ExperimentalCamera2Interop.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This plugin updates [lint-baseline.xml] (https://github.com/flutter/packages/blob/main/packages/camera/camera_android_camerax/android/lint-baseline.xml) to handle this specific warning.
This should be updateable by following https://developer.android.com/studio/write/lint#snapshot in the example app. But this can be updated after getting both LGTMs.
Implements
MediaSettings::fpsincamera_android_cameraxfor image preview, image streaming, and video recording.camera_android_camerax, and uses the existingMediaSettings::fpsinstead of adding parameters toCameraImageStreamOptionsPre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3