package cn.tee3.avd;

/**
 * 网络统计信息结构.
 *
 * 网络统计信息结构定义了网络传输中的统计信息。
 */
public class NetworkStats {
    protected int bps_received;				/**< 当前接收带宽: 3s计算  */
    protected int bps_sent;					/**< 当前发送带宽: 3s计算  */
    protected int lostpercent;				/**< 当前丢包率: 3s计算  */
	protected int lostpercent_received;     /**< 当前接收丢包率:   3s计算  */			
	protected int lostpercent_sent;         /**< 当前发送丢包率:   3s计算  */

    protected NetworkStats(int bps_received, int bps_sent, int lostpercent,int lostpercent_received,int lostpercent_sent) {
        this.bps_received = bps_received;
        this.bps_sent = bps_sent;
        this.lostpercent = lostpercent;
		this.lostpercent_received = lostpercent_received;
		this.lostpercent_sent = lostpercent_sent;
    }
    public int getBps_received() { return this.bps_received; }
    public int getBps_sent() { return this.bps_sent; }
    public int getLostpercent() { return this.lostpercent; }
	public int getLostpercent_received(){return  this.lostpercent_received;}
	public int getLostpercent_sent(){return  this.lostpercent_sent;}

    @Override
    public String toString() {
        return " Net: bps_received=" + bps_received + ",bps_sent="+bps_sent + ",lostpercent="+lostpercent +",lostpercent_received= "+ lostpercent_received + ",lostpercent_sent="+lostpercent_sent;
    }

    /**
     * 媒体统计信息结构.
     *
     * 媒体统计信息结构定义了媒体级的网络，媒体等统计信息。
     */
    public static class MediaStats extends NetworkStats {
        protected String media_type;	            /**< 媒体类型：audio : video  */
        protected String codec_name;	            /**< 媒体编码名称  */
        protected int audio_input_level;		/**< 音频输入音量  */
        protected int audio_output_level;		/**< 音频输出音量  */
        protected int frame_width;				/**< 视频宽度  */
        protected int frame_height;				/**< 视频高度  */
        protected int frame_rate;				/**< 视频帧率  */

        public MediaStats(int bps_received, int bps_sent, int lostpercent,int lostpercent_received,int lostpercent_sent,
                          String media_type, String codec_name,int audio_input_level, int audio_output_level,
                          int frame_width, int frame_height, int frame_rate) {
            super(bps_received,bps_sent,lostpercent,lostpercent_received,lostpercent_sent);
            this.media_type = (null == media_type) ? "" : media_type;
            this.codec_name = (null == codec_name) ? "" : codec_name;
            this.audio_input_level = audio_input_level;
            this.audio_output_level = audio_output_level;
            this.frame_width = frame_width;
            this.frame_height = frame_height;
            this.frame_rate = frame_rate;
        }
        public String getMedia_type() { return this.media_type; }
        public String getCodec_name() { return this.codec_name; }
        public int getFrame_width() { return this.frame_width; }
        public int getFrame_height() { return this.frame_height; }
        public int getFrame_rate() { return this.frame_rate; }
        public int getAudio_input_level() { return this.audio_input_level; }
        public int getAudio_output_level() { return this.audio_output_level; }

        @Override
        public String toString() {
            String spec;
            if (this.media_type.equals("audio")) {
                spec = ",input="+this.audio_input_level + ",output="+this.audio_output_level;
            }
            else {
                spec = ",width="+this.frame_width + ",height="+this.frame_height + ",fps="+this.frame_rate;
            }
            return "MediaStats: media_type=" + media_type + ",codec="+codec_name + spec + super.toString();
        }
    };

    /**
     * 房间统计信息结构.
     *
     * 房间统计信息结构定义了房间级的网络，媒体等统计信息。
     */
    public static class RoomStats extends NetworkStats {
        protected String local_address;	            /**< 本地地址  */
        protected String remote_address;	            /**< 远端地址  */
        protected String transport_type;	            /**< 传输类型：udp : tcp  */
        protected int available_receive_bandwidth;/**< 估计接收带宽  */
        protected int available_send_bandwidth;	/**< 估计发送带宽  */

        public RoomStats(int bps_received, int bps_sent, int lostpercent, int lostpercent_received, int lostpercent_sent,
                          String local_address, String remote_address,String transport_type,
                          int available_receive_bandwidth, int available_send_bandwidth) {
            super(bps_received,bps_sent,lostpercent,lostpercent_received,lostpercent_sent);
            this.local_address = (null == local_address) ? "" : local_address;
            this.remote_address = (null == remote_address) ? "" : remote_address;
            this.transport_type = (null == transport_type) ? "" : transport_type;
            this.available_receive_bandwidth = available_receive_bandwidth;
            this.available_send_bandwidth = available_send_bandwidth;
        }
        public String getLocal_address() { return this.local_address; }
        public String getremote_address() { return this.remote_address; }
        public String getTransport_type() { return this.transport_type; }
        public int getAvailable_receive_bandwidth() { return this.available_receive_bandwidth; }
        public int getAvailable_send_bandwidth() { return this.available_send_bandwidth; }

        @Override
        public String toString() {
            return "RoomStats: address local=" + local_address + ",remote="+remote_address + ",type="+transport_type
                    + ",available receive="+available_receive_bandwidth + ",send="+available_send_bandwidth + super.toString();
        }
    };

}
