📄 invitesession.cxx
字号:
mMinSE = mSessionInterval; sessionRefresh(); } else { // Response must contain Min_SE - if not - just ignore // ?slg? callback? transition(Connected); mProposedLocalSdp.reset(); mProposedEncryptionLevel = DialogUsageManager::None; } break; case OnUpdateRejected: transition(Connected); mProposedLocalSdp.reset(); handler->onOfferRejected(getSessionHandle(), &msg); break; case OnGeneralFailure: sendBye(); transition(Terminated); handler->onTerminated(getSessionHandle(), InviteSessionHandler::GeneralFailure, &msg); break; default: dispatchOthers(msg); break; }}voidInviteSession::dispatchSentReinvite(const SipMessage& msg){ InviteSessionHandler* handler = mDum.mInviteSessionHandler; std::auto_ptr<SdpContents> sdp = InviteSession::getSdp(msg); switch (toEvent(msg, sdp.get())) { case OnInvite: case OnInviteReliable: case OnInviteOffer: case OnInviteReliableOffer: case OnUpdate: case OnUpdateOffer: { SharedPtr<SipMessage> response(new SipMessage); mDialog.makeResponse(*response, msg, 491); send(response); break; } case On1xx: case On1xxEarly: // Some UA's send a 100 response to a ReInvite - just ignore it break; case On2xxAnswer: case On2xxOffer: // .slg. doesn't really make sense { mStaleReInviteTimerSeq++; transition(Connected); handleSessionTimerResponse(msg); setCurrentLocalSdp(msg); // !jf! I need to potentially include an answer in the ACK here sendAck(); mCurrentEncryptionLevel = getEncryptionLevel(msg); if (mSessionRefreshReInvite) { mSessionRefreshReInvite = false; MD5Stream currentRemote; currentRemote<< *mCurrentRemoteSdp; MD5Stream newRemote; newRemote << *sdp; bool changed = currentRemote.getHex() != newRemote.getHex(); if (changed) { mCurrentRemoteSdp = sdp; handler->onRemoteSdpChanged(getSessionHandle(), msg, *mCurrentRemoteSdp); } } else { handler->onAnswer(getSessionHandle(), msg, *sdp); } // !jf! do I need to allow a reINVITE overlapping the retransmission of // the ACK when a 200I is received? If yes, then I need to store all // ACK messages for 64*T1 break; } case On2xx: mStaleReInviteTimerSeq++; sendAck(); transition(Connected); handleSessionTimerResponse(msg); handler->onIllegalNegotiation(getSessionHandle(), msg); mProposedLocalSdp.reset(); mProposedEncryptionLevel = DialogUsageManager::None; break; case On422Invite: mStaleReInviteTimerSeq++; if(msg.exists(h_MinSE)) { // Change interval to min from 422 response mSessionInterval = msg.header(h_MinSE).value(); mMinSE = mSessionInterval; sessionRefresh(); } else { // Response must contact Min_SE - if not - just ignore // ?slg? callback? transition(Connected); mProposedLocalSdp.reset(); mProposedEncryptionLevel = DialogUsageManager::None; } break; case On491Invite: mStaleReInviteTimerSeq++; transition(SentReinviteGlare); start491Timer(); break; case OnGeneralFailure: mStaleReInviteTimerSeq++; sendBye(); transition(Terminated); handler->onTerminated(getSessionHandle(), InviteSessionHandler::GeneralFailure, &msg); break; case OnInviteFailure: case On487Invite: mStaleReInviteTimerSeq++; transition(Connected); mProposedLocalSdp.reset(); handler->onOfferRejected(getSessionHandle(), &msg); break; default: dispatchOthers(msg); break; }}voidInviteSession::dispatchSentReinviteNoOffer(const SipMessage& msg){ InviteSessionHandler* handler = mDum.mInviteSessionHandler; std::auto_ptr<SdpContents> sdp = InviteSession::getSdp(msg); switch (toEvent(msg, sdp.get())) { case OnInvite: case OnInviteReliable: case OnInviteOffer: case OnInviteReliableOffer: case OnUpdate: case OnUpdateOffer: { SharedPtr<SipMessage> response(new SipMessage); mDialog.makeResponse(*response, msg, 491); send(response); break; } case On1xx: case On1xxEarly: // Some UA's send a 100 response to a ReInvite - just ignore it break; case On2xxAnswer: // .slg. doesn't really make sense case On2xxOffer: { mStaleReInviteTimerSeq++; transition(SentReinviteAnswered); handleSessionTimerResponse(msg); // mLastSessionModification = msg; // ?slg? why are we storing 200's? mCurrentEncryptionLevel = getEncryptionLevel(msg); mProposedRemoteSdp = sdp; handler->onOffer(getSessionHandle(), msg, *mProposedRemoteSdp); break; } case On2xx: mStaleReInviteTimerSeq++; sendAck(); transition(Connected); handleSessionTimerResponse(msg); handler->onIllegalNegotiation(getSessionHandle(), msg); mProposedLocalSdp.reset(); mProposedEncryptionLevel = DialogUsageManager::None; break; case On422Invite: mStaleReInviteTimerSeq++; if(msg.exists(h_MinSE)) { // Change interval to min from 422 response mSessionInterval = msg.header(h_MinSE).value(); mMinSE = mSessionInterval; sessionRefresh(); } else { // Response must contact Min_SE - if not - just ignore // ?slg? callback? transition(Connected); mProposedLocalSdp.reset(); mProposedEncryptionLevel = DialogUsageManager::None; } break; case On491Invite: mStaleReInviteTimerSeq++; transition(SentReinviteNoOfferGlare); start491Timer(); break; case OnGeneralFailure: mStaleReInviteTimerSeq++; sendBye(); transition(Terminated); handler->onTerminated(getSessionHandle(), InviteSessionHandler::GeneralFailure, &msg); break; case OnInviteFailure: case On487Invite: mStaleReInviteTimerSeq++; transition(Connected); mProposedLocalSdp.reset(); handler->onOfferRejected(getSessionHandle(), &msg); break; default: dispatchOthers(msg); break; }}void InviteSession::dispatchReceivedReinviteSentOffer(const SipMessage& msg){ InviteSessionHandler* handler = mDum.mInviteSessionHandler; std::auto_ptr<SdpContents> sdp = InviteSession::getSdp(msg); switch (toEvent(msg, sdp.get())) { case OnInvite: case OnInviteReliable: case OnInviteOffer: case OnInviteReliableOffer: case OnUpdate: case OnUpdateOffer: { SharedPtr<SipMessage> response(new SipMessage); mDialog.makeResponse(*response, msg, 491); send(response); break; } case OnAckAnswer: transition(Connected); setCurrentLocalSdp(msg); mCurrentRemoteSdp = sdp; mCurrentEncryptionLevel = getEncryptionLevel(msg); mCurrentRetransmit200 = 0; // stop the 200 retransmit timer handler->onAnswer(getSessionHandle(), msg, *mCurrentRemoteSdp); break; case OnAck: if (mLastRemoteSessionModification->header(h_CSeq).sequence() > msg.header(h_CSeq).sequence()) { InfoLog(<< "dropped stale ACK"); } else { InfoLog(<< "Got Ack with no answer"); transition(Connected); mProposedLocalSdp.reset(); mProposedEncryptionLevel = DialogUsageManager::None; mCurrentRetransmit200 = 0; // stop the 200 retransmit timer //!dcm! -- should this be onIllegalNegotiation? handler->onOfferRejected(getSessionHandle(), &msg); } break; default: dispatchOthers(msg); break; }}voidInviteSession::dispatchGlare(const SipMessage& msg){ InviteSessionHandler* handler = mDum.mInviteSessionHandler; MethodTypes method = msg.header(h_CSeq).method(); if (msg.isRequest() && (method == INVITE || method == UPDATE)) { DebugLog(<< "Re-INVITE or UPDATE received when in SentReinviteGlare or SentUpdateGlare" << endl); // Received inbound reinvite or update, when waiting to resend outbound reinvite or update handler->onOfferRejected(getSessionHandle(), &msg); if(!isTerminated()) // make sure application didn't call end() { dispatchConnected(msg); // act as if we received message in Connected state } else { dispatchTerminated(msg); } } else { dispatchOthers(msg); }}voidInviteSession::dispatchReinviteNoOfferGlare(const SipMessage& msg){ InviteSessionHandler* handler = mDum.mInviteSessionHandler; MethodTypes method = msg.header(h_CSeq).method(); if (msg.isRequest() && (method == INVITE || method == UPDATE)) { // Received inbound reinvite or update, when waiting to resend outbound reinvite or update handler->onOfferRequestRejected(getSessionHandle(), msg); if(!isTerminated()) // make sure application didn't call end() { dispatchConnected(msg); // act as if we received message in Connected state } else { dispatchTerminated(msg); } } else { dispatchOthers(msg); }}voidInviteSession::dispatchReceivedUpdateOrReinvite(const SipMessage& msg){ MethodTypes method = msg.header(h_CSeq).method(); if (method == INVITE || method == UPDATE) { // Means that the UAC has sent us a second reINVITE or UPDATE before we // responded to the first one. Bastard! SharedPtr<SipMessage> response(new SipMessage); mDialog.makeResponse(*response, msg, 500); response->header(h_RetryAfter).value() = Random::getRandom() % 10; send(response); } else { dispatchOthers(msg); }}voidInviteSession::dispatchAnswered(const SipMessage& msg){ if (msg.isRequest() && msg.header(h_RequestLine).method() == ACK) { mCurrentRetransmit200 = 0; // stop the 200 retransmit timer transition(Connected); } else { dispatchOthers(msg); }}voidInviteSession::dispatchSentReinviteAnswered(const SipMessage& msg){ if (msg.isResponse() && msg.header(h_CSeq).method() == INVITE && msg.header(h_StatusLine).statusCode() / 200 == 1) { // Receving a 200 retransmission is possible - but we don't have an ACK response yet - we are still waiting for provideAnswer to be // called by the app - so just drop the retransmission return; } dispatchOthers(msg);}voidInviteSession::dispatchWaitingToOffer(const SipMessage& msg){ if (msg.isRequest() && msg.header(h_RequestLine).method() == ACK) { assert(mProposedLocalSdp.get()); mCurrentRetransmit200 = 0; // stop the 200 retransmit timer provideProposedOffer(); } else { dispatchOthers(msg); }}voidInviteSession::dispatchWaitingToRequestOffer(const SipMessage& msg){ if (msg.isRequest() && msg.header(h_RequestLine).method() == ACK) { mCurrentRetransmit200 = 0; // stop the 200 retransmit timer requestOffer(); } else { dispatchOthers(msg); }}voidInviteSession::dispatchWaitingToTerminate(const SipMessage& msg){ if (msg.isResponse() && msg.header(h_CSeq).method() == INVITE) { if(msg.header(h_StatusLine).statusCode() / 200 == 1) // Note: stack ACK's non-2xx final responses only { // !jf! Need to include the answer here. sendAck(); } sendBye(); transition(Terminated); mDum.mInviteSessionHandler->onTerminated(getSessionHandle(), InviteSessionHandler::Ended); } else if(msg.isRequest()) { if(msg.method() == BYE) { dispatchBye(msg); } else { SharedPtr<SipMessage> response(new SipMessage); mDialog.makeResponse(*response, msg, 400 /* Bad Request */); send(response); } }}voidInviteSession::dispatchWaitingToHangup(const SipMessage& msg){ std::auto_ptr<SdpContents> sdp = InviteSession::getSdp(msg);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -