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

📄 nullhwdevice.cxx

📁 SIP(Session Initiation Protocol)是由IETF定义
💻 CXX
📖 第 1 页 / 共 2 页
字号:
            }            break;            case '4':            {                event->type = DeviceEventDtmf4;            }            break;            case '5':            {                event->type = DeviceEventDtmf5;            }            break;            case '6':            {                event->type = DeviceEventDtmf6;            }            break;            case '7':            {                event->type = DeviceEventDtmf7;            }            break;            case '8':            {                event->type = DeviceEventDtmf8;            }            break;            case '9':            {                event->type = DeviceEventDtmf9;            }            break;            case 'u':            {                if( hookStateOffhook )                {                    cout << "Enter URL: ";                    cout.flush();                    myEntryState = EntryStateEnterUrl;                }                else                {                    cpLog( LOG_ERR, "Enter 'a' first" );                }            }            break;            case '\n':            {                // ignore            }            break;            default:            {                // no events                cpLog( LOG_ERR, "Unknown keyboard input" );                break;            }        } // end switch    }    if (event->type != DeviceEventUndefined)    {        assert( sessionQ != 0 );        event->callId = callId;#ifndef WIN32        sessionQ->add( event );#else        Sptr <SipProxyEvent> proxyEvent;        proxyEvent.dynamicCast( event );        sessionQ->add( proxyEvent );#endif    }    return 0;} // end NullHwDevice::process()//***************************************************************************// NullHwDevice::processRTP// description:  main processing loop for RTP//***************************************************************************voidNullHwDevice::processRTP (){    #if !defined(WIN32)    if (audioStack != 0)    {        //send rtp packets with silence        memset(outBufferPkt, 0x7f, 160);        audioStack->transmitRaw(outBufferPkt, 160);    }    #endif    vusleep(20000);  // sleep for 20 milliseconds}intNullHwDevice::addToFdSet (fd_set* fd){    #ifndef WIN32    FD_SET( stdinFD, fd );    #endif    return 0;} // end NullHwDevice::addToFdSet()//***************************************************************************// NullHwDevice::getRtpPort()//// description:  randomly generates a rtp port//***************************************************************************intNullHwDevice::getRtpPort(){    //this is an arbitrarily defined number    const int MAX_RTP_PORT = UaConfiguration::instance()->getMaxRtpPort();    const int MIN_RTP_PORT = UaConfiguration::instance()->getMinRtpPort();    int port = random();    port = port % ( MAX_RTP_PORT - MIN_RTP_PORT ) + MIN_RTP_PORT;    cpLog( LOG_DEBUG, "rtp port %d is reserved", port);    return port;}//***************************************************************************// NullHwDevice::releaseRtpPort()//// description: for NullHwDevice, nothing needs to be done//***************************************************************************voidNullHwDevice::releaseRtpPort(){}//***************************************************************************// NullHwDevice::audioStart//// description:  creates a new rtp session and also allocates memory for//               incoming and outgoing rtp packet.  ioctl calls to initialize//               the quicknet card.//***************************************************************************intNullHwDevice::audioStart (const HardwareAudioRequest& request){    cerr << "%%%   Establishing audio   %%%\n";    cerr << "%%%   Listening on port: " << request.localPort << "\n";    cerr << "%%%   Sending to host: " << request.remoteHost << "\n";    cerr << "%%%   Sending to port: " << request.remotePort << "\n";    //if generating rtp packets, create outgoing packet and start session    //(without RTCP).  Assume PCMU codec.    if ( UaConfiguration::instance()->getRtpGenOn() )    {        #if !defined(WIN32)        if (audioStack != 0)            delete audioStack;        audioStack = new RtpSession(request.remoteHost,                                    request.remotePort,                                    request.localPort);        audioStack->setApiFormat (rtpPayloadPCMU, RESID_RTP_RATE);        audioStack->setNetworkFormat (rtpPayloadPCMU, request.rtpPacketSize * 8);        // 	audioStack->setNetworkPktSize( request.rtpPacketSize * 8);        //	outRtpPkt = audioStack->createPacket( 0 );        #endif    }    // mark audio as active    audioActive = true;    audioHalfActive = true;    hasPlayed = false;    return 0;} // end NullHwDevice::audioStart()//***************************************************************************// NullHwDevice::audioStop//// description:  tears down audio.  cleans up by delete objects created when//               audioStart was called...  inBuffer, outBuffer, audioStack,//               rtp packets.//***************************************************************************intNullHwDevice::audioStop(){    cout << "%%%   Stopping audio\n";    if (!audioActive) return 1;    // mark audio as deactivated.    audioActive = false;    audioHalfActive = true;    hasPlayed = false;    #if !defined(WIN32)    //reset rtp session and outgoing packet    delete audioStack;    audioStack = 0;    #endif    //delete outRtpPkt;    //outRtpPkt = NULL;    return 0;} // end NullHwDevice::audioStop()//***************************************************************************// NullHwDevice::audioSuspend//// description: suspend the RTP transmit and receive, and also stop the////***************************************************************************intNullHwDevice::audioSuspend (){#if 0    cpLog( LOG_INFO, "Suspending audio");    cpLog( LOG_INFO, "Setting all RTP/RTCP ports to 0");#endifreturn 0;}//***************************************************************************// NullHwDevice ::audioResume//// description:  resume the rtp session using the new sdp information//               enable the quicknet card audio//***************************************************************************intNullHwDevice::audioResume (const HardwareAudioRequest& request){#if 0    if ( audioStack == 0 )    {        cpLog( LOG_ERR, "Try to resume an existing audio channel");        cpLog( LOG_ERR, "No existing audio channel");        return 0;    }    cpLog( LOG_INFO, "Resuming audio");    cpLog( LOG_INFO, "Listening on port: %d", request.localPort);    cpLog( LOG_INFO, "Sending to host: %s", request.remoteHost);    cpLog( LOG_INFO, "Sending to port: %d", request.remotePort);    cpLog( LOG_INFO, "RTP packet size: %d", request.rtpPacketSize);    return 0;#endifreturn 0;}voidNullHwDevice::provideDialToneStart(){    cout << "%%%   Start dial tone\n";}voidNullHwDevice::provideDialToneStop(){    cout << "%%%   Stop dial tones\n";}voidNullHwDevice::provideRingStart(){    cout << "%%%   Start ringing\n";}voidNullHwDevice::provideRingStop(){    cout << "%%%   Stop ringing\n";}voidNullHwDevice::provideLocalRingbackStart(){    cout << "%%%   Start local ringback\n";}voidNullHwDevice::provideLocalRingbackStop(){    cout << "%%%   Stop local ringback\n";}voidNullHwDevice::provideBusyToneStart(){    cout << "%%%   Start busy start\n";}voidNullHwDevice::provideBusyToneStop(){    cout << "%%%   Stop busy stop\n";}voidNullHwDevice::provideFastBusyToneStart(){    cout << "%%%   Start fast busy start\n";}voidNullHwDevice::provideFastBusyToneStop(){    cout << "%%%   Stop fast busy stop\n";}voidNullHwDevice::provideCallWaitingBeepStart(){    cout << "%%% Start call waiting beep" << endl;}voidNullHwDevice::provideCallWaitingBeepStop(){    cout << "%%% Stop call waiting beep" << endl;}/* 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 + -