Android->auto set rotation for uvc&isp
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#include "CameraIspAdapter.h"
|
||||
#include "FakeCameraAdapter.h"
|
||||
|
||||
|
||||
#ifdef TARGET_RK29
|
||||
#include "../libyuvtorgb/yuvtorgb.h"
|
||||
#endif
|
||||
@ -62,6 +63,30 @@ static void gsensor_orientation_cb(uint32_t orientation, uint32_t tilt, void* co
|
||||
}
|
||||
};
|
||||
|
||||
static void Writetxt(const char *flag)
|
||||
{
|
||||
int fileDes;
|
||||
int umask_mode;
|
||||
const char *flagpath = "/data/rotation_flag";
|
||||
|
||||
umask_mode = umask(0);
|
||||
fileDes=open(flagpath,O_CREAT|O_RDWR,0644);
|
||||
if(!fileDes==-1)
|
||||
{
|
||||
LOGD("open the file %s failed",flagpath);
|
||||
umask(umask_mode);
|
||||
return;
|
||||
}
|
||||
LOGD("%s open success!",flagpath);
|
||||
if(write(fileDes,flag,strlen(flag))==-1)
|
||||
{
|
||||
LOGD("write %s error",flagpath);
|
||||
}
|
||||
close(fileDes);
|
||||
umask(umask_mode);
|
||||
return;
|
||||
}
|
||||
|
||||
CameraHal::CameraHal(int cameraId)
|
||||
:commandThreadCommandQ("commandCmdQ")
|
||||
{
|
||||
@ -120,6 +145,7 @@ CameraHal::CameraHal(int cameraId)
|
||||
if((strcmp(gCamInfos[cameraId].driver,"uvcvideo") == 0)) {
|
||||
LOGD("it is a uvc camera!");
|
||||
mCameraAdapter = new CameraUSBAdapter(cameraId);
|
||||
Writetxt("uvc");
|
||||
}
|
||||
else if(gCamInfos[cameraId].pcam_total_info->mHardInfo.mSensorInfo.mPhy.type == CamSys_Phy_Cif){
|
||||
LOGD("it is a isp soc camera");
|
||||
@ -132,6 +158,7 @@ CameraHal::CameraHal(int cameraId)
|
||||
else if(gCamInfos[cameraId].pcam_total_info->mHardInfo.mSensorInfo.mPhy.type == CamSys_Phy_Mipi){
|
||||
LOGD("it is a isp camera");
|
||||
mCameraAdapter = new CameraIspAdapter(cameraId);
|
||||
Writetxt("isp");
|
||||
}
|
||||
else{
|
||||
LOGD("it is a soc camera!");
|
||||
|
||||
@ -86,6 +86,12 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
public class VideoModule extends CameraModule
|
||||
implements ModuleController,
|
||||
VideoController,
|
||||
@ -1097,6 +1103,33 @@ public class VideoModule extends CameraModule
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean readCameraflag(){
|
||||
String str = new String();
|
||||
String str1 = new String();
|
||||
String flag_str = "isp";
|
||||
String flagpath = "/data/rotation_flag";
|
||||
boolean flag;
|
||||
try {
|
||||
File f = new File(flagpath);
|
||||
if (f.exists()) {
|
||||
BufferedReader input = new BufferedReader(new FileReader(f));
|
||||
while ((str = input.readLine()) != null) {
|
||||
str1 = str;
|
||||
Log.i(TAG,"read file " + str1);
|
||||
}
|
||||
flag = str1.equals(flag_str);
|
||||
Log.i(TAG,"flag = " + (flag ? "true":"false"));
|
||||
input.close();
|
||||
} else {
|
||||
Log.i(TAG,"Do not have file " + flagpath);
|
||||
flag = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
// Prepares media recorder.
|
||||
private void initializeRecorder() {
|
||||
Log.i(TAG, "initializeRecorder: " + Thread.currentThread());
|
||||
@ -1179,8 +1212,8 @@ public class VideoModule extends CameraModule
|
||||
Log.e(TAG, "Camera is facing unhandled direction");
|
||||
}
|
||||
}
|
||||
android.util.Log.d("bunchen","setOrientationHint "+rotation);
|
||||
rotation=180;
|
||||
if(readCameraflag()) rotation=180;
|
||||
Log.d(TAG, "bunchen setOrientationHint "+rotation);
|
||||
mMediaRecorder.setOrientationHint(rotation);
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user