• 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 ockchipcameraCameraHalCameraHal.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 ockchipcameraCameraHalCameraHal.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 
    ",Cam_FrontFlip);
    

      

    二.hardware ockchipcameraCameraHalCameraHal_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
    ",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) {    
    

      

      

      

  • 相关阅读:
    java中Object转String
    JSON以及Java转换JSON的方法(前后端常用处理方法)
    JS基础如何理解对象
    图解数据结构(7)——二叉查找树及平衡二叉查找树(一共14篇)
    C++虚函数表解析(图文并茂,非常清楚)( 任何妄图使用父类指针想调用子类中的未覆盖父类的成员函数的行为都会被编译器视为非法)good
    C++中代理类和句柄类
    C++的 RTTI 观念和用途(非常详细)
    川普就是领着一群工业革命时代的棺材瓤子,发动了一次资本主义复辟,面对互联网不过是一次新的砸机器运动
    基于.NET MVC的高性能IOC插件化架构
    雅虎35条
  • 原文地址:https://www.cnblogs.com/crushgirl/p/15214990.html
Copyright © 2020-2023  润新知