summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraAgentImpl.java18
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraCapabilities.java2
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraSettings.java24
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java10
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java13
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java70
6 files changed, 134 insertions, 3 deletions
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraAgentImpl.java b/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraAgentImpl.java
index 8e9d799..0cd8ede 100644
--- a/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraAgentImpl.java
+++ b/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraAgentImpl.java
@@ -38,6 +38,7 @@ import android.view.SurfaceHolder;
import com.android.ex.camera2.portability.debug.Log;
import java.io.IOException;
+import java.util.StringTokenizer;
/**
* A class to implement {@link CameraAgent} of the Android camera framework.
@@ -512,6 +513,7 @@ class AndroidCameraAgentImpl implements CameraAgent {
} else {
mParamsToSet.setPreviewFrameRate(settings.getPreviewFrameRate());
}
+ mParamsToSet.setPreviewFormat(settings.getCurrentPreviewFormat());
mParamsToSet.setJpegQuality(settings.getPhotoJpegCompressionQuality());
if (mCapabilities.supports(CameraCapabilities.Feature.ZOOM)) {
// Should use settings.getCurrentZoomRatio() instead here.
@@ -545,6 +547,10 @@ class AndroidCameraAgentImpl implements CameraAgent {
.setSceneMode(stringifier.stringify(settings.getCurrentSceneMode()));
}
}
+ mParamsToSet.setRecordingHint(settings.isRecordingHintEnabled());
+ Size jpegThumbSize = settings.getExifThumbnailSize();
+ mParamsToSet.setJpegThumbnailSize(jpegThumbSize.width(), jpegThumbSize.height());
+ mParamsToSet.setPictureFormat(settings.getCurrentPhotoFormat());
CameraSettings.GpsData gpsData = settings.getGpsData();
if (gpsData == null) {
@@ -1032,6 +1038,18 @@ class AndroidCameraAgentImpl implements CameraAgent {
}
});
}
+
+ @Override
+ public String dumpDeviceSettings() {
+ String flattened = mParameters.flatten();
+ StringTokenizer tokenizer = new StringTokenizer(flattened, ";");
+ String dumpedSettings = new String();
+ while (tokenizer.hasMoreElements()) {
+ dumpedSettings += tokenizer.nextToken() + '\n';
+ }
+
+ return dumpedSettings;
+ }
}
private static class WaitDoneBundle {
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraCapabilities.java b/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraCapabilities.java
index fc97efa..28d1fd1 100644
--- a/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraCapabilities.java
+++ b/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraCapabilities.java
@@ -47,6 +47,8 @@ class AndroidCameraCapabilities extends CameraCapabilities {
mMaxZoomIndex = p.getMaxZoom();
mZoomRatioList.addAll(p.getZoomRatios());
mMaxZoomRatio = mZoomRatioList.get(mMaxZoomIndex);
+ mHorizontalViewAngle = p.getHorizontalViewAngle();
+ mVerticalViewAngle = p.getVerticalViewAngle();
buildPreviewFpsRange(p);
buildPreviewSizes(p);
buildVideoSizes(p);
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraSettings.java b/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraSettings.java
index 3869188..a4039bd 100644
--- a/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraSettings.java
+++ b/camera2/portability/src/com/android/ex/camera2/portability/AndroidCameraSettings.java
@@ -1,11 +1,29 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.android.ex.camera2.portability;
import android.hardware.Camera;
/**
- * Created by shkong on 6/2/14.
+ * The subclass of {@link CameraSettings} for Android Camera 1 API.
*/
public class AndroidCameraSettings extends CameraSettings {
+ private static final String TRUE = "true";
+ private static final String RECORDING_HINT = "recording-hint";
public AndroidCameraSettings(CameraCapabilities capabilities, Camera.Parameters params) {
CameraCapabilities.Stringifier stringifier = capabilities.getStringifier();
@@ -18,7 +36,7 @@ public class AndroidCameraSettings extends CameraSettings {
params.getPreviewFpsRange(previewFpsRange);
setPreviewFpsRange(previewFpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
previewFpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
-
+ setPreviewFormat(params.getPreviewFormat());
// Capture: Focus, flash, zoom, exposure, scene mode.
if (capabilities.supports(CameraCapabilities.Feature.ZOOM)) {
@@ -37,11 +55,13 @@ public class AndroidCameraSettings extends CameraSettings {
if (capabilities.supports(CameraCapabilities.Feature.VIDEO_STABILIZATION)) {
setVideoStabilization(isVideoStabilizationEnabled());
}
+ setRecordingHintEnabled(TRUE.equals(params.get(RECORDING_HINT)));
// Output: Photo size, compression quality, rotation.
setPhotoRotationDegrees(0f);
setPhotoJpegCompressionQuality(params.getJpegQuality());
Camera.Size paramPictureSize = params.getPictureSize();
setPhotoSize(new Size(paramPictureSize.width, paramPictureSize.height));
+ setPhotoFormat(params.getPictureFormat());
}
}
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java b/camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java
index 91598e3..db3b1d7 100644
--- a/camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java
+++ b/camera2/portability/src/com/android/ex/camera2/portability/CameraAgent.java
@@ -577,5 +577,15 @@ public interface CameraAgent {
* {@code false} to disable it.
*/
public void enableShutterSound(boolean enable);
+
+ /**
+ * Dumps the current settings of the camera device.
+ *
+ * <p>The content varies based on the underlying camera API settings
+ * implementation.</p>
+ *
+ * @return The content of the device settings represented by a string.
+ */
+ public String dumpDeviceSettings();
}
}
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java b/camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java
index 7857425..f08301c 100644
--- a/camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java
+++ b/camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java
@@ -58,6 +58,8 @@ public class CameraCapabilities {
protected int mMaxNumOfFocusAreas;
protected int mMaxNumOfMeteringArea;
protected int mMaxZoomRatio;
+ protected float mHorizontalViewAngle;
+ protected float mVerticalViewAngle;
private final Stringifier mStringifier;
protected final ArrayList<Integer> mZoomRatioList = new ArrayList<Integer>();
protected int mMaxZoomIndex;
@@ -416,9 +418,19 @@ public class CameraCapabilities {
mMaxNumOfFocusAreas = src.mMaxNumOfFocusAreas;
mMaxNumOfMeteringArea = src.mMaxNumOfMeteringArea;
mMaxZoomRatio = src.mMaxZoomRatio;
+ mHorizontalViewAngle = src.mHorizontalViewAngle;
+ mVerticalViewAngle = src.mVerticalViewAngle;
mStringifier = src.mStringifier;
}
+ public float getHorizontalViewAngle() {
+ return mHorizontalViewAngle;
+ }
+
+ public float getVerticalViewAngle() {
+ return mVerticalViewAngle;
+ }
+
/**
* @return the supported picture formats. See {@link android.graphics.ImageFormat}.
*/
@@ -441,7 +453,6 @@ public class CameraCapabilities {
return new ArrayList<Size>(mSupportedPhotoSizes);
}
-
/**
* @return The supported preview fps (frame-per-second) ranges. The returned
* list is sorted by maximum fps then minimum fps in a descending order.
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java b/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
index 9ddac4e..33ceb5c 100644
--- a/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
+++ b/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
@@ -19,8 +19,10 @@ public class CameraSettings {
protected int mPreviewFpsRangeMax;
protected int mPreviewFrameRate;
protected Size mCurrentPreviewSize;
+ private int mCurrentPreviewFormat;
protected Size mCurrentPhotoSize;
protected int mJpegCompressQuality;
+ protected int mCurrentPhotoFormat;
protected float mCurrentZoomRatio;
protected int mCurrentZoomIndex;
protected float mPhotoRotationDegrees;
@@ -32,7 +34,9 @@ public class CameraSettings {
protected boolean mVideoStabilizationEnabled;
protected boolean mAutoExposureLocked;
protected boolean mAutoWhiteBalanceLocked;
+ protected boolean mRecordingHintEnabled;
protected GpsData mGpsData;
+ protected Size mExifThumbnailSize = new Size(0,0);
/**
* An immutable class storing GPS related information.
@@ -85,9 +89,11 @@ public class CameraSettings {
mPreviewFrameRate = src.mPreviewFrameRate;
mCurrentPreviewSize =
(src.mCurrentPreviewSize == null ? null : new Size(src.mCurrentPreviewSize));
+ mCurrentPreviewFormat = src.mCurrentPreviewFormat;
mCurrentPhotoSize =
(src.mCurrentPhotoSize == null ? null : new Size(src.mCurrentPhotoSize));
mJpegCompressQuality = src.mJpegCompressQuality;
+ mCurrentPhotoFormat = src.mCurrentPhotoFormat;
mCurrentZoomRatio = src.mCurrentZoomRatio;
mCurrentZoomIndex = src.mCurrentZoomIndex;
mPhotoRotationDegrees = src.mPhotoRotationDegrees;
@@ -99,7 +105,9 @@ public class CameraSettings {
mVideoStabilizationEnabled = src.mVideoStabilizationEnabled;
mAutoExposureLocked = src.mAutoExposureLocked;
mAutoWhiteBalanceLocked = src.mAutoWhiteBalanceLocked;
+ mRecordingHintEnabled = src.mRecordingHintEnabled;
mGpsData = src.mGpsData;
+ mExifThumbnailSize = src.mExifThumbnailSize;
}
/** General setting **/
@@ -174,6 +182,24 @@ public class CameraSettings {
mCurrentPreviewSize = new Size(previewSize);
}
+ /**
+ * Sets the preview format.
+ *
+ * @param format
+ * @see {@link android.graphics.ImageFormat}.
+ */
+ public void setPreviewFormat(int format) {
+ mCurrentPreviewFormat = format;
+ }
+
+ /**
+ * @return The preview format.
+ * @see {@link android.graphics.ImageFormat}.
+ */
+ public int getCurrentPreviewFormat() {
+ return mCurrentPreviewFormat;
+ }
+
/** Picture **/
/**
@@ -193,6 +219,24 @@ public class CameraSettings {
}
/**
+ * Sets the format for the photo.
+ *
+ * @param format The format for the photos taken.
+ * @see {@link android.graphics.ImageFormat}.
+ */
+ public void setPhotoFormat(int format) {
+ mCurrentPhotoFormat = format;
+ }
+
+ /**
+ * @return The format for the photos taken.
+ * @see {@link android.graphics.ImageFormat}.
+ */
+ public int getCurrentPhotoFormat() {
+ return mCurrentPhotoFormat;
+ }
+
+ /**
* Sets the JPEG compression quality.
*
* @param quality The quality for JPEG.
@@ -363,6 +407,14 @@ public class CameraSettings {
return mVideoStabilizationEnabled;
}
+ public void setRecordingHintEnabled(boolean hintEnabled) {
+ mRecordingHintEnabled = hintEnabled;
+ }
+
+ public boolean isRecordingHintEnabled() {
+ return mRecordingHintEnabled;
+ }
+
public void setGpsData(GpsData data) {
mGpsData = new GpsData(data);
}
@@ -374,4 +426,22 @@ public class CameraSettings {
public void clearGpsData() {
mGpsData = null;
}
+
+ /**
+ * Sets the size of the thumbnail in EXIF header.
+ *
+ * @param s The size for the thumbnail. {@code null} will clear the size to
+ * (0,0).
+ */
+ public void setExifThumbnailSize(Size s) {
+ if (s != null) {
+ mExifThumbnailSize = s;
+ } else {
+ mExifThumbnailSize = new Size(0,0);
+ }
+ }
+
+ public Size getExifThumbnailSize() {
+ return new Size(mExifThumbnailSize);
+ }
}