package com.ez.ertc.meeting.constant;

import com.ez.ertc.meeting.utils.SPUtil;
import com.ez.ertc.meeting.widget.ErtcTextureView;

/**
 * @author xiezuoyuan
 * @time 2020/5/12 16:56
 */
public class MtSets {

    //1080p
    public static final int RESOLUTION_1080P_WIDTH = 1920;
    public static final int RESOLUTION_1080P_HEIGHT = 1080;
    //720p
    public static final int RESOLUTION_720P_WIDTH = 1280;
    public static final int RESOLUTION_720P_HEIGHT = 720;
    //480p
    public static final int RESOLUTION_480P_WIDTH = 640;
    public static final int RESOLUTION_480P_HEIGHT = 480;
    //180p
    public static final int RESOLUTION_180P_WIDTH = 320;
    public static final int RESOLUTION_180P_HEIGHT = 180;

    public static final int DECODE_SOFTWARE = 1;
    public static final int DECODE_HARDWARE = 0;

    public static final int SAMPLE_RATE_32000 = 32000;
    public static final int SAMPLE_RATE_48000 = 48000;
    public static final int SAMPLE_RATE_44100 = 44100;
    public static final int SAMPLE_RATE_22050 = 22050;

    public static final int DELAY_ADAPTATION_0 = 0;
    public static final int DELAY_ADAPTATION_1 = 1;
    public static final int DELAY_ADAPTATION_2 = 2;
    public static final int DELAY_ADAPTATION_3 = 3;

    public static final boolean IMMEDIATE_STATE_ON = true;

    //
    public static final boolean AUDIO_DEFAULT_STATE = true;
    public static final boolean VIDEO_DEFAULT_STATE = false;
    public static final boolean BEAUTY_DEFAULT_STATE = true;

    //public static final String DEFAULT_HOST = "http://180.97.182.244:5000/";
    public static final String DEFAULT_HOST = "https://ezm.ys7.com/";
    public static final String APP_DOWNLOAD_URL = "https://www.me-app.net/fvIj";
    public static final String SHARE_LINK_URL = "meet?room_no=";

    /**
     * 实人认证地址
     * @return
     */
    public static String getPersonCertUrl(){
        String host = getHost();
        if (host.contains("vcs.anyconf.cn")){
            return "https://vcs.anyconf.cn:9001/certification";
        } else if (host.contains("47.99.169.94")){
            return "http://47.99.169.94:9001/www/certification";
        } else if (host.contains("ezm.ys7.com")){
            return "https://ezm.ys7.com/certification/";
        } else if (host.contains("101.37.17.185")){
            return "http://101.37.17.185/certification/";
        }
        return host+"certification/";
    }

    public static boolean isBeautyEnable() {
        return BEAUTY_DEFAULT_STATE;
    }

    /*设置参数保存*/
    public static String getHost(){
        return SPUtil.getStringValue(SPKeys.KEY_HOST_DEFAULT,DEFAULT_HOST);
    }

    public static void saveHost(String host){
        SPUtil.setStringValue(SPKeys.KEY_HOST_DEFAULT,host);
    }
    public static boolean showEnv(){
        return SPUtil.getBooleanValue(SPKeys.KEY_SHOW_ENV,false);
    }

    public static void setShowEnv(boolean showEnv){
        SPUtil.setBooleanValue(SPKeys.KEY_SHOW_ENV,showEnv);
    }

    public static int getResolutionWidth(){
        return SPUtil.getIntValue(SPKeys.KEY_RESOLUTION_WIDTH,RESOLUTION_480P_WIDTH);
    }
    public static int getResolutionHeight(){
        return SPUtil.getIntValue(SPKeys.KEY_RESOLUTION_HEIGHT,RESOLUTION_480P_HEIGHT);
    }
    public static void saveResolution(int width,int height){
        SPUtil.setIntValue(SPKeys.KEY_RESOLUTION_WIDTH,width);
        SPUtil.setIntValue(SPKeys.KEY_RESOLUTION_HEIGHT,height);
    }

