1#include "../UserAgent.hxx"
19#define RESIPROCATE_SUBSYSTEM AppSubsystem::MOHPARKSERVER
21#define PARKLOG_PREFIX << "ParkManager[" << mParkUri << "] "
33 mConversationProfileHandle(0),
67 if(mConversationProfileHandle)
70 mConversationProfileHandle = 0;
73 auto parkConversationProfile = std::make_shared<ConversationProfile>(mServer.mUserAgentMasterProfile);
74 parkConversationProfile->setDefaultRegistrationTime(registrationTime);
75 parkConversationProfile->setDefaultRegistrationRetryTime(120);
76 parkConversationProfile->setDefaultFrom(uri);
77 parkConversationProfile->setDigestCredential(uri.
uri().
host(), uri.
uri().
user(), password);
80 parkConversationProfile->setOutboundProxy(outboundProxy.
uri());
82 parkConversationProfile->challengeOODReferRequests() =
false;
83 parkConversationProfile->setExtraHeadersInReferNotifySipFragEnabled(
true);
88 parkConversationProfile->setUserAgentCapabilities(capabilities);
91 mServer.buildSessionCapabilities(parkConversationProfile->sessionCaps());
98 unsigned long numOrbits,
100 const Data& password,
101 unsigned long registrationTime,
107 OrbitProfileMap::iterator itOrbit = mOrbitProfiles.begin();
108 for(;itOrbit!=mOrbitProfiles.end();itOrbit++)
112 mOrbitProfiles.clear();
115 mOrbitRangeStart = orbitStart;
116 mNumOrbits = numOrbits;
119 mFreeOrbitList.clear();
121 for(
unsigned long orbit = mOrbitRangeStart; orbit < mOrbitRangeStart + mNumOrbits; orbit++)
123 auto orbitConversationProfile = std::make_shared<ConversationProfile>(mServer.mUserAgentMasterProfile);
125 orbitConversationProfile->setDefaultRegistrationTime(registrationTime);
126 orbitConversationProfile->setDefaultRegistrationRetryTime(120);
127 orbitConversationProfile->setDefaultFrom(uri);
128 orbitConversationProfile->getDefaultFrom().uri().user() = orbitData;
129 orbitConversationProfile->setDigestCredential(uri.
uri().
host(), orbitData, password);
132 orbitConversationProfile->setOutboundProxy(outboundProxy.
uri());
134 orbitConversationProfile->challengeOODReferRequests() =
false;
135 orbitConversationProfile->setExtraHeadersInReferNotifySipFragEnabled(
true);
140 orbitConversationProfile->setUserAgentCapabilities(capabilities);
143 mServer.buildSessionCapabilities(orbitConversationProfile->sessionCaps());
147 if(mOrbits.find(orbit) == mOrbits.end())
149 mFreeOrbitList.push_back(orbit);
158 mMaxParkTime = maxParkTime;
159 mMusicFilename = musicFilename;
166 OrbitMap::iterator it = mOrbits.begin();
167 for(;it!=mOrbits.end();it++)
173 mOrbitsByParticipant.clear();
179 if(!shuttingDownServer)
182 if(mConversationProfileHandle)
185 mConversationProfileHandle = 0;
189 OrbitProfileMap::iterator itOrbit = mOrbitProfiles.begin();
190 for(;itOrbit!=mOrbitProfiles.end();itOrbit++)
194 mOrbitProfiles.clear();
203 if(profile.
getHandle() == mConversationProfileHandle)
210 OrbitProfileMap::iterator it = mOrbitProfiles.begin();
211 for(;it!=mOrbitProfiles.end();it++)
223ParkManager::getOrbit(
unsigned long orbit)
226 (orbit < (mOrbitRangeStart + mNumOrbits)));
229 OrbitMap::iterator it = mOrbits.find(orbit);
231 if(it == mOrbits.end())
234 parkOrbit =
new ParkOrbit(mServer, orbit, mMaxParkTime, mMusicFilename);
235 mOrbits[orbit] = parkOrbit;
238 std::deque<unsigned long>::iterator itFree = mFreeOrbitList.begin();
239 for(;itFree!=mFreeOrbitList.end();itFree++)
243 mFreeOrbitList.erase(itFree);
251 parkOrbit = it->second;
259 OrbitsByParticipantMap::iterator it = mOrbitsByParticipant.find(participantHandle);
260 if(it != mOrbitsByParticipant.end())
270 if(orbit->addParticipant(participantHandle, parkedUri, parkerUri))
272 mOrbitsByParticipant[participantHandle] = orbit;
283 unsigned long orbit = 0;
292 if((orbit >= mOrbitRangeStart) &&
293 (orbit < (mOrbitRangeStart + mNumOrbits)))
304 if(mFreeOrbitList.size() > 0)
306 unsigned long freeorbit = mFreeOrbitList.front();
308 mFreeOrbitList.pop_front();
309 mFreeOrbitList.push_back(freeorbit);
310 InfoLog(
PARKLOG_PREFIX <<
"parkParticipant: no valid orbit specified (orbit=" << orbit <<
") redirecting to free orbit=" << freeorbit);
330 unsigned long orbit = 0;
339 if((orbit >= mOrbitRangeStart) &&
340 (orbit < (mOrbitRangeStart + mNumOrbits)))
343 if(msg.
exists(h_ReferredBy))
349 addParticipantToOrbit(parkOrbit, participantHandle, msg.
header(h_From).
uri(), msg.
header(h_ReferredBy).
uri());
355 OrbitMap::iterator it = mOrbits.find(orbit);
357 if(it!=mOrbits.end() && (participantToRetrieve = it->second->getNextQueuedParticipant()) != 0)
360 mServer.
addParticipant(it->second->getConversationHandle(), participantHandle);
365 InfoLog(
PARKLOG_PREFIX <<
"incomingParticipant: retrieving participant " << participantToRetrieve <<
" from orbit " << orbit);
369 WarningLog(
PARKLOG_PREFIX <<
"incomingParticipant: orbit " << orbit <<
" has no call to retrieve, rejecting with 404.");
385 ParkOrbit* orbit = getOrbitByParticipant(participantHandle);
388 mOrbitsByParticipant.erase(participantHandle);
395 unsigned long orbitNum = orbit->
getOrbit();
396 if((orbitNum >= mOrbitRangeStart) &&
397 (orbitNum < (mOrbitRangeStart + mNumOrbits)))
400 mFreeOrbitList.push_back(orbitNum);
403 mOrbits.erase(orbitNum);
416 OrbitMap::iterator it = mOrbits.begin();
417 for(; it != mOrbits.end(); it++)
419 ParkOrbit::ParticipantQueue::iterator it2 = it->second->mParticipants.begin();
420 for(; it2 != it->second->mParticipants.end(); it2++)
425 (*it2)->mParticipantHandle,
426 it->second->mConversationHandle));
437 ParkOrbit* orbit = getOrbitByParticipant(participantHandle);
#define WarningLog(args_)
static const resip::ExtensionParameter p_automaton("automaton")
static const resip::ExtensionParameter p_rendering("+sip.rendering")
static const resip::ExtensionParameter p_byeless("+sip.byeless")
static const resip::ExtensionParameter p_automaton("automaton")
static const resip::ExtensionParameter p_orbit("orbit")
static const resip::ExtensionParameter p_rendering("+sip.rendering")
static const resip::ExtensionParameter p_byeless("+sip.byeless")
#define resip_assert(x)
This file needs to work for both C and C++ code.
resip::NameAddr mOutboundProxy
resip::Uri mMOHFilenameUrl
unsigned long mOrbitRegistrationTime
unsigned long mOrbitRangeStart
unsigned long mMaxParkTime
unsigned long mRegistrationTime
resip::Data mOrbitPassword
resip::NameAddr mOutboundProxy
bool onMaxParkTimeout(recon::ParticipantHandle participantHandle)
void parkParticipant(recon::ParticipantHandle participantHandle, const resip::SipMessage &msg)
void shutdown(bool shuttingDownServer)
void getActiveCallsInfo(CallInfoList &callInfos)
ParkManager(Server &server)
void initializeParkSettings(unsigned long maxParkTime, const resip::Uri &musicFilename)
void incomingParticipant(recon::ParticipantHandle participantHandle, const resip::SipMessage &msg)
bool removeParticipant(recon::ParticipantHandle participantHandle)
void startup(ConfigParser::ParkSettings &settings)
void initializeOrbitConversationProfiles(unsigned long orbitStart, unsigned long numOrbits, const resip::NameAddr &uri, const resip::Data &password, unsigned long registrationTime, const resip::NameAddr &outboundProxy)
bool isMyProfile(recon::ConversationProfile &profile)
void initializeConversationProfile(const resip::NameAddr &uri, const resip::Data &password, unsigned long registrationTime, const resip::NameAddr &outboundProxy)
bool onMaxParkTimeout(recon::ParticipantHandle participantHandle)
unsigned long getNumParticipants()
bool removeParticipant(recon::ParticipantHandle participantHandle)
virtual void redirectParticipant(ParticipantHandle partHandle, const resip::NameAddr &destination, unsigned int redirectCode=302, RedirectSuccessCondition successCondition=RedirectSuccessOnConnected)
Redirects the participant to another endpoint.
virtual void answerParticipant(ParticipantHandle partHandle)
Signal to the participant that the call is answered.
virtual void rejectParticipant(ParticipantHandle partHandle, unsigned int rejectCode)
Rejects an incoming remote participant with the specified code.
virtual void redirectToParticipant(ParticipantHandle partHandle, ParticipantHandle destPartHandle, RedirectSuccessCondition successCondition=RedirectSuccessOnConnected)
This is used for attended transfer scenarios where both participants are no longer managed by the con...
virtual void addParticipant(ConversationHandle convHandle, ParticipantHandle partHandle)
Adds the specified participant to the specified conversation.
virtual void modifyParticipantContribution(ConversationHandle convHandle, ParticipantHandle partHandle, unsigned int inputGain, unsigned int outputGain)
Modifies how the participant contributes to the particular conversation.
This class extends the resip UserProfile to include Conversation Manager specific settings.
virtual ConversationProfileHandle getHandle()
Get the conversation profile handle.
void destroyConversationProfile(ConversationProfileHandle handle)
Destroys an existing Conversation Profile.
ConversationProfileHandle addConversationProfile(std::shared_ptr< ConversationProfile > conversationProfile, bool defaultOutgoing=true)
Adds a Conversation Profile to be managed, by the user agent.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
unsigned long convertUnsignedLong() const
bool empty() const noexcept
Checks whether the Data is empty.
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
const Data & param(const ExtensionParameter ¶m) const
Const accessor for non-natively-supported parameter types.
Represents a SIP message.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
bool exists(const HeaderBase &headerType) const
Returns true if the given header field is present, false otherwise.
resip::MethodTypes method() const
returns the method type of the message
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
bool exists(const Param< Uri > ¶mType) const
Uri getAorAsUri(TransportType transportTypeToRemoveDefaultPort=UNKNOWN_TRANSPORT) const
const Data & param(const ExtensionParameter ¶m) const
Const accessor for non-natively-supported parameter types.
std::list< ActiveCallInfo > CallInfoList
unsigned int ParticipantHandle
dcm! – add UnusedChecking(_enum) below;
std::unique_lock< Mutex > Lock
A convenience class to lock a Lockable (such as a Mutex) on object creation, and unlock on destructio...
unsigned __int64 uint64_t