Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[camera] android-rework part 5: Android FPS range, resolution and sensor orientation features #3799

Conversation

mvanbeusekom
Copy link
Contributor

Adds FPS range, resolution and sensor orientation features containing the implementation to handle FPS range, resolution and sensor orientation via the Android Camera2 API.

This is the fifth PR in a series of pull-requests which will gradually introduce changes from PR #3651, making it easier to review the code (as discussed with @stuartmorgan).

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
    • Since this will be a series of pull-requests I will update the version in the last PR of the series.
  • I updated CHANGELOG.md to add a description of the change.
    • Since this will be a series of pull-requests I will update the version in the last PR of the series.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@google-cla
Copy link

google-cla bot commented Apr 8, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Apr 8, 2021
@mvanbeusekom mvanbeusekom changed the title [camera] android-rework part 5: Android flash and zoom features [camera] android-rework part 5: Android FPS range, resolution and sensor orientation features Apr 8, 2021
@acoutts
Copy link
Contributor

acoutts commented Apr 8, 2021

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Apr 8, 2021
@mvanbeusekom mvanbeusekom force-pushed the camera-android/fps_resolution_sensor_features branch from a8f0e9f to 1ba738d Compare April 20, 2021 11:47
}
} catch (Exception e) {
// TODO: maybe just send a dart error back
// pictureCaptureRequest.error("cameraAccess", e.getMessage(), null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a TODO? It seems like having some kind of error handling is important here, whether that's reporting it back, or setting a default if that would make more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some refactoring the need for error handling is removed. I have removed the obsolete try...catch statement.


verify(mockBuilder).set(eq(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE), any(Range.class));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error codepath, whatever handling ends up going there, should be tested as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has become obsolete


public static CamcorderProfile getBestAvailableCamcorderProfileForResolutionPreset(
String cameraName, ResolutionPreset preset) {
int cameraId = Integer.parseInt(cameraName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If what's actually needed is an integer ID, why does the method take a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored the code to only accept an integer.

angle = 270;
break;
}
if (isFrontFacing) angle *= -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

private void startUIListener() {
if (broadcastReceiver != null) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

private void stopSensorListener() {
if (orientationEventListener == null) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

private void stopUIListener() {
if (broadcastReceiver == null) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

public void start() {
startSensorListener();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment here explaining why we listen to both? It's not clear to me why we need to compute the orientation two different ways. Is it a case of needing a fallback if one isn't available?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

private Display getDisplay() {
return ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class has a lot of non-trivial logic, but no tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mvanbeusekom
Copy link
Contributor Author

@stuartmorgan thank you for reviewing this PR, I have processed all feedback and would appreciate it if you could have another look.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just some small things

@mvanbeusekom
Copy link
Contributor Author

@stuartmorgan I have processed your feedback and would appreciate it if you can have another look. Also I am not sure why the cla/google step is failing. The cla: yes label is correctly applied since the 8th of April and no other users but me have worked on this PR since.

@stuartmorgan-g
Copy link
Contributor

You landed another co-authored commit after #3799 (comment), maybe it needs another consent message? I'm not sure exactly how that check is implemented internally.

@mvanbeusekom
Copy link
Contributor Author

You landed another co-authored commit after #3799 (comment), maybe it needs another consent message? I'm not sure exactly how that check is implemented internally.

Strange after pushing the changes you requested (removed the obsolete comment) the CLA is happy again. Anyway would appreciate it if you could have another look.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mvanbeusekom mvanbeusekom added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Jun 22, 2021
@fluttergithubbot fluttergithubbot merged commit 0232846 into flutter:master Jun 22, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 22, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 22, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 22, 2021
amantoux pushed a commit to amantoux/plugins that referenced this pull request Jul 10, 2021
fotiDim pushed a commit to fotiDim/plugins that referenced this pull request Sep 13, 2021
@mvanbeusekom mvanbeusekom deleted the camera-android/fps_resolution_sensor_features branch September 21, 2021 09:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes p: camera platform-android waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants