⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 voip_state.c

📁 telcobridges voip develop
💻 C
📖 第 1 页 / 共 4 页
字号:
										{
											TbxCliToolsLogPrint( 
												g_pContext->CliContext.hCliTools, 
												TRACE_LEVEL_ALWAYS, 
												FCYAN, 
												"Starting test: %s, with parmameter: %s\n", 
												pStartParam->StartTestParameter.szTestID,
												pStartParam->StartTestParameter.szTestParameter );
											/* start test */

											pAutoTest = TBXPoolOfBuffersFind(
												g_pContext->TestModeContext.hPoolTestFunction,
												(TBX_HASH_KEY)pStartParam->StartTestParameter.szTestID );

											if( pAutoTest != NULL )
											{
												/* keep in context the current Test started */
												g_pContext->TestModeContext.pCurrentTest = pAutoTest;
												if( pAutoTest->pFctStartTest != NULL )
												{
													pAutoTest->pFctStartTest( hMsg, pStartParam->StartTestParameter.szTestParameter );
												}
												else
												{
													/* send confirmation that start routine fail */
													Result = TBTestLibSendConfirmStartTestMessage
													(
														g_pContext->hTbxLib,
														TBX_MSG_ADAPTER_HANDLE_GET( hMsg ),
														0,
														g_pContext->TestModeContext.un32TestId,
														TBX_RESULT_AUTOTEST_INVALID_COMMAND
													);
												}
											}
											else
											{
												TbxCliToolsLogPrint( 
													g_pContext->CliContext.hCliTools, 
													TRACE_LEVEL_ERROR, 
													FRED, 
													"Cannot find testId: %s", pStartParam->StartTestParameter.szTestID );

												TbxCliToolsLogPrint( 
													g_pContext->CliContext.hCliTools, 
													TRACE_LEVEL_ALWAYS, 
													FCYAN, 
													"Test available:\n" );
												
												VoipDisplayTestAvailable();
												/* Error cannot start test... send a command fail confirmation */
												Result = TBTestLibSendConfirmStartTestMessage(
													g_pContext->hTbxLib,
													TBX_MSG_ADAPTER_HANDLE_GET(hMsg),
													0,
													g_pContext->TestModeContext.un32TestId,
													TBX_RESULT_AUTOTEST_FAIL );
												if( TBX_RESULT_FAILURE( Result ) )
												{
													TbxCliToolsLogPrint(
														g_pContext->CliContext.hCliTools,
														TRACE_LEVEL_ERROR,
														FRED,
														"Could not send start test confirmation: 0x%X\n", Result);
												}
											}

										}
										else
										{
											TbxCliToolsLogPrint( 
												g_pContext->CliContext.hCliTools, 
												TRACE_LEVEL_ALWAYS, 
												FCYAN, 
												"Received message for another test application...");
												/* Error cannot start test... send a command fail confirmation */
												Result = TBTestLibSendConfirmStartTestMessage(
													g_pContext->hTbxLib,
													TBX_MSG_ADAPTER_HANDLE_GET(hMsg),
													0,
													g_pContext->TestModeContext.un32TestId,
													TBX_RESULT_AUTOTEST_FAIL );
												if( TBX_RESULT_FAILURE( Result ) )
												{
													TbxCliToolsLogPrint(
														g_pContext->CliContext.hCliTools,
														TRACE_LEVEL_ERROR,
														FRED,
														"Message received is not for this application\n");
												}
										}

									}break;

									case TB_TESTLIB_MSG_ID_NOTIF_STOP_TEST_REQ:
									{
										PTB_TESTLIB_REQ_STOP_TEST		pStopParam;

										TbxCliToolsLogPrint( 
											g_pContext->CliContext.hCliTools, 
											TRACE_LEVEL_ALWAYS, 
											FCYAN, 
											"stop test request received");

										pStopParam = TBX_MSG_PAYLOAD_POINTER( hMsg );
										if( pStopParam->StopTestParameter.un32ApplicationID == g_pContext->TestModeContext.un32TestId )
										{
											TbxCliToolsLogPrint( 
												g_pContext->CliContext.hCliTools, 
												TRACE_LEVEL_ALWAYS, 
												FCYAN, 
												"Stopping test" );
											/* Check if there is a stop function */
											if( g_pContext->TestModeContext.pCurrentTest->pFctStopTest != NULL )
											{
												g_pContext->TestModeContext.pCurrentTest->pFctStopTest( hMsg, pStopParam->StopTestParameter.szTestParameter );
											}
											else
											{
												/* todo default stop routine */

												/* send confirmation that stop fail */
												TBTestLibSendConfirmStopTestMessage
												(
													g_pContext->hTbxLib,
													TBX_MSG_ADAPTER_HANDLE_GET(hMsg),
													0,
													g_pContext->TestModeContext.un32TestId,
													TBX_RESULT_AUTOTEST_INVALID_COMMAND
												);
											}
										}
										else
										{
											TbxCliToolsLogPrint( 
												g_pContext->CliContext.hCliTools, 
												TRACE_LEVEL_ALWAYS, 
												FCYAN, 
												"Received message for another test application...");
										}
									}break;
									default:
									{
										/* Unknown msg. Ignore */
									}break;

								}
							}
						}
						else
						{
							/* Search which state machine this event is for */
							pAdapterContext		= NULL;

							if( TBX_MSG_ID_GET_GROUP( TBX_MSG_ID_GET( hMsg ) ) == TBX_ID_CLASS_TBX_APPS_VOIP_PRIVATE )
							{
								hAdapter = (TBX_ADAPTER_HANDLE)TBX_MSG_USER_CONTEXT1_GET( hMsg );
							}
							else
							{
								hAdapter = TBX_MSG_ADAPTER_HANDLE_GET( hMsg );
							}

							/* Search which adapter this event is for */
							TBXHashFind
							(
								g_pContext->hAdapterHandleHash,
								(TBX_HASH_KEY)hAdapter,
								(PTBX_VOID*)&pAdapterContext
							);

							if( pAdapterContext )
							{
								if( TBX_MSG_ID_GET( hMsg ) == TBX_MSG_ID_API_NOTIF_ADAPTER_ETH_UP )
								{
									PTBX_EVT_API_NOTIF_ADAPTER_ETH_UP	pMsg =
										(PTBX_EVT_API_NOTIF_ADAPTER_ETH_UP)TBX_MSG_PAYLOAD_POINTER( hMsg );

									VoipCliAdapterStatePrint
									(
										pAdapterContext,
										TRACE_LEVEL_1,
										"GW update: gw0 (%s) %s, gw1 (%s) %s\n",
										pMsg->szIpAddress0,
										pMsg->fIpAddress0Available ? "up" : "down",
										pMsg->szIpAddress1,
										pMsg->fIpAddress1Available ? "up" : "down"
									);

									/* Force command-line redraw */
									TbxCliToolsNeedRedraw( pCliContext->hCliTools );
								}
								else if( TBX_MSG_ID_GET( hMsg ) == TBX_MSG_ID_API_NOTIF_ADAPTER_ETH_DOWN )
								{
									PTBX_EVT_API_NOTIF_ADAPTER_ETH_DOWN	pMsg =
										(PTBX_EVT_API_NOTIF_ADAPTER_ETH_DOWN)TBX_MSG_PAYLOAD_POINTER( hMsg );

									VoipCliAdapterStatePrint
									(
										pAdapterContext,
										TRACE_LEVEL_1,
										"GW update: gw0 (%s) %s, gw1 (%s) %s\n",
										pMsg->szIpAddress0,
										pMsg->fIpAddress0Available ? "up" : "down",
										pMsg->szIpAddress1,
										pMsg->fIpAddress1Available ? "up" : "down"
									);

									/* Force command-line redraw */
									TbxCliToolsNeedRedraw( pCliContext->hCliTools );
								}
								else if( TBX_MSG_ID_GET( hMsg ) == TB640_MSG_ID_ADAPTER_NOTIF_CPU_REPORT )
								{
									/* Cpu Report for that adapter */
									PTB640_EVT_ADAPTER_NOTIF_CPU_REPORT	pEvt =
										(PTB640_EVT_ADAPTER_NOTIF_CPU_REPORT)TBX_MSG_PAYLOAD_POINTER( hMsg );

									/* Keep reported CPU usage */
									if( pEvt->un8CpuNumber == 0 )
										pAdapterContext->un32Cpu0Usage	= pEvt->un32CpuUsage;
									else
										pAdapterContext->un32Cpu1Usage	= pEvt->un32CpuUsage;

									/* Force command-line redraw */
									TbxCliToolsNeedRedraw( pCliContext->hCliTools );
								}
								else if( TBX_MSG_ID_GET( hMsg ) == TB640_MSG_ID_VP_GROUP_NOTIF_READY )
								{
									PTB640_EVT_VP_GROUP_NOTIF_READY	pEvt =
										(PTB640_EVT_VP_GROUP_NOTIF_READY)TBX_MSG_PAYLOAD_POINTER( hMsg );

									if( pEvt->GroupType == TB640_VP_GROUP_TYPE_0 )
									{
										TbxCliToolsLogPrint( pCliContext->hCliTools, TRACE_LEVEL_ALWAYS, FCYAN, "Voice processing group 0 is ready.\n" );

										pAdapterContext->Status.fVpGroup0Ready = TBX_TRUE;
									}
									else if( pEvt->GroupType == TB640_VP_GROUP_TYPE_1 )
									{
										TbxCliToolsLogPrint( pCliContext->hCliTools, TRACE_LEVEL_ALWAYS, FCYAN, "Voice processing group 1 is ready.\n" );

										pAdapterContext->Status.fVpGroup1Ready = TBX_TRUE;
									}

									/* Force command-line redraw */
									TbxCliToolsNeedRedraw( pCliContext->hCliTools );
								}
								else if( TBX_MSG_ID_GET( hMsg ) == VOIP_MSG_ID_OP_POLL_STREAM_RES_STATS )
								{
									PVOIP_EVT_OP_POLL_STREAM_RES_STATS	pEvt =
										(PVOIP_EVT_OP_POLL_STREAM_RES_STATS)TBX_MSG_PAYLOAD_POINTER( hMsg );
									PVOIP_STREAM_RES	pStreamRes;

									TbxCliToolsLogPrint( pCliContext->hCliTools, TRACE_LEVEL_ALWAYS, FCYAN, "Poll stream resource stats...\n" );

									pAdapterContext->Stats.fGlobalStats	= pEvt->fGlobalStats;
									pAdapterContext->Stats.Interface	= pEvt->Interface;
									pAdapterContext->Stats.un16RxIPPort	= pEvt->un16RxIPPort;
									pAdapterContext->Stats.un16TxIPPort	= pEvt->un16TxIPPort;
									pAdapterContext->Stats.fResetStats	= pEvt->fResetStats;
									pAdapterContext->Stats.pStreamRes	= NULL;
									if( pAdapterContext->Stats.fGlobalStats == TBX_FALSE )
									{
										pStreamRes = TBXPoolOfBuffersFirst( pAdapterContext->CurrentConfig.hPoolOfStreamRes );
										while( pStreamRes )
										{
											if( (pStreamRes->Params.Interface == pEvt->Interface) &&
												(pStreamRes->Params.un16FromNetworkIPPort == pEvt->un16RxIPPort) && (pStreamRes->Params.un16ToNetworkIPPort == pEvt->un16TxIPPort) )
											{
												/* Gotcha! */
												break;
											}

											pStreamRes = TBXPoolOfBuffersNext( pAdapterContext->CurrentConfig.hPoolOfStreamRes, pStreamRes );
										}
										pAdapterContext->Stats.pStreamRes = pStreamRes;
									}
								}
								else if( TBX_MSG_ID_GET( hMsg ) == VOIP_MSG_ID_OP_START_STRESS_TEST )
								{
									PVOIP_EVT_OP_START_STRESS_TEST	pEvt =
										(PVOIP_EVT_OP_START_STRESS_TEST)TBX_MSG_PAYLOAD_POINTER( hMsg );

									TbxCliToolsLogPrint( pCliContext->hCliTools, TRACE_LEVEL_ALWAYS, FCYAN, "Start stress test...\n" );

									/* Start stress test */
									VoipStressTestStart( pAdapterContext, pEvt );
								}
								else if( TBX_MSG_ID_GET( hMsg ) == VOIP_MSG_ID_OP_STOP_STRESS_TEST )
								{
									TbxCliToolsLogPrint( pCliContext->hCliTools, TRACE_LEVEL_ALWAYS, FCYAN, "Stop stress test...\n" );

									/* Stop stress test */
									VoipStressTestStop( pAdapterContext );
								}
								else if( TBX_MSG_ID_GET( hMsg ) == VOIP_MSG_ID_OP_RESET_STRESS_TEST_STATS )
								{
									TbxCliToolsLogPrint( pCliContext->hCliTools, TRACE_LEVEL_ALWAYS, FCYAN, "Reset stress test stats...\n" );

									/* Reset stress test stats */
									VoipStressTestResetStats( pAdapterContext );
								}
								else if( TBX_MSG_ID_GET( hMsg ) == VOIP_MSG_ID_OP_START_DEMO )
								{
									PVOIP_EVT_OP_START_DEMO	pEvt =
										(PVOIP_EVT_OP_START_DEMO)TBX_MSG_PAYLOAD_POINTER( hMsg );

									TbxCliToolsLogPrint( pCliContext->hCliTools, TRACE_LEVEL_ALWAYS, FCYAN, "Start demo...\n" );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -