reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Sdp.cxx
Go to the documentation of this file.
1#include "Sdp.hxx"
2#include "SdpMediaLine.hxx"
3
4#include <rutil/Data.hxx>
5
6using namespace sdpcontainer;
7
8const char* Sdp::SdpNetTypeString[] =
9{
10 "NONE",
11 "IN"
12};
13
14const char* Sdp::SdpAddressTypeString[] =
15{
16 "NONE",
17 "IP4",
18 "IP6"
19};
20
21const char* Sdp::SdpBandwidthTypeString[] =
22{
23 "NONE",
24 "CT",
25 "AS",
26 "TIAS",
27 "RS",
28 "RR"
29};
30
31const char* Sdp::SdpConferenceTypeString[] =
32{
33 "NONE",
34 "BROADCAST",
35 "MODERATED",
36 "TEST",
37 "H332"
38};
39
40const char* Sdp::SdpGroupSemanticsString[] =
41{
42 "NONE",
43 "LS",
44 "FID",
45 "SRF",
46 "ANAT"
47};
48
49
50// Constructor
52{
53 mSdpVersion = 1;
54 mOriginatorSessionId = 0;
55 mOriginatorSessionVersion = 0;
56 mOriginatorNetType = NET_TYPE_NONE;
57 mOriginatorAddressType = ADDRESS_TYPE_NONE;
58 mConferenceType = CONFERENCE_TYPE_NONE;
59 mIcePassiveOnlyMode = false;
60 mMaximumPacketRate = 0;
61}
62
63// Copy constructor
65{
66 operator=(rhs);
67}
68
69// Destructor
71{
73}
74
75// Assignment operator
76Sdp&
78{
79 if (this == &rhs) // handle the assignment to self case
80 return *this;
81
82 // Assign values
83 mSdpVersion = rhs.mSdpVersion;
84 mOriginatorUserName = rhs.mOriginatorUserName;
85 mOriginatorSessionId = rhs.mOriginatorSessionId;
86 mOriginatorSessionVersion = rhs.mOriginatorSessionVersion;
87 mOriginatorNetType = rhs.mOriginatorNetType;
88 mOriginatorAddressType = rhs.mOriginatorAddressType;
89 mOriginatorUnicastAddress = rhs.mOriginatorUnicastAddress;
90 mSessionName = rhs.mSessionName;
91 mSessionInformation = rhs.mSessionInformation;
92 mSessionUri = rhs.mSessionUri;
93 mEmailAddresses = rhs.mEmailAddresses;
94 mPhoneNumbers = rhs.mPhoneNumbers;
95 mBandwidths = rhs.mBandwidths;
96 mTimes = rhs.mTimes;
97 mTimeZones = rhs.mTimeZones;
98 mCategory = rhs.mCategory;
99 mKeywords = rhs.mKeywords;
100 mToolNameAndVersion = rhs.mToolNameAndVersion;
101 mConferenceType = rhs.mConferenceType;
102 mCharSet = rhs.mCharSet;
103 mIcePassiveOnlyMode = rhs.mIcePassiveOnlyMode;
104 mGroups = rhs.mGroups;
105 mSessionLanguage = rhs.mSessionLanguage;
106 mDescriptionLanguage = rhs.mDescriptionLanguage;
107 mMaximumPacketRate = rhs.mMaximumPacketRate;
108 mFoundationIds = rhs.mFoundationIds;
109
110 // Copy over media lines - deep copy of pointers
112 MediaLineList::const_iterator it = rhs.mMediaLines.begin();
113 for(;it != rhs.mMediaLines.end(); it++)
114 {
117 }
118
119 return *this;
120}
121
124{
125 resip::Data dataType(type);
126
128 {
129 return ADDRESS_TYPE_IP4;
130 }
131 else if(resip::isEqualNoCase("IP6", dataType))
132 {
133 return ADDRESS_TYPE_IP6;
134 }
135 else
136 {
137 return ADDRESS_TYPE_NONE;
138 }
139}
140
143{
144 resip::Data dataType(type);
145
147 {
148 return BANDWIDTH_TYPE_CT;
149 }
150 else if(resip::isEqualNoCase("AS", dataType))
151 {
152 return BANDWIDTH_TYPE_AS;
153 }
154 else if(resip::isEqualNoCase("TIAS", dataType))
155 {
156 return BANDWIDTH_TYPE_TIAS;
157 }
158 else if(resip::isEqualNoCase("RS", dataType))
159 {
160 return BANDWIDTH_TYPE_RS;
161 }
162 else if(resip::isEqualNoCase("RR", dataType))
163 {
164 return BANDWIDTH_TYPE_RR;
165 }
166 else
167 {
168 return BANDWIDTH_TYPE_NONE;
169 }
170}
171
174{
175 resip::Data dataType(type);
176
177 if(resip::isEqualNoCase("broadcast", dataType))
178 {
180 }
181 else if(resip::isEqualNoCase("moderated", dataType))
182 {
184 }
185 else if(resip::isEqualNoCase("test", dataType))
186 {
188 }
189 else if(resip::isEqualNoCase("H332", dataType))
190 {
192 }
193 else
194 {
196 }
197}
198
201{
202 resip::Data dataType(type);
203
205 {
206 return GROUP_SEMANTICS_LS;
207 }
208 else if(resip::isEqualNoCase("FID", dataType))
209 {
210 return GROUP_SEMANTICS_FID;
211 }
212 else if(resip::isEqualNoCase("SRF", dataType))
213 {
214 return GROUP_SEMANTICS_SRF;
215 }
216 else if(resip::isEqualNoCase("ANAT", dataType))
217 {
219 }
220 else
221 {
223 }
224}
225
226void
232 const char* unicastAddress)
233{
234 mOriginatorUserName = userName;
235 mOriginatorSessionId = sessionId;
236 mOriginatorSessionVersion = sessionVersion;
237 mOriginatorNetType = netType;
238 mOriginatorAddressType = addressType;
239 mOriginatorUnicastAddress = unicastAddress;
240}
241
242void
244{
245 mMediaLines.push_back(mediaLine);
246}
247
248void
250{
251 MediaLineList::iterator it = mMediaLines.begin();
252 for(;it != mMediaLines.end(); it++)
253 {
254 delete *it;
255 }
256 mMediaLines.clear();
257}
258
259const Sdp::MediaLineList&
261{
262 return mMediaLines;
263}
264
267{
268 MediaLineList::iterator it = mMediaLines.begin();
269 int mediaLineIndex = 0;
270 for (; it != mMediaLines.end(); it++, mediaLineIndex++)
271 {
273 {
274 return *it;
275 }
276 }
277 return nullptr;
278}
279
282 const char * baseAddress,
283 const char * stunAddress)
284{
286
287 std::map<resip::Data, SdpFoundation>::iterator it;
288 for(it = mFoundationIds.begin(); it != mFoundationIds.end(); it++)
289 {
290 if(it->second == sdpFoundation)
291 {
292 return it->first;
293 }
294 }
295
296 // Not found - insert
297 std::string foundationId = std::to_string(mFoundationIds.size() + 1);
298 mFoundationIds[foundationId] = sdpFoundation;
299
300 return foundationId;
301}
302
304sdpcontainer::operator<<( EncodeStream& strm, const Sdp& sdp)
305{
306 strm << "Sdp:" << std::endl
307 << "SdpVersion: " << sdp.mSdpVersion << std::endl
308 << "OrigUserName: '" << sdp.mOriginatorUserName << "'" << std::endl
309 << "OrigSessionId: " << sdp.mOriginatorSessionId << std::endl
310 << "OrigSessionVersion: " << sdp.mOriginatorSessionVersion << std::endl
311 << "OrigNetType: " << Sdp::SdpNetTypeString[sdp.mOriginatorNetType] << std::endl
312 << "OrigAddressType: " << Sdp::SdpAddressTypeString[sdp.mOriginatorAddressType] << std::endl
313 << "OrigUnicastAddr: '" << sdp.mOriginatorUnicastAddress << "'" << std::endl
314 << "SessionName: '" << sdp.mSessionName << "'" << std::endl
315 << "SessionInformation: '" << sdp.mSessionInformation << "'" << std::endl
316 << "SessionUri: '" << sdp.mSessionUri << "'" << std::endl;
317
318 Sdp::EmailAddressList::const_iterator itEmail = sdp.mEmailAddresses.begin();
319 for(;itEmail != sdp.mEmailAddresses.end(); itEmail++)
320 {
321 strm << "EmailAddress: '" << *itEmail << "'" << std::endl;
322 }
323
324 Sdp::PhoneNumberList::const_iterator itPhone = sdp.mPhoneNumbers.begin();
325 for(;itPhone != sdp.mPhoneNumbers.end(); itPhone++)
326 {
327 strm << "PhoneNumber: '" << *itPhone << "'" << std::endl;
328 }
329
330 Sdp::BandwidthList::const_iterator itBandwidth = sdp.mBandwidths.begin();
331 for(;itBandwidth != sdp.mBandwidths.end(); itBandwidth++)
332 {
333 strm << "Bandwidth: type=" << Sdp::SdpBandwidthTypeString[itBandwidth->getType()]
334 << ", bandwidth=" << itBandwidth->getBandwidth() << std::endl;
335 }
336
337 Sdp::TimeList::const_iterator itTime = sdp.mTimes.begin();
338 for(;itTime != sdp.mTimes.end(); itTime++)
339 {
340 strm << "Time: start=" << itTime->getStartTime()
341 << ", stop=" << itTime->getStopTime() << std::endl;
342
343 Sdp::SdpTime::RepeatsList::const_iterator itRepeat = itTime->getRepeats().begin();
344 for(;itRepeat!=itTime->getRepeats().end(); itRepeat++)
345 {
346 strm << "TimeRepeat: interval=" << itRepeat->getRepeatInterval()
347 << ", duration=" << itRepeat->getActiveDuration();
348
349 Sdp::SdpTime::SdpTimeRepeat::OffsetsList::const_iterator itOffset = itRepeat->getOffsetsFromStartTime().begin();
350 for(;itOffset!=itRepeat->getOffsetsFromStartTime().end(); itOffset++)
351 {
352 strm << ", offset=" << *itOffset;
353 }
354 strm << std::endl;
355 }
356 }
357
358 Sdp::TimeZoneList::const_iterator itTimeZone = sdp.mTimeZones.begin();
359 for(;itTimeZone != sdp.mTimeZones.end(); itTimeZone++)
360 {
361 strm << "TimeZone: adjustment time=" << itTimeZone->getAdjustmentTime()
362 << ", offset=" << itTimeZone->getOffset() << std::endl;
363 }
364
365 strm << "Category: '" << sdp.mCategory << "'" << std::endl
366 << "Keywords: '" << sdp.mKeywords << "'" << std::endl
367 << "ToolNameAndVersion: '" << sdp.mToolNameAndVersion << "'" << std::endl
368 << "ConferenceType: " << Sdp::SdpConferenceTypeString[sdp.mConferenceType] << std::endl
369 << "CharSet: '" << sdp.mCharSet << "'" << std::endl
370 << "IcePassiveOnlyMode: " << sdp.mIcePassiveOnlyMode << std::endl;
371
372 Sdp::GroupList::const_iterator itGroup = sdp.mGroups.begin();
373 for(;itGroup != sdp.mGroups.end(); itGroup++)
374 {
375 strm << "Group: semantics=" << Sdp::SdpGroupSemanticsString[itGroup->getSemantics()];
376 Sdp::SdpGroup::TagsList::const_iterator itTag = itGroup->getIdentificationTags().begin();
377 for(;itTag!=itGroup->getIdentificationTags().end(); itTag++)
378 {
379 strm << ", idTag=" << *itTag;
380 }
381 strm << std::endl;
382 }
383
384 strm << "SessionLanguage: '" << sdp.mSessionLanguage << "'" << std::endl
385 << "DescriptionLanguage: '" << sdp.mDescriptionLanguage << "'" << std::endl
386 << "MaximumPacketRate: " << sdp.mMaximumPacketRate << std::endl;
387
388 Sdp::MediaLineList::const_iterator itMediaLine = sdp.mMediaLines.begin();
389 for(;itMediaLine!=sdp.mMediaLines.end();itMediaLine++)
390 {
391 strm << std::endl << *(*itMediaLine);
392 }
393
394 return strm;
395}
396
397
398/* ====================================================================
399
400 Copyright (c) 2026, SIP Spectrum, Inc. https://www.sipspectrum.com
401 Copyright (c) 2007-2008, Plantronics, Inc.
402 All rights reserved.
403
404 Redistribution and use in source and binary forms, with or without
405 modification, are permitted provided that the following conditions are
406 met:
407
408 1. Redistributions of source code must retain the above copyright
409 notice, this list of conditions and the following disclaimer.
410
411 2. Redistributions in binary form must reproduce the above copyright
412 notice, this list of conditions and the following disclaimer in the
413 documentation and/or other materials provided with the distribution.
414
415 3. Neither the name of Plantronics nor the names of its contributors
416 may be used to endorse or promote products derived from this
417 software without specific prior written permission.
418
419 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
420 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
421 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
422 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
423 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
424 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
425 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
426 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
427 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
428 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
429 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
430
431 ==================================================================== */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static SdpBandwidthType getTypeFromString(const char *type)
Definition Sdp.cxx:142
static SdpGroupSemantics getSemanticsFromString(const char *type)
Definition Sdp.cxx:200
static const char * SdpBandwidthTypeString[]
Definition Sdp.hxx:49
static const char * SdpConferenceTypeString[]
Definition Sdp.hxx:145
static const char * SdpAddressTypeString[]
Definition Sdp.hxx:38
virtual ~Sdp()
Definition Sdp.cxx:70
resip::Data getLocalFoundationId(SdpCandidate::SdpCandidateType candidateType, const char *baseAddress, const char *stunAddress=0)
Definition Sdp.cxx:281
@ CONFERENCE_TYPE_BROADCAST
Definition Sdp.hxx:140
@ CONFERENCE_TYPE_MODERATED
Definition Sdp.hxx:141
SdpMediaLine * getMediaLineAtIndex(int indexNumber)
Definition Sdp.cxx:266
static SdpConferenceType getConferenceTypeFromString(const char *type)
Definition Sdp.cxx:173
static SdpAddressType getAddressTypeFromString(const char *type)
Definition Sdp.cxx:123
std::list< SdpMediaLine * > MediaLineList
Definition Sdp.hxx:274
void addMediaLine(SdpMediaLine *mediaLine)
Definition Sdp.cxx:243
const MediaLineList & getMediaLines() const
Definition Sdp.cxx:260
void clearMediaLines()
Definition Sdp.cxx:249
Sdp & operator=(const Sdp &rhs)
Definition Sdp.cxx:77
@ BANDWIDTH_TYPE_TIAS
Definition Sdp.hxx:45
@ BANDWIDTH_TYPE_NONE
Definition Sdp.hxx:42
static const char * SdpGroupSemanticsString[]
Definition Sdp.hxx:155
void setOriginatorInfo(const char *userName, uint64_t sessionId, uint64_t sessionVersion, SdpNetType netType, SdpAddressType addressType, const char *unicastAddress)
Definition Sdp.cxx:227
static const char * SdpNetTypeString[]
Definition Sdp.hxx:30
bool isEqualNoCase(const Data &left, const Data &right)
Definition Data.hxx:1116
EncodeStream & operator<<(EncodeStream &strm, const Sdp &)
Definition Sdp.cxx:304
#define EncodeStream
unsigned __int64 uint64_t
Definition stdint.h:95
void list()
Definition userAdmin.cxx:66