📄 cmgeneral.c
字号:
TRANSERR cmEvTransNewMessage(IN HSTRANSSESSION hsTransSession,
IN HATRANSSESSION haTransSession,
IN RvH323ConnectionType type,
IN int pvtNode,
IN void *hMsgContext);
TRANSERR cmEvTransWrite(IN HSTRANSSESSION hsTransSession,
IN HATRANSSESSION haTransSession );
TRANSERR cmEvTransBadMessage(IN HSTRANSSESSION hsTransSession,
IN HATRANSSESSION haTransSession,
IN RvH323ConnectionType type,
RvUint8 *msg,
int msgSize,
RvBool outgoing);
TRANSERR cmEvTransGetMessageNode(IN HAPPATRANS hAppATrans,
IN cmCallQ931MsgType msgType,
OUT int *nodeId);
TRANSERR cmEvTransNewH450Message(IN HSTRANSSESSION hsTransSession,
IN HATRANSSESSION haTransSession,
IN int msg,
IN int msgSize,
IN int msgType);
TRANSERR cmEvTransNewAnnexMMessage(IN HSTRANSSESSION hsTransSession,
IN HATRANSSESSION haTransSession,
IN int annexMElement,
IN int msgType);
TRANSERR cmEvTransNewAnnexLMessage(IN HSTRANSSESSION hsTransSession,
IN HATRANSSESSION haTransSession,
IN int annexLElement,
IN int msgType);
TRANSERR cmEvTransHostConnected(
IN HSTRANSHOST hsTransHost,
IN HATRANSHOST haTransHost,
IN TRANSCONNTYPE type,
IN RvBool isOutgoing);
TRANSERR cmEvTransHostClosed(
IN HSTRANSHOST hsTransHost,
IN HATRANSHOST haTransHost,
IN RvBool wasConnected);
TRANSERR cmEvTransNewRawMessage(IN HSTRANSHOST hsTransHost,
IN HATRANSHOST haTransHost,
IN RvH323ConnectionType type,
INOUT int pvtNode,
IN RvUint8 *msg,
IN int msgSize,
OUT int *decoded,
OUT void **hMsgContext);
TRANSERR cmEvTransSendRawMessage(
IN HSTRANSHOST hsTransHost,
IN HATRANSHOST haTransHost,
IN HSTRANSSESSION hsSession,
IN HATRANSSESSION haSession,
IN int pvtNode,
IN int size,
OUT RvUint8 *msg,
OUT int *msgSize);
TRANSERR cmEvTransHostNewMessage(
IN HSTRANSHOST hsTransHost,
IN HATRANSHOST haTransHost,
IN TRANSTYPE type,
IN int pvtNode,
IN void *hMsgContext);
TRANSERR cmEvTransHostBadMessage(
IN HSTRANSHOST hsTransHost,
IN HATRANSHOST haTransHost,
IN TRANSTYPE type,
IN RvUint8 *msg,
IN int msgSize,
IN RvBool outgoing,
IN void *hMsgContext);
TRANSERR cmEvTransHostListen(
IN HSTRANSHOST hsTransHost,
IN HATRANSHOST haTransHost,
IN TRANSCONNTYPE type,
IN cmTransportAddress *address);
TRANSERR cmEvTransHostListening(
IN HSTRANSHOST hsTransHost,
IN HATRANSHOST haTransHost,
IN TRANSCONNTYPE type,
IN cmTransportAddress *address,
IN RvBool error);
TRANSERR cmEvTransHostConnecting(
IN HSTRANSHOST hsTransHost,
IN HATRANSHOST haTransHost,
IN TRANSCONNTYPE type,
IN cmTransportAddress *address);
/************************************************************************
* rvCmWakeWatchdog
* purpose: Timeout of a watchdog interval. We should print statistics to
* the log here
* input : context - The stack's instance
* output : None
* return : None
************************************************************************/
static RvBool rvCmWakeWatchdog(IN void* context)
{
cmElem* app = (cmElem *)context;
RvLogDebug(&app->logWatchdog, (&app->logWatchdog,
"Watchdog Timer invoked:"));
RvWatchdogPrint(&app->watchdog, &app->logWatchdog);
return RV_TRUE;
}
/*---------------------------------------------------------------------------------------
* cmWatchdogResourceCallback :
*
* this function sets the resources of cm at the watchdog internal table
*
* Input: context - the watchdog handle of the ss instnace.
* resource - the requested resource's enumeration
* type - the typ eof info requested;
*
* Output: value - The actual resource value
* Return: non negative value - if success.
* negative value - if failed
*
*---------------------------------------------------------------------------------------*/
static int RVCALLCONV cmWatchdogResourceCallback(
IN void* context,
IN RvUint32 resource,
IN RvH323WatchdogResourceType type,
OUT RvUint32* value)
{
cmElem* app=(cmElem*)context;
if (resource == app->cmTimersResourceVal)
{
RvRaStatistics statistics;
if (RvH323TimerStatistics(app->hTimers, &statistics) >= 0)
{
switch (type)
{
case RvH323WatchdogMaxVal: *value = statistics.max; return 0;
case RvH323WatchdogMaxUsage: *value = statistics.maxUsage; return 0;
case RvH323WatchdogCurrent: *value = statistics.cur; return 0;
default:
return RV_ERROR_UNKNOWN;
}
}
}
else if (resource == app->cmValTreeResourceVal)
{
switch (type)
{
case RvH323WatchdogMaxVal: *value = pvtMaxSize(app->hVal); return 0;
case RvH323WatchdogMaxUsage: *value = pvtMaxUsage(app->hVal); return 0;
case RvH323WatchdogCurrent: *value = pvtCurSize(app->hVal); return 0;
default:
return RV_ERROR_UNKNOWN;
}
}
return RV_ERROR_UNKNOWN;
}
/********************************************************************************************
* cmStartUp
* purpose : This function should be called prior to any cmInit() or cmInitialize() calls.
* It must be called when several cmInitialize() functions are called from
* different threads at the same time.
* input : none
* output : none
* return : RV_OK on success, or a negative value on failure
********************************************************************************************/
RVAPI
RvStatus RVCALLCONV cmStartUp(void)
{
RvStatus res;
if (rvCmStartupTimes == 0)
{
RvMemoryInfo memInfo;
/* Make sure we've got a global mutex to synchronize between several stack instances */
res = RvCBaseInit();
if (res != RV_OK)
return res;
res = RvMutexConstruct(&rvCmGlobalMutex);
if (res != RV_OK)
{
RvCBaseEnd();
return res;
}
/* Count the number of allocated memory blocks */
RvMemoryGetInfo(NULL, &memInfo);
rvCmStartingMemorySize = memInfo.bytes_requested_total;
{
/* todo: What are we going to do with it? Leave it here??? */
RvThread* thInfo;
/* Create a threadInfo object if we have to */
thInfo = RvThreadCurrent();
if (thInfo == NULL)
{
if (RvMemoryAlloc(NULL, (void**)&thInfo, sizeof(RvThread)) == RV_OK)
{
if (RvThreadConstructFromUserThread(thInfo) == RV_OK)
RvThreadSetName(thInfo, "H323Main");
rvCmAllocatedThreadInfo = RV_TRUE;
}
}
}
}
RvMutexLock(&rvCmGlobalMutex);
rvCmStartupTimes++;
RvMutexUnlock(&rvCmGlobalMutex);
return RV_OK;
}
/********************************************************************************************
* cmShutdown
* purpose : This function should be called when all stack instances where destructed using
* cmEnd(), before shutting down the application.
* It should be called only if cmStartUp() was called.
* input : none
* output : none
* return : RV_OK on success, or a negative value on failure
* notes : cmShutdown() must be called from the same thread that called cmStartUp().
********************************************************************************************/
RVAPI
RvStatus RVCALLCONV cmShutdown(void)
{
if (rvCmStartupTimes <= 0)
return RV_ERROR_UNINITIALIZED;
RvMutexLock(&rvCmGlobalMutex);
rvCmStartupTimes--;
if (rvCmStartupTimes == 0)
{
RvMemoryInfo memInfo;
/* See if we have any memory leaks to deal with */
RvMemoryGetInfo(NULL, &memInfo);
if (rvCmStartingMemorySize != memInfo.bytes_requested_total)
{
RvLogSource tmpSrc;
/* Send an exception message to a CMAPI log after creating it */
RvLogSourceConstruct(RvLogGet(), &tmpSrc, RV_LOG_LIBCODE_H323, "CMAPI", "Conference Management API");
RvLogExcep(&tmpSrc, (&tmpSrc, "cmShutdown: Started with %d bytes, but ended with %d bytes!",
rvCmStartingMemorySize, memInfo.bytes_requested_total));
RvLogSourceDestruct(RvLogGet(), &tmpSrc);
}
/* Destruct the global lock - it's not needed anymore */
RvMutexDestruct(&rvCmGlobalMutex);
/* Deallocate the thread object we're using
todo: fix somehow
if (rvCmAllocatedThreadInfo == RV_TRUE)
{
RvThread* thInfo = RvThreadCurrent();
if (thInfo != NULL)
RvMemoryFree(thInfo);
rvCmAllocatedThreadInfo = RV_FALSE;
}*/
/* Close the common core */
RvCBaseEnd();
}
else
RvMutexUnlock(&rvCmGlobalMutex);
return RV_OK;
}
/************************************************************************
* cmInitialize
* purpose: Initializes the Conference Manager instance.
* This function must be called before any other H.323 function
* except cmGetVersion().
* input : name - Configuration file name to use
* output : lphApp - Application handle created for the initialized
* stack instance
* return : non-negative value on success
* negative value on failure
************************************************************************/
RVAPI
int RVCALLCONV cmInitialize(IN char * name, OUT LPHAPP lphApp)
{
TRANSSESSIONEVENTS tse =
{
cmEvTransNewSession,cmEvTransConnectionOnSessionClosed,
cmEvTransSessionNewConnection,cmEvTransNewMessage,
NULL/*cmEvTransWrite*/,cmEvTransBadMessage,cmEvTransGetMessageNode,
cmEvTransNewH450Message,cmEvTransNewAnnexMMessage,cmEvTransNewAnnexLMessage
};
TRANSHOSTEVENTS the =
{
cmEvTransHostConnected,
cmEvTransHostClosed,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -