sipXcallLib home page


Macros | Functions | Variables
sipXtapiEvents.cpp File Reference
#include <stddef.h>
#include <assert.h>
#include "tapi/sipXtapiEvents.h"
#include "tapi/sipXtapiInternal.h"
#include "tapi/SipXHandleMap.h"
#include "tapi/SipXEventDispatcher.h"
#include "utl/UtlSList.h"
#include "utl/UtlSListIterator.h"
#include "utl/UtlVoidPtr.h"
#include "os/OsMutex.h"
#include "utl/UtlString.h"
#include "os/OsLock.h"
#include "net/Url.h"
#include "utl/UtlHashMap.h"
#include "net/SipSession.h"
#include "cp/CallManager.h"
Include dependency graph for sipXtapiEvents.cpp:

Macros

#define SNPRINTF   snprintf
 
#define SAFE_STRDUP(X)   (((X) == NULL) ? NULL : strdup((X)))
 

Functions

const char * convertSubscriptionStateToString (SIPX_SUBSCRIPTION_STATE state)
 
const char * convertSubscriptionCauseToString (SIPX_SUBSCRIPTION_CAUSE cause)
 
SIPXTAPI_API SIPX_RESULT sipxDuplicateEvent (SIPX_EVENT_CATEGORY category, const void *pEventSource, void **pEventCopy)
 Duplicate the event information for a sipXtapi event. More...
 
SIPXTAPI_API SIPX_RESULT sipxFreeDuplicatedEvent (SIPX_EVENT_CATEGORY category, void *pEventCopy)
 Frees up memory allocated as part of sipxDuplicateEvent. More...
 
