BaseModule.java 1.99 KB
package com.sw.laryngoscope.camera;

import android.content.ContentValues;
import android.hardware.Camera;
import android.media.CamcorderProfile;
import android.provider.MediaStore.Video;

import com.sw.laryngoscope.activity.fragment.HomeFragment;
import com.sw.laryngoscope.utils.Logger;

import java.io.File;

public class BaseModule {

    public HomeFragment fragment;
    public VideoUI mUI;
    public VideoManager mVideoManager;

    public static /*final*/ int FACING_BACK_ID = 0;
    public static /*final*/ int FACING_FRONT_ID = 1;
    //0 OV6946 //1 typec USBcamera //2 OV9734

    public long mRecordingStartTime;

    //public static long dateTaken = 0l;
    public long stopTime = 0l;

    public boolean mMediaRecorderRecording = false;

    public int mMaxVideoDurationInMs = 3 * 60 * 1000;//2 * 60 * 1000;
    public static final int MSG_UPDATE_RECORD_TIME = 5;

    Camera frontCamera;
    Camera backCamera;

    public boolean isBackError = false;

    //public static /*final*/ int TMP_CAM_ID = 0;

    public void saveVideoFile(String fileName, ContentValues contentValues) {
        try {
            String finalName = contentValues.getAsString(Video.Media.DATA);
            File finalFile = new File(finalName);
            if (new File(fileName).renameTo(finalFile)) {

            }
        } catch (Exception e) {
        }
    }


    public void deleteVideoFile(String fileName) {
        File f = new File(fileName);
        if (!f.delete()) {
        }
    }


    public int getVideoQuality(int param) {
        Logger.d(" -- param " + param);
        int type = 0;
        if ( param == 0 ) {
            type = CamcorderProfile.QUALITY_HIGH;
        } else if ( param == 1 ) {
            type = CamcorderProfile.QUALITY_720P;
        } else if ( param == 2 ) {
            type = CamcorderProfile.QUALITY_480P;
        }
        return type;
    }

    public boolean isOpenCameraError() {
        return isBackError ;
    }

}