📄 invitesession.hxx
字号:
#if !defined(RESIP_INVITESESSION_HXX)#define RESIP_INVITESESSION_HXX#include "resip/stack/SipMessage.hxx"#include "resip/stack/SdpContents.hxx"#include "resip/dum/DialogUsage.hxx"#include "resip/dum/DialogUsageManager.hxx"#include <map>#include <queue>namespace resip{class SdpContents;/** Base class for class ClientInviteSession and class ServerInviteSession. Implements common attributes and behavior (i.e.t post connected) of the two classes.*/class InviteSession : public DialogUsage{ public: /** Called to set the offer that will be used in the next message that sends an offer. If possible, this will synchronously send the appropriate request or response. In some cases, the UAS might have to call accept in order to cause the message to be sent. */ virtual void provideOffer(const SdpContents& offer); virtual void provideOffer(const SdpContents& offer, DialogUsageManager::EncryptionLevel level, const SdpContents* alternative); /** Similar to provideOffer - called to set the answer to be signalled to the peer. May result in message being sent synchronously depending on the state. */ virtual void provideAnswer(const SdpContents& answer); /** Called to request that the far end provide an offer. This will cause a reinvite with no sdp to be sent. */ virtual void requestOffer(); enum EndReason { NotSpecified=0, UserHangup, AppRejectedSdp, IllegalNegotiation, AckNotReceived, SessionExpired, StaleReInvite, ENDREASON_MAX }; /** Makes the specific dialog end. Will send a BYE (not a CANCEL) */ virtual void end(EndReason reason); virtual void end(); // reason == NotSpecified ; same as above - required for BaseUsage pure virtual /** Rejects an offer at the SIP level. Can also be used to send a 488 to a reINVITE or UPDATE */ virtual void reject(int statusCode, WarningCategory *warning = 0); /** will send a reINVITE (current sdp) or UPDATE with new Contact header */ virtual void targetRefresh(const NameAddr& localUri); // Following methods are for sending requests within a dialog /** sends a refer request */ virtual void refer(const NameAddr& referTo, bool referSub = true); virtual void refer(const NameAddr& referTo, std::auto_ptr<resip::Contents> contents, bool referSub = true); /** sends a refer request with a replaces header */ virtual void refer(const NameAddr& referTo, InviteSessionHandle sessionToReplace, bool referSub = true); /** sends an info request */ virtual void info(const Contents& contents); /** sends a message request @warning From RFC3428 - The authors recognize that there may be valid reasons to send MESSAGE requests in the context of a dialog. For example, one participant in a voice session may wish to send an IM to another participant, and associate that IM with the session. But implementations SHOULD NOT create dialogs for the primary purpose of associating MESSAGE requests with one another. */ virtual void message(const Contents& contents); /** accepts an INFO or MESSAGE request with a 2xx and an optional contents */ virtual void acceptNIT(int statusCode = 200, const Contents * contents = 0); /** rejects an INFO or MESSAGE request with an error status code */ virtual void rejectNIT(int statusCode = 488); /** * Provide asynchronous method access by using command */ virtual void provideOfferCommand(const SdpContents& offer); virtual void provideOfferCommand(const SdpContents& offer, DialogUsageManager::EncryptionLevel level, const SdpContents* alternative); virtual void provideAnswerCommand(const SdpContents& answer); /** Asynchronously makes the specific dialog end. Will send a BYE (not a CANCEL) */ virtual void endCommand(EndReason reason = NotSpecified); /** Asynchronously rejects an offer at the SIP level. Can also be used to send a 488 to a reINVITE or UPDATE */ virtual void rejectCommand(int statusCode, WarningCategory *warning = 0); virtual void referCommand(const NameAddr& referTo, bool referSub = true); virtual void referCommand(const NameAddr& referTo, InviteSessionHandle sessionToReplace, bool referSub = true); virtual void infoCommand(const Contents& contents); virtual void messageCommand(const Contents& contents); /** Asynchronously accepts an INFO or MESSAGE request with a 2xx and an optional contents */ virtual void acceptNITCommand(int statusCode = 200, const Contents * contents = 0); /** Asynchronously rejects an INFO or MESSAGE request with an error status code */ virtual void rejectNITCommand(int statusCode = 488); virtual void acceptReferNoSub(int statusCode = 200); virtual void rejectReferNoSub(int responseCode); // Convenience methods for accessing attributes of a dialog. const NameAddr& myAddr() const; const NameAddr& peerAddr() const; const SdpContents& getLocalSdp() const; const SdpContents& getRemoteSdp() const; const SdpContents& getProposedRemoteSdp() const; const Data& getDialogId() const; bool isConnected() const; bool isTerminated() const; bool isEarly() const; // UAC Early states bool isAccepted() const; // UAS States after accept is called Tokens& getPeerSupportedMethods() { return mPeerSupportedMethods; } Tokens& getPeerSupportedOptionTags() { return mPeerSupportedOptionTags; } Mimes& getPeerSupportedMimeTypes() { return mPeerSupportedMimeTypes; } Tokens& getPeerSupportedEncodings() { return mPeerSupportedEncodings; } Tokens& getPeerSupportedLanguages() { return mPeerSupportedLanguages; } Tokens& getPeerAllowedEvents() { return mPeerAllowedEvents; } Data& getPeerUserAgent() { return mPeerUserAgent; } NameAddrs& getPeerPAssertedIdentities() { return mPeerPAssertedIdentities; } virtual std::ostream& dump(std::ostream& strm) const; InviteSessionHandle getSessionHandle(); typedef enum { None, // means no Offer or Answer (may have SDP) Offer, Answer } OfferAnswerType; protected: typedef enum { Undefined, // Not used Connected, SentUpdate, // Sent an UPDATE SentUpdateGlare, // got a 491 SentReinvite, // Sent a reINVITE SentReinviteGlare, // Got a 491 SentReinviteNoOffer, // Sent a reINVITE with no offer (requestOffer) SentReinviteAnswered, // Sent a reINVITE no offer and received a 200-offer SentReinviteNoOfferGlare, // Got a 491 ReceivedUpdate, // Received an UPDATE ReceivedReinvite, // Received a reINVITE ReceivedReinviteNoOffer, // Received a reINVITE with no offer ReceivedReinviteSentOffer, // Sent a 200 to a reINVITE with no offer Answered, WaitingToOffer, WaitingToRequestOffer, WaitingToTerminate, // Waiting for 2xx response before sending BYE WaitingToHangup, // Waiting for ACK before sending BYE Terminated, // Ended. waiting to delete UAC_Start, UAC_Early, UAC_EarlyWithOffer, UAC_EarlyWithAnswer, UAC_Answered, UAC_SentUpdateEarly, UAC_SentUpdateEarlyGlare, UAC_ReceivedUpdateEarly, UAC_SentAnswer, UAC_QueuedUpdate, UAC_Cancelled, UAS_Start, UAS_Offer, UAS_OfferProvidedAnswer, UAS_EarlyOffer, UAS_EarlyProvidedAnswer, UAS_NoOffer, UAS_ProvidedOffer, UAS_EarlyNoOffer, UAS_EarlyProvidedOffer, UAS_Accepted, UAS_WaitingToOffer, UAS_WaitingToRequestOffer, UAS_AcceptedWaitingAnswer, UAS_ReceivedOfferReliable, UAS_NoOfferReliable, UAS_FirstSentOfferReliable, UAS_FirstSentAnswerReliable, UAS_NegotiatedReliable, UAS_SentUpdate, UAS_SentUpdateAccepted, UAS_ReceivedUpdate, UAS_ReceivedUpdateWaitingAnswer, UAS_WaitingToTerminate, UAS_WaitingToHangup } State; typedef enum { OnRedirect, // 3xx OnGeneralFailure, // 481 or 408 OnInvite, // UAS OnInviteOffer,// UAS OnInviteReliableOffer, // UAS OnInviteReliable, // UAS OnCancel, // UAS OnBye, On200Bye, On1xx, // UAC On1xxEarly, // UAC On1xxOffer, // UAC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -