Loading camera/libcameraservice/CameraService.cpp +24 −8 Original line number Diff line number Diff line Loading @@ -1191,14 +1191,6 @@ status_t CameraService::Client::setParameters(const String8& params) CameraParameters p(params); // The orientation parameter is actually for CameraService, not for the camera driver. if (p.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) { LOGV("portrait mode"); mOrientation = ISurface::BufferHeap::ROT_90; } else { mOrientation = 0; } return mHardware->setParameters(p); } Loading @@ -1224,6 +1216,30 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a status_t result = checkPid(); if (result != NO_ERROR) return result; if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) { // The orientation cannot be set during preview. if (mHardware->previewEnabled()) { return INVALID_OPERATION; } switch (arg1) { case 0: mOrientation = ISurface::BufferHeap::ROT_0; break; case 90: mOrientation = ISurface::BufferHeap::ROT_90; break; case 180: mOrientation = ISurface::BufferHeap::ROT_180; break; case 270: mOrientation = ISurface::BufferHeap::ROT_270; break; default: return BAD_VALUE; } return OK; } if (mHardware == 0) { LOGE("mHardware is NULL, returning."); return INVALID_OPERATION; Loading core/java/android/hardware/Camera.java +15 −0 Original line number Diff line number Diff line Loading @@ -542,6 +542,21 @@ public class Camera { */ public native final void stopSmoothZoom(); /** * Set the display orientation. This affects the preview frames and the * picture displayed after snapshot. This method is useful for portrait * mode applications. * * This does not affect the order of byte array passed in * {@link PreviewCallback#onPreviewFrame}. This method is not allowed to * be called during preview. * * @param degrees the angle that the picture will be rotated clockwise. * Valid values are 0, 90, 180, and 270. * @hide */ public native final void setDisplayOrientation(int degrees); /** * Handles the zoom callback. * Loading core/jni/android_hardware_Camera.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -546,6 +546,18 @@ static void android_hardware_Camera_stopSmoothZoom(JNIEnv *env, jobject thiz) } } static void android_hardware_Camera_setDisplayOrientation(JNIEnv *env, jobject thiz, jint value) { LOGV("setDisplayOrientation"); sp<Camera> camera = get_native_camera(env, thiz, NULL); if (camera == 0) return; if (camera->sendCommand(CAMERA_CMD_SET_DISPLAY_ORIENTATION, value, 0) != NO_ERROR) { jniThrowException(env, "java/lang/RuntimeException", "set display orientation failed"); } } //------------------------------------------------- static JNINativeMethod camMethods[] = { Loading Loading @@ -603,6 +615,9 @@ static JNINativeMethod camMethods[] = { { "stopSmoothZoom", "()V", (void *)android_hardware_Camera_stopSmoothZoom }, { "setDisplayOrientation", "(I)V", (void *)android_hardware_Camera_setDisplayOrientation }, }; struct field { Loading include/ui/Camera.h +1 −1 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ enum { enum { CAMERA_CMD_START_SMOOTH_ZOOM = 1, CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, }; // camera fatal errors Loading Loading @@ -209,4 +210,3 @@ private: }; // namespace android #endif include/ui/CameraParameters.h +0 −9 Original line number Diff line number Diff line Loading @@ -29,12 +29,6 @@ public: CameraParameters(const String8 ¶ms) { unflatten(params); } ~CameraParameters(); enum { CAMERA_ORIENTATION_UNKNOWN = 0, CAMERA_ORIENTATION_PORTRAIT = 1, CAMERA_ORIENTATION_LANDSCAPE = 2, }; String8 flatten() const; void unflatten(const String8 ¶ms); Loading Loading @@ -63,9 +57,6 @@ public: void setPictureFormat(const char *format); const char *getPictureFormat() const; int getOrientation() const; void setOrientation(int orientation); void dump() const; status_t dump(int fd, const Vector<String16>& args) const; Loading Loading
camera/libcameraservice/CameraService.cpp +24 −8 Original line number Diff line number Diff line Loading @@ -1191,14 +1191,6 @@ status_t CameraService::Client::setParameters(const String8& params) CameraParameters p(params); // The orientation parameter is actually for CameraService, not for the camera driver. if (p.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) { LOGV("portrait mode"); mOrientation = ISurface::BufferHeap::ROT_90; } else { mOrientation = 0; } return mHardware->setParameters(p); } Loading @@ -1224,6 +1216,30 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a status_t result = checkPid(); if (result != NO_ERROR) return result; if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) { // The orientation cannot be set during preview. if (mHardware->previewEnabled()) { return INVALID_OPERATION; } switch (arg1) { case 0: mOrientation = ISurface::BufferHeap::ROT_0; break; case 90: mOrientation = ISurface::BufferHeap::ROT_90; break; case 180: mOrientation = ISurface::BufferHeap::ROT_180; break; case 270: mOrientation = ISurface::BufferHeap::ROT_270; break; default: return BAD_VALUE; } return OK; } if (mHardware == 0) { LOGE("mHardware is NULL, returning."); return INVALID_OPERATION; Loading
core/java/android/hardware/Camera.java +15 −0 Original line number Diff line number Diff line Loading @@ -542,6 +542,21 @@ public class Camera { */ public native final void stopSmoothZoom(); /** * Set the display orientation. This affects the preview frames and the * picture displayed after snapshot. This method is useful for portrait * mode applications. * * This does not affect the order of byte array passed in * {@link PreviewCallback#onPreviewFrame}. This method is not allowed to * be called during preview. * * @param degrees the angle that the picture will be rotated clockwise. * Valid values are 0, 90, 180, and 270. * @hide */ public native final void setDisplayOrientation(int degrees); /** * Handles the zoom callback. * Loading
core/jni/android_hardware_Camera.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -546,6 +546,18 @@ static void android_hardware_Camera_stopSmoothZoom(JNIEnv *env, jobject thiz) } } static void android_hardware_Camera_setDisplayOrientation(JNIEnv *env, jobject thiz, jint value) { LOGV("setDisplayOrientation"); sp<Camera> camera = get_native_camera(env, thiz, NULL); if (camera == 0) return; if (camera->sendCommand(CAMERA_CMD_SET_DISPLAY_ORIENTATION, value, 0) != NO_ERROR) { jniThrowException(env, "java/lang/RuntimeException", "set display orientation failed"); } } //------------------------------------------------- static JNINativeMethod camMethods[] = { Loading Loading @@ -603,6 +615,9 @@ static JNINativeMethod camMethods[] = { { "stopSmoothZoom", "()V", (void *)android_hardware_Camera_stopSmoothZoom }, { "setDisplayOrientation", "(I)V", (void *)android_hardware_Camera_setDisplayOrientation }, }; struct field { Loading
include/ui/Camera.h +1 −1 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ enum { enum { CAMERA_CMD_START_SMOOTH_ZOOM = 1, CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, }; // camera fatal errors Loading Loading @@ -209,4 +210,3 @@ private: }; // namespace android #endif
include/ui/CameraParameters.h +0 −9 Original line number Diff line number Diff line Loading @@ -29,12 +29,6 @@ public: CameraParameters(const String8 ¶ms) { unflatten(params); } ~CameraParameters(); enum { CAMERA_ORIENTATION_UNKNOWN = 0, CAMERA_ORIENTATION_PORTRAIT = 1, CAMERA_ORIENTATION_LANDSCAPE = 2, }; String8 flatten() const; void unflatten(const String8 ¶ms); Loading Loading @@ -63,9 +57,6 @@ public: void setPictureFormat(const char *format); const char *getPictureFormat() const; int getOrientation() const; void setOrientation(int orientation); void dump() const; status_t dump(int fd, const Vector<String16>& args) const; Loading