📄 复件 (2) h323f.cpp
字号:
}
}
}
else if((*state == ST_H323_BIDIR_VOICE_STATE)&& !connected)
{
connected =1;
ringed = 0;
num = 0;
if (clock_gettime(CLOCK_REALTIME, &tpShow) == OK)
{
if(gmtime_r(&(tpShow.tv_sec), &voice_Buffer) == OK)
{
sprintf(voice_msg, "%04u-%02u-%02u %02u:%02u:%02u",
voice_Buffer.tm_year + 1900,
voice_Buffer.tm_mon + 1,
voice_Buffer.tm_mday,
voice_Buffer.tm_hour,
voice_Buffer.tm_min,
voice_Buffer.tm_sec);
printf("The time we received alerting is %s\n", voice_msg);
/* strcpy(Vptr->SVoiceMsg,voice_msg);
Vptr->next= (SCallInfo*)malloc(sizeof(SCallInfo));
Vptr = Vptr->next;
Vptr->next = NULL;*/
Sptr->interval = (voice_Buffer.tm_hour*3600+voice_Buffer.tm_min*60+voice_Buffer.tm_sec)-
(send_connect_Buffer.tm_hour*3600+send_connect_Buffer.tm_min*60+send_connect_Buffer.tm_sec);
Sptr->next = (Interval*)malloc(sizeof(Interval));
Sptr = Sptr->next;
Sptr->next = NULL;
}
}
taskDelay(bivoicetime*100);
if((msg=(NonWrapperMsg *)MQBufGet()) == NULL)
{
continue;
}
msg->event = speaker_event;
msg->digit = 0;
if (MQSend((char*)msg, NO_WAIT) == -1)
{
MQBufFree((char*)msg);
return ;
}
}
else if(*state == ST_H323_DEAD_END_STATE && !num)
{
num = 1;
ringed = 0;
if((msg=(NonWrapperMsg *)MQBufGet()) == NULL)
{
continue;
}
msg->event = speaker_event;
msg->digit = 0;
if (MQSend((char*)msg, NO_WAIT) == -1)
{
MQBufFree((char*)msg);
return ;
}
/* if((msg=(NonWrapperMsg *)MQBufGet()) == NULL)
{
continue;
}
msg->event = speaker_event;
msg->digit = 0;
if (MQSend((char*)msg, NO_WAIT) == -1)
{
MQBufFree((char*)msg);
return ;
}*/
}
taskDelay(0);
}
}
void SShowCallNumber()
{
/* SCallInfo* ptr;*/
Interval* sptr;
int i= 0;
double sum = 0;
/* for(ptr= &SVoiceInfo;ptr->next!=NULL;ptr=ptr->next)
printf("the time slave begin to talk is %s\n",ptr->SVoiceMsg);*/
for(sptr = &svoice_interval;sptr->next!=NULL;sptr=sptr->next)
{
i++;
sum += sptr->interval;
printf("the slave's interval between connect and voice is %d\n",sptr->interval);
}
printf("mean time is %f\n", sum/i);
ClearBlock(svoice_interval.next);
/* printf("received setup message %d times!\n",SetupCount);*/
}
}
int callout(int event_type)
{
if (AppGetCallingNumber() != OK)
{
return to_dead_end_state;
}
LcdShowRemote(dig_id, digit_set, num_digits, 0, FLAG_NORMAL);
PreserveLcdMessage = FALSE;
menu_event = reset_event;
if (!networkStatus)
{
PreserveLcdMessage = TRUE;
LcdShowMessage(H323_NETWORK_NOT_CONNECTED);
PlayBusyTone(FIFTEEN_SEC);
return to_dead_end_state;
}
/*else if (gkEnabled && !gatekeeperStatus)
{
PreserveLcdMessage = TRUE;
LcdShowMessage(H323_GK_NOT_AVAILABLE);
AppTerminateAction( ST_H323_COLLECT_DIGITS_STATE );
PlayBusyTone(FIFTEEN_SEC);
return to_dead_end_state;
}*/
else if ((callIndex = AppSendWrapper( WP_SEND_QUERY_AVA, -1)) == -1 )
{
// rest to do
}
else
{
/*H323TRACE("Going to query_availability_state\n");*/
/* 设置等待响应计时器 */
DeleteTimer(&h323_timer);
h323_timer = CreateTimer(ALERTING_SEC);
return event_type;
}
}
/**
* 发送当前的号码(WP_SEND_QUERY_AVA),记录拨出电话;
* 若出错产生to_dead_end_state事件
*/
int h323_collect_digits_state_callout_key_event(s_event* psEvent, s_task*
psTask)
{
H323TRACE("action: h323_collect_digits_state_callout_key_event\n");
DeleteTimer(&h323_timer);
return callout(null_event);
}
/**
* 发送当前的号码(WP_SEND_QUERY_AVA),记录拨出电话;
* 产生to_query_availability_state事件;
* 若出错产生to_dead_end_state事件
*/
int h323_collect_digits_state_timeout_event(s_event* psEvent, s_task* psTask)
{
H323TRACE("action: h323_collect_digits_state_timeout_event\n");
msg = (NonWrapperMsg *)psEvent->pMsg;
if ((msg->digit != h323_timer) && (msg->digit != call_forward_timer))
{
return null_event;
}
h323_timer = -1;
return callout(to_query_availability_state);
}
/**
* 终结,回到初始状态
*/
int h323_collect_digits_state_local_on_hook_event(s_event* psEvent, s_task*
psTask)
{
H323TRACE("action: h323_collect_digits_state_local_on_hook_event\n");
/* 若为免提状态,状态不变 */
if (on_speakerphone == TRUE)
return to_collect_digits_state;
AppTerminateAction( ST_H323_COLLECT_DIGITS_STATE );
menu_event = reset_event;
return null_event;
}
/**
* 已输入的号码向前清除一位
*/
int h323_collect_digits_state_cancel_key_event(s_event* psEvent, s_task* psTask)
{
H323TRACE("action: h323_collect_digits_state_cancel_key_event\n");
digit_set[--num_digits] = '\0';
ClearLcd();
WriteLcd(digit_set, 0, 0);
LcdDShowCursor(TRUE);
if (toAddr[0] != '\0')
{
memset(toAddr, 0, sizeof(toAddr));
}
if (num_digits == 0)
{
return to_wait_first_digit_state;
}
return null_event;
}
/**
* 清空所有输入的内容,
* 回到wait_first_digit_state状态
*/
int h323_collect_digits_state_long_cancel_key_event(s_event* psEvent, s_task*
psTask)
{
H323TRACE("action: h323_collect_digits_state_long_cancel_key_event\n");
digit_set[0] = '\0';
num_digits = 0;
ClearLcd();
LcdDShowCursor(TRUE);
return null_event;
}
int h323_collect_digits_state_to_dead_end_state(s_event* psEvent, s_task*
psTask)
{
H323TRACE("action: h323_collect_digits_state_to_dead_end_state\n");
return null_event;
}
int h323_collect_digits_state_to_bidir_voice_state(s_event* psEvent, s_task*
psTask)
{
H323TRACE("action: h323_collect_digits_state_to_bidir_voice_state\n");
PreserveLcdMessage = FALSE;
return null_event;
}
int h323_collect_digits_state_to_wait_first_digit_state(s_event* psEvent,
s_task* psTask)
{
H323TRACE("action: h323_collect_digits_state_to_wait_first_digit_state\n");
return null_event;
}
int h323_collect_digits_state_to_query_availability_state(s_event* psEvent,
s_task* psTask)
{
H323TRACE("action: h323_collect_digits_state_to_query_availability_state\n");
return null_event;
}
int h323_query_availability_state_to_bidir_voice_state(s_event* psEvent, s_task*
psTask)
{
H323TRACE("action: h323_query_availability_state_to_bidir_voice_state\n");
PreserveLcdMessage = FALSE;
return null_event;
}
int h323_query_availability_state_to_on_hook_state(s_event* psEvent, s_task*
psTask)
{
H323TRACE("action: h323_query_availability_state_to_on_hook_state\n");
return null_event;
}
int h323_query_availability_state_to_dead_end_state(s_event* psEvent, s_task*
psTask)
{
H323TRACE("action: h323_query_availability_state_to_dead_end_state\n");
return null_event;
}
/**
* 返回忙或进行呼叫转移
*/
int h323_query_availability_state_receive_query_availability_event(s_event*
psEvent, s_task* psTask)
{
H323TRACE("action: h323_query_availability_state_receive_query_availability_event\n");
wp_msg = (WrapperMsg *) psEvent->pMsg;
AppReplyNotAvailOrFwd(wp_msg);
return null_event;
}
/**
* 停止播放等待铃声;
* 发送WP_SEND_CONN_ACK,接通voice开始通话;
* 若出错则产生to_dead_end_state事件
*/
int h323_query_availability_state_receive_connect_event(s_event* psEvent,
s_task* psTask)
{
H323TRACE("action: h323_query_availability_state_receive_connect_event\n");
StopTone();
//chenguoyin
bufferStopTone();
wp_msg = (WrapperMsg *) psEvent->pMsg;
appCallInfo[callIndex].ipAddr[3] = wp_msg->d.codec.remoteRtpIpAddr>> 24;
appCallInfo[callIndex].ipAddr[2] = (wp_msg->d.codec.remoteRtpIpAddr >> 16) & 0xFF;
appCallInfo[callIndex].ipAddr[1] = (wp_msg->d.codec.remoteRtpIpAddr >> 8) & 0xFF;
appCallInfo[callIndex].ipAddr[0] = wp_msg->d.codec.remoteRtpIpAddr & 0xFF;
strncpy(appCallInfo[callIndex].display,
wp_msg->baseInfo.display, MAX_DISPLAY_LENGTH);
appCallInfo[callIndex].display[MAX_DISPLAY_LENGTH] = '\0';
appCallInfo[callIndex].codec.remoteRtpIpAddr = wp_msg->d.codec.remoteRtpIpAddr;
appCallInfo[callIndex].codec.remoteRtpPort = wp_msg->d.codec.remoteRtpPort;
appCallInfo[callIndex].codec.rx = wp_msg->d.codec.rx;
appCallInfo[callIndex].codec.tx = wp_msg->d.codec.tx;
if(transferred_flag)
{
awaiting_transfer = FALSE;
transferred_flag = FALSE;
}
if(forwarded_flag)
forwarded_flag = FALSE;
SetRemoteName(appCallInfo[callIndex].display, digit_set);
SetRemoteNumber(digit_set);
H323TRACE("remote name = %s\n", appCallInfo[callIndex].display);
//H323TRACE("digit_set = %s\n", digit_set);
H323TRACE("remote number = %s\n", remoteNumber);
/* 通知菜单复位 */
menu_event = reset_event;
PreserveLcdMessage = FALSE;
if(AppGetCodec(appCallInfo[callIndex].codec.rx) != codeTypeNum)
AppSetCodec(AppGetCodec(appCallInfo[callIndex].codec.rx),
AppGetCodec(appCallInfo[callIndex].codec.tx));
#if 1
#else
{
int ii;
for( ii = 0; ii < 0x10000; ii++ )
;
}
#endif
startJbAndRtp(callIndex);
StartVoice();
startVoiceTime = getCurrentTime();
//wpCallConnectH245Control(callIndex);
/* 开始通话,设置计时器 */
DeleteTimer(&h323_timer);
return null_event;
}
/**
* 终结terminate所指通道的通话
*/
int h323_query_availability_state_receive_terminate_event(s_event* psEvent,
s_task* psTask)
{
H323TRACE("action: h323_query_availability_state_receive_terminate_event\n");
wp_msg = (WrapperMsg *) psEvent->pMsg;
if (callIndex != wp_msg->baseInfo.callIndex)
{
H323TRACE("Terminate on call index %d, not current call index %d, ignored\n",
wp_msg->baseInfo.callIndex, callIndex);
return null_event;
}
/*H323TRACE("Doing terminate action\n");*/
if (!(*menu_inuse))
{
PreserveLcdMessage = TRUE;
if(((WrapperMsg *) psEvent->pMsg)->reason == cmCallStateModeDisconnectedReject)
{
LcdShowMessage(H323_REMOTE_REJECT_THE_CALL);
}
else if(((WrapperMsg *) psEvent->pMsg)->reason == cmCallStateModeDisconnectedUnreachable)
{
LcdShowMessage(H323_REMOTE_UNREACHABLE);
}
else
{
LcdShowMessage(H323_UNKNOWN_ERROR);
}
}
AppTerminateAction( ST_H323_QUERY_AVAILABILITY_STATE );
PlayBusyTone(FIFTEEN_SEC);
return to_dead_end_state;
}
/**
* 播放忙音,产生to_dead_end_state
*/
int h323_query_availability_state_receive_not_available_event(s_event* psEvent,
s_task* psTask)
{
H323TRACE("action: h323_query_availability_state_receive_not_available_event\n");
PreserveLcdMessage = TRUE;
AppTerminateAction(ST_H323_QUERY_AVAILABILITY_STATE);
/* 未进入菜单 */
if (!(*menu_inuse))
{
LcdShowMessage(H323_REMOTE_BUSY);
}
PlayBusyTone(FIFTEEN_SEC);
return to_dead_end_state;
}
/**
* 收到CFU、CFB重定向消息;
* 向“B”发送CallRerouting.ReturnResult、terminate消息;
* 向"C"发送divertingLegInfo2消息;
* 出错则产生to_dead_end_state事件
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -