1#include "../UserAgent.hxx"
15#define RESIPROCATE_SUBSYSTEM AppSubsystem::MOHPARKSERVER
17#define MOHLOG_PREFIX << "MOHManager[" << mMOHUri << "] "
28 mConversationProfileHandle(0),
29 mMusicFilenameChanged(false)
51 mConversations[convHandle];
52 mMusicFilenameChanged =
false;
60 if(mConversationProfileHandle)
63 mConversationProfileHandle = 0;
67 auto mohConversationProfile = std::make_shared<ConversationProfile>(mServer.mUserAgentMasterProfile);
68 mohConversationProfile->setDefaultRegistrationTime(registrationTime);
69 mohConversationProfile->setDefaultRegistrationRetryTime(120);
70 mohConversationProfile->setDefaultFrom(uri);
71 mohConversationProfile->setDigestCredential(uri.
uri().
host(), uri.
uri().
user(), password);
74 mohConversationProfile->setOutboundProxy(outboundProxy.
uri());
76 mohConversationProfile->challengeOODReferRequests() =
false;
77 mohConversationProfile->setExtraHeadersInReferNotifySipFragEnabled(
true);
82 mohConversationProfile->setUserAgentCapabilities(capabilities);
85 mServer.buildSessionCapabilities(mohConversationProfile->sessionCaps());
94 mMusicFilename = musicFilename;
97 if(mConversations.size() == 1 && mConversations.begin()->second.size() == 0)
100 mConversations.clear();
105 mConversations[convHandle];
109 mMusicFilenameChanged =
true;
118 ConversationMap::iterator it = mConversations.begin();
119 for (; it != mConversations.end(); it++)
122 ParticipantMap::iterator partIt = it->second.begin();
123 for (; partIt != it->second.end(); partIt++)
125 delete partIt->second;
131 mConversations.clear();
137 if(mConversationProfileHandle && !shuttingDownServer)
140 mConversationProfileHandle = 0;
149 return profile.
getHandle() == mConversationProfileHandle;
158 ConversationMap::iterator it = mConversations.begin();
159 for(; it != mConversations.end(); it++)
161 if(it->second.size() < DEFAULT_BRIDGE_MAX_IN_OUTPUTS-3)
164 conversationToUse = it->first;
170 if(!conversationToUse)
173 InfoLog(
MOHLOG_PREFIX <<
"addParticipant: created new conversation for music on hold, id=" << conversationToUse);
180 InfoLog(
MOHLOG_PREFIX <<
"addParticipant: using existing conversation for music on hold, id=" << conversationToUse);
188 mConversations[conversationToUse].insert(std::make_pair(participantHandle,
new ParticipantMOHInfo(participantHandle, heldUri, holdingUri)));
196 ConversationMap::iterator it = mConversations.begin();
197 for(; it != mConversations.end(); it++)
199 ParticipantMap::iterator partIt = it->second.find(participantHandle);
200 if(partIt != it->second.end())
202 InfoLog(
MOHLOG_PREFIX <<
"removeParticipant: found in conversation id=" << it->first <<
", size=" << it->second.size());
205 delete partIt->second;
206 it->second.erase(partIt);
209 if(it->second.size() == 0)
211 if(mConversations.size() > 1)
217 mConversations.erase(it);
219 InfoLog(
MOHLOG_PREFIX <<
"removeParticipant: last participant in conversation, destroying conversation, num conversations now=" << mConversations.size());
221 else if(mConversations.size() == 1 && mMusicFilenameChanged)
224 mConversations.clear();
229 mConversations[convHandle];
230 mMusicFilenameChanged =
false;
244 ConversationMap::iterator it = mConversations.begin();
245 for(; it != mConversations.end(); it++)
247 ParticipantMap::iterator partIt = it->second.begin();
248 for(; partIt != it->second.end(); partIt++)
250 callInfos.push_back(
ActiveCallInfo(partIt->second->mHeldUri, partIt->second->mHoldingUri,
"MOH", partIt->first, it->first));
static const resip::ExtensionParameter p_automaton("automaton")
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::Uri mMOHFilenameUrl
unsigned long mRegistrationTime
resip::NameAddr mOutboundProxy
resip::NameAddr mOutboundProxy
MOHManager(Server &server)
bool removeParticipant(recon::ParticipantHandle participantHandle)
void startup(ConfigParser::MOHSettings &settings)
void addParticipant(recon::ParticipantHandle participantHandle, const resip::Uri &heldUri, const resip::Uri &holdingUri)
void shutdown(bool shuttingDownServer)
void getActiveCallsInfo(CallInfoList &callInfos)
void initializeSettings(const resip::Uri &musicFilename)
bool isMyProfile(recon::ConversationProfile &profile)
void initializeConversationProfile(const resip::NameAddr &uri, const resip::Data &password, unsigned long registrationTime, const resip::NameAddr &outboundProxy)
virtual ParticipantHandle createMediaResourceParticipant(ConversationHandle convHandle, const resip::Uri &mediaUrl, const std::shared_ptr< resip::Data > &playAudioBuffer=std::shared_ptr< resip::Data >(), void *recordingCircularBuffer=0)
Creates a new media resource participant in the specified conversation.
virtual void answerParticipant(ParticipantHandle partHandle)
Signal to the participant that the call is answered.
virtual void addParticipant(ConversationHandle convHandle, ParticipantHandle partHandle)
Adds the specified participant to the specified conversation.
virtual void destroyConversation(ConversationHandle convHandle)
Destroys an existing Conversation, and ends all participants that solely belong to this conversation.
virtual ConversationHandle createConversation(AutoHoldMode autoHoldMode=AutoHoldEnabled)
Create a new empty Conversation to which participants can be added.
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.
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 the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
std::list< ActiveCallInfo > CallInfoList
unsigned int ConversationHandle
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...