Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
/pluginsPublic archive

[camera] android-rework part 9: Final implementation of camera class#4059

Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
107 commits
Select commitHold shift + click to select a range
2b7aa9b
Base classes to support Android camera features
mvanbeusekomApr 8, 2021
f780742
Fixed formatting
mvanbeusekomApr 8, 2021
76bc5bd
Applied feedback from PR
mvanbeusekomApr 20, 2021
0bbed99
Added Android FPS range, resolution and sensor orientation features
mvanbeusekomApr 8, 2021
1ba738d
Use mockito-inline
mvanbeusekomApr 9, 2021
de4e70f
Merge remote-tracking branch 'upstream/master' into camera-android/fp…
mvanbeusekomApr 21, 2021
728346a
Fix issue Pixel 4A
mvanbeusekomMay 26, 2021
c014fe3
Merge remote-tracking branch 'upstream/master' into camera-android/fp…
mvanbeusekomMay 31, 2021
84f5e73
Added API documentation
mvanbeusekomMay 31, 2021
f763f77
Processed feedback on PR
mvanbeusekomMay 31, 2021
4a7c73a
Fix formatting
mvanbeusekomMay 31, 2021
a890919
Fix formatting
mvanbeusekomMay 31, 2021
f60a0d3
Merge remote-tracking branch 'upstream/master'
BeMacizedJun 8, 2021
55a6702
Only exclude 60 FPS limit for Pixel 4a
mvanbeusekomJun 8, 2021
cd53321
Removed redundant empty line
mvanbeusekomJun 8, 2021
35831d3
Fixed comment
mvanbeusekomJun 8, 2021
a9f3142
Test Pixel 4a workaround
mvanbeusekomJun 8, 2021
551800e
Add tests for orientation updates
mvanbeusekomJun 10, 2021
68cbc56
Fix formatting
mvanbeusekomJun 10, 2021
1b137c2
Fix formatting
mvanbeusekomJun 10, 2021
6514a00
Added missing license header
mvanbeusekomJun 10, 2021
baae5f6
Add feature classes for exposure- and focus point functionality.
BeMacizedJun 10, 2021
cae8a90
Merge remote-tracking branch 'upstream/master'
BeMacizedJun 11, 2021
94fed08
Added noise reduction feature
BeMacizedJun 14, 2021
be05e67
Merge branch 'camera-android/noise_reduction_feature' into camera-and…
BeMacizedJun 14, 2021
a68b9fb
Merge branch 'camera-android/exposure_focus_point_features' into came…
BeMacizedJun 14, 2021
e5253c1
Merge remote-tracking branch 'origin/camera-android/fps_resolution_se…
BeMacizedJun 14, 2021
4f169ab
Implemented PR feedback
BeMacizedJun 15, 2021
3a68294
Implemented PR feedback
BeMacizedJun 15, 2021
70dbbd5
Add supporting functionality for android refactor
BeMacizedJun 15, 2021
8e65f33
Merge branch 'camera-android/exposure_focus_point_features' into came…
BeMacizedJun 16, 2021
2c64ea2
Merge branch 'camera-android/noise_reduction_feature' into camera-and…
BeMacizedJun 16, 2021
ab332ee
Update packages/camera/camera/android/src/main/java/io/flutter/plugin…
BeMacizedJun 16, 2021
bc16dd3
Update packages/camera/camera/android/src/main/java/io/flutter/plugin…
BeMacizedJun 16, 2021
a85e312
Update packages/camera/camera/android/src/main/java/io/flutter/plugin…
BeMacizedJun 16, 2021
84d6db2
Update packages/camera/camera/android/src/main/java/io/flutter/plugin…
BeMacizedJun 16, 2021
071e879
Update packages/camera/camera/android/src/main/java/io/flutter/plugin…
BeMacizedJun 16, 2021
273762b
Update packages/camera/camera/android/src/test/java/io/flutter/plugin…
BeMacizedJun 16, 2021
e9e9bc5
Update packages/camera/camera/android/src/test/java/io/flutter/plugin…
BeMacizedJun 16, 2021
1af5437
Update packages/camera/camera/android/src/test/java/io/flutter/plugin…
BeMacizedJun 16, 2021
b49b743
Added documentation to DartMessenger
mvanbeusekomJun 16, 2021
5b8c0d8
Update packages/camera/camera/android/src/main/java/io/flutter/plugin…
BeMacizedJun 16, 2021
62a2f21
Add missing CaptureTimeoutsWrapper documentation
BeMacizedJun 16, 2021
43c0716
Update packages/camera/camera/android/src/main/java/io/flutter/plugin…
BeMacizedJun 16, 2021
24c6c9a
Added documentation to the CameraCaptureCallback
mvanbeusekomJun 16, 2021
fc2d78b
Merge branch 'camera-android/supporting_functionality' of github.com:…
mvanbeusekomJun 16, 2021
b2536d4
Add missing documentation for ImageSaver runnable
BeMacizedJun 16, 2021
1748503
Merge remote-tracking branch 'origin/camera-android/supporting_functi…
BeMacizedJun 16, 2021
3118680
Update packages/camera/camera/android/src/main/java/io/flutter/plugin…
BeMacizedJun 16, 2021
7dbbdce
Added documentation to the CameraFeatureFactory
mvanbeusekomJun 16, 2021
2b2bea3
Configure log tag in one place and optimised loggin
mvanbeusekomJun 16, 2021
96d285b
Android rework finalization (wip)
BeMacizedJun 16, 2021
81920e0
Progress on final implementation of android rework
BeMacizedJun 16, 2021
6fe67da
Update tests
BeMacizedJun 16, 2021
7f0180e
Accept cameraName as String
mvanbeusekomJun 16, 2021
24af367
Format
mvanbeusekomJun 16, 2021
a987711
Changes required for integrating main camera class
BeMacizedJun 16, 2021
66a713d
Merge branch 'camera-android/fps_resolution_sensor_features' into cam…
BeMacizedJun 16, 2021
ce9df6c
Changes required for integrating main camera class
BeMacizedJun 16, 2021
32cb969
Remove debug statement
BeMacizedJun 16, 2021
44acbf7
Merge branch 'camera-android/supporting_functionality' into camera-an…
BeMacizedJun 16, 2021
dd3416b
Updated pubspec version and changelog
BeMacizedJun 16, 2021
d215ac7
Merge branch 'master' into camera-android/supporting_functionality
BeMacizedJun 22, 2021
d10397a
Merge branch 'camera-android/supporting_functionality' into camera-an…
BeMacizedJun 22, 2021
914b187
Merge branch 'master' into camera-android/supporting_functionality
BeMacizedJun 24, 2021
6e13430
Merge branch 'camera-android/supporting_functionality' into camera-an…
BeMacizedJun 24, 2021
9282d9a
Remove unused classes after refactor
BeMacizedJun 28, 2021
cb3a35c
Fix camera orientation issues
BeMacizedJun 28, 2021
5cfbf1c
Merge branch 'camera-android/final-rework-implementation' into fix/ca…
BeMacizedJun 28, 2021
5e3eac8
Fix unit tests
BeMacizedJun 29, 2021
9779a28
Fix rotation issues with exposure- and focus point features.
BeMacizedJul 8, 2021
90000ce
Fix unit tests & Format
BeMacizedJul 12, 2021
3b7f053
Add unit tests for metering rectangle rotation
BeMacizedJul 12, 2021
6bb305e
Merge branch 'master' into camera-android/final-rework-implementation
BeMacizedJul 12, 2021
8e44421
Merge branch 'camera-android/final-rework-implementation' into fix/ca…
BeMacizedJul 12, 2021
36d7173
Revert adjustments to platform interface to prevent unnecessary break…
BeMacizedJul 13, 2021
a2607d1
Revert naming refactor
BeMacizedJul 13, 2021
9fb1019
Update project.pbxproj
BeMacizedJul 13, 2021
777c696
Undo version bump
BeMacizedJul 13, 2021
6c8f16e
Merge branch 'camera-android/final-rework-implementation' into fix/ca…
BeMacizedJul 13, 2021
5d9fb6d
Updated changelog and pubspec version
BeMacizedJul 13, 2021
890605a
Merge branch 'fix/camera-orientation' into camera-android/final-rewor…
BeMacizedJul 13, 2021
7c916c2
Merge branch 'master' into camera-android/final-rework-implementation
BeMacizedJul 22, 2021
28ed2a3
Merge branch 'master' into camera-android/final-rework-implementation
BeMacizedJul 28, 2021
8a0864c
First processing of basic feedback
BeMacizedJul 29, 2021
376af33
Implement more PR feedback
BeMacizedJul 29, 2021
bc13ee7
Remove unnecessary comment
BeMacizedAug 2, 2021
cc8a566
Added unit-tests for pause and resume recording
mvanbeusekomAug 2, 2021
944e7c5
Merge branch 'camera-android/final-rework-implementation' of github.c…
mvanbeusekomAug 2, 2021
393f5a2
Fix formatting mistake
mvanbeusekomAug 2, 2021
06c19ae
Implemented more PR feedback
BeMacizedAug 2, 2021
335c899
Merge remote-tracking branch 'origin/camera-android/final-rework-impl…
BeMacizedAug 2, 2021
0bb5d2c
Implement more PR feedback
BeMacizedAug 2, 2021
780feed
Format
BeMacizedAug 2, 2021
eb5d164
Implement more PR feedback
BeMacizedAug 2, 2021
b88fc46
Implement more PR feedback
BeMacizedAug 3, 2021
f2beeb8
Add lifecycle events for recreating camera background thread
BeMacizedAug 3, 2021
88c91c1
Implement PR feedback
BeMacizedAug 3, 2021
ecde1b7
Added more unit tests
BeMacizedAug 5, 2021
f56cce0
Format fix
BeMacizedAug 5, 2021
d87cfa9
Merge branch 'master' into camera-android/final-rework-implementation
BeMacizedAug 16, 2021
880af3a
Add missing license header
BeMacizedAug 16, 2021
9adcd02
Fix noise reduction tests failing on CI
BeMacizedAug 16, 2021
88f8c50
[camera] Fix casing on all android tests
BeMacizedAug 16, 2021
7fbb028
Split up certain unit tests
BeMacizedAug 16, 2021
4ae42f8
Add two missing tests
BeMacizedAug 20, 2021
6c514cb
Merge branch 'master' into camera-android/final-rework-implementation
BeMacizedAug 20, 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
PrevPrevious commit
NextNext commit
Changes required for integrating main camera class
  • Loading branch information
