RK 微信视频通话预览倒立
09-01 15:43:01.319 D/CameraHal( 157): Calling process is: com.tencent.mm
09-01 15:43:01.319 D/CameraHal( 157): camera_get_camera_info(1367): camera_get_camera_info(1367): camera_0 facing(0), orientation(180)
Android5.1
一.hardware\rockchip\camera\CameraHal\CameraHal.h
CONFIG_CAMERA_FRONT_MIRROR_MDATACB_APK 左右镜像
CONFIG_CAMERA_FRONT_FLIP_MDATACB_APK 上下翻转
#define CONFIG_CAMERA_FRONT_MIRROR_MDATACB 1 #define CONFIG_CAMERA_FRONT_MIRROR_MDATACB_ALL 0 #define CONFIG_CAMERA_FRONT_MIRROR_MDATACB_APK "<com.skype.raider>,<com.yahoo.mobile.client.andro>,<com.tencent.mm>" #define CONFIG_CAMERA_FRONT_FLIP_MDATACB_APK "<com.tencent.mm>,<com.xiaomi.channel>" #define CONFIG_CAMERA_SETVIDEOSIZE 0
一些宏开关
#define CONFIG_CAMERA_ORIENTATION_SKYPE 0 #define CONFIG_CAMERA_FRONT_ORIENTATION_SKYPE 0 #define CONFIG_CAMERA_BACK_ORIENTATION_SKYPE 0
CONFIG_CAMERA_ORIENTATION_SKYPE 是宏开关,若要开启,设为 1
CONFIG_CAMERA_BACK_ORIENTATION_SKYPE 是后置摄像头的角度信息,可以设为 0、90、180、270
CONFIG_CAMERA_FRONT_ORIENTATION_SKYPE 是前置摄像头的角度信息,可以设为 0、90、180、270
hardware\rockchip\camera\CameraHal\CameraHal.cpp 镜像
#if CONFIG_CAMERA_FRONT_MIRROR_MDATACB
if (gCamInfos[cameraId].facing_info.facing == CAMERA_FACING_FRONT) {
#if CONFIG_CAMERA_FRONT_MIRROR_MDATACB_ALL
dataCbFrontMirror = true;
#else
const char* cameraCallProcess = getCallingProcess();
if (strstr(CONFIG_CAMERA_FRONT_MIRROR_MDATACB_APK,cameraCallProcess)) {
dataCbFrontMirror = true;
} else {
dataCbFrontMirror = false;
}
if (strstr(CONFIG_CAMERA_FRONT_FLIP_MDATACB_APK,cameraCallProcess)) {
dataCbFrontFlip = true;
} else {
dataCbFrontFlip = false;
}
#endif
} else {
dataCbFrontMirror = false;
dataCbFrontFlip = false;
}
#else
dataCbFrontMirror = false;
#endif
property_get("persist.sf.Cam_front_filp", cam_FrontFilp, "0");
Cam_FrontFlip = strtol(cam_FrontFilp,0,0);
LOGD("dataCbFrontMirror22222 = %d \n",Cam_FrontFlip);
二.hardware\rockchip\camera\CameraHal\CameraHal_Module.cpp
配置 camerainfo 中的方向 通过获取进程名来旋转 camera方向 getCallingProcess()
int camera_get_camera_info(int camera_id, struct camera_info *info)
{
int rv = 0,fp;
int face_value = CAMERA_FACING_BACK;
int orientation = 0;
char process_name[30];
char cam_hwrotaion[PROPERTY_VALUE_MAX];
int hwrotation = 0;
const char* xh_cameraCallProcess = getCallingProcess();
if(camera_id > gCamerasNumber) {
LOGE("%s camera_id out of bounds, camera_id = %d, num supported = %d",__FUNCTION__,
camera_id, gCamerasNumber);
rv = -EINVAL;
goto end;
}
#if CONFIG_CAMERA_ORIENTATION_SKYPE //默认不开
process_name[0] = 0x00;
sprintf(process_name,"/proc/%d/cmdline",getCallingPid());
fp = open(process_name, O_RDONLY);
if (fp < 0) {
memset(process_name,0x00,sizeof(process_name));
LOGE("%s(%d): Obtain calling process info failed",__FUNCTION__,__LINE__);
} else {
memset(process_name,0x00,sizeof(process_name));
read(fp, process_name, 30);
close(fp);
fp = -1;
}
info->facing = gCamInfos[camera_id].facing_info.facing;
if (strstr(process_name,"com.skype.rover")) {
info->orientation = (info->facing == CAMERA_FACING_BACK)? CONFIG_CAMERA_BACK_ORIENTATION_SKYPE : CONFIG_CAMERA_FRONT_ORIENTATION_SKYPE;
} else {
info->orientation = gCamInfos[camera_id].facing_info.orientation;
}
#else
info->facing = gCamInfos[camera_id].facing_info.facing;
info->orientation = gCamInfos[camera_id].facing_info.orientation;
property_get("persist.sf.CameraRotation", cam_hwrotaion, "0");//add by eric
hwrotation = strtol(cam_hwrotaion,0,0);
//LOGE("hwrotation %d",hwrotation);
if(hwrotation == 0){
info->orientation = 0;
}else if(hwrotation == 90){
info->orientation = 90;
}else if(hwrotation == 180){
info->orientation = 180;
}else{
info->orientation = 270;
}
if (strstr(CONFIG_CAMERA_FRONT_MIRROR_MDATACB_APK,xh_cameraCallProcess)) {
LOGD("gatsby cam_hwrotaion %d\n",hwrotation);
if(hwrotation == 0){
info->orientation = 180;
}else if(hwrotation == 90){
info->orientation = 270;
}else if(hwrotation == 180){
info->orientation = 0;
}else{
info->orientation = 90;
}
}
#endif
设置camera 预览镜像
diff --git a/frameworks/av/services/camera/libcameraservice/api1/CameraClient.cpp b/frameworks/av/services/camera/libcameraservice/api1/CameraClient.cpp
index 070be2d..0250f92 100755
--- a/frameworks/av/services/camera/libcameraservice/api1/CameraClient.cpp
+++ b/frameworks/av/services/camera/libcameraservice/api1/CameraClient.cpp
@@ -654,8 +654,8 @@ status_t CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {
if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) {
// Mirror the preview if the camera is front-facing.
// 如果相机是正面的,则镜像预览。
- orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT);
+ //orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT);
+ orientation = getOrientation(arg1, 1);
if (orientation == -1) return BAD_VALUE;
if (mOrientation != orientation) {

浙公网安备 33010602011771号