package cn.tee3.avd;

/**
 * 设备信息结构.
 *
 * 设备信息结构定义了设备基本信息，此处设备包括麦克风、扬声器、摄像头和屏幕窗口。
 */
public class Device {
    /**
     * 设备状态.
     */
    public static enum DeviceStatus
    {
        none,                                   /**< 无设备状态  */
        ready,                                  /**< 设备初始化状态  */
        published,                              /**< 设备已发布  */
        muted,                                  /**< 设备静默状态  */
    };

    protected String id;                       /**< 设备Id，唯一标识一个设备；产生规则：音频设备为与用户相关唯一号；视频设备nodeid+deviceid(MD5(idd) or mobileid+0(front)1(back)) */
    protected String name;                     /**< 设备名称，应用层可用于设备显示  */
    protected DeviceStatus status;             /**< 设备状态  */

    protected Device(String id, String name,DeviceStatus status) {
        this.id = (null == id) ? "" : id;
        this.name =  (null == name) ? "" : name;
        this.status = status;
    }
    public String getId() { return this.id; }
    public void setId(String id) { this.id = id; }
    public String getName() { return this.name; }
    public void setName(String name) {
        this.name = (null == name) ? "" : name;
    }
    public DeviceStatus getStatus() { return this.status; }
    public void setStatus(DeviceStatus status) { this.status = status; }
    public boolean valid() { return !( null == this.id || this.id.isEmpty()); }

    @Override
    public boolean equals(Object obj) {
        Device objd = (Device) obj;
        if (null == objd) {
            return false;
        }
        return objd.getId().equals(this.getId());
    }
    @Override
    public String toString() {
        return "Device: id=" + this.id + ",status="+this.status + ",name="+this.name;
    }
}
