-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[camera_android_camerax] Implement setDescriptionWhileRecording
#9878
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
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.
Code Review
This pull request successfully implements the ability to switch cameras while recording video on Android by introducing a persistent recording mode. The changes are well-structured across the camera
, camera_platform_interface
, and camera_android_camerax
packages. My review includes a few suggestions to improve the code, such as removing some dead code and improving test practices. Please also remember to remove the temporary dependency_overrides
from the various pubspec.yaml
files before merging.
packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart
Outdated
Show resolved
Hide resolved
|
||
await controller.startVideoRecording(enablePersistentRecording: true); | ||
|
||
sleep(const Duration(seconds: 2)); |
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.
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.
Is this also in the camera/camera integration test? I would assume we are using the exact same test.
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've updated both tests to match
Thanks for the contribution! All of the changes in
The native test suites do not currently build; please see the CI failure output and resolve the failures. |
Adds a section to the review agent configuration to try to get it to stop leaving comments like [this one](#9878 (comment)) on federated plugin PRs that are following our standard, documented process.
setDescriptionWhileRecording
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.
Thank you so much for your contribution! I'm looking forward to having this feature implemented :)
Took a first pass (at the camera_android_camerax
code because the rest can be reverted). Overall looks good, but I think the main changes need a few adjustments.
packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart
Show resolved
Hide resolved
packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart
Outdated
Show resolved
Hide resolved
packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart
Outdated
Show resolved
Hide resolved
packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart
Outdated
Show resolved
Hide resolved
packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart
Outdated
Show resolved
Hide resolved
packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart
Show resolved
Hide resolved
packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart
Outdated
Show resolved
Hide resolved
…9879) Adds a section to the review agent configuration to try to get it to stop leaving comments like [this one](#9878 (comment)) on federated plugin PRs that are following our standard, documented process.
I need help on the failing checks @stuartmorgan-g @camsim99. For the repo_checks, I'm having issue with format and federated safety check. I believe the federated check will be fixed when the dependencies overrides are reverted but the format is throwing error:
Even though there are no issues when I ran it locally:
Also, I can't figure out why the tree-status check failed for the last commit. |
@blackorbs-dev Agreed on the federated check, for format, I see the error Also, thanks for making edits! I'll take a look soon. |
By the way, this PR can also remove this line: https://github.com/flutter/packages/blob/main/packages/camera/camera_android_camerax/README.md#setdescriptionwhilerecording-is-unimplemented-issue-148013 🥳 |
Noted ✅, I can also revert the dependency overrides right? |
I would guess network or server error downloading the formatter, since it's pulled on demand rather than via cipd. |
See this comment; those are the only ones that should be reverted right now, otherwise all the CI will start failing. |
…amera platform packages
@stuartmorgan-g, @camsim99 I've made edits, only the federated check is failing, please take a look |
I think this PR can be re-review @stuartmorgan-g @camsim99 |
/// * calling [CameraController.setDescription] while a recording is in progress | ||
/// | ||
/// Defaults to `false`. | ||
final bool enableAndroidPersistentRecording; |
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.
Platform interfaces should not be platform-specific. What if another platform needs this configuration in the future?
The name and documentation should be sufficiently generic that it could apply to any relevant platform, even if not all platforms require it.
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.
Done
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.
The example/pubspec.yaml files in the reverted packages should be reverted as well.
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.
Done
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.
Thanks for the edits! Left a few more comments, mostly small things.
@@ -275,7 +275,9 @@ void main() { | |||
await controller.initialize(); | |||
await controller.prepareForVideoRecording(); | |||
|
|||
await controller.startVideoRecording(); | |||
await controller.startVideoRecording( | |||
enableAndroidPersistentRecording: true, |
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.
Assuming enableAndroidPersistentRecording
is kept in this PR, this probably needs to be gated by a check for the Android platform.
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.
Done
|
||
await controller.startVideoRecording(enablePersistentRecording: true); | ||
|
||
sleep(const Duration(seconds: 2)); |
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.
Is this also in the camera/camera integration test? I would assume we are using the exact same test.
@@ -288,7 +288,7 @@ class AndroidCameraCameraX extends CameraPlatform { | |||
ResolutionSelector? _presetResolutionSelector; | |||
|
|||
/// The ID of the surface texture that the camera preview is drawn to. | |||
late int _flutterSurfaceTextureId; | |||
int? _flutterSurfaceTextureId; |
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 don't understand this change. To me, it implies you no longer have to call createCamera
and initializeCamera
before doing anything and that should never be the case.
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've reverted the change
// Retrieve info required for correcting the rotation of the camera preview | ||
sensorOrientationDegrees = description.sensorOrientation.toDouble(); | ||
|
||
if (_flutterSurfaceTextureId != null) { |
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.
Correct me if I'm wrong but this should never be null; see my comment above.
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've made changes
if (options.enableAndroidPersistentRecording) { | ||
pendingRecording = await pendingRecording?.asPersistentRecording(); | ||
} | ||
|
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.
If I'm understanding correctly, a developer will have to set enableAndroidPersistentRecording
to set description while recording. Let's please make this clear in documentation everywhere: on this method, in the README, and on the setDescriptionWhileRecording
method.
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.
Done
/// * lifecycle events | ||
/// * calling [CameraController.setDescription] while a recording is in progress | ||
/// | ||
/// Defaults to `false`. |
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 noted this elsewhere but can you clarify in the docs that you need to set this in order to set description while recording on Android?
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.
Done
@@ -4107,28 +4107,141 @@ void main() { | |||
); | |||
|
|||
test( | |||
'setDescriptionWhileRecording does not make any calls involving starting video recording', | |||
'setDescriptionWhileRecording changes the camera description', |
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.
Can you add to this test or make another to test that if imageCapture
and imageAnalysis
are bound, then setDescriptionWhileRecording
also changes them?
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've included verification for imageCapture and imageAnalysis are bound after setting description
I've made edits based on your comments @stuartmorgan-g @camsim99. Please take a look. |
setDescriptionWhileRecording allows switching camera while a video recording is in progress. This feature was only working with camera2 setup, but the camera plugin uses camerax by default. So, this PR includes update to address the issue.
Fixes #148013
Pre-Review Checklist
[shared_preferences]
pubspec.yaml
with 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.md
to 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-assist
bot 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