package com.yfd.monitor.gdw2019.transmit.cmd;

import com.yfd.monitor.gdw2019.bean.*;
import com.yfd.monitor.gdw2019.event.SipSubscribe;
import org.springframework.lang.Nullable;

import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import javax.sip.header.WWWAuthenticateHeader;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

public interface ISIPCommanderForPlatform {

    /**
     * 向上级平台注册
     * @param parentPlatform
     * @return
     */

    //开机首次注册
    void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException;


    void register(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException;

    //携带授权二次注册
    void register(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, WWWAuthenticateHeader www, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean isRegister) throws SipException, InvalidArgumentException, ParseException;

    /**
     * 向上级平台注销
     * @param parentPlatform
     * @return
     */
    void unregister(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException;

    //向上级主动同步目录信息
    void sendCatalogNotice(ParentPlatform parentPlatform,@Nullable SipTransactionInfo sipTransactionInfo) throws InvalidArgumentException, ParseException, SipException;

    /**
     * 向上级回复通道信息
     * @param Code 通道信息
     * @param FromIndex
     * @param ToIndex
     * @return
     */
    String queryCatalog(ParentPlatform parentPlatform,String Code,String FromIndex,String ToIndex,String fromTag) ;

    /**
     * 查询设备历史报警信息
     * @param Code 查询告警地址编码，视频通道
     * @param UserCode 用户地址编码
     * @param Type 告警类型，见订阅行为
     * @param BeginTime 开始时间，格式如 1990-01-01T00:00:00Z
     * @param EndTime 结束时间，格式如 1990-01-01T00:00:00Z
     * @param Level 告警级别，仅当节点为告警且全网有统一的告
     * 警级别规划时有效，0 表示未定义告警级别
     * @param FromIndex
     * @param ToIndex
     * @return
     */
    String queryHistoryAlarm(ParentPlatform parentPlatform,String Code, String UserCode, String Type, String BeginTime, String EndTime, String Level, String FromIndex, String ToIndex) ;

    /**
     * 查询设备录像信息
     * @param Code 查询告警地址编码，视频通道
     * @param UserCode 用户地址编码
     * @param Type 告警类型，见订阅行为
     * @param BeginTime 开始时间，格式如 1990-01-01T00:00:00Z
     * @param EndTime 结束时间，格式如 1990-01-01T00:00:00Z
     * @param FromIndex
     * @param ToIndex
     * @return
     */
    String queryDeviceRecord(ParentPlatform parentPlatform,String Code, String UserCode, String Type, String BeginTime, String EndTime, String FromIndex, String ToIndex) ;

    /**
     * 向上级回复DeviceStatus查询信息
     * @param parentPlatform 平台信息
     * @param sn
     * @param fromTag
     * @return
     */
    void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,boolean status) throws SipException, InvalidArgumentException, ParseException;


    /**
     * 向上级回复报警消息
     * @param parentPlatform 平台信息
     * @param deviceAlarms 报警信息信息
     * @return
     */
    void sendAlarmMessage(ParentPlatform parentPlatform, List<DeviceAlarm> deviceAlarms) throws SipException, InvalidArgumentException, ParseException;



    /**
     * 回复recordInfo
     * @param deviceChannel 通道信息
     * @param parentPlatform 平台信息
     * @param fromTag fromTag
     * @param recordInfo 录像信息
     */
    void recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) throws SipException, InvalidArgumentException, ParseException;




    /**
     * 从设备上截图，并发送截图通知
     * @param deviceid  摄像头ID
     * @param PicServer 截图会传地址
     * @param platform
     * @return
     */
    void snapImageAndsendNoticeMsg(String deviceid,String PicServer,ParentPlatform platform,@Nullable SipTransactionInfo sipTransactionInfo) throws SipException, InvalidArgumentException, ParseException;


    /**
     * 向上级发送订阅成功的通知
     * @param parentPlatform 平台信息
     * @return
     */
    void sendNotify(ParentPlatform parentPlatform,
                    SubscribeInfo subscribeInfo, SipSubscribe.Event errorEvent,  SipSubscribe.Event okEvent )
            throws SipException, ParseException, InvalidArgumentException;



    void sendAlarmNotice(ParentPlatform parentPlatform, List<Map<String,String>> alarmitems, @Nullable SipTransactionInfo sipTransactionInfo) throws InvalidArgumentException, ParseException, SipException;

    void sendDeviceStatusNotice(ParentPlatform parentPlatform, List<Map<String,String>> devicestatus, @Nullable SipTransactionInfo sipTransactionInfo) throws InvalidArgumentException, ParseException, SipException;
    /**
     * 向发起点播的上级回复bye
     * @param platform 平台信息
     * @param callId  callId
     */
    void streamByeCmd(ParentPlatform platform, String callId) throws SipException, InvalidArgumentException, ParseException;
    void streamByeCmd(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException;
}
