int InitialiseOPAL() { OpalMessage command; OpalMessage * response; unsigned version; if ((hDLL = OPEN_LIBRARY(OPAL_DLL)) == NULL) { fprintf(stderr, "Could not file %s\n", OPAL_DLL); return 0; } InitialiseFunction = (OpalInitialiseFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_INITIALISE_FUNCTION ); ShutDownFunction = (OpalShutDownFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_SHUTDOWN_FUNCTION ); GetMessageFunction = (OpalGetMessageFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_GET_MESSAGE_FUNCTION ); SendMessageFunction = (OpalSendMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_SEND_MESSAGE_FUNCTION); FreeMessageFunction = (OpalFreeMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_FREE_MESSAGE_FUNCTION); if (InitialiseFunction == NULL || ShutDownFunction == NULL || GetMessageFunction == NULL || SendMessageFunction == NULL || FreeMessageFunction == NULL) { fputs("OPAL.DLL is invalid\n", stderr); return 0; } /////////////////////////////////////////////// // Initialisation version = OPAL_C_API_VERSION; if ((hOPAL = InitialiseFunction(&version, "pc h323 sip TraceLevel=4")) == NULL) { fputs("Could not initialise OPAL\n", stderr); return 0; } // General options memset(&command, 0, sizeof(command)); command.m_type = OpalCmdSetGeneralParameters; if ((response = MySendCommand(&command, "Could not set general options")) == NULL) return 0; FreeMessageFunction(response); // Options across all protocols memset(&command, 0, sizeof(command)); command.m_type = OpalCmdSetProtocolParameters; command.m_param.m_protocol.m_name = "robertj"; command.m_param.m_protocol.m_displayName = "Robert Jongbloed"; command.m_param.m_protocol.m_interfaceAddresses = "*"; if ((response = MySendCommand(&command, "Could not set protocol options")) == NULL) return 0; FreeMessageFunction(response); return 1; }
int InitialiseOPAL() { OpalMessage command; OpalMessage * response; unsigned version; if ((hDLL = OPEN_LIBRARY(OPAL_DLL)) == NULL) { fprintf(stderr, "Could not file %s\n", OPAL_DLL); return 0; } InitialiseFunction = (OpalInitialiseFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_INITIALISE_FUNCTION ); ShutDownFunction = (OpalShutDownFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_SHUTDOWN_FUNCTION ); GetMessageFunction = (OpalGetMessageFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_GET_MESSAGE_FUNCTION ); SendMessageFunction = (OpalSendMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_SEND_MESSAGE_FUNCTION); FreeMessageFunction = (OpalFreeMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_FREE_MESSAGE_FUNCTION); if (InitialiseFunction == NULL || ShutDownFunction == NULL || GetMessageFunction == NULL || SendMessageFunction == NULL || FreeMessageFunction == NULL) { fputs("OPAL.DLL is invalid\n", stderr); return 0; } /////////////////////////////////////////////// // Initialisation #if LOCAL_MEDIA #define LOCAL_PREFIX OPAL_PREFIX_LOCAL #else #define LOCAL_PREFIX OPAL_PREFIX_PCSS #endif version = OPAL_C_API_VERSION; if ((hOPAL = InitialiseFunction(&version, OPAL_PREFIX_H323 " " OPAL_PREFIX_SIP " " OPAL_PREFIX_IAX2 " " LOCAL_PREFIX " TraceLevel=4")) == NULL) { fputs("Could not initialise OPAL\n", stderr); return 0; } // General options memset(&command, 0, sizeof(command)); command.m_type = OpalCmdSetGeneralParameters; //command.m_param.m_general.m_audioRecordDevice = "Camera Microphone (2- Logitech"; command.m_param.m_general.m_autoRxMedia = command.m_param.m_general.m_autoTxMedia = "audio"; #if LOCAL_MEDIA command.m_param.m_general.m_mediaReadData = MyReadMediaData; command.m_param.m_general.m_mediaWriteData = MyWriteMediaData; command.m_param.m_general.m_mediaDataHeader = OpalMediaDataPayloadOnly; #endif if ((response = MySendCommand(&command, "Could not set general options")) == NULL) return 0; FreeMessageFunction(response); // Options across all protocols memset(&command, 0, sizeof(command)); command.m_type = OpalCmdSetProtocolParameters; command.m_param.m_protocol.m_name = "robertj"; command.m_param.m_protocol.m_displayName = "Robert Jongbloed"; command.m_param.m_protocol.m_interfaceAddresses = "*"; if ((response = MySendCommand(&command, "Could not set protocol options")) == NULL) return 0; FreeMessageFunction(response); return 1; }
int InitialiseOPAL() { OpalMessage command; OpalMessage * response; unsigned version; static const char OPALOptions[] = OPAL_PREFIX_H323 " " OPAL_PREFIX_SIP " " OPAL_PREFIX_IAX2 " " #if LOCAL_MEDIA OPAL_PREFIX_LOCAL #else OPAL_PREFIX_PCSS #endif " " OPAL_PREFIX_IVR " TraceLevel=4 TraceFile=debugstream"; if ((hDLL = OPEN_LIBRARY(OPAL_DLL)) == NULL) { fprintf(stderr, "Could not file %s\n", OPAL_DLL); return 0; } InitialiseFunction = (OpalInitialiseFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_INITIALISE_FUNCTION ); ShutDownFunction = (OpalShutDownFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_SHUTDOWN_FUNCTION ); GetMessageFunction = (OpalGetMessageFunction )GET_LIBRARY_FUNCTION(hDLL, OPAL_GET_MESSAGE_FUNCTION ); SendMessageFunction = (OpalSendMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_SEND_MESSAGE_FUNCTION); FreeMessageFunction = (OpalFreeMessageFunction)GET_LIBRARY_FUNCTION(hDLL, OPAL_FREE_MESSAGE_FUNCTION); if (InitialiseFunction == NULL || ShutDownFunction == NULL || GetMessageFunction == NULL || SendMessageFunction == NULL || FreeMessageFunction == NULL) { fputs("OPAL.DLL is invalid\n", stderr); return 0; } /////////////////////////////////////////////// // Initialisation version = OPAL_C_API_VERSION; if ((hOPAL = InitialiseFunction(&version, OPALOptions)) == NULL) { fputs("Could not initialise OPAL\n", stderr); return 0; } #if 0 // Test shut down and re-initialisation ShutDownFunction(hOPAL); if ((hOPAL = InitialiseFunction(&version, OPALOptions)) == NULL) { fputs("Could not re-initialise OPAL\n", stderr); return 0; } #endif // General options memset(&command, 0, sizeof(command)); command.m_type = OpalCmdSetGeneralParameters; //command.m_param.m_general.m_audioRecordDevice = "Camera Microphone (2- Logitech"; command.m_param.m_general.m_autoRxMedia = command.m_param.m_general.m_autoTxMedia = "audio"; command.m_param.m_general.m_stunServer = "stun.voxgratia.org"; command.m_param.m_general.m_mediaMask = "RFC4175*"; #if LOCAL_MEDIA command.m_param.m_general.m_mediaReadData = MyReadMediaData; command.m_param.m_general.m_mediaWriteData = MyWriteMediaData; command.m_param.m_general.m_mediaDataHeader = OpalMediaDataPayloadOnly; #endif if ((response = MySendCommand(&command, "Could not set general options")) == NULL) return 0; FreeMessageFunction(response); // Options across all protocols memset(&command, 0, sizeof(command)); command.m_type = OpalCmdSetProtocolParameters; command.m_param.m_protocol.m_userName = "******"; command.m_param.m_protocol.m_displayName = "Robert Jongbloed"; command.m_param.m_protocol.m_interfaceAddresses = "*"; if ((response = MySendCommand(&command, "Could not set protocol options")) == NULL) return 0; FreeMessageFunction(response); memset(&command, 0, sizeof(command)); command.m_type = OpalCmdSetProtocolParameters; command.m_param.m_protocol.m_prefix = "sip"; command.m_param.m_protocol.m_defaultOptions = "PRACK-Mode=0\nInitial-Offer=false"; if ((response = MySendCommand(&command, "Could not set SIP options")) == NULL) return 0; FreeMessageFunction(response); return 1; }