本文整理汇总了C++中SipUserAgent类的典型用法代码示例。如果您正苦于以下问题:C++ SipUserAgent类的具体用法?C++ SipUserAgent怎么用?C++ SipUserAgent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SipUserAgent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setUp
void setUp()
{
hostIp = "127.0.0.1";
eventName = SIP_EVENT_MESSAGE_SUMMARY;
mwiMimeType = CONTENT_TYPE_SIMPLE_MESSAGE_SUMMARY;;
// Construct a user agent that will function both as the subscriber
// and the notfier.
// Construct the URI of the notifier, which is also the URI of
// the subscriber.
// Also construct the name-addr version of the URI, which may be
// different if it has a "transport" parameter.
// And the resource-id to use, which is the AOR with any
// parameters stripped off.
createTestSipUserAgent(hostIp,
"111",
userAgentp,
aor,
aor_name_addr,
aor_contact_name_addr,
resource_id);
subServerp =
SipSubscribeServer::buildBasicServer(*userAgentp,
eventName);
subServerp->start();
// Get pointers to the Subscription Manager and Dialog Manager.
subMgrp = subServerp->getSubscriptionMgr(eventName);
CPPUNIT_ASSERT(subMgrp);
dialogMgrp = subMgrp->getDialogMgr();
CPPUNIT_ASSERT(dialogMgrp);
// Create a simple Subscription client
// Register an interest in SUBSCRIBE responses and NOTIFY requests
// for this event type
userAgentp->addMessageObserver(incomingClientMsgQueue,
SIP_SUBSCRIBE_METHOD,
FALSE, // no requests
TRUE, // reponses
TRUE, // incoming
FALSE, // no outgoing
eventName,
NULL,
NULL);
userAgentp->addMessageObserver(incomingClientMsgQueue,
SIP_NOTIFY_METHOD,
TRUE, // requests
FALSE, // not reponses
TRUE, // incoming
FALSE, // no outgoing
eventName,
NULL,
NULL);
}
示例2: osPrintf
SipConfigServerAgent* SipConfigServerAgent::startAgents(const char* configFileName)
{
int sipTcpPort;
int sipUdpPort;
int sipTlsPort;
OsConfigDb configDb;
if(configDb.loadFromFile(configFileName) == OS_SUCCESS)
{
osPrintf("Found config file: %s\n", configFileName);
}
else
{
configDb.set("SIP_SDS_UDP_PORT", "5090");
configDb.set("SIP_SDS_TCP_PORT", "5090");
configDb.set("SIP_SDS_TLS_PORT", "5091");
configDb.set(CONFIG_SETTING_LOG_DIR, "");
configDb.set(CONFIG_SETTING_LOG_LEVEL, "");
configDb.set(CONFIG_SETTING_LOG_CONSOLE, "");
if (configDb.storeToFile(configFileName) != OS_SUCCESS)
osPrintf("Could not store config file: %s\n", configFileName);
}
sipTcpPort = configDb.getPort("SIP_SDS_UDP_PORT") ;
sipUdpPort = configDb.getPort("SIP_SDS_TCP_PORT") ;
sipTlsPort = configDb.getPort("SIP_SDS_TLS_PORT") ;
// Start the sip stack
SipUserAgent* pAgent = new SipUserAgent(sipTcpPort,
sipUdpPort,
sipTlsPort,
NULL, // public IP address (nopt used in proxy)
NULL, // default user (not used in proxy)
NULL, // default SIP address (not used in proxy)
NULL, // outbound proxy
NULL, // directory server
NULL, // registry server
NULL, // auth scheme
NULL, //auth realm
NULL, // auth DB
NULL, // auth user IDs
NULL, // auth passwords
NULL, // line mgr
SIP_DEFAULT_RTT, // first resend timeout
TRUE, // default to UA transaction
SIPUA_DEFAULT_SERVER_UDP_BUFFER_SIZE, // socket layer read buffer size
SIPUA_DEFAULT_SERVER_OSMSG_QUEUE_SIZE // OsServerTask message queue size
);
pAgent->start();
// Start the SipConfigServerAgent
SipConfigServerAgent* pConfigAgent = new SipConfigServerAgent(pAgent) ;
pConfigAgent->start() ;
return(pConfigAgent);
}
示例3: setUp
void setUp()
{
// Construct a SipUserAgent to provide the isMyHostAlias recognizer
UserAgent = new SipUserAgent(0, 0, -1);
UtlString internalDomainAlias("example.com:5060");
UserAgent->setHostAliases(internalDomainAlias);
UtlString internalHostAlias("internal.example.com:5060");
UserAgent->setHostAliases(internalHostAlias);
UtlString externalAlias("external.example.net:5060");
UserAgent->setHostAliases(externalAlias);
}
示例4: testOnOffHook
void testOnOffHook()
{
PsMsg *keyMsg;
SipUserAgent *ua = CpTestSupport::newSipUserAgent();
ua->start();
CallManager *callmgr = CpTestSupport::newCallManager(ua);
callmgr->start();
keyMsg = new PsMsg(PsMsg::HOOKSW_STATE, NULL, PsHookswTask::OFF_HOOK, 0);
callmgr->postMessage(*keyMsg);
delete keyMsg;
keyMsg = new PsMsg(PsMsg::BUTTON_DOWN, NULL, 0, '1');
callmgr->postMessage(*keyMsg);
delete keyMsg;
keyMsg = new PsMsg(PsMsg::BUTTON_UP, NULL, 0, '1');
callmgr->postMessage(*keyMsg);
delete keyMsg;
keyMsg = new PsMsg(PsMsg::BUTTON_DOWN, NULL, 0, '0');
callmgr->postMessage(*keyMsg);
delete keyMsg;
keyMsg = new PsMsg(PsMsg::BUTTON_UP, NULL, 0, '0');
callmgr->postMessage(*keyMsg);
delete keyMsg;
keyMsg = new PsMsg(PsMsg::BUTTON_DOWN, NULL, 0, '0');
callmgr->postMessage(*keyMsg);
delete keyMsg;
keyMsg = new PsMsg(PsMsg::BUTTON_UP, NULL, 0, '0');
callmgr->postMessage(*keyMsg);
delete keyMsg;
keyMsg = new PsMsg(PsMsg::BUTTON_DOWN, NULL, 0, '4');
callmgr->postMessage(*keyMsg);
delete keyMsg;
keyMsg = new PsMsg(PsMsg::BUTTON_UP, NULL, 0, '4');
callmgr->postMessage(*keyMsg);
delete keyMsg;
delete callmgr;
delete ua;
}
示例5: testPickupCall
void testPickupCall()
{
PsMsg *keyMsg;
SipUserAgent *ua = CpTestSupport::newSipUserAgent();
ua->start();
CallManager *callmgr = CpTestSupport::newCallManager(ua);
callmgr->start();
// Wait a little and pick up the hook assuming it is ringing
OsTask::delay(30000);
printf("Picking up ringing phone\n");
keyMsg = new PsMsg(PsMsg::HOOKSW_STATE, NULL, PsHookswTask::OFF_HOOK, 0);
callmgr->postMessage(*keyMsg);
delete keyMsg;
delete callmgr;
delete ua;
}
示例6: getMessageQueue
// Constructor
SipPimClient::SipPimClient(SipUserAgent& userAgent,
Url& presentityAor)
{
presentityAor.toString(mFromField);
mPresentityAor = presentityAor;
mpUserAgent = &userAgent;
// Register to get incoming MESSAGE requests
OsMsgQ* myQueue = getMessageQueue();
userAgent.addMessageObserver(*myQueue,
SIP_MESSAGE_METHOD,
TRUE, // requests
FALSE, // responces
TRUE, // incoming
FALSE); // outgoing
}
示例7: main
//
// The main entry point to the sipXpark
//
int main(int argc, char* argv[])
{
// Configuration Database (used for OsSysLog)
OsConfigDb configDb;
// Register Signal handlers so we can perform graceful shutdown
pt_signal(SIGINT, sigHandler); // Trap Ctrl-C on NT
pt_signal(SIGILL, sigHandler);
pt_signal(SIGABRT, sigHandler); // Abort signal 6
pt_signal(SIGFPE, sigHandler); // Floading Point Exception
pt_signal(SIGSEGV, sigHandler); // Address access violations signal 11
pt_signal(SIGTERM, sigHandler); // Trap kill -15 on UNIX
#if defined(__pingtel_on_posix__)
pt_signal(SIGHUP, sigHandler); // Hangup
pt_signal(SIGQUIT, sigHandler);
pt_signal(SIGPIPE, SIG_IGN); // Handle TCP Failure
pt_signal(SIGBUS, sigHandler);
pt_signal(SIGSYS, sigHandler);
pt_signal(SIGXCPU, sigHandler);
pt_signal(SIGXFSZ, sigHandler);
pt_signal(SIGUSR1, sigHandler);
pt_signal(SIGUSR2, sigHandler);
#endif
UtlString argString;
for (int argIndex = 1; argIndex < argc; argIndex++)
{
osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if(argString.compareTo("-v") == 0)
{
osPrintf("Version: %s (%s)\n", SIPXCHANGE_VERSION, SIPXCHANGE_VERSION_COMMENT);
return(1);
}
else
{
osPrintf("usage: %s [-v]\nwhere:\n -v provides the software version\n",
argv[0]);
return(1);
}
}
// Load configuration file file
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
exit(1);
}
// Initialize log file
initSysLog(&configDb);
// Read the user agent parameters from the config file.
int UdpPort;
if (configDb.get(CONFIG_SETTING_UDP_PORT, UdpPort) != OS_SUCCESS)
{
UdpPort = DEFAULT_UDP_PORT;
}
int TcpPort;
if (configDb.get(CONFIG_SETTING_TCP_PORT, TcpPort) != OS_SUCCESS)
{
TcpPort = DEFAULT_TCP_PORT;
}
int HttpPort;
if (configDb.get(CONFIG_SETTING_HTTP_PORT, HttpPort) != OS_SUCCESS)
{
HttpPort = DEFAULT_HTTP_PORT;
}
// Bind the SIP user agent to a port and start it up
SipUserAgent* userAgent = new SipUserAgent(TcpPort, UdpPort);
userAgent->start();
UtlString domainName;
configDb.get(CONFIG_SETTING_DOMAIN_NAME, domainName);
int refreshTimeout;
//.........这里部分代码省略.........
示例8: main
//
// The main entry point to the sipXpark
//
int main(int argc, char* argv[])
{
// Configuration Database (used for OsSysLog)
OsConfigDb configDb;
// Register Signal handlers so we can perform graceful shutdown
pt_signal(SIGINT, sigHandler); // Trap Ctrl-C on NT
pt_signal(SIGILL, sigHandler);
pt_signal(SIGABRT, sigHandler); // Abort signal 6
pt_signal(SIGFPE, sigHandler); // Floading Point Exception
pt_signal(SIGSEGV, sigHandler); // Address access violations signal 11
pt_signal(SIGTERM, sigHandler); // Trap kill -15 on UNIX
#if defined(__pingtel_on_posix__)
pt_signal(SIGHUP, sigHandler); // Hangup
pt_signal(SIGQUIT, sigHandler);
pt_signal(SIGPIPE, SIG_IGN); // Handle TCP Failure
pt_signal(SIGBUS, sigHandler);
pt_signal(SIGSYS, sigHandler);
pt_signal(SIGXCPU, sigHandler);
pt_signal(SIGXFSZ, sigHandler);
pt_signal(SIGUSR1, sigHandler);
pt_signal(SIGUSR2, sigHandler);
#endif
UtlString argString;
for(int argIndex = 1; argIndex < argc; argIndex++)
{
osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
argString = argv[argIndex];
NameValueTokenizer::frontBackTrim(&argString, "\t ");
if(argString.compareTo("-v") == 0)
{
osPrintf("Version: %s (%s)\n", SIPXCHANGE_VERSION, SIPXCHANGE_VERSION_COMMENT);
return(1);
}
else
{
osPrintf("usage: %s [-v]\nwhere:\n -v provides the software version\n",
argv[0]);
return(1);
}
}
// Load configuration file file
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_ETC_DIR))
{
workingDirectory = CONFIG_ETC_DIR;
OsPath path(workingDirectory);
path.getNativePath(workingDirectory);
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
}
UtlString fileName = workingDirectory +
OsPathBase::separator +
CONFIG_SETTINGS_FILE;
if (configDb.loadFromFile(fileName) != OS_SUCCESS)
{
exit(1);
}
// Initialize log file
initSysLog(&configDb);
// Read the user agent parameters from the config file.
int UdpPort;
if (configDb.get(CONFIG_SETTING_UDP_PORT, UdpPort) != OS_SUCCESS)
{
UdpPort = PRESENCE_DEFAULT_UDP_PORT;
}
int TcpPort;
if (configDb.get(CONFIG_SETTING_TCP_PORT, TcpPort) != OS_SUCCESS)
{
TcpPort = PRESENCE_DEFAULT_TCP_PORT;
}
UtlString bindIp;
if (configDb.get(CONFIG_SETTING_BIND_IP, bindIp) != OS_SUCCESS ||
!OsSocket::isIp4Address(bindIp))
{
bindIp = PRESENCE_DEFAULT_BIND_IP;
}
// Bind the SIP user agent to a port and start it up
SipUserAgent* userAgent = new SipUserAgent(TcpPort, UdpPort, PORT_NONE,
NULL, NULL, bindIp );
userAgent->start();
if (!userAgent->isOk())
{
//.........这里部分代码省略.........
示例9: loadConfig
//
// Create the real Server, passing in the configured parameters
//
void ParkService::run()
{
int UdpPort;
int TcpPort;
int RtpBase;
UtlString bindIp;
int MaxSessions;
UtlBoolean OneButtonBLF;
UtlString domain;
UtlString realm;
UtlString user;
SipLineMgr* lineMgr = NULL;
int Lifetime;
int BlindXferWait;
int KeepAliveTime;
loadConfig(
UdpPort,
TcpPort,
RtpBase,
bindIp,
MaxSessions,
OneButtonBLF,
domain,
realm,
user,
lineMgr,
Lifetime,
BlindXferWait,
KeepAliveTime
);
// initialize other pieces
// This is not configurable, as consultative transfers should
// succeed or fail immediately.
int ConsXferWait;
ConsXferWait = CONS_XFER_WAIT;
// Bind the SIP user agent to a port and start it up
SipUserAgent* userAgent = new SipUserAgent(TcpPort,
UdpPort,
TcpPort+1,
NULL, // publicAddress
user.isNull() ? NULL : user.data(), // default user
bindIp,
domain.isNull() ? NULL : domain.data(), // outbound proxy
NULL, // sipDirectoryServers (deprecated)
NULL, // sipRegistryServers (deprecated)
NULL, // authenicateRealm
NULL, // authenticateDb
NULL, // authorizeUserIds (deprecated)
NULL, // authorizePasswords (deprecated)
lineMgr
);
userAgent->setUserAgentHeaderProperty("sipXecs/park");
userAgent->start();
if (!userAgent->isOk())
{
OsSysLog::add(LOG_FACILITY, PRI_EMERG, "SipUserAgent failed to initialize, requesting shutdown");
setShutdownFlag(true);
}
// Read the list of codecs from the configuration file.
SdpCodecFactory codecFactory;
initCodecs(&codecFactory, &getConfigDb());
// Initialize and start up the media subsystem
mpStartUp(MP_SAMPLE_RATE, MP_SAMPLES_PER_FRAME, 6 * MaxSessions, &getConfigDb());
MpMediaTask::getMediaTask(MaxSessions);
#ifdef INCLUDE_RTCP
CRTCManager::getRTCPControl();
#endif //INCLUDE_RTCP
mpStartTasks();
// Instantiate the call processing subsystem
UtlString localAddress;
int localPort ;
userAgent->getLocalAddress(&localAddress, &localPort) ;
if (localAddress.isNull())
OsSocket::getHostIp(&localAddress);
// Construct an address to be used in outgoing requests (primarily
// INVITEs stimulated by REFERs).
UtlString outgoingAddress;
{
char buffer[100];
sprintf(buffer, "sip:[email protected]%s:%d", localAddress.data(),
portIsValid(UdpPort) ? UdpPort : TcpPort);
outgoingAddress = buffer;
}
CallManager callManager(FALSE,
NULL,
TRUE, // early media in 180 ringing
//.........这里部分代码省略.........
示例10: main
int main(int argc, char* argv[])
{
const char* configFileName = "siptest-config";
int proxyTcpPort;
int proxyUdpPort;
int proxyTlsPort;
OsConfigDb configDb;
// siptest uses osPrintf for output, so we have to un-suppress it.
enableConsoleOutput(TRUE);
if(configDb.loadFromFile(configFileName) == OS_SUCCESS)
{
osPrintf("Found config file: %s\n", configFileName);
}
else
{
configDb.set("SIP_TEST_UDP_PORT", "3000");
configDb.set("SIP_TEST_TCP_PORT", "3000");
configDb.set("SIP_TEST_TLS_PORT", "3001");
if(configDb.storeToFile(configFileName) == OS_SUCCESS)
{
osPrintf("Could not write config file: %s\n", configFileName);
}
}
proxyUdpPort = configDb.getPort("SIP_TEST_UDP_PORT") ;
proxyTcpPort = configDb.getPort("SIP_TEST_TCP_PORT") ;
proxyTlsPort = configDb.getPort("SIP_TEST_TLS_PORT") ;
UtlBoolean commandStatus = CommandProcessor::COMMAND_SUCCESS;
char buffer[1024];
char* commandLine;
CommandProcessor processor;
SipLineMgr* lineMgr = new SipLineMgr();
SipRefreshMgr* refreshMgr = new SipRefreshMgr();
lineMgr->StartLineMgr();
lineMgr->initializeRefreshMgr( refreshMgr );
SipUserAgent* sipUA = new SipUserAgent( proxyTcpPort
,proxyUdpPort
,proxyTlsPort
,NULL // default publicAddress
,NULL // default defaultUser
,NULL // default defaultSipAddress
,NULL // default sipProxyServers
,NULL // default sipDirectoryServers
,NULL // default sipRegistryServers
,NULL // default authenicateRealm
,NULL // default authenticateDb
,NULL // default authorizeUserIds
,NULL // default authorizePasswords
,lineMgr
);
sipUA->allowMethod(SIP_REGISTER_METHOD);
sipUA->allowMethod(SIP_SUBSCRIBE_METHOD);
sipUA->allowMethod(SIP_NOTIFY_METHOD);
sipUA->start();
sipUA->startMessageLog();
osPrintf( "SIP logging Started\n" );
refreshMgr->init( sipUA );
CommandMsgProcessor* msgProc = new CommandMsgProcessor(sipUA);
msgProc->start();
processor.registerCommand("help", new HelpCommand(&processor));
processor.registerCommand("?", new HelpCommand(&processor));
processor.registerCommand("history", new HistoryCommand(&processor));
processor.registerCommand("send", new SipSendCommand(sipUA));
processor.registerCommand("lsend", new SipLSendCommand());
processor.registerCommand("get", new HttpGetCommand());
processor.registerCommand("respond", new RespondCommand(msgProc));
processor.registerCommand("rt", new RespondTemplate(msgProc));
processor.registerCommand("rrespond", new ResendResponse(msgProc));
processor.registerCommand("log", new SipLogCommand(*sipUA));
processor.registerCommand("auth", new AuthCommand(lineMgr));
processor.registerCommand("sleep", new SleepCommand());
processor.registerCommand("quit", new ExitCommand());
processor.registerCommand("exit", new ExitCommand());
//Initialization
UtlBoolean doPrompt = isatty(STDIN_FILENO);
if ( doPrompt )
{
printf("Enter command or help/? for help\n");
printf("SIPdriver: ");
}
for ( commandStatus = CommandProcessor::COMMAND_SUCCESS;
( commandStatus < CommandProcessor::COMMAND_FAILED_EXIT
&& commandStatus != CommandProcessor::COMMAND_SUCCESS_EXIT
&& (commandLine = fgets(buffer,1024,stdin))
);
//.........这里部分代码省略.........
示例11: fprintf
//.........这里部分代码省略.........
}
Os::Logger::instance().log(FAC_SIP, PRI_INFO,
"SIP_STATUS_MAX_EXPIRES : %s",
defaultMaxExpiresTime.data());
int maxExpiresTime = atoi(defaultMaxExpiresTime.data());
// SIP_STATUS_MIN_EXPIRES
if ( defaultMinExpiresTime.isNull() )
{
defaultMinExpiresTime.append("300"); // default to 300 seconds
}
Os::Logger::instance().log(FAC_SIP, PRI_INFO,
"SIP_STATUS_MIN_EXPIRES : %s",
defaultMinExpiresTime.data());
int webServerPort = httpPort;
UtlBoolean isSecureServer = false;
// Determine whether we should start the web server or not. Use the port
// value as the decision point. A valid port means enable.
// If isSecureServer then start the port as a secure web server.
OsServerSocket* serverSocket = NULL;
HttpServer* httpServer = NULL;
if( portIsValid(webServerPort) )
{
if ( isSecureServer )
{
# ifdef HAVE_SSL
serverSocket = new OsSSLServerSocket(50, webServerPort, bindIp);
httpServer = new HttpServer(serverSocket,
pValidIpAddressDB,
false /* no persistent tcp connection */);
# else /* ! HAVE_SSL */
// SSL is not configured in, so we cannot open the requested
// socket.
Os::Logger::instance().log(FAC_SIP, PRI_CRIT,
"StatusServer::startStatusServer SSL not configured; "
"cannot open secure socket %d", webServerPort);
httpServer = NULL;
# endif /* HAVE_SSL */
}
else
{
serverSocket = new OsServerSocket(50, webServerPort, bindIp);
httpServer = new HttpServer(serverSocket,
pValidIpAddressDB );
}
}
// Start the SIP stack
SipUserAgent* sipUserAgent =
new SipUserAgent(
tcpPort,
udpPort,
tlsPort,
NULL, // public IP address (nopt used in proxy)
NULL, // default user (not used in proxy)
bindIp,
NULL, // outbound proxy
NULL, // directory server
NULL, // registry server
NULL, // auth realm
NULL, // auth DB
NULL, // auth user IDs
NULL, // auth passwords
NULL, // line mgr
SIP_DEFAULT_RTT, // first resend timeout
TRUE, // default to UA transaction
SIPUA_DEFAULT_SERVER_UDP_BUFFER_SIZE, // socket layer read buffer size
SIPUA_DEFAULT_SERVER_OSMSG_QUEUE_SIZE // OsServerTask message queue size
);
// No need to log the message as it goes in the syslog
//sipUserAgent->startMessageLog(100000);
sipUserAgent->setDnsSrvTimeout(dnsSrvTimeout);
sipUserAgent->setMaxSrvRecords(maxNumSrvRecords);
sipUserAgent->setUserAgentHeaderProperty("sipXecs/publisher");
sipUserAgent->start();
Notifier* notifier = new Notifier(sipUserAgent);
// Start the status server
StatusServer* status = new StatusServer(
notifier,
maxExpiresTime,
domainName,
defaultMinExpiresTime,
isCredentialDB,
authAlgorithm,
authQop,
authRealm,
workingDir,
serverSocket,
httpServer);
status->start();
return(status);
}
示例12: sendToAppearanceAgentUnderTest
// Primitive to send a SIP message to the AppearanceAgent server under test
bool sendToAppearanceAgentUnderTest( SipMessage& msg )
{
return pSipUserAgent->send( msg );
}
示例13: testRefreshMgrUATeardown
void testRefreshMgrUATeardown()
{
for (int i=0; i<NUM_OF_RUNS; ++i)
{
SipLineMgr* lineMgr = new SipLineMgr();
SipRefreshMgr* refreshMgr = new SipRefreshMgr();
lineMgr->startLineMgr();
lineMgr->initializeRefreshMgr( refreshMgr );
SipUserAgent* sipUA = new SipUserAgent( 5090
,5090
,5091
,NULL // default publicAddress
,NULL // default defaultUser
,"127.0.0.1" // default defaultSipAddress
,NULL // default sipProxyServers
,NULL // default sipDirectoryServers
,NULL // default sipRegistryServers
,NULL // default authenicateRealm
,NULL // default authenticateDb
,NULL // default authorizeUserIds
,NULL // default authorizePasswords
,lineMgr
);
sipUA->start();
refreshMgr->init(sipUA);
CallManager *pCallManager =
new CallManager(FALSE,
NULL, //LineMgr
TRUE, // early media in 180 ringing
NULL, // CodecFactory
9000, // rtp start
9002, // rtp end
"sip:[email protected]",
"sip:[email protected]",
sipUA, //SipUserAgent
0, // sipSessionReinviteTimer
NULL, // mgcpStackTask
NULL, // defaultCallExtension
Connection::RING, // availableBehavior
NULL, // unconditionalForwardUrl
-1, // forwardOnNoAnswerSeconds
NULL, // forwardOnNoAnswerUrl
Connection::BUSY, // busyBehavior
NULL, // sipForwardOnBusyUrl
NULL, // speedNums
CallManager::SIP_CALL, // phonesetOutgoingCallProtocol
4, // numDialPlanDigits
CallManager::NEAR_END_HOLD, // holdType
5000, // offeringDelay
"", // pLocal
CP_MAXIMUM_RINGING_EXPIRE_SECONDS, //inviteExpireSeconds
QOS_LAYER3_LOW_DELAY_IP_TOS, // expeditedIpTos
10, //maxCalls
sipXmediaFactoryFactory(NULL)); //pMediaFactory
#if 0
printf("Starting CallManager\n");
#endif
pCallManager->start();
lineMgr->requestShutdown();
refreshMgr->requestShutdown();
sipUA->shutdown(TRUE);
pCallManager->requestShutdown();
#if 0
printf("Deleting CallManager\n");
#endif
delete pCallManager;
delete refreshMgr;
delete lineMgr;
}
for (int i=0; i<NUM_OF_RUNS; ++i)
{
sipxDestroyMediaFactoryFactory() ;
}
}
示例14: main
int main(int argc, char* argv[])
{
int port;
int expiration;
char* targetURI;
char* eventType;
char* contentType;
char* realm;
char* user;
char* password;
// Initialize logging.
OsSysLog::initialize(0, "test");
OsSysLog::setOutputFile(0, "log");
OsSysLog::setLoggingPriority(PRI_DEBUG);
OsSysLog::setLoggingPriorityForFacility(FAC_SIP_INCOMING_PARSED, PRI_ERR);
if (!parseArgs(argc, argv, &port, &expiration,
&targetURI, &eventType, &contentType,
&realm, &user, &password))
{
usage(argv[0]);
exit(1);
}
// The domain name to call myself, obtained from the gethostname()
// system call.
char buffer[100];
memset(buffer, 0, sizeof (buffer));
// Do not allow gethostname to write over the last NUL in buffer[].
gethostname(buffer, (sizeof (buffer)) - 1);
UtlString myDomainName(buffer, strlen(buffer));
// Use "example.com" if gethostname() failed.
if (myDomainName.isNull())
{
myDomainName = "example.com";
}
UtlString fromString = "sip:[email protected]" + myDomainName;
Url fromUri(fromString, TRUE);
// Create the SIP Subscribe Client
SipLineMgr lineMgr;
// Add credentials if they were specified.
if (realm)
{
UtlString id;
id += "sip:";
id += user;
id += "@";
id += realm;
Url identity(id, TRUE);
SipLine line( fromUri // user entered url
,identity // identity url
,user // user
,TRUE // visible
,SipLine::LINE_STATE_PROVISIONED
,TRUE // auto enable
,FALSE // use call handling
);
lineMgr.addLine(line);
UtlString cred_input;
UtlString cred_digest;
cred_input.append(user);
cred_input.append(":");
cred_input.append(realm);
cred_input.append(":");
cred_input.append(password);
NetMd5Codec::encode(cred_input.data(), cred_digest);
fprintf(stderr,
"Adding identity '%s': user='%s' realm='%s' password='%s' H(A1)='%s'\n",
identity.toString().data(), user, realm, password, cred_digest.data()
);
assert(lineMgr.addCredentialForLine(identity, realm, user, cred_digest,
HTTP_DIGEST_AUTHENTICATION));
}
SipUserAgent* pSipUserAgent =
new SipUserAgent(port, port, PORT_NONE,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
&lineMgr);
//.........这里部分代码省略.........
示例15: proxy
//.........这里部分代码省略.........
foo.setRequestData(method,
uri, //uri,
"sip:[email protected]", // fromField,
"\"lajdflsdk ff\"<sip:[email protected]>", // toField,
"lkadsj902387", // callId,
123, // CSeq,
"sip:10.1.1.123");// contactUrl
// Set the event type
foo.setHeaderValue(SIP_EVENT_FIELD,
eventType, // event type
0);
Url msgUrl(uri);
UtlString routeTo;
UtlString routeType;
bool authRequired;
OsStatus routeStatus = forwardingRules.getRoute(msgUrl,
foo,
routeTo,
routeType,
authRequired);
Url msgRouteToUri(routeTo);
osPrintf("Message:\n\tmethod: %s\n\turi: %s\n\tevent: %s\nRouted:\n\tstring: %s\n\turi: %s\n\ttype: %s\n",
method, uri, eventType, routeTo.data(), msgRouteToUri.toString().data(), routeType.data());
if(routeStatus != OS_SUCCESS)
osPrintf("forwardingRules.getRoute returned: %d\n",
routeStatus);
}
#endif // TEST_PRINT
// Start the sip stack
SipUserAgent* pSipUserAgent = new SipUserAgent(
proxyTcpPort,
proxyUdpPort,
proxyTlsPort,
NULL, // public IP address (not used in proxy)
NULL, // default user (not used in proxy)
bindIp,
NULL, // outbound proxy
NULL, // directory server
NULL, // registry server
NULL, // auth realm
NULL, // auth DB
NULL, // auth user IDs
NULL, // auth passwords
NULL, // line mgr
SIP_DEFAULT_RTT, // first resend timeout
FALSE, // default to proxy transaction
SIPUA_DEFAULT_SERVER_UDP_BUFFER_SIZE, // socket layer read buffer size
SIPUA_DEFAULT_SERVER_OSMSG_QUEUE_SIZE, // OsServerTask message queue size
FALSE, // Use Next Available Port
TRUE, // Perform message checks
TRUE, // Use symmetric signaling
SipUserAgent::HANDLE_OPTIONS_AUTOMATICALLY);
if (!pSipUserAgent->isOk())
{
Os::Logger::instance().log(FAC_SIP, PRI_EMERG, "SipUserAgent reported a problem, setting shutdown flag...");
gShutdownFlag = TRUE;
}
pSipUserAgent->setDnsSrvTimeout(dnsSrvTimeout);
pSipUserAgent->setMaxSrvRecords(maxNumSrvRecords);
pSipUserAgent->setUserAgentHeaderProperty("sipXecs/sipXproxy");