Skip to content

Commit 0a27359

Browse files
Eino-Ville TalvalaAndroid (Google) Code Review
authored andcommitted
Merge "Add video stabilization control to Camera parameters." into ics-mr0
2 parents 421648e + 037abb8 commit 0a27359

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

core/java/android/hardware/Camera.java

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,8 @@ public class Parameters {
14641464
private static final String KEY_MAX_NUM_DETECTED_FACES_SW = "max-num-detected-faces-sw";
14651465
private static final String KEY_RECORDING_HINT = "recording-hint";
14661466
private static final String KEY_VIDEO_SNAPSHOT_SUPPORTED = "video-snapshot-supported";
1467+
private static final String KEY_VIDEO_STABILIZATION = "video-stabilization";
1468+
private static final String KEY_VIDEO_STABILIZATION_SUPPORTED = "video-stabilization-supported";
14671469

14681470
// Parameter key suffix for supported values.
14691471
private static final String SUPPORTED_VALUES_SUFFIX = "-values";
@@ -2443,7 +2445,7 @@ public String getWhiteBalance() {
24432445
*
24442446
* @param value new white balance.
24452447
* @see #getWhiteBalance()
2446-
* @see #setAutoWhiteBalanceLock()
2448+
* @see #setAutoWhiteBalanceLock(boolean)
24472449
*/
24482450
public void setWhiteBalance(String value) {
24492451
set(KEY_WHITE_BALANCE, value);
@@ -3208,6 +3210,59 @@ public boolean isVideoSnapshotSupported() {
32083210
return TRUE.equals(str);
32093211
}
32103212

3213+
/**
3214+
* <p>Enables and disables video stabilization. Use
3215+
* {@link #isVideoStabilizationSupported} to determine if calling this
3216+
* method is valid.</p>
3217+
*
3218+
* <p>Video stabilization reduces the shaking due to the motion of the
3219+
* camera in both the preview stream and in recorded videos, including
3220+
* data received from the preview callback. It does not reduce motion
3221+
* blur in images captured with
3222+
* {@link Camera#takePicture takePicture}.</p>
3223+
*
3224+
* <p>Video stabilization can be enabled and disabled while preview or
3225+
* recording is active, but toggling it may cause a jump in the video
3226+
* stream that may be undesirable in a recorded video.</p>
3227+
*
3228+
* @param toggle Set to true to enable video stabilization, and false to
3229+
* disable video stabilization.
3230+
* @see #isVideoStabilizationSupported()
3231+
* @see #getVideoStabilization()
3232+
* @hide
3233+
*/
3234+
public void setVideoStabilization(boolean toggle) {
3235+
set(KEY_VIDEO_STABILIZATION, toggle ? TRUE : FALSE);
3236+
}
3237+
3238+
/**
3239+
* Get the current state of video stabilization. See
3240+
* {@link #setVideoStabilization} for details of video stabilization.
3241+
*
3242+
* @return true if video stabilization is enabled
3243+
* @see #isVideoStabilizationSupported()
3244+
* @see #setVideoStabilization(boolean)
3245+
* @hide
3246+
*/
3247+
public boolean getVideoStabilization() {
3248+
String str = get(KEY_VIDEO_STABILIZATION);
3249+
return TRUE.equals(str);
3250+
}
3251+
3252+
/**
3253+
* Returns true if video stabilization is supported. See
3254+
* {@link #setVideoStabilization} for details of video stabilization.
3255+
*
3256+
* @return true if video stabilization is supported
3257+
* @see #setVideoStabilization(boolean)
3258+
* @see #getVideoStabilization()
3259+
* @hide
3260+
*/
3261+
public boolean isVideoStabilizationSupported() {
3262+
String str = get(KEY_VIDEO_STABILIZATION_SUPPORTED);
3263+
return TRUE.equals(str);
3264+
}
3265+
32113266
// Splits a comma delimited string to an ArrayList of String.
32123267
// Return null if the passing string is null or the size is 0.
32133268
private ArrayList<String> split(String str) {

include/camera/CameraParameters.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,25 @@ class CameraParameters
504504
// Example value: "true" or "false". Read only.
505505
static const char KEY_VIDEO_SNAPSHOT_SUPPORTED[];
506506

507+
// The state of the video stabilization. If set to true, both the
508+
// preview stream and the recorded video stream are stabilized by
509+
// the camera. Only valid to set if KEY_VIDEO_STABILIZATION_SUPPORTED is
510+
// set to true.
511+
//
512+
// The value of this key can be changed any time the camera is
513+
// open. If preview or recording is active, it is acceptable for
514+
// there to be a slight video glitch when video stabilization is
515+
// toggled on and off.
516+
//
517+
// This only stabilizes video streams (between-frames stabilization), and
518+
// has no effect on still image capture.
519+
static const char KEY_VIDEO_STABILIZATION[];
520+
521+
// Returns true if video stabilization is supported. That is, applications
522+
// can set KEY_VIDEO_STABILIZATION to true and have a stabilized preview
523+
// stream and record stabilized videos.
524+
static const char KEY_VIDEO_STABILIZATION_SUPPORTED[];
525+
507526
// Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.
508527
static const char TRUE[];
509528
static const char FALSE[];

libs/camera/CameraParameters.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ const char CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW[] = "max-num-detected
8888
const char CameraParameters::KEY_MAX_NUM_DETECTED_FACES_SW[] = "max-num-detected-faces-sw";
8989
const char CameraParameters::KEY_RECORDING_HINT[] = "recording-hint";
9090
const char CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED[] = "video-snapshot-supported";
91+
const char CameraParameters::KEY_VIDEO_STABILIZATION[] = "video-stabilization";
92+
const char CameraParameters::KEY_VIDEO_STABILIZATION_SUPPORTED[] = "video-stabilization-supported";
9193

9294
const char CameraParameters::TRUE[] = "true";
9395
const char CameraParameters::FALSE[] = "false";

0 commit comments

Comments
 (0)