    public static int getDecodeType(){
        return SPUtil.getIntValue(SPKeys.KEY_DECODE_TYPE,DECODE_HARDWARE);
    }

    public static void saveDecodeType(int type){
        SPUtil.setIntValue(SPKeys.KEY_DECODE_TYPE,type);
    }

    public static int getSampleRate(){
        return SPUtil.getIntValue(SPKeys.KEY_AUDIO_SAMPLE, MtSets.SAMPLE_RATE_48000);
    }
    public static void saveSampleRate(int sampleRate){
        SPUtil.setIntValue(SPKeys.KEY_AUDIO_SAMPLE,sampleRate);
    }

    /*即时会议入会参数保存*/
    public static void saveImmediateAudioState(boolean on){
        SPUtil.setBooleanValue(SPKeys.KEY_IMMEDIATE_AUDIO_STATE,on);
    }
    public static boolean getImmediateAudioState(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IMMEDIATE_AUDIO_STATE, MtSets.IMMEDIATE_STATE_ON);
    }
    public static void saveImmediateVideoState(boolean on){
        SPUtil.setBooleanValue(SPKeys.KEY_IMMEDIATE_VIDEO_STATE,on);
    }
    public static boolean getImmediateVideoState(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IMMEDIATE_VIDEO_STATE, MtSets.IMMEDIATE_STATE_ON);
    }
    public static void saveImmediateSoundState(boolean on){
        SPUtil.setBooleanValue(SPKeys.KEY_IMMEDIATE_SOUND_STATE,on);
    }
    public static boolean getImmediateSoundState(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IMMEDIATE_SOUND_STATE, MtSets.IMMEDIATE_STATE_ON);
    }
    /*加入会议入会参数保存*/
    public static void saveJoinAudioState(boolean on){
        SPUtil.setBooleanValue(SPKeys.KEY_JOIN_RECORDS_AUDIO,on);
    }
    public static boolean getJoinAudioState(){
        return SPUtil.getBooleanValue(SPKeys.KEY_JOIN_RECORDS_AUDIO, true);
    }
    public static void saveJoinVideoState(boolean on){
        SPUtil.setBooleanValue(SPKeys.KEY_JOIN_RECORDS_VIDEO,on);
    }
    public static boolean getJoinVideoState(){
        return SPUtil.getBooleanValue(SPKeys.KEY_JOIN_RECORDS_VIDEO, true);
    }
    /*token*/
    public static void setToken(String token){
        SPUtil.setStringValue(SPKeys.KEY_TOKEN,token);
    }

    public static String getToken(){
        return SPUtil.getStringValue(SPKeys.KEY_TOKEN,null);
    }
    public static void setAccountData(String data){
        SPUtil.setStringValue(SPKeys.KEY_MEETING_ACCOUNT_DATA,data);
    }
    public static String getAccountData(){
        return SPUtil.getStringValue(SPKeys.KEY_MEETING_ACCOUNT_DATA,null);
    }
    /*是否游客登录*/
    public static void setVisitorLogin(boolean isVisitorLogin){
        SPUtil.setBooleanValue(SPKeys.KEY_IS_VISITOR_LOGIN,isVisitorLogin);
    }
    public static boolean isVisitorLogin(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IS_VISITOR_LOGIN,false);
    }
    public static void setDebug(boolean debug){
        SPUtil.setBooleanValue(SPKeys.KEY_IS_DEBUG,debug);
    }
    public static boolean isDebug(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IS_DEBUG,false);
    }
    public static void setDebugMode(boolean debugMode){
        SPUtil.setBooleanValue(SPKeys.KEY_IS_DEBUG_MODE,debugMode);
    }
    public static boolean isDebugMode(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IS_DEBUG_MODE,false);
    }
    public static void setVoiceStimulation(boolean on){
        SPUtil.setBooleanValue(SPKeys.KEY_IS_VOICE_STIMULATION,on);
    }
    public static boolean isVoiceStimulation(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IS_VOICE_STIMULATION,true);
    }
    public static void setAudioDisplay(boolean on){
        SPUtil.setBooleanValue(SPKeys.KEY_IS_AUDIO_DISPLAY,on);
    }
    public static boolean isAudioDisplay(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IS_AUDIO_DISPLAY,true);
    }
    public static void setShowMemberToast(boolean on){
        SPUtil.setBooleanValue(SPKeys.KEY_IS_MEMBER_TOAST,on);
    }
    public static boolean isShowMemberToast(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IS_MEMBER_TOAST,false);
    }
    public static void setSaveAVData(boolean on){
        SPUtil.setBooleanValue(SPKeys.KEY_IS_SAVE_AV_DATA,on);
    }
    public static boolean isSaveAVData(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IS_SAVE_AV_DATA,false);
    }
    public static void setDelayAdaptation(int level){
        SPUtil.setIntValue(SPKeys.KEY_DELAY_ADAPTATION,level);
    }
    public static int getDelayAdaptation(){
        return SPUtil.getIntValue(SPKeys.KEY_DELAY_ADAPTATION,DELAY_ADAPTATION_2);
    }
    public static void setQualityMonitoring(int qualityMonitoring){
        SPUtil.setIntValue(SPKeys.KEY_QUALITY_MONITOR_GAP,qualityMonitoring);
    }
    public static int getQualityMonitoring(){
        return SPUtil.getIntValue(SPKeys.KEY_QUALITY_MONITOR_GAP,1);
    }
    public static void setDownStreamGap(int gap){
        SPUtil.setIntValue(SPKeys.KEY_DOWN_STREAM_GAP,gap);
    }
    public static int getDownStreamGap(){
        return SPUtil.getIntValue(SPKeys.KEY_DOWN_STREAM_GAP,5);
    }
    public static void setQualityFix(String array){
        SPUtil.setStringValue(SPKeys.KEY_QUALITY_FIX,array);
    }
    public static String getQualityFix(){
        return SPUtil.getStringValue(SPKeys.KEY_QUALITY_FIX,null);
    }
    public static void setTraceServer(String traceSever){
        SPUtil.setStringValue(SPKeys.KEY_MEETING_CONFIG_SERVER,traceSever);
    }
    public static String getTraceServer(){
        return SPUtil.getStringValue(SPKeys.KEY_MEETING_CONFIG_SERVER,null);
    }
    public static void setLoadingGap(int gap){
        SPUtil.setIntValue(SPKeys.KEY_LOADING_DURATION,gap);
    }
    public static int getLoadingGap(){
        return SPUtil.getIntValue(SPKeys.KEY_LOADING_DURATION, ErtcTextureView.PERIOD_DEFAULT);
    }
    public static void setCallMode(boolean callMode){
        SPUtil.setBooleanValue(SPKeys.KEY_CALL_MODE,callMode);
    }
    public static boolean isCallMode(){
        return SPUtil.getBooleanValue(SPKeys.KEY_CALL_MODE,false);
    }
    public static String getSavedRoomId(){
        return SPUtil.getStringValue(SPKeys.KEY_SAVED_ROOM_ID,"12345678");
    }
    public static String getSavedRoomPwd(){
        return SPUtil.getStringValue(SPKeys.KEY_SAVED_ROOM_PWD,null);
    }
    public static String getSavedAccountId(){
        return SPUtil.getStringValue(SPKeys.KEY_SAVED_ACCOUNT_ID, null);
    }
    public static void setSavedRoomInfo(final String roomId, final String accountId){
        SPUtil.setStringValue(SPKeys.KEY_SAVED_ROOM_ID,roomId);
        SPUtil.setStringValue(SPKeys.KEY_SAVED_ACCOUNT_ID,accountId);
    }
    public static void setNetAdapt(boolean enable){
        SPUtil.setBooleanValue(SPKeys.KEY_NET_ADAPT,enable);
    }
    public static boolean getNetAdapt(){
        return SPUtil.getBooleanValue(SPKeys.KEY_NET_ADAPT, true);
    }
    public static void setLanListen(boolean enable){
        SPUtil.setBooleanValue(SPKeys.KEY_LAN_LISTEN,enable);
    }
    public static boolean getLanListen(){
        return SPUtil.getBooleanValue(SPKeys.KEY_LAN_LISTEN, false);
    }
    public static boolean isEnableBeauty(){
        return SPUtil.getBooleanValue(SPKeys.KEY_IS_ENABLE_BEAUTY, true);
    }
    public static void setBeautyEnable(boolean enable){
        SPUtil.setBooleanValue(SPKeys.KEY_IS_ENABLE_BEAUTY, enable);
    }
    public static boolean isShowHomeNotice(){
        return SPUtil.getBooleanValue(SPKeys.KEY_SHOW_HOME_NOTICE, true);
    }
    public static void setShowHomeNotice(boolean show){
        SPUtil.setBooleanValue(SPKeys.KEY_SHOW_HOME_NOTICE, show);
    }
    public static void setFilterName(String filterName){
        SPUtil.setStringValue(SPKeys.KEY_BEAUTY_FILTER_NAME,filterName);
    }
    public static String getFilterName(){
        return SPUtil.getStringValue(SPKeys.KEY_BEAUTY_FILTER_NAME,null);
    }
    public static void setFilterIntensityPercent(int filterIntensityPercent){
        SPUtil.setIntValue(SPKeys.KEY_BEAUTY_FILTER_INTENSITY,filterIntensityPercent);
    }
    public static int getFilterIntensityPercent(){
        return SPUtil.getIntValue(SPKeys.KEY_BEAUTY_FILTER_INTENSITY,40);
    }
    public static void setColorIntensityPercent(int colorIntensityPercent){
        SPUtil.setIntValue(SPKeys.KEY_BEAUTY_COLOR_INTENSITY,colorIntensityPercent);
    }
    public static int getColorIntensityPercent(){
        return SPUtil.getIntValue(SPKeys.KEY_BEAUTY_COLOR_INTENSITY,30);
    }
    public static void setRedIntensityPercent(int redIntensityPercent){
        SPUtil.setIntValue(SPKeys.KEY_BEAUTY_RED_INTENSITY,redIntensityPercent);
    }
    public static int getRedIntensityPercent(){
        return SPUtil.getIntValue(SPKeys.KEY_BEAUTY_RED_INTENSITY,30);
    }
    public static void setBlurIntensityPercent(int blurIntensityPercent){
        SPUtil.setIntValue(SPKeys.KEY_BEAUTY_BLUR_INTENSITY,blurIntensityPercent);
    }
    public static int getBlurIntensityPercent(){
        return SPUtil.getIntValue(SPKeys.KEY_BEAUTY_BLUR_INTENSITY,70);
    }
    public static void setSelectedBeautyType(int beautyType){
        SPUtil.setIntValue(SPKeys.KEY_BEAUTY_SELECTED,beautyType);
    }
    public static int getSelectedBeautyType(){
        return SPUtil.getIntValue(SPKeys.KEY_BEAUTY_SELECTED,3);
    }
    public static void setImageHost(String imageHost){
        SPUtil.setStringValue(SPKeys.KEY_IMAGE_HOST,imageHost);
    }
    public static String getImageHost(){
        return SPUtil.getStringValue(SPKeys.KEY_IMAGE_HOST,null);
    }
    public static void setLineId(String lineId){
        SPUtil.setStringValue(SPKeys.KEY_LINE_ID,lineId);
    }
    public static String getLineId(){
        return SPUtil.getStringValue(SPKeys.KEY_LINE_ID,null);
    }
    public static void setDeviceId(String deviceId){
        SPUtil.setStringValue(SPKeys.KEY_DEVICE_ID,deviceId);
    }
    public static String getDeviceId(){
        return SPUtil.getStringValue(SPKeys.KEY_DEVICE_ID,null);
    }
}
