Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2b7aa9b
Base classes to support Android camera features
mvanbeusekom Apr 8, 2021
f780742
Fixed formatting
mvanbeusekom Apr 8, 2021
76bc5bd
Applied feedback from PR
mvanbeusekom Apr 20, 2021
0bbed99
Added Android FPS range, resolution and sensor orientation features
mvanbeusekom Apr 8, 2021
1ba738d
Use mockito-inline
mvanbeusekom Apr 9, 2021
de4e70f
Merge remote-tracking branch 'upstream/master' into camera-android/fp…
mvanbeusekom Apr 21, 2021
728346a
Fix issue Pixel 4A
mvanbeusekom May 26, 2021
c014fe3
Merge remote-tracking branch 'upstream/master' into camera-android/fp…
mvanbeusekom May 31, 2021
84f5e73
Added API documentation
mvanbeusekom May 31, 2021
f763f77
Processed feedback on PR
mvanbeusekom May 31, 2021
4a7c73a
Fix formatting
mvanbeusekom May 31, 2021
a890919
Fix formatting
mvanbeusekom May 31, 2021
55a6702
Only exclude 60 FPS limit for Pixel 4a
mvanbeusekom Jun 8, 2021
cd53321
Removed redundant empty line
mvanbeusekom Jun 8, 2021
35831d3
Fixed comment
mvanbeusekom Jun 8, 2021
a9f3142
Test Pixel 4a workaround
mvanbeusekom Jun 8, 2021
551800e
Add tests for orientation updates
mvanbeusekom Jun 10, 2021
68cbc56
Fix formatting
mvanbeusekom Jun 10, 2021
1b137c2
Fix formatting
mvanbeusekom Jun 10, 2021
6514a00
Added missing license header
mvanbeusekom Jun 10, 2021
7f0180e
Accept cameraName as String
mvanbeusekom Jun 16, 2021
24af367
Format
mvanbeusekom Jun 16, 2021
8313dd0
Removed obsolete comment
mvanbeusekom Jun 16, 2021
a39c2e1
update method structure in class to a more logical order
mvanbeusekom Jun 16, 2021
3eecfe9
Merge remote-tracking branch 'origin/master' into camera-android/fps_…
mvanbeusekom Jun 22, 2021
7299b1d
Fix formatting
mvanbeusekom Jun 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Accept cameraName as String
  • Loading branch information
mvanbeusekom committed Jun 16, 2021
commit 7f0180e7a389340a0a857df63d589115eb5d5461
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ public class ResolutionFeature extends CameraFeature<ResolutionPreset> {
*
* @param cameraProperties Collection of characteristics for the current camera device.
* @param resolutionPreset Platform agnostic enum containing resolution information.
* @param cameraId Camera identifier of the camera for which to configure the resolution.
* @param cameraName Camera identifier of the camera for which to configure the resolution.
*/
public ResolutionFeature(
CameraProperties cameraProperties, ResolutionPreset resolutionPreset, int cameraId) {
CameraProperties cameraProperties, ResolutionPreset resolutionPreset, String cameraName) {
super(cameraProperties);
this.currentSetting = resolutionPreset;
this.cameraId = cameraId;

try {
this.cameraId = Integer.parseInt(cameraName, 10);
} catch (NumberFormatException e) {
this.cameraId = -1;
return;
}
configureResolution(resolutionPreset, cameraId);
}

Expand All @@ -54,9 +58,13 @@ public ResolutionFeature(
*/
public static CamcorderProfile getBestAvailableCamcorderProfileForResolutionPreset(
int cameraId, ResolutionPreset preset) {
if (cameraId < 0) {
throw new AssertionError(
"getBestAvailableCamcorderProfileForResolutionPreset can only be used with valid (>=0) camera identifiers.");
}

switch (preset) {
// All of these cases deliberately fall through to get the best available profile.
// All of these cases deliberately fall through to get the best available profile.
case max:
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_HIGH)) {
return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_HIGH);
Expand Down Expand Up @@ -103,6 +111,9 @@ static Size computeBestPreviewSize(int cameraId, ResolutionPreset preset) {
}

private void configureResolution(ResolutionPreset resolutionPreset, int cameraId) {
if (!checkIsSupported()) {
return;
}
recordingProfile =
getBestAvailableCamcorderProfileForResolutionPreset(cameraId, resolutionPreset);
captureSize = new Size(recordingProfile.videoFrameWidth, recordingProfile.videoFrameHeight);
Expand All @@ -128,7 +139,7 @@ public void setValue(ResolutionPreset value) {
// Always supported
@Override
public boolean checkIsSupported() {
return true;
return cameraId >= 0;
}

@Override
Expand Down Expand Up @@ -163,4 +174,4 @@ public Size getPreviewSize() {
public Size getCaptureSize() {
return this.captureSize;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.mockito.MockedStatic;

public class ResolutionFeatureTest {
private static final int cameraId = 1;
private static final String cameraName = "1";
private CamcorderProfile mockProfileLow;
private MockedStatic<CamcorderProfile> mockedStaticProfile;

Expand Down Expand Up @@ -82,7 +82,7 @@ public void after() {
public void getDebugName_should_return_the_name_of_the_feature() {
CameraProperties mockCameraProperties = mock(CameraProperties.class);
ResolutionFeature resolutionFeature =
new ResolutionFeature(mockCameraProperties, ResolutionPreset.max, cameraId);
new ResolutionFeature(mockCameraProperties, ResolutionPreset.max, cameraName);

assertEquals("ResolutionFeature", resolutionFeature.getDebugName());
}
Expand All @@ -91,7 +91,7 @@ public void getDebugName_should_return_the_name_of_the_feature() {
public void getValue_should_return_initial_value_when_not_set() {
CameraProperties mockCameraProperties = mock(CameraProperties.class);
ResolutionFeature resolutionFeature =
new ResolutionFeature(mockCameraProperties, ResolutionPreset.max, cameraId);
new ResolutionFeature(mockCameraProperties, ResolutionPreset.max, cameraName);

assertEquals(ResolutionPreset.max, resolutionFeature.getValue());
}
Expand All @@ -100,7 +100,7 @@ public void getValue_should_return_initial_value_when_not_set() {
public void getValue_should_echo_setValue() {
CameraProperties mockCameraProperties = mock(CameraProperties.class);
ResolutionFeature resolutionFeature =
new ResolutionFeature(mockCameraProperties, ResolutionPreset.max, cameraId);
new ResolutionFeature(mockCameraProperties, ResolutionPreset.max, cameraName);

resolutionFeature.setValue(ResolutionPreset.high);

Expand All @@ -111,7 +111,7 @@ public void getValue_should_echo_setValue() {
public void checkIsSupport_returns_true() {
CameraProperties mockCameraProperties = mock(CameraProperties.class);
ResolutionFeature resolutionFeature =
new ResolutionFeature(mockCameraProperties, ResolutionPreset.max, cameraId);
new ResolutionFeature(mockCameraProperties, ResolutionPreset.max, cameraName);

assertTrue(resolutionFeature.checkIsSupported());
}
Expand Down Expand Up @@ -187,4 +187,4 @@ public void computeBestPreviewSize_should_use_QVGA_when_resolution_preset_low()

mockedStaticProfile.verify(() -> CamcorderProfile.get(1, CamcorderProfile.QUALITY_QVGA));
}
}
}