package com.qmth.themis.business.enums;

import com.qmth.themis.common.enums.Source;

import java.util.Objects;

/**
 * @Description: 监控源 enum
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/8/11
 */
public enum MonitorVideoSourceEnum {
    CLIENT_SCREEN("客户端屏幕"),

    CLIENT_CAMERA("客户端摄像头"),

    MOBILE_FIRST("移动端第一机位"),

    MOBILE_SECOND("移动端第二机位");

    private MonitorVideoSourceEnum(String code) {
        this.code = code;
    }

    private String code;

    public String getCode() {
        return code;
    }

    /**
     * 状态转换 toName
     *
     * @param title
     * @return
     */
    public static MonitorVideoSourceEnum convertToName(String title) {
        for (MonitorVideoSourceEnum e : MonitorVideoSourceEnum.values()) {
            if (Objects.equals(title, e.name())) {
                return e;
            }
        }
        return null;
    }

    /**
     * 根据监控视频源判断设备访问会话来源
     *
     * @return
     */
    public Source getSessionSource() {
        if (this == MOBILE_FIRST) {
            return Source.MOBILE_MONITOR_FIRST;
        } else if (this == MOBILE_SECOND) {
            return Source.MOBILE_MONITOR_SECOND;
        } else {
            return Source.OE_CLIENT;
        }
    }
}
