modify 修改后置camera方向/镜像diff --git a/frameworks/av/services/camera/libcameraservice/api1/CameraClient.cpp b/frameworks/av/services/camera/libc
old mode 100644
new mode 100755
index 8497ff6..e5519c1
--- a/frameworks/av/services/camera/libcameraservice/api1/CameraClient.cpp
+++ b/frameworks/av/services/camera/libcameraservice/api1/CameraClient.cpp
@@ -45,6 +45,8 @@ static int getCallingPid() {return IPCThreadState::self()->getCallingPid();}+static int cameraIdd = 0;
+CameraClient::CameraClient(const sp& cameraService,const sp& cameraClient,const String16& clientPackageName,
@@ -55,6 +57,7 @@ CameraClient::CameraClient(const sp& cameraService,String8::format("%d", cameraId), cameraFacing, clientPid,clientUid, servicePid){
+ cameraIdd = cameraId;int callingPid = getCallingPid();bool mirror;LOG1("CameraClient::CameraClient E (pid %d, id %d)", callingPid, cameraId);
@@ -67,11 +70,14 @@ CameraClient::CameraClient(const sp& cameraService,// Callback is disabled by defaultmPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP;
- if (((cameraId == 0) && (mCameraFacing == CAMERA_FACING_FRONT)) || (cameraId == 1))
- mirror = true;
+ /*if (((cameraId == 0) && (mCameraFacing == CAMERA_FACING_FRONT)) || (cameraId == 1))
+ mirror = false;elsemirror = false;
+ *///mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT);
+ mirror=false;
+mOrientation = getOrientation(0, mirror);mLegacyMode = legacyMode;mPlayShutterSound = true;
@@ -771,17 +777,42 @@ status_t CameraClient::enableShutterSound(bool enable) {status_t CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {LOG1("sendCommand (pid %d)", getCallingPid());
- int orientation;
+ int orientation=0;Mutex::Autolock lock(mLock);status_t result = checkPidAndHardware();if (result != NO_ERROR) return result;if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) {//!++
- LOG1("CAMERA_CMD_SET_DISPLAY_ORIENTATION - tid(%d), (degrees, mirror)=(%d, %d)", ::gettid(), arg1, mCameraFacing); //Add debug log
+ LOG1("leon 11 CAMERA_CMD_SET_DISPLAY_ORIENTATION - tid(%d), (degrees, mirror)=(%d, %d)", ::gettid(), arg1, mCameraFacing); //Add debug log//!--// Mirror the preview if the camera is front-facing.
- orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT);
+ if(mCameraFacing==0){//back
+ if(arg1==0){
+ orientation = getOrientation(0, false);
+ arg1=0;
+ }else if(arg1==90){
+ orientation = getOrientation(90, false);
+ arg1=90;
+ }else if(arg1==180){
+ orientation = getOrientation(180, false);
+ arg1=180;
+ }else if(arg1==270){
+ orientation = getOrientation(270, false);
+ arg1=270;
+ }
+ }else if(mCameraFacing == 1){//front
+ orientation = getOrientation(arg1, false);
+ }if (orientation == -1) return BAD_VALUE;if (mOrientation != orientation) {
@@ -1242,6 +1273,12 @@ void CameraClient::copyFrameAndPostCopiedFrame(}int CameraClient::getOrientation(int degrees, bool mirror) {
+ if (!mirror) {
+ if (degrees == 0) return 0;
+ else if (degrees == 90) return HAL_TRANSFORM_ROT_90;
+ else if (degrees == 180) return HAL_TRANSFORM_ROT_180;
+ else if (degrees == 270) return HAL_TRANSFORM_ROT_270;
+ }
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!