SIPXTAPI_API char * sipxCallEventToString (SIPX_CALLSTATE_EVENT event, SIPX_CALLSTATE_CAUSE cause, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated call state event ids. More...
 
SIPXTAPI_API char * sipxLineEventToString (SIPX_LINESTATE_EVENT event, SIPX_LINESTATE_CAUSE cause, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated line event ids. More...
 
SIPXTAPI_API char * sipxEventToString (const SIPX_EVENT_CATEGORY category, const void *pEvent, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated event. More...
 
void ReportCallback (SIPX_CALL hCall, SIPX_LINE hLine, SIPX_CALLSTATE_EVENT event, SIPX_CALLSTATE_CAUSE cause, void *pUserData)
 
void sipxFireCallEvent (const void *pSrc, const char *szCallId, SipSession *pSession, const char *szRemoteAddress, SIPX_CALLSTATE_EVENT event, SIPX_CALLSTATE_CAUSE cause, void *pEventData, const char *szRemoteAssertedIdentity)
 Fire events to interested listeners (call events only). More...
 
void sipxFireMediaEvent (const void *pSrc, const char *szCallId, const char *szRemoteAddress, SIPX_MEDIA_EVENT event, SIPX_MEDIA_CAUSE cause, SIPX_MEDIA_TYPE type, void *pEventData)
 Fires events to interested listener (media events only) More...
 
void sipxFireKeepaliveEvent (const void *pSrc, SIPX_KEEPALIVE_EVENT event, SIPX_KEEPALIVE_CAUSE cause, SIPX_KEEPALIVE_TYPE type, const char *szRemoteAddress, int remotePort, int keepAliveSecs, const char *szFeedbackAddress, int feedbackPort)
 Fires events to interested listener (keepalive events only) More...
 
SIPXTAPI_API SIPX_RESULT sipxEventListenerAdd (const SIPX_INST hInst, SIPX_EVENT_CALLBACK_PROC pCallbackProc, void *pUserData)
 Add a callback/observer for the purpose of receiving sipXtapi events. More...
 
SIPXTAPI_API SIPX_RESULT sipxEventListenerRemove (const SIPX_INST hInst, SIPX_EVENT_CALLBACK_PROC pCallbackProc, void *pUserData)
 Remove a sipXtapi event callback/observer. More...
 
SIPX_RESULT __sipxEventListenerAdd (const SIPX_INST hInst, SIPX_EVENT_CALLBACK_PROC pCallbackProc, void *pUserData)
 
SIPX_RESULT __sipxEventListenerRemove (const SIPX_INST hInst, SIPX_EVENT_CALLBACK_PROC pCallbackProc, void *pUserData)
 
void sipxUpdateListeners (SIPX_INST hOldInst, SIPX_INST hNewInst)
 
SIPXTAPI_API char * sipxConfigEventToString (SIPX_CONFIG_EVENT event, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated config event. More...
 
SIPXTAPI_API char * sipxMediaEventToString (SIPX_MEDIA_EVENT event, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated media event. More...
 
SIPXTAPI_API char * sipxMediaCauseToString (SIPX_MEDIA_CAUSE cause, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated media cause. More...
 
SIPXTAPI_API char * sipxKeepaliveEventToString (SIPX_KEEPALIVE_EVENT event, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated keepalive event. More...
 
SIPXTAPI_API char * sipxKeepaliveCauseToString (SIPX_KEEPALIVE_CAUSE cause, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated keepalive cause. More...
 
SIPXTAPI_API char * sipxSecurityEventToString (SIPX_SECURITY_EVENT event, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated security event. More...
 
SIPXTAPI_API char * sipxSecurityCauseToString (SIPX_SECURITY_CAUSE cause, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated security cause. More...
 
SIPXTAPI_API char * sipxSubStatusStateToString (const SIPX_SUBSCRIPTION_STATE state, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated subscription status state. More...
 
SIPXTAPI_API char * sipxSubStatusCauseToString (const SIPX_SUBSCRIPTION_CAUSE cause, char *szBuffer, size_t nBuffer)
 Create a printable string version of the designated subscription status cause. More...
 
void sipxFireLineEvent (const void *pSrc, const char *szLineIdentifier, SIPX_LINESTATE_EVENT event, SIPX_LINESTATE_CAUSE cause, const char *bodyBytes)
 Fires a Line Event to the listeners. More...
 
bool sipxFireEvent (const void *pSrc, SIPX_EVENT_CATEGORY category, void *pInfo)
 Bubbles up all non-line and non-call events to the application layer. More...
 

Variables

UtlBoolean g_bListenersEnabled = true
 
UtlSList * g_pEventListeners = new UtlSList()
 
OsMutex * g_pEventListenerLock = new OsMutex(OsMutex::Q_FIFO)
 
SipXHandleMapgpCallHandleMap
 Global Map of call handles. More...
 

Macro Definition Documentation

#define SAFE_STRDUP (   X)    (((X) == NULL) ? NULL : strdup((X)))
#define SNPRINTF   snprintf

Function Documentation

SIPX_RESULT __sipxEventListenerAdd ( const SIPX_INST  hInst,
SIPX_EVENT_CALLBACK_PROC  pCallbackProc,
void *  pUserData 
)
SIPX_RESULT __sipxEventListenerRemove ( const SIPX_INST  hInst,
SIPX_EVENT_CALLBACK_PROC  pCallbackProc,
void *  pUserData 
)
const char* convertSubscriptionCauseToString ( SIPX_SUBSCRIPTION_CAUSE  cause)
const char* convertSubscriptionStateToString ( SIPX_SUBSCRIPTION_STATE  state)
void ReportCallback ( SIPX_CALL  hCall,
SIPX_LINE  hLine,
SIPX_CALLSTATE_EVENT  event,
SIPX_CALLSTATE_CAUSE  cause,
void *  pUserData 
)
SIPXTAPI_API char* sipxCallEventToString ( SIPX_CALLSTATE_EVENT  event,
SIPX_CALLSTATE_CAUSE  cause,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated call state event ids.

This is generally used for debugging.

Parameters
eventsipxtapi event code
causesipxtapi cause event code
szBufferbuffer to store event string
nBufferlength of string buffer szBuffer
SIPXTAPI_API char* sipxConfigEventToString ( SIPX_CONFIG_EVENT  event,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated config event.

This is generally used for debugging.

Parameters
eventConfiguration event id
szBufferBuffer to store event string
nBufferLength of string buffer szBuffer
SIPXTAPI_API SIPX_RESULT sipxDuplicateEvent ( SIPX_EVENT_CATEGORY  category,
const void *  pEventSource,
void **  pEventCopy 
)

Duplicate the event information for a sipXtapi event.

This method is only needed if you wish to post the event information to another thread context. Once the event has been handled, you must call sipxFreeDuplicatedEvent on the copy to avoid memory leaks.

Parameters
categoryCategory type supplied by the sipXtapi event callback.
pEventSourceSource of event data supplied by the sipXtapi event callback.
pEventCopyNew copy of the event data. This data must be freed by calling sipxFreeDuplicatedEvent.
SIPXTAPI_API SIPX_RESULT sipxEventListenerAdd ( const SIPX_INST  hInst,
SIPX_EVENT_CALLBACK_PROC  pCallbackProc,
void *  pUserData 
)

Add a callback/observer for the purpose of receiving sipXtapi events.

Parameters
hInstInstance pointer obtained by sipxInitialize.
pCallbackProcFunction to receive sipx events
pUserDatauser data passed along with event data
SIPXTAPI_API SIPX_RESULT sipxEventListenerRemove ( const SIPX_INST  hInst,
SIPX_EVENT_CALLBACK_PROC  pCallbackProc,
void *  pUserData 
)

Remove a sipXtapi event callback/observer.

Supply the same pCallbackProc and pUserData values as sipxEventListenerAdd.

Parameters
hInstInstance pointer obtained by sipxInitialize.
pCallbackProcFunction used to receive sipx events
pUserDatauser data specified as part of sipxListenerAdd
SIPXTAPI_API char* sipxEventToString ( const SIPX_EVENT_CATEGORY  category,
const void *  pEvent,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated event.

This is generally used for debugging.

Parameters
categoryEvent category code
pEventPointer to the Event.
szBufferbuffer to store event string
nBufferlength of string buffer szBuffer
void sipxFireCallEvent ( const void *  pSrc,
const char *  szCallId,
SipSession *  pSession,
const char *  szRemoteAddress,
SIPX_CALLSTATE_EVENT  event,
SIPX_CALLSTATE_CAUSE  cause,
void *  pEventData,
const char *  szRemoteAssertedIdentity 
)

Fire events to interested listeners (call events only).

bool sipxFireEvent ( const void *  pSrc,
SIPX_EVENT_CATEGORY  category,
void *  pInfo 
)

Bubbles up all non-line and non-call events to the application layer.

void sipxFireKeepaliveEvent ( const void *  pSrc,
SIPX_KEEPALIVE_EVENT  event,
SIPX_KEEPALIVE_CAUSE  cause,
SIPX_KEEPALIVE_TYPE  type,
const char *  szRemoteAddress,
int  remotePort,
int  keepAliveSecs,
const char *  szFeedbackAddress,
int  feedbackPort 
)

Fires events to interested listener (keepalive events only)

void sipxFireLineEvent ( const void *  pSrc,
const char *  szLineIdentifier,
SIPX_LINESTATE_EVENT  event,
SIPX_LINESTATE_CAUSE  cause,
const char *  bodyBytes 
)

Fires a Line Event to the listeners.

void sipxFireMediaEvent ( const void *  pSrc,
const char *  szCallId,
const char *  szRemoteAddress,
SIPX_MEDIA_EVENT  event,
SIPX_MEDIA_CAUSE  cause,
SIPX_MEDIA_TYPE  type,
void *  pEventData 
)

Fires events to interested listener (media events only)

SIPXTAPI_API SIPX_RESULT sipxFreeDuplicatedEvent ( SIPX_EVENT_CATEGORY  category,
void *  pEventCopy 
)

Frees up memory allocated as part of sipxDuplicateEvent.

Do not call this API on pointers received as part of the sipXtapi call back.

Parameters
categoryCategory type supplied by the sipXtapi event callback.
pEventCopyCopy of event data supplied by sipxDuplicateEvent.
SIPXTAPI_API char* sipxKeepaliveCauseToString ( SIPX_KEEPALIVE_CAUSE  cause,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated keepalive cause.

This is generally used for debugging.

Parameters
causeKeepalive cause id
szBufferBuffer to store cause string
nBufferLength of string buffer szBuffer
SIPXTAPI_API char* sipxKeepaliveEventToString ( SIPX_KEEPALIVE_EVENT  event,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated keepalive event.

This is generally used for debugging.

Parameters
eventKeepalive event id
szBufferBuffer to store event string
nBufferLength of string buffer szBuffer
SIPXTAPI_API char* sipxLineEventToString ( SIPX_LINESTATE_EVENT  event,
SIPX_LINESTATE_CAUSE  cause,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated line event ids.

This is generally used for debugging.

Deprecated:
Use sipxEventToString instead.
Parameters
eventmajor event type id
causeevent type id
szBufferbuffer to store event string
nBufferlength of string buffer szBuffer
SIPXTAPI_API char* sipxMediaCauseToString ( SIPX_MEDIA_CAUSE  cause,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated media cause.

This is generally used for debugging.

Parameters
causeMedia cause id
szBufferBuffer to store cause string
nBufferLength of string buffer szBuffer
SIPXTAPI_API char* sipxMediaEventToString ( SIPX_MEDIA_EVENT  event,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated media event.

This is generally used for debugging.

Parameters
eventMedia event id
szBufferBuffer to store event string
nBufferLength of string buffer szBuffer
SIPXTAPI_API char* sipxSecurityCauseToString ( SIPX_SECURITY_CAUSE  cause,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated security cause.

This is generally used for debugging.

Parameters
causeSecurity cause id
szBufferBuffer to store cause string
nBufferLength of string buffer szBuffer
SIPXTAPI_API char* sipxSecurityEventToString ( SIPX_SECURITY_EVENT  event,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated security event.

This is generally used for debugging.

Parameters
eventSecurity event id
szBufferBuffer to store event string
nBufferLength of string buffer szBuffer
SIPXTAPI_API char* sipxSubStatusCauseToString ( SIPX_SUBSCRIPTION_CAUSE  cause,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated subscription status cause.

This is generally used for debugging.

Parameters
causeSubscription cause id
szBufferBuffer to store event string
nBufferLength of string buffer szBuffer
SIPXTAPI_API char* sipxSubStatusStateToString ( SIPX_SUBSCRIPTION_STATE  state,
char *  szBuffer,
size_t  nBuffer 
)

Create a printable string version of the designated subscription status state.

This is generally used for debugging.

Parameters
stateSubscription state id
szBufferBuffer to store event string
nBufferLength of string buffer szBuffer
void sipxUpdateListeners ( SIPX_INST  hOldInst,
SIPX_INST  hNewInst 
)

Variable Documentation

UtlBoolean g_bListenersEnabled = true
OsMutex* g_pEventListenerLock = new OsMutex(OsMutex::Q_FIFO)
UtlSList* g_pEventListeners = new UtlSList()
SipXHandleMap* gpCallHandleMap

Global Map of call handles.