📄 sdpbuild.cpp
字号:
status = (int) SipCall::putMeOnHold; setExtHost(ipaddress); return doReturn (status); } else { if(evaluateA==true) { evaluateAV=true; status = (int)SipCall::auviCall; } else { status = (int)SipCall::videoCall; evaluateV=true; } setExtPort(curline.section(' ',1,1)); setExtHost(ipaddress); int i = (-1); do { i++; vcc[i] = curline.section(' ', i+3, i+3); } while (vcc[i].length() != 0); receivedVideoMediaNumber = i; } } if( ( curline.contains("m=application") ) ) { if(ipaddress.contains("0.0.0.0") || forceHold){ status = (int) SipCall::putMeOnHold; setExtHost(ipaddress); return doReturn (status); } else { setExtHost(ipaddress); setExtPort(curline.section(' ',1,1)); transT=curline.section(' ',2,2); sec=curline.section(' ',3,3); status = checkVectorId(status,sec); // find the load type call->setRemoteStart(false); // if(status==0){ return doReturn (status); // error } if(!testTrans(status,transT)) return doReturn (0); } } if( curline.contains("a=")) { // full duplex only; if( curline.contains("a=sendonly") || curline.contains("a=recvonly") || curline.contains("a=inactive") ) { status = 0; return doReturn (status); } if (curline.contains("a=fmtp:" + sec) ) {// we have a=vec or a=cmd if(curline.contains("rstart")) { call->setRemoteStart(true); return doReturn (status); } } // we look for audio and video if( curline.contains("a=rtpmap")) { isRtpMap++; codecstr=curline.section(' ',1,1); codecstr1=curline.section(':',1,1); codecstr2=codecstr1.section(' ',0,0); // STORE RECEIVED MEDIA ATTRIBUTES bool concerningAudio = false; // search for audio i=0; while ( i<receivedAudioMediaNumber) { if (codecstr2 == acc[i]) { acstr[i] = codecstr.section('/',0,0); concerningAudio = true; break; } i++; } // search for video, if not audio if (concerningAudio == false) { for (i=0; i<receivedVideoMediaNumber; i++) { if (codecstr2 == vcc[i]) { vcstr[i] = codecstr.section('/',0,0); break; } } } } if ( curline.contains("a=fmtp:97")) { // looks strange, but works, as only ILBC uses responsePay if ( curline.contains ("mode=30") ) tempresponsepay = 240; if ( curline.contains ("mode=20") ) tempresponsepay = 160; } } } // END OF WHILE-LOOP if( (isRtpMap<receivedAudioMediaNumber) && ( evaluateA || evaluateV || evaluateAV) ){ for(i=0;i<=receivedAudioMediaNumber;i++) { for(j=0;j<=NAUDIO;j++) { if (acc[i] == sessionC->getACodecNum(j) ) { if(acstr[i] == "" )acstr[i] = sessionC->getACodecName(j); break; } } } for(i=0;i<=receivedVideoMediaNumber;i++) { for(j=0;j<=NAUDIO;j++) { if (vcc[i] == sessionC->getCodecNum(j) ) { vcstr[i] = sessionC->getCodecName(j); break; } } } } if( evaluateV || evaluateAV) { // *** VIDEO *** if (videoMediaNegotiationINVITE(receivedVideoMediaNumber) == false) { status=0; // no good codec for us; audiocheck is not necessary any longer return doReturn (status); } } if( evaluateA || evaluateAV) { // *** AUDIO *** if (audioMediaNegotiationINVITE(receivedAudioMediaNumber) == false) { status=0; // no good codec for us; return doReturn (status); } } // We have a good Codec return doReturn (status);}// *** A U D I O ***************************************************************************************************************// Read local supported Payload Type for received AUDIO Encoding NameQString SdpBuild::readSupportedAudioPayloadType( QString receivedEncodingName ) {int prio; QString localPayloadType = "-1"; // init: Payload Type not supported int suppMediaNumber = sessionC->getTotalNumberOfPrefAudioCodecs(); // Anzahl aller Audio-Codecs, die wir untersttzen prio = 0; while (prio < suppMediaNumber) { if (receivedEncodingName.upper() == sessionC->getPrefCodec(prio)) { localPayloadType = sessionC->getPrefCodecNum(prio); break; } prio++; } return localPayloadType;}// Negotiation of AUDIO Codecsbool SdpBuild::audioMediaNegotiationINVITE(int recAttributeNumber) { bool success = false; int negPriority = 0; // start with highest priority of negotiation codecs int recAttrCounter = 0; while (recAttrCounter < recAttributeNumber) { // get received Encoding Name QString recEncoding = acstr[recAttrCounter]; QString localPayload = readSupportedAudioPayloadType( recEncoding );// get local Payload Type for the received Encoding Name if (localPayload != "-1") {// Encoding supported? // Highest priority (1st coincidence) if (negPriority == 0) { setPrefCodec(recEncoding); setPrefCodecNum(acc[recAttrCounter]); // PAYLOAD TYPE NUMBER OF THE Partner success = true; } negPriority++; // for next entry in Negotiation Parameter file } recAttrCounter++; } if (getPrefCodecNum() == "97") { if ( sessionC->getPayload() != tempresponsepay ) { success = false; } else { setResponsePay(tempresponsepay); } } return success;}// *** V I D E O ***************************************************************************************************************// Read local supported Payload Type for received VIDEO Encoding NameQString SdpBuild::readSupportedVideoPayloadType( QString receivedEncodingName ) { QString localPayloadType = "-1"; // init: Payload Type not supported int suppMediaNumber = sessionC->getTotalNumberOfPrefVideoCodecs(); // Anzahl aller Video-Codecs, die wir untersttzen for (int prio = 0; prio < suppMediaNumber; prio++) { if (receivedEncodingName.upper() == sessionC->getVidPrefCodec(prio)) { localPayloadType = sessionC->getVidPrefCodecNum(prio); break; } } return localPayloadType;}// Negotiation of VIDEO Codecsbool SdpBuild::videoMediaNegotiationINVITE(int recAttributeNumber) { bool success = false; int negPriority = 0; // start with highest priority of negotiation codecs for (int recAttrCounter = 0; recAttrCounter < recAttributeNumber; recAttrCounter++) { QString recEncoding = vcstr[recAttrCounter]; // get received Encoding Name QString localPayload = readSupportedVideoPayloadType( recEncoding ); // get local Payload Type for the received Encoding Name // Encoding supported? if (localPayload != "-1") { // Highest priority? if (negPriority == 0) { setVidPrefCodec(recEncoding); setVidPrefCodecNum(vcc[recAttrCounter]);// PAYLOAD TYPE NUMBER VON DER ANDEREN SEITE!!!!! success = true; } negPriority++; // for next entry in Negotiation Parameter file } } return success;}void SdpBuild::setExtHost( const QString &tc ){ if (tc != testHost) cntParam ++; testHost = tc;}void SdpBuild::setExtPort( const QString &tp ) { if (tp != testPort) cntParam ++; testPort = tp;}void SdpBuild::setExtHomePort( const QString &thp ) { if( thp == QString::null ) { testHomePort = "0"; } else { testHomePort = thp; }}void SdpBuild::setSExtHomePort( const QString &thp ) { if( thp == QString::null ) { testSHomePort = "0"; } else { testSHomePort = thp; }}void SdpBuild::setAudioPort( const QString &tp ) { if (tp != audioPort) cntParam ++; audioPort = tp;}void SdpBuild::setAudioHomePort( const QString &thp ){ if( thp == QString::null ) { audioHomePort = "0"; } else { audioHomePort = thp; }} void SdpBuild::setVidCodec (const QString &vc0 ){ if( vc0 == QString::null ) { videoCodec = "0"; } else { videoCodec = vc0; }}codecType SdpBuild::getRtpCodec(void) { if (getPrefCodecNum()== "3") return codecGSM; if (getPrefCodecNum()== "8") return codecALAW; if (getPrefCodecNum()== "97") { if(sessionC->getPayload() == 160) return codecILBC_20; else return codecILBC_30; } if (getPrefCodecNum()== "98") return codecSpeex; return codecULAW;}codecType SdpBuild::getVideoRtpCodec(void) {return codecULAW;}int SdpBuild::getRtpCodecNum(void) {if (getPrefCodecNum()== "3") return 3;if (getPrefCodecNum()== "8") return 8;if (getPrefCodecNum()== "97") return 97;if (getPrefCodecNum()== "98") return 98;return 0;}bool SdpBuild::testTrans(int status,QString trans) {int tr = sessionC->useL4(status); if ( (tr == useudpL4) && (trans.lower() == "udp") ) return true; if ( (tr == usertpL4) && (trans.lower() == "rtp/avp") ) return true; return false;}void SdpBuild::setVidPrefCodec (const QString &vc) {if (vc != videoPrefCodec) cntParam ++;videoPrefCodec = vc; }void SdpBuild::setVidPrefCodecNum (const QString &vc) {if (vc != videoPrefCodecNum) cntParam ++;videoPrefCodecNum = vc; }void SdpBuild::setPrefCodec (const QString &pc) {if (pc != prefCodec) cntParam ++;prefCodec = pc; }void SdpBuild::setPrefCodecNum (const QString &pc) {if (pc != prefCodecNum) cntParam ++;prefCodecNum = pc; }int SdpBuild::doReturn (int stat) { realLoad=stat; if( ReInvite) { if( (stat == 0) || (stat == (int) SipCall::putMeOnHold) ) { return stat; } else { if (cntParam >0 ) return stat; return (int)SipCall::noChange; } } else return stat;}void SdpBuild::setResponsePay(int pay) {if ( pay != responsePay) cntParam ++;responsePay = pay;}/*QString SdpBuild::prepOptString(void) { msg = "Accept: application/sdp\r\n"; msg += "Accept-Language: en\r\n"; msg += "Supported: eventlist\r\n";return msg;}*/QString SdpBuild::prepOptString(void) { msg = "v=0\r\n"; // Version msg += "o=username 0 0 IN IP4 0.0.0.0\r\n"; msg += "s=The Funky Flow\r\n"; // Session Name msg += "c=IN IP4 0.0.0.0\r\n"; msg += "t=0 0\r\n"; // Time active msg += "audio 0 RTP/AVP 0 8 3 97 98 101\r\n"; msg += "a=rtpmap:0 PCMU/8000\r\n"; msg += "a=rtpmap:8 PCMA/8000\r\n"; msg += "a=rtpmap:3 GSM/8000\r\n"; msg += "a=rtpmap:97 ILBC/8000\r\n"; msg += "a=rtpmap:98 SPEEX/8000\r\n"; msg += "a=rtpmap:101 telephone-event/8000\r\n";// msg += "a=fmtp:97 mode=20\r\n";// msg += "m=video 8000 RTP/AVP 31 34 103\r\n";// msg += "a=rtpmap:31 H261/90000\r\n";// msg += "a=rtpmap:34 H263/90000\r\n";// msg += "a=rtpmap:103 H263-1998/90000\r\n";return msg;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -