summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2012-05-23 13:17:37 -0700
committerPannag Sanketi <psanketi@google.com>2012-05-23 16:22:31 -0700
commit403f759fa224243d6f90412c3324fdac609097e2 (patch)
tree389e95b519cb1b862020c4b13c919eab1218f692 /src
parent0acd2e9e8ed49c1930fe4d60796ef14bc5328e34 (diff)
downloadCamera-403f759fa224243d6f90412c3324fdac609097e2.tar.gz
Fix incorrect video orientation in effects recording.
bug:6535207 Change-Id: I08574bdf95bfa12a3b3a765f9d0b95918a77503e
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/EffectsRecorder.java22
-rwxr-xr-xsrc/com/android/camera/VideoCamera.java33
2 files changed, 36 insertions, 19 deletions
diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java
index aeea2759..26412dcc 100644
--- a/src/com/android/camera/EffectsRecorder.java
+++ b/src/com/android/camera/EffectsRecorder.java
@@ -86,7 +86,7 @@ public class EffectsRecorder {
private long mMaxFileSize = 0;
private int mMaxDurationMs = 0;
private int mCameraFacing = Camera.CameraInfo.CAMERA_FACING_BACK;
- private boolean mAppIsLandscape;
+ private int mCameraDisplayOrientation;
private int mEffect = EFFECT_NONE;
private int mCurrentEffect = EFFECT_NONE;
@@ -354,14 +354,12 @@ public class EffectsRecorder {
setRecordingOrientation();
}
- /** Passes the native orientation of the Camera app (device dependent)
- * to allow for correct output aspect ratio. Defaults to portrait */
- public void setAppToLandscape(boolean landscape) {
+ public void setCameraDisplayOrientation(int orientation) {
if (mState != STATE_CONFIGURE) {
throw new RuntimeException(
- "setAppToLandscape called after configuration!");
+ "setCameraDisplayOrientation called after configuration!");
}
- mAppIsLandscape = landscape;
+ mCameraDisplayOrientation = orientation;
}
public void setCameraFacing(int facing) {
@@ -406,10 +404,18 @@ public class EffectsRecorder {
mGraphEnv = new GraphEnvironment();
mGraphEnv.createGLEnvironment();
+ int videoFrameWidth = mProfile.videoFrameWidth;
+ int videoFrameHeight = mProfile.videoFrameHeight;
+ if (mCameraDisplayOrientation == 90 || mCameraDisplayOrientation == 270) {
+ int tmp = videoFrameWidth;
+ videoFrameWidth = videoFrameHeight;
+ videoFrameHeight = tmp;
+ }
+
mGraphEnv.addReferences(
"textureSourceCallback", mSourceReadyCallback,
- "recordingWidth", mProfile.videoFrameWidth,
- "recordingHeight", mProfile.videoFrameHeight,
+ "recordingWidth", videoFrameWidth,
+ "recordingHeight", videoFrameHeight,
"recordingProfile", mProfile,
"learningDoneListener", mLearningDoneListener,
"recordingDoneListener", mRecordingDoneListener);
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 54eba4ea..18971874 100755
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -458,7 +458,20 @@ public class VideoCamera extends ActivityBase
// the camera then point the camera to floor or sky, we still have
// the correct orientation.
if (orientation == ORIENTATION_UNKNOWN) return;
- mOrientation = Util.roundOrientation(orientation, mOrientation);
+ int newOrientation = Util.roundOrientation(orientation, mOrientation);
+
+ if (mOrientation != newOrientation) {
+ mOrientation = newOrientation;
+ // The input of effects recorder is affected by
+ // android.hardware.Camera.setDisplayOrientation. Its value only
+ // compensates the camera orientation (no Display.getRotation).
+ // So the orientation hint here should only consider sensor
+ // orientation.
+ if (effectsActive()) {
+ mEffectsRecorder.setOrientationHint(mOrientation);
+ }
+ }
+
// When the screen is unlocked, display rotation may change. Always
// calculate the up-to-date orientationCompensation.
int orientationCompensation =
@@ -466,10 +479,6 @@ public class VideoCamera extends ActivityBase
if (mOrientationCompensation != orientationCompensation) {
mOrientationCompensation = orientationCompensation;
- if (effectsActive()) {
- mEffectsRecorder.setOrientationHint(
- mOrientationCompensation % 360);
- }
// Do not rotate the icons during recording because the video
// orientation is fixed after recording.
if (!mMediaRecorderRecording) {
@@ -1166,7 +1175,7 @@ public class VideoCamera extends ActivityBase
// TODO: Confirm none of the following need to go to initializeEffectsRecording()
// and none of these change even when the preview is not refreshed.
- mEffectsRecorder.setAppToLandscape(inLandscape);
+ mEffectsRecorder.setCameraDisplayOrientation(mCameraDisplayOrientation);
mEffectsRecorder.setCamera(mCameraDevice.getCamera());
mEffectsRecorder.setCameraFacing(info.facing);
mEffectsRecorder.setProfile(mProfile);
@@ -1174,13 +1183,15 @@ public class VideoCamera extends ActivityBase
mEffectsRecorder.setOnInfoListener(this);
mEffectsRecorder.setOnErrorListener(this);
- // See android.hardware.Camera.Parameters.setRotation for
- // documentation.
- int rotation = 0;
+ // The input of effects recorder is affected by
+ // android.hardware.Camera.setDisplayOrientation. Its value only
+ // compensates the camera orientation (no Display.getRotation). So the
+ // orientation hint here should only consider sensor orientation.
+ int orientation = 0;
if (mOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
- rotation = mOrientationCompensation % 360;
+ orientation = mOrientation;
}
- mEffectsRecorder.setOrientationHint(rotation);
+ mEffectsRecorder.setOrientationHint(orientation);
mOrientationCompensationAtRecordStart = mOrientationCompensation;