11#include "../UserAgent.hxx"
26#include <os/OsSysLog.h>
32#define RESIPROCATE_SUBSYSTEM AppSubsystem::MOHPARKSERVER
43 const Tuple &destination,
44 const Data& sigcompId)
52 DebugLog( <<
"SdpMessageDecorator: src=" << source <<
", dest=" << destination <<
", msg=" << endl << msg.
brief());
66 void onApplicationTimer(
unsigned int id, std::chrono::duration<double> duration,
unsigned int seq)
override
74 InfoLog(<<
"onApplicationTimeout: id=" <<
id
75 <<
" dur=" << std::chrono::duration_cast<std::chrono::milliseconds>(duration).count()
83 InfoLog(<<
"onSubscriptionTerminated: handle=" << handle <<
" statusCode=" << statusCode);
88 InfoLog(<<
"onSubscriptionNotify: handle=" << handle <<
" data=" << endl << notifyData);
105 const Data& messageWithHeaders,
106 const Data& instanceName)
131 OsSysLog::initialize(0,
"MOHParkServer");
137 InfoLog( <<
"MOHParkServer settings:");
141 InfoLog(<<
" MOH" << itMOH->first <<
" URI = " << itMOH->second.mUri);
142 InfoLog(<<
" MOH" << itMOH->first <<
" Registration Time = " << itMOH->second.mRegistrationTime);
143 InfoLog(<<
" MOH" << itMOH->first <<
" Outbound Proxy = " << itMOH->second.mOutboundProxy);
144 InfoLog(<<
" MOH" << itMOH->first <<
" Filename URL = " << itMOH->second.mMOHFilenameUrl);
149 InfoLog(<<
" Park" << itPark->first <<
" URI = " << itPark->second.mUri);
150 InfoLog(<<
" Park" << itPark->first <<
" Registration Time = " << itPark->second.mRegistrationTime);
151 InfoLog(<<
" Park" << itPark->first <<
" Outbound Proxy = " << itPark->second.mOutboundProxy);
152 InfoLog(<<
" Park" << itPark->first <<
" Filename URL = " << itPark->second.mMOHFilenameUrl);
153 InfoLog(<<
" Park" << itPark->first <<
" Orbit Range Start = " << itPark->second.mOrbitRangeStart);
154 InfoLog(<<
" Park" << itPark->first <<
" Number of Orbits = " << itPark->second.mNumOrbits);
155 InfoLog(<<
" Park" << itPark->first <<
" Orbit Registration Time = " << itPark->second.mOrbitRegistrationTime);
156 InfoLog(<<
" Park" << itPark->first <<
" Max Park Time = " << itPark->second.mMaxParkTime);
186 std::list<std::pair<Data,Data> >::iterator itInt = interfaces.begin();
187 for(;itInt != interfaces.end(); itInt++)
201 auto profile = std::make_shared<UserAgentMasterProfile>();
244 std::cerr <<
"Cannot start a transport, likely a port is already in use" << endl;
258 pb.
data(dnsServer, start);
261 InfoLog( <<
"Adding DNS Server: " << dnsServer);
262 profile->addAdditionalDnsServer(dnsServer);
266 ErrLog( <<
"Tried to add dns server, but invalid format: " << dnsServer);
275 profile->statisticsManagerEnabled() =
false;
279 profile->setKeepAliveTimeForDatagram(30);
280 profile->setKeepAliveTimeForStream(180);
284 profile->validateContentEnabled() =
false;
285 profile->validateContentLanguageEnabled() =
false;
286 profile->validateAcceptEnabled() =
false;
288 profile->clearSupportedLanguages();
289 profile->addSupportedLanguage(
Token(
"en"));
291 profile->clearSupportedMimeTypes();
292 profile->addSupportedMimeType(INVITE,
Mime(
"application",
"sdp"));
293 profile->addSupportedMimeType(INVITE,
Mime(
"multipart",
"mixed"));
294 profile->addSupportedMimeType(INVITE,
Mime(
"multipart",
"signed"));
295 profile->addSupportedMimeType(INVITE,
Mime(
"multipart",
"alternative"));
296 profile->addSupportedMimeType(OPTIONS,
Mime(
"application",
"sdp"));
297 profile->addSupportedMimeType(OPTIONS,
Mime(
"multipart",
"mixed"));
298 profile->addSupportedMimeType(OPTIONS,
Mime(
"multipart",
"signed"));
299 profile->addSupportedMimeType(OPTIONS,
Mime(
"multipart",
"alternative"));
300 profile->addSupportedMimeType(NOTIFY,
Mime(
"message",
"sipfrag"));
302 profile->clearSupportedMethods();
303 profile->addSupportedMethod(INVITE);
304 profile->addSupportedMethod(ACK);
305 profile->addSupportedMethod(CANCEL);
306 profile->addSupportedMethod(OPTIONS);
307 profile->addSupportedMethod(BYE);
308 profile->addSupportedMethod(REFER);
309 profile->addSupportedMethod(NOTIFY);
310 profile->addSupportedMethod(SUBSCRIBE);
312 profile->clearSupportedOptionTags();
321 profile->clearSupportedSchemes();
322 profile->addSupportedScheme(
"sip");
324 profile->addSupportedScheme(
"sips");
328 profile->clearAdvertisedCapabilities();
329 profile->addAdvertisedCapability(Headers::Allow);
331 profile->addAdvertisedCapability(Headers::AcceptLanguage);
332 profile->addAdvertisedCapability(Headers::Supported);
333 profile->setMethodsParamEnabled(
true);
335 profile->setUserAgent(
"MOHParkServer");
340 profile->setOutboundDecorator(std::make_shared<SdpMessageDecorator>());
342 mUserAgentMasterProfile = profile;
353 mWebAdminThread->
run();
362 mWebAdminThread->
join();
363 delete mWebAdminThread;
376 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
377 for (; itMOH != mMOHManagerMap.end(); itMOH++)
379 delete itMOH->second;
382 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
383 for (; itPark != mParkManagerMap.end(); itPark++)
385 delete itPark->second;
409 mMOHManagerMap[itMOH->first] = mohManager;
410 mohManager->
startup(itMOH->second);
419 mParkManagerMap[itPark->first] = parkManager;
420 parkManager->
startup(itPark->second);
425Server::process(
int timeoutMs)
428 mMyUserAgent->
process(timeoutMs);
434 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
435 for (; itMOH != mMOHManagerMap.end(); itMOH++)
437 itMOH->second->shutdown(
true );
438 delete itMOH->second;
440 mMOHManagerMap.clear();
442 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
443 for (; itPark != mParkManagerMap.end(); itPark++)
445 itPark->second->shutdown(
true );
446 delete itPark->second;
448 mParkManagerMap.clear();
452 OsSysLog::shutdown();
458 std::vector<unsigned int> codecIds = { SdpCodec::SDP_CODEC_PCMU ,
459 SdpCodec::SDP_CODEC_PCMA ,
460 SdpCodec::SDP_CODEC_G729A ,
461 SdpCodec::SDP_CODEC_OPUS ,
462 SdpCodec::SDP_CODEC_SPEEX ,
463 SdpCodec::SDP_CODEC_SPEEX_15 ,
464 SdpCodec::SDP_CODEC_SPEEX_24 ,
465 SdpCodec::SDP_CODEC_L16_44100_MONO ,
466 SdpCodec::SDP_CODEC_G726_16,
467 SdpCodec::SDP_CODEC_G726_24,
468 SdpCodec::SDP_CODEC_G726_32,
469 SdpCodec::SDP_CODEC_G726_40,
470 SdpCodec::SDP_CODEC_ILBC ,
471 SdpCodec::SDP_CODEC_ILBC_20MS ,
472 SdpCodec::SDP_CODEC_SPEEX_5 ,
473 SdpCodec::SDP_CODEC_GSM ,
474 SdpCodec::SDP_CODEC_TONES };
484 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
485 for (; itMOH != mMOHManagerMap.end(); itMOH++)
487 itMOH->second->getActiveCallsInfo(callInfos);
491 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
492 for (; itPark != mParkManagerMap.end(); itPark++)
494 itPark->second->getActiveCallsInfo(callInfos);
501 InfoLog(<<
"onConversationDestroyed: handle=" << convHandle);
507 InfoLog(<<
"onParticipantDestroyed: handle=" << partHandle);
510 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
511 for (; itMOH != mMOHManagerMap.end(); itMOH++)
513 if (itMOH->second->removeParticipant(partHandle))
519 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
520 for (; itPark != mParkManagerMap.end(); itPark++)
522 if (itPark->second->removeParticipant(partHandle))
532 InfoLog(<<
"onDtmfEvent: handle=" << partHandle <<
" tone=" << dtmf <<
" dur=" << duration <<
" up=" << up);
538 InfoLog(<<
"onIncomingParticipant: handle=" << partHandle <<
" auto=" << autoAnswer <<
" msg=" << msg.
brief());
541 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
542 for (; itMOH != mMOHManagerMap.end(); itMOH++)
544 if (itMOH->second->isMyProfile(conversationProfile))
546 itMOH->second->addParticipant(partHandle, msg.
header(h_From).
uri(), msg.
header(h_From).
uri());
551 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
552 for (; itPark != mParkManagerMap.end(); itPark++)
554 if (itPark->second->isMyProfile(conversationProfile))
556 itPark->second->incomingParticipant(partHandle, msg);
568 InfoLog(<<
"onRequestOutgoingParticipant: handle=" << partHandle <<
" msg=" << msg.
brief());
571 MOHManagerMap::iterator itMOH = mMOHManagerMap.begin();
572 for (; itMOH != mMOHManagerMap.end(); itMOH++)
574 if (itMOH->second->isMyProfile(conversationProfile))
581 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
582 for (; itPark != mParkManagerMap.end(); itPark++)
584 if (itPark->second->isMyProfile(conversationProfile))
586 itPark->second->parkParticipant(partHandle, msg);
598 InfoLog(<<
"onParticipantTerminated: handle=" << partHandle);
604 InfoLog(<<
"onParticipantProceeding: handle=" << partHandle <<
" msg=" << msg.
brief());
611 InfoLog(<<
"onRelatedConversation: relatedConvHandle=" << relatedConvHandle <<
" relatedPartHandle=" << relatedPartHandle
612 <<
" origConvHandle=" << origConvHandle <<
" origPartHandle=" << origPartHandle);
618 InfoLog(<<
"onParticipantAlerting: handle=" << partHandle <<
" msg=" << msg.
brief());
624 InfoLog(<<
"onParticipantConnected: handle=" << partHandle <<
" msg=" << msg.
brief());
630 InfoLog(<<
"onParticipantRedirectSuccess: handle=" << partHandle);
637 InfoLog(<<
"onParticipantRedirectFailure: handle=" << partHandle <<
" statusCode=" << statusCode);
643 InfoLog(<<
"onParticipantRequestedHold: handle=" << partHandle <<
" held=" << held);
650 ParkManagerMap::iterator itPark = mParkManagerMap.begin();
651 for (; itPark != mParkManagerMap.end(); itPark++)
653 if (itPark->second->onMaxParkTimeout(participantHandle))
#define resip_assert(x)
This file needs to work for both C and C++ code.
static AppSubsystem MOHPARKSERVER
unsigned short mMediaPortRangeSize
resip::NameAddr mOutboundProxy
MOHSettingsMap mMOHSettingsMap
unsigned int mLogFileMaxBytes
resip::AfterSocketCreationFuncPtr mSocketFunc
unsigned short mMediaPortRangeStart
ParkSettingsMap mParkSettingsMap
resip::Data mCertificatePath
resip::Data mSipXLogFilename
void startup(ConfigParser::MOHSettings &settings)
virtual bool operator()(Log::Level level, const Subsystem &subsystem, const Data &appName, const char *file, int line, const Data &message, const Data &messageWithHeaders, const Data &instanceName)
return true to also do default logging, false to supress default logging.
virtual ~MOHParkServerLogger()
MyUserAgent(Server &server, std::shared_ptr< UserAgentMasterProfile > profile, resip::AfterSocketCreationFuncPtr socketFunc)
void onSubscriptionNotify(SubscriptionHandle handle, const Data ¬ifyData) override
Callback used when a subscription has received an event notification from the server.
void onApplicationTimer(unsigned int id, std::chrono::duration< double > duration, unsigned int seq) override
Callback used when an application timer expires.
void onSubscriptionTerminated(SubscriptionHandle handle, unsigned int statusCode) override
Callback used when a subscription is terminated.
void startup(ConfigParser::ParkSettings &settings)
virtual MessageDecorator * clone() const
virtual void decorateMessage(SipMessage &msg, const Tuple &source, const Tuple &destination, const Data &sigcompId)
virtual ~SdpMessageDecorator()
virtual void rollbackMessage(SipMessage &msg)
virtual void onRelatedConversation(recon::ConversationHandle relatedConvHandle, recon::ParticipantHandle relatedPartHandle, recon::ConversationHandle origConvHandle, recon::ParticipantHandle origPartHandle)
Notifies an applications that a outbound remote participant request has forked.
virtual void onRequestOutgoingParticipant(recon::ParticipantHandle partHandle, const resip::SipMessage &msg, recon::ConversationProfile &conversationProfile)
Notifies an application about a new remote participant that is trying to be contacted.
virtual void onParticipantRedirectFailure(recon::ParticipantHandle partHandle, unsigned int statusCode)
Notifies an application that a redirect request has failed.
void startup()
Starts the recon thread(s).
virtual void onConversationDestroyed(recon::ConversationHandle convHandle)
Notifies an application when a conversation has been destroyed.
void getActiveCallsInfo(CallInfoList &callInfos)
virtual void onDtmfEvent(recon::ParticipantHandle partHandle, int dtmf, int duration, bool up)
Notifies an application when an RFC2833 DTMF event is received from a particular remote participant.
virtual void onParticipantRedirectSuccess(recon::ParticipantHandle partHandle)
Notifies an application that a redirect request has succeeded.
virtual void onParticipantConnected(recon::ParticipantHandle partHandle, const resip::SipMessage &msg)
Notifies an application that a remote participant call attempt is now connected.
void initializeResipLogging(unsigned int maxByteCount, const resip::Data &level, const resip::Data &resipFilename)
virtual void onParticipantRequestedHold(recon::ParticipantHandle partHandle, bool held)
virtual void onParticipantProceeding(recon::ParticipantHandle partHandle, const resip::SipMessage &msg)
Notifies an application that a remote participant call attempt is proceeding at the first hop.
virtual void onParticipantDestroyed(recon::ParticipantHandle partHandle)
Notifies an application when a Participant has been destroyed.
Server(ConfigParser &config)
virtual void onParticipantTerminated(recon::ParticipantHandle partHandle, unsigned int statusCode)
Notifies an application about a disconnect by a remote participant.
virtual void onParticipantAlerting(recon::ParticipantHandle partHandle, const resip::SipMessage &msg)
Notifies an application that a remote participant call attempt is alerting the remote party.
virtual void onMaxParkTimeout(recon::ParticipantHandle participantHandle)
void shutdown()
Used to initiate a shutdown of the server.
virtual void onIncomingParticipant(recon::ParticipantHandle partHandle, const resip::SipMessage &msg, bool autoAnswer, recon::ConversationProfile &conversationProfile)
Notifies an application about a new remote participant that is attempting to contact it.
This class is one of two main classes of concern to an application using the UserAgent library.
virtual void setMediaStackAdapter(std::shared_ptr< MediaStackAdapter > mediaStackAdapter)
virtual void rejectParticipant(ParticipantHandle partHandle, unsigned int rejectCode)
Rejects an incoming remote participant with the specified code.
MediaStackAdapter & getMediaStackAdapter()
virtual void destroyParticipant(ParticipantHandle partHandle)
Ends connections to the participant and removes it from all active conversations.
This class extends the resip UserProfile to include Conversation Manager specific settings.
This class is one of two main classes of concern to an application using the UserAgent library.
virtual void process(int timeoutMs)
This should be called in a loop to give process cycles to the UserAgent.
void shutdown()
Used to initiate a shutdown of the useragent.
void startup()
Starts the SIP stack thread.
The abstract base-class for all exceptions thrown by resip code.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
const char * c_str() const
Returns a null-terminated string representing.
bool empty() const noexcept
Checks whether the Data is empty.
static std::list< std::pair< Data, Data > > getInterfaces(const Data &matchingInterface=Data::Empty)
static bool isIpV4Address(const Data &ipAddress)
Interface functor for external logging.
static void setMaxByteCount(unsigned int maxByteCount)
static void initialize(Type type, Level level, const Data &appName, const char *logFileName=0, ExternalLogger *externalLogger=0, const Data &syslogFacility="LOG_DAEMON", MessageStructure messageStructure=Unstructured, const Data &instanceName="")
virtual Brief brief() const
return a facet for brief encoding of message
Represents the "media-type" element in the RFC 3261 grammar.
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipWhitespace()
CurrentPosition position() const
CurrentPosition skipToOneOf(const char *cs)
CurrentPosition skipChar()
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
static const char * Whitespace
const Data & getAddress() const
returns the connection address
void setAddress(const Data &host, AddrType type=IP4)
set the address for the connection
void setAddress(const Data &host, AddrType type=IP4)
set the address for the session
const Origin & origin() const
return session Origin line
const Connection & connection() const
return session Connection
const MediumContainer & media() const
return session Media lines
Provides an interface to process and generate SDP bodies (MIME content-type application/sdp).
Session & session()
get the parsed SDP
Represents a SIP message.
Contents * getContents() const
Retrieves the body of a SIP message.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
Class used to specify what sub-system given sections of code belong to, for use by the logging system...
const Data & getSubsystem() const
static const char * Timer
static const char * AnswerMode
static const char * Replaces
static const char * NoReferSub
static const char * TargetDialog
Represents the "token" element in the RFC 3261 grammar.
Represents a network address.
IpVersion ipVersion() const
Returns V4 or V6 as appropriate.
static Data inet_ntop(const Tuple &tuple)
Converts the binary socket address to presentation format, via the DnsUtil::inet_ntop() method.
Uri getAorAsUri(TransportType transportTypeToRemoveDefaultPort=UNKNOWN_TRANSPORT) const
MOHParkServerLogger g_MOHParkServerLogger
unsigned int ConversationHandle
unsigned int ParticipantHandle
unsigned int SubscriptionHandle
dcm! – add UnusedChecking(_enum) below;
void(* AfterSocketCreationFuncPtr)(Socket s, int transportType, const char *file, int line)