📄 mgcp_test.c
字号:
} } if (ptmgcp_cbk_crcx->pMode != NULL) { printf("\r\n mode == "); switch (ptmgcp_cbk_crcx->pMode->eMode) { case CONNECTION_MODE_SENDONLY: { printf("sendonly"); break; } case CONNECTION_MODE_RECEIVEONLY: { printf("receiveonly"); break; } case CONNECTION_MODE_SENDRECEIVE: { printf("sendreceive"); break; } case CONNECTION_MODE_CONFERENCE: { printf("conference"); break; } case CONNECTION_MODE_INACTIVE: { printf("inactive"); break; } case CONNECTION_MODE_LOOPBACK: { printf("loopback"); break; } case CONNECTION_MODE_CONTINUITY: { printf("continuity"); break; } case CONNECTION_MODE_NET_CONTINUITY: { printf("net continuity"); break; } case CONNECTION_MODE_NET_LOOP: { printf("net continuity"); break; } case CONNECTION_MODE_EXTENSION_MODE: { printf("extension mode\r\n"); printf(" %s : %s", ptmgcp_cbk_crcx->pMode->pExtenMode->pcExtenPackageName, ptmgcp_cbk_crcx->pMode->pExtenMode->pcExtenModeName); break; } } } else { printf("\r\n %s : L%d\r\n", __FILE__, __LINE__); return FAIL; } if (ptmgcp_cbk_crcx->pRemoteConnectDescrpt != NULL) { return (Print_Sdp_Desc(ptmgcp_cbk_crcx->pRemoteConnectDescrpt)); } return OK;}H_MGCP_ENDPOINT FindEptHdByLocalName(char * pch_local_name){ int i=0; H_MGCP_ENDPOINT tmgcp_endpoint_handle = NULL; if (pch_local_name == NULL) { return NULL; } for (; i<ENDPOINT_TOTALL_CNT; i++) { tmgcp_endpoint_handle = (H_MGCP_ENDPOINT)gpEndpoint[i]; if (strcmp(tmgcp_endpoint_handle->pcEndpointName, pch_local_name) == 0) { return tmgcp_endpoint_handle; } } return NULL;}int Deal_Msg(PTInternal_Msg ptinternal_msg){ if (ptinternal_msg == NULL) { printf("\r\n %s : L%d\r\n", __FILE__, __LINE__); return FAIL; } switch (ptinternal_msg->imsg_type) { case CBK_MGCP_STACK_PARAM: { MGCP_CBK_MSG *pCbkMsg = ptinternal_msg->u.tmgcp_stack_param.pCbkMsg; WORD * pwErrorCode = ptinternal_msg->u.tmgcp_stack_param.pwErrorCode; if (pCbkMsg == NULL) { printf("\r\n %s : L%d\r\n", __FILE__, __LINE__); break; } printf("\r\n CBK_MGCP_STACK_PARAM"); switch (pCbkMsg->eType) { case MGCP_CBK_MSG_CREATRE_CONNECTION: // 请求创建连接 { // 收到了创建连接消息 // if (Print_Mgcp_Cbk_Crcx_Msg(&(pCbkMsg->u.CbkCreateConnection)) == OK) { // 正常处理 CONNECTION_DESCRIPTOR *ptlocal_sdp_desc = (CONNECTION_DESCRIPTOR *)malloc(sizeof(CONNECTION_DESCRIPTOR)); if (ptlocal_sdp_desc == NULL) { printf("\r\n %s : L%d", __FILE__, __LINE__); goto creatre_connection_label; } printf("\r\n\r\n Print_Mgcp_Cbk_Crcx_Msg( ... ) return OK\r\n"); if (Construct_Sdp_Desc(ptlocal_sdp_desc, pCbkMsg->u.CbkCreateConnection.pLocalConnecOpt) == OK) { MGCP_OBSERVED_EVENT *ptnotify_event = NULL; printf("\r\n Construct_Sdp_Desc( ... ) return OK\r\n\r\n"); Print_Sdp_Desc(ptlocal_sdp_desc); // 打印刚刚构造好的 sdp 描述 // 接受创建连接命令 if (MgcpEndpointAcceptCRCX(ptinternal_msg->u.tmgcp_stack_param.pEndpointHandle, pCbkMsg->u.CbkCreateConnection.dwConnectionID, ptlocal_sdp_desc, NULL) != OK) { printf("\r\n %s : L%d", __FILE__, __LINE__); Destroy_Sdp_Desc(ptlocal_sdp_desc); free(ptlocal_sdp_desc); goto creatre_connection_label; } printf("\r\n MgcpEndpointAcceptCRCX( ... ) return OK\r\n"); Destroy_Sdp_Desc(ptlocal_sdp_desc); free(ptlocal_sdp_desc); // 保存端点信息 ************************************************************ ptnotify_event = (MGCP_OBSERVED_EVENT *)malloc(sizeof(MGCP_OBSERVED_EVENT)); if (ptnotify_event == NULL) { printf("\r\n %s : L%d", __FILE__, __LINE__); goto creatre_connection_label; } memset(ptnotify_event, 0, sizeof(MGCP_OBSERVED_EVENT)); ptnotify_event->ePkgID = MGCP_PKG_LINE; ptnotify_event->eEventID = L_OFF_HOOK_TRANSITION; ptnotify_event->dwConnecID = pCbkMsg->u.CbkCreateConnection.dwConnectionID; // 发送摘机通知 if (MgcpEndpointNotifyEvent(ptinternal_msg->u.tmgcp_stack_param.pEndpointHandle, ptnotify_event, NULL) != OK) { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MgcpEndpointNotifyEvent( ... ) : FAIL\r\n"); free(ptnotify_event); goto creatre_connection_label; } printf("\r\n MgcpEndpointNotifyEvent( ... ) : OK\r\n"); free(ptnotify_event); } else { printf("\r\n %s : L%d\r\n", __FILE__, __LINE__); free(ptlocal_sdp_desc); goto creatre_connection_label; } }// else// {// printf("\r\n %s : L%d\r\n", __FILE__, __LINE__);// goto creatre_connection_label;// }creatre_connection_label: free(pCbkMsg); free(pwErrorCode); break; } case MGCP_CBK_MSG_MODIFY_CONNECTION: // 请求修改连接 { int iret = 0; printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MGCP_CBK_MSG_MODIFY_CONNECTION \r\n"); iret = MgcpEndpointAcceptMDCX(ptinternal_msg->u.tmgcp_stack_param.pEndpointHandle, pCbkMsg->u.CbkModifyConnection.dwConnectionID, NULL, NULL); if (iret != OK) { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MgcpEndpointAcceptMDCX( ... ) FAIL \r\n"); } else { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MgcpEndpointAcceptMDCX( ... ) OK \r\n"); } break; } case MGCP_CBK_MSG_DELETE_CONNECTION: // 请求删除连接 { MGCP_OBSERVED_EVENT *ptnotify_event = NULL; int iconnect_cnt = 0; int mm = 0; printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MGCP_CBK_MSG_DELETE_CONNECTION \r\n"); ptnotify_event = (MGCP_OBSERVED_EVENT *)malloc(sizeof(MGCP_OBSERVED_EVENT)); if (ptnotify_event == NULL) { printf("\r\n %s : L%d", __FILE__, __LINE__); break; } memset(ptnotify_event, 0, sizeof(MGCP_OBSERVED_EVENT)); ptnotify_event->ePkgID = MGCP_PKG_LINE; ptnotify_event->eEventID = L_ON_HOOK_TRANSITION; iconnect_cnt = pCbkMsg->u.CbkDeleteConnection.wConnectionNum; printf("\r\n iconnect_cnt == %d\r\n", iconnect_cnt); for (; mm<iconnect_cnt; mm++) { ptnotify_event->dwConnecID = pCbkMsg->u.CbkDeleteConnection.pdwConnecIdList[mm]; // 发送挂机通知 if (MgcpEndpointNotifyEvent(ptinternal_msg->u.tmgcp_stack_param.pEndpointHandle, ptnotify_event, NULL) != OK) { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MgcpEndpointNotifyEvent( ... ) : FAIL\r\n"); printf("\r\n pCbkMsg->u.CbkDeleteConnection.wConnectionNum == %d", (int)(pCbkMsg->u.CbkDeleteConnection.wConnectionNum)); printf("\r\n mm == %d", mm); free(ptnotify_event); goto delete_connection_label; } } printf("\r\n MgcpEndpointNotifyEvent( ... ) : OK\r\n"); free(ptnotify_event); delete_connection_label: break; } case MGCP_CBK_MSG_CONFIG_ENDPOINT: // 请求配置端点 { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MGCP_CBK_MSG_CONFIG_ENDPOINT \r\n"); break; } case MGCP_CBK_MSG_RESTART_STATE: // 汇报端点重启动状态 { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MGCP_CBK_MSG_RESTART_STATE \r\n"); // 收到了对注册消息的肯定确认 if (pCbkMsg->u.CbkRestartState == RESTART_STATE_CONNECTED) { printf("\r\n %s : L%d", __FILE__, __LINE__); printf(" RESTART_STATE_CONNECTED \r\n"); } else if (pCbkMsg->u.CbkRestartState == RESTART_STATE_DISCONNECTED) { printf("\r\n %s : L%d", __FILE__, __LINE__); printf(" RESTART_STATE_DISCONNECTED \r\n"); } break; } case MGCP_CBK_MSG_SIGNAL_REQUEST: // 汇报信号请求 { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MGCP_CBK_MSG_SIGNAL_REQUEST \r\n"); break; } case MGCP_CBK_MSG_EXPERIMENTAL_PARM: // 汇报实验消息 { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MGCP_CBK_MSG_EXPERIMENTAL_PARM \r\n"); break; } } break; } case MGCP_USER_MSG: // 用于解除端口锁定 { switch (ptinternal_msg->u.pch_user_msg[0]) { case USER_HOOK_ON: { H_MGCP_ENDPOINT ptmgcp_endpoint_handle = NULL; MGCP_OBSERVED_EVENT *ptnotify_event = NULL; char pch_local_name[MGCP_MAX_LOCAL_NAME_LEN+1];// MGCP_PENDING_CONNEC_CMD *pPendingCmd = NULL; int iname_len = 0; printf("\r\n\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MGCP_USER_MSG : USER_HOOK_ON"); iname_len = ptinternal_msg->u.pch_user_msg[1]; if (iname_len < 1) { printf("\r\n %s : L%d\r\n", __FILE__, __LINE__); break; } // 复制端点名称 memcpy(pch_local_name, &(ptinternal_msg->u.pch_user_msg[2]), iname_len); pch_local_name[iname_len] = 0; printf("\r\n pch_local_name == %s\r\n", pch_local_name); ptmgcp_endpoint_handle = FindEptHdByLocalName(pch_local_name); if (ptmgcp_endpoint_handle == NULL) { printf("\r\n %s : L%d\r\n", __FILE__, __LINE__); break; } ptnotify_event = (MGCP_OBSERVED_EVENT *)malloc(sizeof(MGCP_OBSERVED_EVENT)); if (ptnotify_event == NULL) { printf("\r\n %s : L%d", __FILE__, __LINE__); break; } memset(ptnotify_event, 0, sizeof(MGCP_OBSERVED_EVENT)); ptnotify_event->ePkgID = MGCP_PKG_LINE; ptnotify_event->eEventID = L_ON_HOOK_TRANSITION; // 发送挂机通知 if (MgcpEndpointNotifyEvent((H_ENDPOINT)ptmgcp_endpoint_handle, ptnotify_event, NULL) != OK) { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MgcpEndpointNotifyEvent( ... ) : FAIL\r\n"); free(ptnotify_event); break; }/* SListReset(&(ptmgcp_endpoint_handle->PendingCmdsIn.PendingMdcxList)); while ((pPendingCmd = SListGetCurData(&(ptmgcp_endpoint_handle->PendingCmdsIn.PendingMdcxList))) != NULL) { ptnotify_event->dwConnecID = pPendingCmd->PendingConn.dwConnectionID; // 发送挂机通知 if (MgcpEndpointNotifyEvent((H_ENDPOINT)ptmgcp_endpoint_handle, ptnotify_event, NULL) != OK) { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MgcpEndpointNotifyEvent( ... ) : FAIL\r\n"); free(ptnotify_event); break; } SListNextNode(&(ptmgcp_endpoint_handle->PendingCmdsIn.PendingMdcxList)); } SListReset(&(ptmgcp_endpoint_handle->PendingCmdsIn.PendingCrcxList)); while ((pPendingCmd = SListGetCurData(&(ptmgcp_endpoint_handle->PendingCmdsIn.PendingCrcxList))) != NULL) { ptnotify_event->dwConnecID = pPendingCmd->PendingConn.dwConnectionID; // 发送挂机通知 if (MgcpEndpointNotifyEvent((H_ENDPOINT)ptmgcp_endpoint_handle, ptnotify_event, NULL) != OK) { printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MgcpEndpointNotifyEvent( ... ) : FAIL\r\n"); free(ptnotify_event); break; } SListNextNode(&(ptmgcp_endpoint_handle->PendingCmdsIn.PendingMdcxList)); }*/ printf("\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MgcpEndpointNotifyEvent( ... ) : OK\r\n"); free(ptnotify_event); break; } case USER_HOOK_OFF: { H_MGCP_ENDPOINT ptmgcp_endpoint_handle = NULL; MGCP_OBSERVED_EVENT *ptnotify_event = NULL; char pch_local_name[MGCP_MAX_LOCAL_NAME_LEN+1]; int iname_len = 0; printf("\r\n\r\n %s : L%d", __FILE__, __LINE__); printf("\r\n MGCP_USER_MSG : USER_HOOK_ON"); iname_len = ptinternal_msg->u.pch_user_msg[1]; if (iname_len < 1) { printf("\r\n %s : L%d\r\n", __FILE__, __LINE__); break; } // 复制端点名称 memcpy(pch_local_name, &(ptinternal_msg->u.pch_user_msg[2]), iname_len); pch_local_name[iname_len] = 0; printf("\r\n pch_local_name == %s\r\n", pch_local_name); ptmgcp_endpoint_handle = FindEptHdByLocalName(pch_local_name); if (ptmgcp_endpoint_handle == NULL) { printf("\r\n %s : L%d\r\n", __FILE__, __LINE__); break; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -