reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ConversationProfile.cxx
Go to the documentation of this file.
4
5#include "ReconSubsystem.hxx"
7
8#include <utility>
9
10using namespace recon;
11using namespace resip;
12using namespace std;
13
14#define RESIPROCATE_SUBSYSTEM ReconSubsystem::RECON
15
16static const resip::ExtensionParameter p_answerafter("answer-after");
17static const resip::ExtensionParameter p_required("required");
18
20 mHandle(0),
21 mAllowAutoAnswer(false),
22 mAllowPriorityAutoAnswer(false),
23 mChallengeAutoAnswerRequests(false),
24 mChallengeOODReferRequests(true),
25 mDelayedMediaOutboundMode(false),
26 mSecureMediaMode(Srtp),
27 mSecureMediaRequired(false),
28 mDefaultSecureMediaCryptoSuite(SRTP_AES_CM_128_HMAC_SHA1_80),
29 mNatTraversalMode(NoNatTraversal),
30 mForceCOMedia(true),
31 mNatTraversalServerPort(0),
32 mMaximumVideoBandwidth(0)
33{
34}
35
36ConversationProfile::ConversationProfile(std::shared_ptr<Profile> baseProfile) :
37 UserProfile(baseProfile),
38 mHandle(0),
39 mAllowAutoAnswer(false),
40 mAllowPriorityAutoAnswer(false),
41 mChallengeAutoAnswerRequests(false),
42 mChallengeOODReferRequests(true),
43 mDelayedMediaOutboundMode(false),
44 mSecureMediaMode(Srtp),
45 mSecureMediaRequired(false),
46 mDefaultSecureMediaCryptoSuite(SRTP_AES_CM_128_HMAC_SHA1_80),
47 mNatTraversalMode(NoNatTraversal),
48 mForceCOMedia(true),
49 mNatTraversalServerPort(0),
50 mMaximumVideoBandwidth(0)
51{
52}
53
56{
57 return mHandle;
58}
59
60void
61ConversationProfile::setHandle(ConversationProfileHandle handle)
62{
63 resip_assert(mHandle==0);
64 mHandle = handle;
65}
66
69{
70 return mSessionCaps;
71}
72
73const SdpContents
75{
76 return mSessionCaps;
77}
78
79bool
80ConversationProfile::shouldAutoAnswer(const SipMessage& inviteRequest, bool *required)
81{
82 resip_assert(inviteRequest.method() == INVITE);
83 bool shouldAutoAnswer = false;
84 bool autoAnswerRequired = false;
85 if(inviteRequest.exists(h_PrivAnswerMode) && inviteRequest.header(h_PrivAnswerMode).value() == "Auto")
86 {
88 {
89 shouldAutoAnswer = true;
90 }
91 if(inviteRequest.header(h_PrivAnswerMode).exists(p_required))
92 {
93 autoAnswerRequired = true;
94 }
95 }
96 else if(inviteRequest.exists(h_AnswerMode) && inviteRequest.header(h_AnswerMode).value() == "Auto")
97 {
98 if(allowAutoAnswer())
99 {
100 shouldAutoAnswer = true;
101 }
102 if(inviteRequest.header(h_AnswerMode).exists(p_required))
103 {
104 autoAnswerRequired = true;
105 }
106 }
107 else if(allowAutoAnswer() && inviteRequest.exists(h_CallInfos))
108 {
109 // Iterate through Call-Info headers and look for answer-after=0 parameter
110 for(GenericUris::const_iterator i = inviteRequest.header(h_CallInfos).begin(); i != inviteRequest.header(h_CallInfos).end(); i++)
111 {
112 if(i->exists(p_answerafter) && i->param(p_answerafter) == "0")
113 {
114 shouldAutoAnswer = true;
115 }
116 }
117 }
118
119 if(required)
120 {
121 *required = autoAnswerRequired;
122 }
123 return shouldAutoAnswer;
124}
125
126
127/* ====================================================================
128
129 Copyright (c) 2022, SIP Spectrum, Inc. http://sipspectrum.com
130 Copyright (c) 2021, Daniel Pocock https://danielpocock.com
131 Copyright (c) 2007-2008, Plantronics, Inc.
132 All rights reserved.
133
134 Redistribution and use in source and binary forms, with or without
135 modification, are permitted provided that the following conditions are
136 met:
137
138 1. Redistributions of source code must retain the above copyright
139 notice, this list of conditions and the following disclaimer.
140
141 2. Redistributions in binary form must reproduce the above copyright
142 notice, this list of conditions and the following disclaimer in the
143 documentation and/or other materials provided with the distribution.
144
145 3. Neither the name of Plantronics nor the names of its contributors
146 may be used to endorse or promote products derived from this
147 software without specific prior written permission.
148
149 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
150 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
151 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
152 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
153 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
154 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
155 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
156 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
157 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
158 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
159 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
160
161 ==================================================================== */
static const resip::ExtensionParameter p_required("required")
static const resip::ExtensionParameter p_answerafter("answer-after")
#define resip_assert(x)
This file needs to work for both C and C++ code.
virtual bool shouldAutoAnswer(const resip::SipMessage &inviteRequest, bool *required=0)
Checks an Invite message for auto-answer headers against the current allow settings.
virtual resip::SdpContents & sessionCaps()
Get/Set the session capabilities.
virtual bool & allowAutoAnswer()
Get/Set wether auto answers are allowed, if an autoanswer indication is found in a new inbound call r...
virtual bool & allowPriorityAutoAnswer()
Get/Set wether priority auto answers are allowed, if a priority autoanswer indication is found in a n...
virtual ConversationProfileHandle getHandle()
Get the conversation profile handle.
Provides an interface to process and generate SDP bodies (MIME content-type application/sdp).
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
unsigned int ConversationProfileHandle
dcm! – add UnusedChecking(_enum) below;