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

📄 opswapcalls.cxx

📁 Vovida 社区开源的 SIP 协议源码
💻 CXX
📖 第 1 页 / 共 2 页
字号:
    //sending re-invite    deviceEvent->getSipStack()->sendAsync( *reInvite );    Sptr < UaHardwareEvent > signal =	new UaHardwareEvent( UaDevice::getDeviceQueue() );    signal->type = HardwareAudioType;    struct HardwareAudioRequest* request = &(signal->signalOrRequest.request);    request->type = AudioStop;    UaDevice::getDeviceQueue()->add( signal );    return true;}voidOpSwapCalls::restoreHeldCall( const Sptr < UaDeviceEvent > deviceEvent ){    Sptr < UaCallInfo > call;    call.dynamicCast( deviceEvent->getCallInfo() );    assert( call != 0 );    // Find contact data of held call    Sptr < InviteMsg > inviteMsg;    if ( !firstCall )    {        cpLog( LOG_DEBUG, "Restoring 2nd call");        inviteMsg = call->getRing2Invite();    }    else    {        cpLog( LOG_DEBUG, "Restoring 1st call");        inviteMsg = call->getRingInvite();    }    Sptr < Contact > contact = call->findContact( *inviteMsg );    if ( contact == 0 )    {        cpLog( LOG_ERR, "No contact data" );        return ;    }    call->setContact( contact );    // Restore media    Sptr < InviteMsg > reInvite;    int status = contact->getStatus();    if ( status == 200 )    {        cpLog( LOG_DEBUG, "Restore callee" );        const StatusMsg& msg = contact->getStatusMsg();        if ( &msg != 0 )        {            cout << endl            << "Switch back to call "            << msg.getTo().encode().logData()            << endl;            reInvite = new InviteMsg( msg );            // Add Sdp for later use            Sptr < SipSdp > localSdp = call->getLocalSdp();            assert( localSdp != 0 );            SipSdp sipSdp = *localSdp;            reInvite->setContentData( &sipSdp );        }        else        {            cpLog( LOG_ERR , "No status message for re-INVITE" );        }    }    else    {        cpLog( LOG_DEBUG, "Restore caller" );        const InviteMsg& msg = contact->getInviteMsg();        if ( &msg != 0 )        {            cout << endl            << "Switch back to call "            << msg.getFrom().encode().logData()            << endl;            string sipPort = UaConfiguration::instance()->getLocalSipPort();            reInvite = new InviteMsg( msg.getFrom().getUrl(),                                      atoi( sipPort.c_str() ) );            SipFrom from( msg.getTo().getUrl() );            reInvite->setFrom( from );            //TODO Check if it is necessary to set To:            reInvite->setCallId( msg.getCallId() );            // Convert RecordRoute to reverse Route            int numRecordRoute = msg.getNumRecordRoute();            SipRecordRoute recordroute;            SipRoute route;            for ( int i = 0; i < numRecordRoute; i++ )            {                recordroute = msg.getRecordRoute( i );                route.setUrl( recordroute.getUrl() );                reInvite->setRoute( route );     // to beginning            }            int numContact = msg.getNumContact();            if ( numContact )            {                SipContact contact = msg.getContact( numContact - 1 );                route.setUrl( contact.getUrl() );                reInvite->setRoute( route );     // to beginning            }        }        else        {            cpLog( LOG_ERR , "No INVITE message for re-INVITE" );        }    }    assert( reInvite != 0 );    SipVia sipVia;    sipVia.setprotoVersion( "2.0" );    sipVia.setHost( Data( theSystem.gethostAddress() ) );    sipVia.setPort( atoi( UaConfiguration::instance()			  ->getLocalSipPort().c_str() ) );    reInvite->flushViaList();    reInvite->setVia( sipVia, 0 );    // Set Contact: header    Sptr< SipUrl > myUrl = new SipUrl;    myUrl->setUserValue( UaConfiguration::instance()->getUserName() );    myUrl->setHost( Data( theSystem.gethostAddress() ) );    myUrl->setPort( UaConfiguration::instance()->getLocalSipPort() );    SipContact me;    me.setUrl( myUrl );    reInvite->setNumContact( 0 );    // Clear    reInvite->setContact( me );    //TODO Is it going to be a problem if the other side also use the next    //TODO CSeq at the same time?    unsigned int cseq = contact->getCSeqNum();    contact->setCSeqNum( ++cseq );    SipCSeq sipCSeq = reInvite->getCSeq();    sipCSeq.setCSeq( cseq );    reInvite->setCSeq( sipCSeq );    //get local sdp    Sptr < SipSdp > localSdp = call->getLocalSdp();    assert( localSdp != 0 );    Sptr<SipSdp> sipSdp;    sipSdp.dynamicCast ( reInvite->getContentData( 0 ) );    assert( sipSdp != 0 );    sipSdp->setSdpDescriptor( localSdp->getSdpDescriptor() );    deviceEvent->getSipStack()->sendAsync( *reInvite );    Sptr < SipSdp > remoteSdp;    if ( firstCall )    {        remoteSdp = call->getRemoteSdp();    }    else    {        remoteSdp = call->getRemote2Sdp();    }    if ( remoteSdp == 0)    {        cpLog( LOG_ERR, "No remote SDP" );        //TODO send BYE ???        return ;    }    Sptr < UaHardwareEvent > signal =	new UaHardwareEvent( UaDevice::getDeviceQueue() );    signal->type = HardwareAudioType;    struct HardwareAudioRequest* request = &(signal->signalOrRequest.request);    request->type = AudioStart;    // Set remote host and port    LocalScopeAllocator lo;    strcpy( request->remoteHost,            remoteSdp->getConnAddress().getData(lo) );    request->remotePort = remoteSdp->getRtpPort();    // Set local host and port    request->localPort = localSdp->getRtpPort();    strcpy( request->localHost,            localSdp->getConnAddress().getData(lo) );    //TODO Why echo cancellation always true?    request->echoCancellation = true;    // Set rtpPacketSize to default in ua.cfg file    int rtpPacketSize = UaConfiguration::instance()->getNetworkRtpRate();    // Check local, not remote ???    // How is this related to Network_RTP_Rate in configuration file???    int tmp;    cpLog( LOG_DEBUG, "Local SDP:\n%s", localSdp->encodeBody(tmp).logData() );    SdpSession sdpDesc = localSdp->getSdpDescriptor();    list < SdpMedia* > mediaList;    mediaList = sdpDesc.getMediaList();    list < SdpMedia* > ::iterator mediaIterator = mediaList.begin();    MediaAttributes* mediaAttrib;    mediaAttrib = (*mediaIterator)->getMediaAttributes();    if ( mediaAttrib != 0 )    {        vector < ValueAttribute* > * valueAttribList =	    mediaAttrib->getValueAttributes();        if ( valueAttribList->size() == 0 )        {            cpLog( LOG_DEBUG, "No value attribute in media" );        }        vector < ValueAttribute* > ::iterator attribIterator =	    valueAttribList->begin();        while ( attribIterator != valueAttribList->end() )        {            char* attribName = (*attribIterator)->getAttribute();            if ( strcmp( attribName, "ptime" ) == 0 )            {                rtpPacketSize = Data( (*attribIterator)->getValue() ).convertInt();                break;            }            attribIterator++;        }        request->rtpPacketSize = rtpPacketSize;    }    else    {        cpLog( LOG_DEBUG, "No media attributes in local SDP" );    }    request->sendRingback = false;    cpLog( LOG_DEBUG, "Start audio( duplex ):" );    cpLog( LOG_DEBUG, "localHost     = %s", request->localHost);    cpLog( LOG_DEBUG, "localPort     = %d", request->localPort);    cpLog( LOG_DEBUG, "remoteHost    = %s", request->remoteHost);    cpLog( LOG_DEBUG, "remotePort    = %d", request->remotePort);    cpLog( LOG_DEBUG, "rtpPacketSize = %d", request->rtpPacketSize);    UaDevice::getDeviceQueue()->add( signal );}/* Local Variables: *//* c-file-style: "stroustrup" *//* indent-tabs-mode: nil *//* c-file-offsets: ((access-label . -) (inclass . ++)) *//* c-basic-offset: 4 *//* End: */

⌨️ 快捷键说明

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