MTK 修改后置Camera方向/镜像 Patch
生活随笔
收集整理的這篇文章主要介紹了
MTK 修改后置Camera方向/镜像 Patch
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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>& cameraService,const sp<hardware::ICameraClient>& cameraClient,const String16& clientPackageName,
@@ -55,6 +57,7 @@ CameraClient::CameraClient(const sp<CameraService>& 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>& 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;
+ }
總結
以上是生活随笔為你收集整理的MTK 修改后置Camera方向/镜像 Patch的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MTK 修改默认Text-to-spee
- 下一篇: MTK MtkSettings Sim