Add zoom and postview callbacks to Camera. This patch
adds a zoom callback to the Java layer. If the hardware supports a smooth zoom function, this provides a way to update the UI as the zoom is moving from its original setting to the new commanded setting. This postview callback supports receive a processed image before the JPEG encode completes. This allows the display to be rotated without losing the final preview frame.
This commit is contained in:
@@ -65986,6 +65986,19 @@
|
||||
<exception name="IOException" type="java.io.IOException">
|
||||
</exception>
|
||||
</method>
|
||||
<method name="setZoomCallback"
|
||||
return="void"
|
||||
abstract="false"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="true"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<parameter name="cb" type="android.hardware.Camera.ZoomCallback">
|
||||
</parameter>
|
||||
</method>
|
||||
<method name="startPreview"
|
||||
return="void"
|
||||
abstract="false"
|
||||
@@ -66025,6 +66038,25 @@
|
||||
<parameter name="jpeg" type="android.hardware.Camera.PictureCallback">
|
||||
</parameter>
|
||||
</method>
|
||||
<method name="takePicture"
|
||||
return="void"
|
||||
abstract="false"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="true"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<parameter name="shutter" type="android.hardware.Camera.ShutterCallback">
|
||||
</parameter>
|
||||
<parameter name="raw" type="android.hardware.Camera.PictureCallback">
|
||||
</parameter>
|
||||
<parameter name="postview" type="android.hardware.Camera.PictureCallback">
|
||||
</parameter>
|
||||
<parameter name="jpeg" type="android.hardware.Camera.PictureCallback">
|
||||
</parameter>
|
||||
</method>
|
||||
<field name="CAMERA_ERROR_SERVER_DIED"
|
||||
type="int"
|
||||
transient="false"
|
||||
@@ -66426,6 +66458,29 @@
|
||||
>
|
||||
</field>
|
||||
</class>
|
||||
<interface name="Camera.ZoomCallback"
|
||||
abstract="true"
|
||||
static="true"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<method name="onZoomUpdate"
|
||||
return="void"
|
||||
abstract="true"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<parameter name="zoomLevel" type="int">
|
||||
</parameter>
|
||||
<parameter name="camera" type="android.hardware.Camera">
|
||||
</parameter>
|
||||
</method>
|
||||
</interface>
|
||||
<class name="GeomagneticField"
|
||||
extends="java.lang.Object"
|
||||
abstract="false"
|
||||
|
||||
@@ -56,7 +56,9 @@ public class Camera {
|
||||
private PictureCallback mRawImageCallback;
|
||||
private PictureCallback mJpegCallback;
|
||||
private PreviewCallback mPreviewCallback;
|
||||
private PictureCallback mPostviewCallback;
|
||||
private AutoFocusCallback mAutoFocusCallback;
|
||||
private ZoomCallback mZoomCallback;
|
||||
private ErrorCallback mErrorCallback;
|
||||
private boolean mOneShot;
|
||||
|
||||
@@ -72,6 +74,8 @@ public class Camera {
|
||||
mRawImageCallback = null;
|
||||
mJpegCallback = null;
|
||||
mPreviewCallback = null;
|
||||
mPostviewCallback = null;
|
||||
mZoomCallback = null;
|
||||
|
||||
Looper looper;
|
||||
if ((looper = Looper.myLooper()) != null) {
|
||||
@@ -245,13 +249,15 @@ public class Camera {
|
||||
return;
|
||||
|
||||
case CAMERA_MSG_RAW_IMAGE:
|
||||
if (mRawImageCallback != null)
|
||||
if (mRawImageCallback != null) {
|
||||
mRawImageCallback.onPictureTaken((byte[])msg.obj, mCamera);
|
||||
}
|
||||
return;
|
||||
|
||||
case CAMERA_MSG_COMPRESSED_IMAGE:
|
||||
if (mJpegCallback != null)
|
||||
if (mJpegCallback != null) {
|
||||
mJpegCallback.onPictureTaken((byte[])msg.obj, mCamera);
|
||||
}
|
||||
return;
|
||||
|
||||
case CAMERA_MSG_PREVIEW_FRAME:
|
||||
@@ -263,15 +269,29 @@ public class Camera {
|
||||
}
|
||||
return;
|
||||
|
||||
case CAMERA_MSG_POSTVIEW_FRAME:
|
||||
if (mPostviewCallback != null) {
|
||||
mPostviewCallback.onPictureTaken((byte[])msg.obj, mCamera);
|
||||
}
|
||||
return;
|
||||
|
||||
case CAMERA_MSG_FOCUS:
|
||||
if (mAutoFocusCallback != null)
|
||||
if (mAutoFocusCallback != null) {
|
||||
mAutoFocusCallback.onAutoFocus(msg.arg1 == 0 ? false : true, mCamera);
|
||||
}
|
||||
return;
|
||||
|
||||
case CAMERA_MSG_ZOOM:
|
||||
if (mZoomCallback != null) {
|
||||
mZoomCallback.onZoomUpdate(msg.arg1, mCamera);
|
||||
}
|
||||
return;
|
||||
|
||||
case CAMERA_MSG_ERROR :
|
||||
Log.e(TAG, "Error " + msg.arg1);
|
||||
if (mErrorCallback != null)
|
||||
if (mErrorCallback != null) {
|
||||
mErrorCallback.onError(msg.arg1, mCamera);
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
@@ -364,13 +384,63 @@ public class Camera {
|
||||
*/
|
||||
public final void takePicture(ShutterCallback shutter, PictureCallback raw,
|
||||
PictureCallback jpeg) {
|
||||
mShutterCallback = shutter;
|
||||
mRawImageCallback = raw;
|
||||
mJpegCallback = jpeg;
|
||||
native_takePicture();
|
||||
takePicture(shutter, raw, null, jpeg);
|
||||
}
|
||||
private native final void native_takePicture();
|
||||
|
||||
/**
|
||||
* Triggers an asynchronous image capture. The camera service
|
||||
* will initiate a series of callbacks to the application as the
|
||||
* image capture progresses. The shutter callback occurs after
|
||||
* the image is captured. This can be used to trigger a sound
|
||||
* to let the user know that image has been captured. The raw
|
||||
* callback occurs when the raw image data is available. The
|
||||
* postview callback occurs when a scaled, fully processed
|
||||
* postview image is available (NOTE: not all hardware supports
|
||||
* this). The jpeg callback occurs when the compressed image is
|
||||
* available. If the application does not need a particular
|
||||
* callback, a null can be passed instead of a callback method.
|
||||
*
|
||||
* @param shutter callback after the image is captured, may be null
|
||||
* @param raw callback with raw image data, may be null
|
||||
* @param postview callback with postview image data, may be null
|
||||
* @param jpeg callback with jpeg image data, may be null
|
||||
*/
|
||||
public final void takePicture(ShutterCallback shutter, PictureCallback raw,
|
||||
PictureCallback postview, PictureCallback jpeg) {
|
||||
mShutterCallback = shutter;
|
||||
mRawImageCallback = raw;
|
||||
mPostviewCallback = postview;
|
||||
mJpegCallback = jpeg;
|
||||
native_takePicture();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the zoom callback.
|
||||
*/
|
||||
public interface ZoomCallback
|
||||
{
|
||||
/**
|
||||
* Callback for zoom updates
|
||||
* @param zoomLevel new zoom level in 1/1000 increments,
|
||||
* e.g. a zoom of 3.2x is stored as 3200. Accuracy of the
|
||||
* value is dependent on the hardware implementation. Not
|
||||
* all devices will generate this callback.
|
||||
* @param camera the Camera service object
|
||||
*/
|
||||
void onZoomUpdate(int zoomLevel, Camera camera);
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers a callback to be invoked when the zoom
|
||||
* level is updated by the camera driver.
|
||||
* @param cb the callback to run
|
||||
*/
|
||||
public final void setZoomCallback(ZoomCallback cb)
|
||||
{
|
||||
mZoomCallback = cb;
|
||||
}
|
||||
|
||||
// These match the enum in include/ui/Camera.h
|
||||
/** Unspecified camerar error. @see #ErrorCallback */
|
||||
public static final int CAMERA_ERROR_UNKNOWN = 1;
|
||||
|
||||
Reference in New Issue
Block a user