@BeMacized
BeMacized committedJun 16, 2021
commitce9df6c4b70719bf4ca934af7e9e1702b7970869
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,8 +24,8 @@ class CameraCaptureCallback extends CaptureCallback {
private final CaptureTimeoutsWrapper captureTimeouts;

private CameraCaptureCallback(
@NonNull CameraCaptureStateListener cameraStateListener,
@NonNull CaptureTimeoutsWrapper captureTimeouts) {
@NonNull CameraCaptureStateListener cameraStateListener,
@NonNull CaptureTimeoutsWrapper captureTimeouts) {
cameraState = CameraState.STATE_PREVIEW;
this.cameraStateListener = cameraStateListener;
this.captureTimeouts = captureTimeouts;
Expand All@@ -40,8 +40,8 @@ private CameraCaptureCallback(
* @return a configured instance of the {@link CameraCaptureCallback} class.
*/
public static CameraCaptureCallback create(
@NonNull CameraCaptureStateListener cameraStateListener,
@NonNull CaptureTimeoutsWrapper captureTimeouts) {
@NonNull CameraCaptureStateListener cameraStateListener,
@NonNull CaptureTimeoutsWrapper captureTimeouts) {
return new CameraCaptureCallback(cameraStateListener, captureTimeouts);
}

Expand DownExpand Up@@ -69,63 +69,63 @@ private void process(CaptureResult result) {

if (cameraState != CameraState.STATE_PREVIEW) {
Log.d(
TAG,
"CameraCaptureCallback | state: "
+ cameraState
+ " | afState: "
+ afState
+ " | aeState: "
+ aeState);
TAG,
"CameraCaptureCallback | state: "
+ cameraState
+ " | afState: "
+ afState
+ " | aeState: "
+ aeState);
}

switch (cameraState) {
case STATE_PREVIEW:
{
// We have nothing to do when the camera preview is working normally.
break;
}
{
// We have nothing to do when the camera preview is working normally.
break;
}
case STATE_WAITING_FOCUS:
{
if (afState == null) {
return;
} else if (afState == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED
|| afState == CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) {
handleWaitingFocusState(aeState);
} else if (captureTimeouts.getPreCaptureFocusing().getIsExpired()) {
Log.w(TAG, "Focus timeout, moving on with capture");
handleWaitingFocusState(aeState);
{
if (afState == null) {
return;
} else if (afState == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED
|| afState == CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) {
handleWaitingFocusState(aeState);
} else if (captureTimeouts.getPreCaptureFocusing().getIsExpired()) {
Log.w(TAG, "Focus timeout, moving on with capture");
handleWaitingFocusState(aeState);
}

break;
}

break;
}
case STATE_WAITING_PRECAPTURE_START:
{
// CONTROL_AE_STATE can be null on some devices
if (aeState == null
|| aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED
|| aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE
|| aeState == CaptureResult.CONTROL_AE_STATE_FLASH_REQUIRED) {
setCameraState(CameraState.STATE_WAITING_PRECAPTURE_DONE);
} else if (captureTimeouts.getPreCaptureMetering().getIsExpired()) {
Log.w(TAG, "Metering timeout waiting for pre-capture to start, moving on with capture");

setCameraState(CameraState.STATE_WAITING_PRECAPTURE_DONE);
{
// CONTROL_AE_STATE can be null on some devices
if (aeState == null
|| aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED
|| aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE
|| aeState == CaptureResult.CONTROL_AE_STATE_FLASH_REQUIRED) {
setCameraState(CameraState.STATE_WAITING_PRECAPTURE_DONE);
} else if (captureTimeouts.getPreCaptureMetering().getIsExpired()) {
Log.w(TAG, "Metering timeout waiting for pre-capture to start, moving on with capture");

setCameraState(CameraState.STATE_WAITING_PRECAPTURE_DONE);
}
break;
}
break;
}
case STATE_WAITING_PRECAPTURE_DONE:
{
// CONTROL_AE_STATE can be null on some devices
if (aeState == null || aeState != CaptureResult.CONTROL_AE_STATE_PRECAPTURE) {
cameraStateListener.onConverged();
} else if (captureTimeouts.getPreCaptureMetering().getIsExpired()) {
Log.w(
TAG, "Metering timeout waiting for pre-capture to finish, moving on with capture");
cameraStateListener.onConverged();
{
// CONTROL_AE_STATE can be null on some devices
if (aeState == null || aeState != CaptureResult.CONTROL_AE_STATE_PRECAPTURE) {
cameraStateListener.onConverged();
} else if (captureTimeouts.getPreCaptureMetering().getIsExpired()) {
Log.w(
TAG, "Metering timeout waiting for pre-capture to finish, moving on with capture");
cameraStateListener.onConverged();
}

break;
}

break;
}
}
}

Expand All@@ -140,17 +140,17 @@ private void handleWaitingFocusState(Integer aeState) {

@Override
public void onCaptureProgressed(
@NonNull CameraCaptureSession session,
@NonNull CaptureRequest request,
@NonNull CaptureResult partialResult) {
@NonNull CameraCaptureSession session,
@NonNull CaptureRequest request,
@NonNull CaptureResult partialResult) {
process(partialResult);
}

@Override
public void onCaptureCompleted(
@NonNull CameraCaptureSession session,
@NonNull CaptureRequest request,
@NonNull TotalCaptureResult result) {
@NonNull CameraCaptureSession session,
@NonNull CaptureRequest request,
@NonNull TotalCaptureResult result) {
process(result);
}

Expand All@@ -165,4 +165,4 @@ interface CameraCaptureStateListener {
*/
void onPrecapture();
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -246,7 +246,7 @@ class CameraPropertiesImpl implements CameraProperties {
private final String cameraName;

public CameraPropertiesImpl(String cameraName, CameraManager cameraManager)
throws CameraAccessException {
throws CameraAccessException {
this.cameraName = cameraName;
this.cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraName);
}
Expand All@@ -270,7 +270,7 @@ public Range<Integer> getControlAutoExposureCompensationRange() {
@Override
public double getControlAutoExposureCompensationStep() {
Rational rational =
cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP);
cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP);

return rational == null ? 0.0 : rational.doubleValue();
}
Expand DownExpand Up@@ -330,7 +330,7 @@ public Size getSensorInfoPixelArraySize() {
@Override
public Rect getSensorInfoPreCorrectionActiveArraySize() {
return cameraCharacteristics.get(
CameraCharacteristics.SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE);
CameraCharacteristics.SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE);
}

@Override
Expand All@@ -346,6 +346,6 @@ public int getHardwareLevel() {
@Override
public int[] getAvailableNoiseReductionModes() {
return cameraCharacteristics.get(
CameraCharacteristics.NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES);
CameraCharacteristics.NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES);
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,12 +6,20 @@

import android.app.Activity;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.media.CamcorderProfile;
import android.util.Size;
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
import io.flutter.plugins.camera.types.ResolutionPreset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All@@ -21,24 +29,23 @@ public final class CameraUtils {

private CameraUtils() {}

/**
* Gets the {@link CameraManager} singleton.
*
* @param context The context to get the {@link CameraManager} singleton from.
* @return The {@link CameraManager} singleton.
*/
static CameraManager getCameraManager(Context context) {
return (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
static PlatformChannel.DeviceOrientation getDeviceOrientationFromDegrees(int degrees) {
// Round to the nearest 90 degrees.
degrees = (int) (Math.round(degrees / 90.0) * 90) % 360;
// Determine the corresponding device orientation.
switch (degrees) {
case 90:
return PlatformChannel.DeviceOrientation.LANDSCAPE_LEFT;
case 180:
return PlatformChannel.DeviceOrientation.PORTRAIT_DOWN;
case 270:
return PlatformChannel.DeviceOrientation.LANDSCAPE_RIGHT;
case 0:
default:
return PlatformChannel.DeviceOrientation.PORTRAIT_UP;
}
}

/**
* Serializes the {@link PlatformChannel.DeviceOrientation} to a string value.
*
* @param orientation The orientation to serialize.
* @return The serialized orientation.
* @throws UnsupportedOperationException when the provided orientation not have a corresponding
* string value.
*/
static String serializeDeviceOrientation(PlatformChannel.DeviceOrientation orientation) {
if (orientation == null)
throw new UnsupportedOperationException("Could not serialize null device orientation.");
Expand All@@ -53,19 +60,10 @@ static String serializeDeviceOrientation(PlatformChannel.DeviceOrientation orien
return "landscapeRight";
default:
throw new UnsupportedOperationException(
"Could not serialize device orientation: " + orientation.toString());
"Could not serialize device orientation: " + orientation.toString());
}
}

/**
* Deserializes a string value to its corresponding {@link PlatformChannel.DeviceOrientation}
* value.
*
* @param orientation The string value to deserialize.
* @return The deserialized orientation.
* @throws UnsupportedOperationException when the provided string value does not have a
* corresponding {@link PlatformChannel.DeviceOrientation}.
*/
static PlatformChannel.DeviceOrientation deserializeDeviceOrientation(String orientation) {
if (orientation == null)
throw new UnsupportedOperationException("Could not deserialize null device orientation.");
Expand All@@ -80,19 +78,29 @@ static PlatformChannel.DeviceOrientation deserializeDeviceOrientation(String ori
return PlatformChannel.DeviceOrientation.LANDSCAPE_RIGHT;
default:
throw new UnsupportedOperationException(
"Could not deserialize device orientation: " + orientation);
"Could not deserialize device orientation: " + orientation);
}
}

/**
* Gets all the available cameras for the device.
*
* @param activity The current Android activity.
* @return A map of all the available cameras, with their name as their key.
* @throws CameraAccessException when the camera could not be accessed.
*/
static Size computeBestPreviewSize(String cameraName, ResolutionPreset preset) {
if (preset.ordinal() > ResolutionPreset.high.ordinal()) {
preset = ResolutionPreset.high;
}

CamcorderProfile profile =
getBestAvailableCamcorderProfileForResolutionPreset(cameraName, preset);
return new Size(profile.videoFrameWidth, profile.videoFrameHeight);
}

static Size computeBestCaptureSize(StreamConfigurationMap streamConfigurationMap) {
// For still image captures, we use the largest available size.
return Collections.max(
Arrays.asList(streamConfigurationMap.getOutputSizes(ImageFormat.JPEG)),
new CompareSizesByArea());
}

public static List<Map<String, Object>> getAvailableCameras(Activity activity)
throws CameraAccessException {
throws CameraAccessException {
CameraManager cameraManager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
String[] cameraNames = cameraManager.getCameraIdList();
List<Map<String, Object>> cameras = new ArrayList<>();
Expand All@@ -119,4 +127,52 @@ public static List<Map<String, Object>> getAvailableCameras(Activity activity)
}
return cameras;
}

static CamcorderProfile getBestAvailableCamcorderProfileForResolutionPreset(
String cameraName, ResolutionPreset preset) {
int cameraId = Integer.parseInt(cameraName);
switch (preset) {
// 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);
}
case ultraHigh:
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_2160P)) {
return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_2160P);
}
case veryHigh:
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_1080P)) {
return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_1080P);
}
case high:
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_720P)) {
return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_720P);
}
case medium:
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_480P)) {
return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_480P);
}
case low:
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_QVGA)) {
return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_QVGA);
}
default:
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_LOW)) {
return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_LOW);
} else {
throw new IllegalArgumentException(
"No capture session available for current capture session.");
}
}
}

private static class CompareSizesByArea implements Comparator<Size> {
@Override
public int compare(Size lhs, Size rhs) {
// We cast here to ensure the multiplications won't overflow.
return Long.signum(
(long) lhs.getWidth() * lhs.getHeight() - (long) rhs.getWidth() * rhs.getHeight());
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,4 +102,4 @@ public static FileOutputStream create(File file) throws FileNotFoundException {
return new FileOutputStream(file);
}
}
}
}
Loading

[8]ページ先頭

©2009-2026 Movatter.jp