#ifndef _MGC_CONNECT_H
#define _MGC_CONNECT_H
#include "mgc_struct.h"

void mgc_connect_setup(void);
void mgc_connect_init(CONNECT_INFO *pConnect , int id);
CONNECT_INFO *mgc_connect_get_unused(void);
void mgc_connect_set_status(CONNECT_INFO *pConnect , MGC_CONNECT_STATUS status);
MGC_CONNECT_STATUS mgc_connect_get_status(CONNECT_INFO *pConnect);
char *mgc_connect_print_statuts(MGC_CONNECT_STATUS status);
void mgc_connect_codec_list_init(MGC_CODEC_LIST  *pList);

/*fuplayers and downlayer operation*/
CHNL_INFO  *mgc_connect_get_own_chnl_info(CONNECT_INFO *pConnect);
PHY_PORT_INFO  *mgc_connect_get_own_phy_port_info(CONNECT_INFO *pConnect);
MGC_SAP *mgc_connect_get_conn_report_sap(CONNECT_INFO *pConnect);
MG_INFO *mgc_connect_get_own_mg_info(CONNECT_INFO *pConnect);
CONNECT_INFO *mgc_connect_find_connect_of_chnl(CHNL_INFO *pChnlInfo , int connNo);
BOOL mgc_connect_attach_connect_to_chnl(CONNECT_INFO *pConnect , CHNL_INFO *pChnlInfo);
int mgc_connect_get_connNo_of_chnl_info(CONNECT_INFO *pConnect , CHNL_INFO *pChnlInfo);


/*attr*/
BOOL mgc_connect_set_conn_mode(CONNECT_INFO *pConnect , MGC_CON_MODE mode);
MGC_CON_MODE mgc_connect_get_conn_mode(CONNECT_INFO *pConnect);
void mgc_connect_attr_init(CONNECT_INFO *pConnect);
BOOL mgc_connect_attr_negotiate(CONNECT_INFO *pConnect);
BOOL mgc_connect_set_dtmf(CONNECT_INFO *pConnect , BYTE dtmfNo);
BOOL mgc_connect_set_tone(CONNECT_INFO *pConnect , BYTE toneNo);
BOOL mgc_connect_clear_tone(CONNECT_INFO *pConnect);
BOOL mgc_connect_set_req(CONNECT_INFO *pConnect , BYTE pkg , BYTE req);


/*operate */
BOOL mgc_connect_attach_step_info(CONNECT_INFO *pConnect , MGCF_OPER_STEP *pOperStep);
BOOL mgc_connect_dettach_step_info(CONNECT_INFO *pConnect);
MGCF_OPER_STEP *mgc_connect_get_step_info(CONNECT_INFO *pConnect);


/*para create*/
BOOL mgc_connect_auep_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara);
BOOL mgc_connect_crcx_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara);
BOOL mgc_connect_mdcx_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara);
BOOL mgc_connect_dlcx_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara);
BOOL mgc_connect_crcx_resp_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara);
BOOL mgc_connect_mdcx_resp_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara);
BOOL mgc_connect_rqnt_para_create(CONNECT_INFO *pConnect , MGCP_PARA *pPara);
BOOL mgc_connect_is_conn_need_update(CONNECT_INFO *pConnect , MGCP_PARA *pPara);

/*para parse*/
CONNECT_INFO *mgc_connect_assign_conn_by_para(MGCP_PARA *pPara);
CONNECT_INFO *mgc_connect_find_conn_by_conid(MGCP_PARA *pPara);
BOOL mgc_connect_crcx_req_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara);
BOOL mgc_connect_mdcx_req_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara);
BOOL mgc_connect_req_parse_para(CONNECT_INFO *pConnect , MGCP_PARA *pPara);

BOOL mgc_connect_add_auep(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo);
BOOL mgc_connect_add_crcx(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo);
BOOL mgc_connect_add_crcx_with_mode(CONNECT_INFO *pConnect, MGC_CON_MODE mode ,PORT_INFO *pPortInfo);
BOOL mgc_connect_add_crcx_aas(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect, PORT_INFO *pPortInfo);
BOOL mgc_connect_add_mdcx_aas(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect,PORT_INFO *pPortInfo);
BOOL mgc_connect_add_dlcx(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo);
BOOL mgc_connect_add_mdcx(CONNECT_INFO *pConnect, CONNECT_INFO *pPeerConnect , MGC_CON_MODE mode, PORT_INFO *pPortInfo);
BOOL mgc_connect_add_nop_with_delay(CONNECT_INFO *pConnect, DWORD delay ,PORT_INFO *pPortInfo);
BOOL mgc_connect_add_nop(CONNECT_INFO *pConnect, PORT_INFO *pPortInfo);
BOOL mgc_connect_add_rqnt(CONNECT_INFO *pConnect, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig, PORT_INFO *pPortInfo);
BOOL mgc_connect_add_rqnt_with_delay(CONNECT_INFO *pConnect, WORD delay, PKG_EVENT *pPkgEvent, PKG_SIGNAL *pPkgSig, PORT_INFO *pPortInfo);

CONNECT_INFO *mgc_connect_dup_attr(CONNECT_INFO *pConnect);

#endif
