📄 endpoint.c
字号:
/******************************************************************** * * File: endpoint.c * * Description: * Endpoint functions. * * Revisions: * 04-may-01 J.H and S.J.M initial version. * * Copyright 2003 Netergy Microelectronics, Inc. All rights reserved. * ********************************************************************/#include "h248app.h"#include "stdlib.h"void EndPointInit(END_POINT *pEndPoint, WORD wChannel){ pthread_mutexattr_t attr; APPLOG(LOG_INFO, "EndPointInit():: channel %d\n", wChannel); memset(pEndPoint, 0, sizeof(END_POINT)); pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&(pEndPoint->mMutex), &attr); pthread_mutexattr_destroy(&attr); pEndPoint->wChannel = wChannel;}void _H248LineEvent(END_POINT *pEndPoint, E_H248_EVENTTYPE eEvent){ H248_EVENT xEvent; memset(&xEvent, 0, sizeof(H248_EVENT)); xEvent.eType = eEvent; H248InstanceSendEvent(pEndPoint->hInstance, &xEvent); _SendRTPTelephoneEvent(pEndPoint, eEvent, START);}/************************************************************************** * _OffHookEvent * Called when Handset is placed off hook (picked up) **************************************************************************/void _OffHookEvent(END_POINT *pEndPoint){ _H248LineEvent(pEndPoint, H248_EVENT_L_HD);}/************************************************************************** * _OnHookEvent() * Called when Handset is placed on hook **************************************************************************/void _OnHookEvent(END_POINT *pEndPoint){ _H248LineEvent(pEndPoint, H248_EVENT_L_HU);}/************************************************************************** * _ProcessHandset * Checks for any handset activity and handle the applied signals **************************************************************************/void EndPointProcess(END_POINT *pEndPoint){ unsigned char chKey[20]; LONG lReturnCode; pthread_mutex_lock(&(pEndPoint->mMutex)); lReturnCode = HandsetProcess(pEndPoint->wChannel, chKey); switch(lReturnCode) { case HANDSET_ON_HOOK_EVENT: /* On hook. Include application specific hook handling here */ _H248LineEvent(pEndPoint, H248_EVENT_L_HU); break; case HANDSET_OFF_HOOK_EVENT: /* Off hook. Include application specific hook handling here */ _H248LineEvent(pEndPoint, H248_EVENT_L_HD); break; case HANDSET_FLASH_HOOK_EVENT: _H248LineEvent(pEndPoint, H248_EVENT_L_HF); break; case HANDSET_DTMF_START_EVENT: /* A key was pressed. Include application specific key handling here */ switch(chKey[0]) { /* DTMF digit */ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '*': case '#': /* call the dial function to send the event */ _H248LineEvent(pEndPoint , chKey[0]); break; } break; default: break; } pthread_mutex_unlock(&(pEndPoint->mMutex));}void msleep(DWORD nMsec){ struct timespec stTime; stTime.tv_sec=0; stTime.tv_nsec=nMsec; nanosleep(&stTime,NULL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -