~ubuntu-branches/ubuntu/utopic/resiprocate/utopic

« back to all changes in this revision

Viewing changes to resip/recon/RemoteParticipant.cxx

  • Committer: Package Import Robot
  • Author(s): Daniel Pocock
  • Date: 2014-03-25 21:34:22 UTC
  • mfrom: (18.1.26 sid)
  • Revision ID: package-import@ubuntu.com-20140325213422-s8qr5lsrnjfkbm8i
* New upstream release
* Fix crash in librecon when UA is not using
  a UserProfile derived from ConversationProfile (Closes: #742638)
* Ensure consistent use of milliseconds in DTMF tone API.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <rutil/Logger.hxx>
20
20
#include <rutil/DnsUtil.hxx>
21
21
#include <rutil/Random.hxx>
 
22
#include <resip/stack/DtmfPayloadContents.hxx>
22
23
#include <resip/stack/SipFrag.hxx>
23
24
#include <resip/stack/ExtensionHeader.hxx>
24
25
#include <resip/dum/DialogUsageManager.hxx>
122
123
void 
123
124
RemoteParticipant::initiateRemoteCall(const NameAddr& destination)
124
125
{
 
126
   SharedPtr<UserProfile> profile;
 
127
   initiateRemoteCall(destination, profile, std::multimap<resip::Data,resip::Data>());
 
128
}
 
129
 
 
130
void
 
131
RemoteParticipant::initiateRemoteCall(const NameAddr& destination, SharedPtr<UserProfile>& callingProfile, const std::multimap<resip::Data,resip::Data>& extraHeaders)
 
132
{
125
133
   SdpContents offer;
126
 
   SharedPtr<ConversationProfile> profile = mConversationManager.getUserAgent()->getDefaultOutgoingConversationProfile();
 
134
   SharedPtr<UserProfile> profile = callingProfile;
 
135
   if(!profile)
 
136
   {
 
137
      profile = mConversationManager.getUserAgent()->getDefaultOutgoingConversationProfile();
 
138
   }
127
139
   buildSdpOffer(mLocalHold, offer);
128
140
   SharedPtr<SipMessage> invitemsg = mDum.makeInviteSession(
129
141
      destination, 
131
143
      &offer, 
132
144
      &mDialogSet);
133
145
 
 
146
   std::multimap<resip::Data,resip::Data>::const_iterator it = extraHeaders.begin();
 
147
   for( ; it != extraHeaders.end(); it++)
 
148
   {
 
149
      resip::Data headerName(it->first);
 
150
      resip::Data value(it->second);
 
151
      StackLog(<<"processing an extension header: " << headerName << ": " << value);
 
152
      resip::Headers::Type hType = resip::Headers::getType(headerName.data(), (int)headerName.size());
 
153
      if(hType == resip::Headers::UNKNOWN)
 
154
      {
 
155
         resip::ExtensionHeader h_Tmp(headerName.c_str());
 
156
         resip::ParserContainer<resip::StringCategory>& pc = invitemsg->header(h_Tmp);
 
157
         resip::StringCategory sc(value);
 
158
         pc.push_back(sc);
 
159
      }
 
160
      else
 
161
      {
 
162
         WarningLog(<<"Discarding header '"<<headerName<<"', only extension headers permitted");
 
163
      }
 
164
   }
 
165
 
134
166
   mDialogSet.sendInvite(invitemsg);
135
167
 
136
168
   // Clear any pending hold/unhold requests since our offer/answer here will handle it
863
895
      // Add any codecs from our capabilities that may not be in current local sdp - since endpoint may have changed and may now be capable 
864
896
      // of handling codecs that it previously could not (common when endpoint is a B2BUA).
865
897
 
866
 
      SdpContents& sessionCaps = dynamic_cast<ConversationProfile*>(mDialogSet.getUserProfile().get())->sessionCaps();
 
898
      SdpContents& sessionCaps = profile->sessionCaps();
867
899
      int highPayloadId = 96;  // Note:  static payload id's are in range of 0-96
868
900
      // Iterate through codecs in session caps and check if already in offer
869
901
      for (std::list<SdpContents::Session::Codec>::iterator codecsIt = sessionCaps.session().media().front().codecs().begin();
2245
2277
}
2246
2278
 
2247
2279
void
2248
 
RemoteParticipant::onInfo(InviteSessionHandle, const SipMessage& msg)
 
2280
RemoteParticipant::onInfo(InviteSessionHandle session, const SipMessage& msg)
2249
2281
{
2250
2282
   InfoLog(<< "onInfo: handle=" << mHandle << ", " << msg.brief());
2251
 
   //assert(0);
 
2283
   if(mHandle)
 
2284
   {
 
2285
      DtmfPayloadContents* contents = dynamic_cast<DtmfPayloadContents*>(msg.getContents());
 
2286
      if(contents)
 
2287
      {
 
2288
         DtmfPayloadContents::DtmfPayload& payload = contents->dtmfPayload();
 
2289
         mConversationManager.onDtmfEvent(mHandle, payload.getEventCode(), payload.getDuration(), true);
 
2290
         session->acceptNIT();
 
2291
      }
 
2292
      else
 
2293
      {
 
2294
         WarningLog(<<"INFO message without dtmf-relay payload, rejecting");
 
2295
         session->rejectNIT();
 
2296
      }
 
2297
   }
 
2298
   else
 
2299
   {
 
2300
      WarningLog(<<"INFO message received, but mHandle not set, rejecting");
 
2301
      session->rejectNIT();
 
2302
   }
2252
2303
}
2253
2304
 
2254
2305
void