reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
RemoteParticipant.hxx
Go to the documentation of this file.
1#if !defined(RemoteParticipant_hxx)
2#define RemoteParticipant_hxx
3
4#include <map>
5
7#include "Participant.hxx"
10
13
19
20#include <memory>
21
22namespace resip
23{
24class DialogUsageManager;
25class SipMessage;
26}
27
28namespace recon
29{
30
40{
41public:
42 // UAC
47
48 // UAS or forked leg
52
53 virtual ~RemoteParticipant();
54
55 virtual resip::InviteSessionHandle& getInviteSessionHandle() { return mInviteSessionHandle; }
56
57 typedef std::function<void(bool sdpOk, std::unique_ptr<resip::SdpContents> sdp)>
59 virtual void buildSdpOffer(bool holdSdp, CallbackSdpReady sdpReady, bool preferExistingSdp = false) = 0;
60
61 virtual bool isHolding() { return mLocalHold; }
62 virtual bool isRemoteHold() { return mRemoteHold; }
63
64 virtual void initiateRemoteCall(const resip::NameAddr& destination);
65 virtual void initiateRemoteCall(const resip::NameAddr& destination, const std::shared_ptr<ConversationProfile>& callingProfile, const std::multimap<resip::Data,resip::Data>& extraHeaders);
66 virtual void destroyParticipant() override;
67 virtual void addToConversation(Conversation *conversation, unsigned int inputGain = 100, unsigned int outputGain = 100) override;
68 virtual void removeFromConversation(Conversation *conversation) override;
69 virtual void accept();
70 virtual void alert(bool earlyFlag);
71 virtual void reject(unsigned int rejectCode);
74 virtual void info(const resip::Contents& contents);
75 virtual void checkHoldCondition();
76 virtual void setLocalHold(bool hold);
77 virtual void sendInstantMessage(std::unique_ptr<resip::Contents> contents) override;
78
80 virtual void setPendingOODReferInfo(resip::ServerSubscriptionHandle ss, const resip::SipMessage& referMsg); // OOD-Refer (with Sub)
81 virtual void acceptPendingOODRefer();
82 virtual void rejectPendingOODRefer(unsigned int statusCode);
83 virtual void redirectPendingOODRefer(resip::NameAddr& destination);
85
88
89 // Called by RemoteParticipantDialogSet when Related Conversations should be destroyed
90 virtual void destroyConversations();
91 virtual void notifyTerminating();
92 virtual void adjustRTPStreams(bool sendingOffer=false) = 0;
93
94 // Invite Session Handler /////////////////////////////////////////////////////
107 virtual void onOffer(resip::InviteSessionHandle handle, const resip::SipMessage& msg, const resip::SdpContents& offer);
112 virtual void onInfo(resip::InviteSessionHandle, const resip::SipMessage& msg);
118 virtual void doReferNoSub(const resip::SipMessage& msg);
124
125 // ClientSubscriptionHandler ///////////////////////////////////////////////////
126 virtual void onUpdatePending(resip::ClientSubscriptionHandle h, const resip::SipMessage& notify, bool outOfOrder);
127 virtual void onUpdateActive(resip::ClientSubscriptionHandle h, const resip::SipMessage& notify, bool outOfOrder);
128 virtual void onUpdateExtension(resip::ClientSubscriptionHandle, const resip::SipMessage& notify, bool outOfOrder);
132
133 virtual void requestKeyframe() = 0;
134 virtual void requestKeyframeFromPeer();
135 virtual void requestKeyframeFromPeerTimeout(bool reset);
136 // force a SIP re-INVITE to this RemoteParticipant
137 virtual void reInvite();
138
139protected:
140 void addExtraHeader(const std::shared_ptr<resip::SipMessage>& invitemsg, const resip::Data& headerName, const resip::Data& headerValue);
141 void setRemoteHold(bool remoteHold);
144 std::shared_ptr<resip::SdpContents> getLocalSdp() { return mLocalSdp; };
145 void setRemoteSdp(const resip::SdpContents& sdp, bool answer=false);
146 std::shared_ptr<resip::SdpContents> getRemoteSdp() { return mRemoteSdp; };
148 std::shared_ptr<resip::SdpContents> getLocalSdpGathering() { return mLocalSdpGathering; };
149
150 virtual bool mediaStackPortAvailable() = 0;
151
154 RemoteParticipantDialogSet& getDialogSet() { return mDialogSet; };
155
157 virtual void hold();
158 virtual void unhold();
159
160 virtual bool holdPreferExistingSdp() { return false; };
161
162 bool isTrickleIce() { return mTrickleIce; };
163 virtual void enableTrickleIce();
164
165 virtual void conversationsConfirm();
166
167 virtual std::chrono::duration<double> getKeyframeRequestInterval() const { return mKeyframeRequestInterval; }
168
169 virtual void onLocalIceCandidate(const resip::Data& candidate, unsigned int lineIndex, const resip::Data& mid);
170
171private:
172 void provideOffer(bool postOfferAccept, bool preferExistingSdp = false);
173 void provideAnswer(const resip::SdpContents& offer, bool postAnswerAccept, bool postAnswerAlert);
174 virtual void buildSdpAnswer(const resip::SdpContents& offer, CallbackSdpReady sdpReady) = 0;
175 virtual void replaceWithParticipant(Participant* replacingParticipant) override;
176
178 resip::InviteSessionHandle mInviteSessionHandle;
179 resip::ClientSubscriptionHandle mReferSubscriptionHandle;
180 RemoteParticipantDialogSet& mDialogSet;
181 resip::DialogId mDialogId;
182
184 typedef enum
185 {
186 Connecting=1,
187 Accepted,
188 Connected,
189 Redirecting,
190 Holding,
191 Unholding,
192 Replacing,
193 PendingOODRefer,
194 Terminating
195 } State;
196 State getState() { return mState; };
197 State mState;
198 bool mOfferRequired;
199 bool mLocalHold;
200 bool mRemoteHold;
201 void stateTransition(State state);
202 bool mTrickleIce;
203
204 resip::AppDialogHandle mReferringAppDialog;
205
206 resip::SipMessage mPendingOODReferMsg;
207 resip::ServerOutOfDialogReqHandle mPendingOODReferNoSubHandle;
208 resip::ServerSubscriptionHandle mPendingOODReferSubHandle;
209 ConversationManager::RedirectSuccessCondition mRedirectSuccessCondition;
210
211 typedef enum
212 {
213 None = 0,
214 Hold,
215 Unhold,
216 Redirect,
217 RedirectTo
218 } PendingRequestType;
219 class PendingRequest
220 {
221 public:
222 PendingRequest() : mType(None) {}
223 PendingRequestType mType;
224 resip::NameAddr mDestination;
225 resip::InviteSessionHandle mDestInviteSessionHandle;
226 unsigned int mRedirectCode;
227 ConversationManager::RedirectSuccessCondition mRedirectSuccessCondition;
228 };
229 PendingRequest mPendingRequest;
230 std::unique_ptr<resip::SdpContents> mPendingOffer;
231
232 std::shared_ptr<resip::SdpContents> mLocalSdp;
233 std::shared_ptr<resip::SdpContents> mRemoteSdp;
234
235 std::shared_ptr<resip::SdpContents> mLocalSdpGathering;
236
237 std::chrono::time_point<std::chrono::steady_clock> mLastRemoteKeyframeRequest = std::chrono::steady_clock::now();
238 std::chrono::duration<double> mKeyframeRequestInterval = std::chrono::milliseconds(1000);
239
240 unsigned int mCurrentIntervalIndex = 0;
241 const std::vector<int> mKeyframeIntervals;
242};
243
244}
245
246#endif
247
248
249/* ====================================================================
250
251 Copyright (c) 2021-2026, SIP Spectrum, Inc. http://www.sipspectrum.com
252 Copyright (c) 2022, Software Freedom Institute https://softwarefreedom.institute
253 Copyright (c) 2021-2022, Daniel Pocock https://danielpocock.com
254 Copyright (c) 2007-2008, Plantronics, Inc.
255 All rights reserved.
256
257 Redistribution and use in source and binary forms, with or without
258 modification, are permitted provided that the following conditions are
259 met:
260
261 1. Redistributions of source code must retain the above copyright
262 notice, this list of conditions and the following disclaimer.
263
264 2. Redistributions in binary form must reproduce the above copyright
265 notice, this list of conditions and the following disclaimer in the
266 documentation and/or other materials provided with the distribution.
267
268 3. Neither the name of Plantronics nor the names of its contributors
269 may be used to endorse or promote products derived from this
270 software without specific prior written permission.
271
272 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
273 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
274 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
275 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
276 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
277 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
278 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
279 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
280 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
281 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
282 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
283
284 ==================================================================== */
This class is one of two main classes of concern to an application using the UserAgent library.
This class extends the resip UserProfile to include Conversation Manager specific settings.
This class is used to manage membership of participants.
This class represents base functionality for a participant that supports IMs.
This class represents events from the Media stream.
This is the base class for a RemoteParticipant, LocalParticipant and a MediaResourceParticipant.
This class is used by Invite DialogSets.
This class represent a remote participant.
virtual void onConnectedConfirmed(resip::InviteSessionHandle, const resip::SipMessage &msg)
virtual void onNewSession(resip::ClientInviteSessionHandle h, resip::InviteSession::OfferAnswerType oat, const resip::SipMessage &msg)
virtual void onFailure(resip::ClientInviteSessionHandle h, const resip::SipMessage &msg)
virtual void processReferNotify(resip::ClientSubscriptionHandle h, const resip::SipMessage &notify)
virtual void onUpdateExtension(resip::ClientSubscriptionHandle, const resip::SipMessage &notify, bool outOfOrder)
void setProposedSdp(const resip::SdpContents &sdp)
void setRemoteSdp(const resip::SdpContents &sdp, bool answer=false)
virtual void onRedirected(resip::ClientInviteSessionHandle, const resip::SipMessage &msg)
virtual void requestKeyframeFromPeerTimeout(bool reset)
virtual void redirectToParticipant(resip::InviteSessionHandle &destParticipantInviteSessionHandle, ConversationManager::RedirectSuccessCondition successCondition=ConversationManager::RedirectSuccessOnConnected)
virtual int onRequestRetry(resip::ClientSubscriptionHandle h, int retryMinimum, const resip::SipMessage &notify)
virtual void onRemoteSdpChanged(resip::InviteSessionHandle, const resip::SipMessage &msg, const resip::SdpContents &sdp)
virtual std::chrono::duration< double > getKeyframeRequestInterval() const
virtual void onRefer(resip::InviteSessionHandle, resip::ServerSubscriptionHandle, const resip::SipMessage &msg)
virtual void onLocalIceCandidate(const resip::Data &candidate, unsigned int lineIndex, const resip::Data &mid)
virtual void redirect(resip::NameAddr &destination, unsigned int redirectCode=302, ConversationManager::RedirectSuccessCondition successCondition=ConversationManager::RedirectSuccessOnConnected)
virtual void rejectPendingOODRefer(unsigned int statusCode)
virtual void onMessageFailure(resip::InviteSessionHandle, const resip::SipMessage &msg)
std::shared_ptr< resip::SdpContents > getLocalSdpGathering()
virtual void onOfferRequestRejected(resip::InviteSessionHandle, const resip::SipMessage &msg)
virtual void onUpdatePending(resip::ClientSubscriptionHandle h, const resip::SipMessage &notify, bool outOfOrder)
virtual bool onMediaControlEvent(resip::MediaControlContents::MediaControl &mediaControl)
virtual void initiateRemoteCall(const resip::NameAddr &destination)
virtual bool mediaStackPortAvailable()=0
virtual void setPendingOODReferInfo(resip::ServerOutOfDialogReqHandle ood, const resip::SipMessage &referMsg)
virtual void onOffer(resip::InviteSessionHandle handle, const resip::SipMessage &msg, const resip::SdpContents &offer)
virtual void onInfo(resip::InviteSessionHandle, const resip::SipMessage &msg)
virtual void setLocalHold(bool hold)
virtual void onReferRejected(resip::InviteSessionHandle, const resip::SipMessage &msg)
virtual void onInfoSuccess(resip::InviteSessionHandle, const resip::SipMessage &msg)
virtual void onReferNoSub(resip::InviteSessionHandle, const resip::SipMessage &msg)
std::function< void(bool sdpOk, std::unique_ptr< resip::SdpContents > sdp)> CallbackSdpReady
void addExtraHeader(const std::shared_ptr< resip::SipMessage > &invitemsg, const resip::Data &headerName, const resip::Data &headerValue)
virtual void sendInstantMessage(std::unique_ptr< resip::Contents > contents) override
virtual void onUpdateActive(resip::ClientSubscriptionHandle h, const resip::SipMessage &notify, bool outOfOrder)
virtual void onNewSubscription(resip::ClientSubscriptionHandle h, const resip::SipMessage &notify)
void setLocalSdp(const resip::SdpContents &sdp)
virtual void onConnected(resip::ClientInviteSessionHandle h, const resip::SipMessage &msg)
void setLocalSdpGathering(const resip::SdpContents &sdp)
virtual void onOfferRequired(resip::InviteSessionHandle, const resip::SipMessage &msg)
virtual void addToConversation(Conversation *conversation, unsigned int inputGain=100, unsigned int outputGain=100) override
std::shared_ptr< resip::SdpContents > getLocalSdp()
virtual void onProvisional(resip::ClientInviteSessionHandle, const resip::SipMessage &msg)
virtual void notifyIncomingParticipant(const resip::SipMessage &msg, bool autoAnswer, ConversationProfile &conversationProfile)
virtual void onForkDestroyed(resip::ClientInviteSessionHandle)
virtual void info(const resip::Contents &contents)
virtual void onMessage(resip::InviteSessionHandle, const resip::SipMessage &msg)
virtual void onStaleCallTimeout(resip::ClientInviteSessionHandle)
virtual void onAnswer(resip::InviteSessionHandle, const resip::SipMessage &msg, const resip::SdpContents &)
virtual void removeFromConversation(Conversation *conversation) override
std::shared_ptr< resip::SdpContents > getRemoteSdp()
virtual void buildSdpOffer(bool holdSdp, CallbackSdpReady sdpReady, bool preferExistingSdp=false)=0
virtual bool onTrickleIce(resip::TrickleIceContents &trickleIce)
virtual void destroyParticipant() override
virtual void onReferAccepted(resip::InviteSessionHandle, resip::ClientSubscriptionHandle, const resip::SipMessage &msg)
virtual void doReferNoSub(const resip::SipMessage &msg)
virtual void adjustRTPStreams(bool sendingOffer=false)=0
virtual void reject(unsigned int rejectCode)
virtual void onEarlyMedia(resip::ClientInviteSessionHandle, const resip::SipMessage &, const resip::SdpContents &)
virtual void onMessageSuccess(resip::InviteSessionHandle, const resip::SipMessage &msg)
virtual resip::InviteSessionHandle & getInviteSessionHandle()
virtual void alert(bool earlyFlag)
void setRemoteHold(bool remoteHold)
virtual void onInfoFailure(resip::InviteSessionHandle, const resip::SipMessage &msg)
virtual void onOfferRejected(resip::InviteSessionHandle, const resip::SipMessage *msg)
virtual void onTerminated(resip::InviteSessionHandle h, resip::InviteSessionHandler::TerminatedReason reason, const resip::SipMessage *msg)
virtual void redirectPendingOODRefer(resip::NameAddr &destination)
virtual void requestKeyframe()=0
RemoteParticipantDialogSet & getDialogSet()
Base class for all SIP body types.
Definition Contents.hxx:51
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
TerminatedReason
called when an dialog enters the terminated state - this can happen after getting a BYE,...
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Definition NameAddr.hxx:19
Provides an interface to process and generate SDP bodies (MIME content-type application/sdp).
Represents a SIP message.
unsigned int ParticipantHandle
dcm! – add UnusedChecking(_enum) below;
Handle< AppDialog > AppDialogHandle
Definition Handles.hxx:28
void list()
Definition userAdmin.cxx:66