⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 useragent.cxx

📁 Vovida 社区开源的 SIP 协议源码
💻 CXX
字号:
/* ==================================================================== * The Vovida Software License, Version 1.0  *  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: *  * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. *  * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. *  * 3. The names "VOCAL", "Vovida Open Communication Application Library", *    and "Vovida Open Communication Application Library (VOCAL)" must *    not be used to endorse or promote products derived from this *    software without prior written permission. For written *    permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor *    may "VOCAL" appear in their name, without prior written *    permission of Vovida Networks, Inc. *  * THIS    SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. *  * ==================================================================== *  * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc.  For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const UserAgent_cxx_Version =    "$Id: UserAgent.cxx,v 1.36 2002/03/19 21:40:17 jason Exp $";#include "global.h"#include "UserAgent.hxx"#include "UaCommandLine.hxx"#include "UaConfiguration.hxx"#include "UaDevice.hxx"#include "DeviceThread.hxx"#include "RtpThread.hxx"#include "FeatureThread.hxx"#include "UaCallContainer.hxx"#ifdef HAS_PHONEDEV#include "CheckHardware.hxx"#endif#include "SubscribeManager.hxx"#include "ResGwDevice.hxx"#include "cpLog.h"#include "UaDigitTimerEvent.hxx"#include "LoadGenMonitor.hxx"#include "LoadGenThread.hxx"using namespace Vocal;extern int numOfCallsStarted;///UserAgent::UserAgent( Sptr<UaBuilder> uaBuilder, unsigned short sipPort, Data appName )         : HeartLessProxy( uaBuilder, sipPort, appName ){    const char* useDevice = "NULL";  // default to NULL_HARDWARE    if ( UaCommandLine::instance()->getBoolOpt( "quicknet" ) &&         UaCommandLine::instance()->getBoolOpt( "voicemail" ) &&         UaCommandLine::instance()->getBoolOpt( "soundcard" ) )    {        cpLog(LOG_ERR, "Quicknet and Soundcard and Voicemail mutually exclusive");        exit( -1 );    }#ifdef HAS_PHONEDEV    if ( UaCommandLine::instance()->getBoolOpt( "quicknet" ) )    {        // then create a CheckHardware object        CheckHardware check;        useDevice = check.GetType();    }    else#endif#ifdef HAS_SOUNDCARD    if( UaCommandLine::instance()->getBoolOpt( "soundcard" ) )    {            useDevice = "SOUNDCARD";    }    else#endif#ifdef HAS_VOICEMAIL     if( UaCommandLine::instance()->getBoolOpt( "voicemail" ) )    {            useDevice = "VOICEMAIL";    }    else#endif   {   }    if(! UaConfiguration::instance()->getLoadGenOn())    {        // Create devices only if load gen is turned OFF.        UaDevice::instance( useDevice, myCallProcessingQueue );        if( ! (strcmp(useDevice, "NONE") == 0) )        {            cpLog( LOG_DEBUG, "Create RTP Thread" );            rtpThread = new RtpThread( UaDevice::instance() );            assert( rtpThread != 0 );        }        cpLog( LOG_DEBUG, "Create Device Thread" );        deviceThread = new DeviceThread( UaDevice::instance() );        assert( deviceThread != 0 );        cpLog( LOG_DEBUG, "Create SubscribeManager" );        Sptr<SubscribeManager> subManager = new SubscribeManager( mySipStack );        if ( UaConfiguration::instance()->getSubscribeOn() )        {            cpLog( LOG_DEBUG, "Create Feature Thread" );            featureThread = new FeatureThread( subManager );            assert( featureThread != 0 );            uaBuilder->setSubscribeManager( subManager );        }    }    else    {        // Create monitor thread        cpLog (LOG_DEBUG, "Load Generation turned on....  no devices created");        if ( UaConfiguration::instance()->getMonitorMsgOn() )        {            // If load generation is turned on then create monitor thread            // to capture statisics.            cpLog(LOG_INFO, "Creating Load Generation Monitor thread...");            LoadGenMonitor::instance();            loadGenThread = new LoadGenThread( LoadGenMonitor::instance() );            assert( loadGenThread != 0 );        }        //create Rtp thread if Rtp is to be generated in load generation        if ( ( UaConfiguration::instance()->getRtpGenOn() ) &&	     ( strcmp(useDevice, "NULL") == 0) )        {            UaDevice::instance( useDevice, myCallProcessingQueue );            cpLog(LOG_INFO, "Create RTP Thread" );            rtpThread = new RtpThread( UaDevice::instance() );            assert( rtpThread != 0 );            cpLog( LOG_DEBUG, "Create Device Thread" );            deviceThread = new DeviceThread( UaDevice::instance() );            assert( deviceThread != 0 );        }    }    // Turn off retransmission    if (UaCommandLine::instance( ) -> getBoolOpt( "retransmit" ) )    {        SipTransceiver::reTransOn();    }    else    {        SipTransceiver::reTransOff();    }    // Replace base CallContainer    myCallContainer = new UaCallContainer;    assert( myCallContainer != 0 );    uaBuilder->setCallContainer( myCallContainer );    uaBuilder->setSipStack( mySipStack );    uaBuilder->startRegistration();    cout << "Ready" << endl;}    // UserAgent::UserAgent///voidUserAgent::run(){    HeartLessProxy::run();    if (deviceThread != 0)    {        cpLog( LOG_DEBUG, "Spawning Device Thread" );        deviceThread->run();    }    if ( rtpThread != 0 )    {        cpLog( LOG_DEBUG, "Spawning RTP Thread" );        rtpThread->run();    }    if ( featureThread != 0 )    {        cpLog( LOG_DEBUG, "Spawning Feature Thread" );        featureThread->run();    }    if ( loadGenThread != 0 )    {        cpLog( LOG_DEBUG, "Spawning Load Generation Monitor Thread");        loadGenThread->run();    }    // User TimerEvent to kick start the load generator    if ( UaConfiguration::instance()->getLoadGenOn() )    {        if (UaConfiguration::instance()->getRunMode() == "Calling" ||                UaConfiguration::instance()->getRunMode() == "RSTest" )        {            printf("*****  Create kick start event *****\n");            int numStarts = UaConfiguration::instance()->getNumKickStarts();            if (numStarts < 1)            {                numStarts = 1;            }            int avgCallTime = 500;  // average length of one call is 500 ms            int delay = avgCallTime / numStarts;  //kickstart all units in 500 ms            for (int i = 0; i < numStarts; i++)            {                ++numOfCallsStarted;                Sptr < UaDigitTimerEvent > kickStartEvent =                    new UaDigitTimerEvent( myCallProcessingQueue );                assert (kickStartEvent != 0);                kickStartEvent->setLoadGenSignalType(LoadGenStartCall);                kickStartEvent->setSipStack( mySipStack );                myCallProcessingQueue->addDelayMs( kickStartEvent,                                                    (UaConfiguration::instance()->getStartTime()) +                                                    (delay * i));            }        }    }}    // UserAgent::run///voidUserAgent::join(){    HeartLessProxy::join();}    // UserAgent::join///UserAgent::~UserAgent(){}    // UserAgent::~UserAgent

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -