reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
MediaControlContents.cxx
Go to the documentation of this file.
1
#if defined(HAVE_CONFIG_H)
2
#include "config.h"
3
#endif
4
5
#include "
resip/stack/MediaControlContents.hxx
"
6
#include "
resip/stack/Helper.hxx
"
7
#include "
rutil/ParseBuffer.hxx
"
8
#include "
rutil/DataStream.hxx
"
9
#include "
resip/stack/Symbols.hxx
"
10
#include "
rutil/Logger.hxx
"
11
#include "
rutil/WinLeakCheck.hxx
"
12
#include "
resip/stack/SdpContents.hxx
"
13
14
#define RESIPROCATE_SUBSYSTEM resip::Subsystem::SDP
15
16
using namespace
resip
;
17
using namespace
std;
18
19
//const MediaControlContents MediaControlContents::Empty;
20
21
bool
22
MediaControlContents::init
()
23
{
24
static
ContentsFactory<MediaControlContents>
factory;
25
(void)factory;
26
return
true
;
27
}
28
29
MediaControlContents::MediaControlContents
() :
Contents
(getStaticType())
30
{
31
}
32
33
MediaControlContents::MediaControlContents
(
const
HeaderFieldValue
& hfv,
const
Mime
& contentTypes)
34
:
Contents
(hfv, contentTypes)
35
{
36
}
37
38
MediaControlContents::~MediaControlContents
()
39
{
40
}
41
42
MediaControlContents
&
43
MediaControlContents::operator=
(
const
MediaControlContents
& rhs)
44
{
45
if
(
this
!= &rhs)
46
{
47
Contents::operator=
(rhs);
48
mMediaControl = rhs.mMediaControl;
49
}
50
return
*
this
;
51
}
52
53
Contents
*
54
MediaControlContents::clone
()
const
55
{
56
return
new
MediaControlContents
(*
this
);
57
}
58
59
void
60
MediaControlContents::parse
(
ParseBuffer
& pb)
61
{
62
mMediaControl.
parse
(pb);
63
}
64
65
EncodeStream
&
66
MediaControlContents::encodeParsed
(EncodeStream& s)
const
67
{
68
mMediaControl.
encode
(s);
69
return
s;
70
}
71
72
const
Mime
&
73
MediaControlContents::getStaticType
()
74
{
75
static
Mime
type(
"application"
,
"media_control+xml"
);
76
return
type;
77
}
78
79
MediaControlContents::MediaControl::VCPrimitive::VCPrimitive
(
const
StreamIDList
& streamIDs,
bool
pictureFastUpdate)
80
: mStreamIDs(streamIDs),
81
mPictureFastUpdate(pictureFastUpdate)
82
{
83
}
84
85
MediaControlContents::MediaControl::VCPrimitive::VCPrimitive
(
const
VCPrimitive
& rhs)
86
{
87
*
this
= rhs;
88
}
89
90
MediaControlContents::MediaControl::VCPrimitive
&
91
MediaControlContents::MediaControl::VCPrimitive::operator=
(
const
VCPrimitive
& rhs)
92
{
93
if
(
this
!= &rhs)
94
{
95
mStreamIDs = rhs.mStreamIDs;
96
mPictureFastUpdate = rhs.mPictureFastUpdate;
97
}
98
return
*
this
;
99
}
100
101
MediaControlContents::MediaControl::MediaControl
(
const
VCPrimitive::StreamIDList
& streamIDs,
bool
pictureFastUpdate)
102
{
103
VCPrimitive
p(streamIDs, pictureFastUpdate);
104
mVCPrimitives.push_back(p);
105
}
106
107
MediaControlContents::MediaControl::MediaControl
(
const
GeneralErrorList
&
generalErrors
)
108
: mGeneralErrors(
generalErrors
)
109
{
110
}
111
112
MediaControlContents::MediaControl::MediaControl
()
113
{
114
}
115
116
MediaControlContents::MediaControl::MediaControl
(
const
MediaControl
& rhs)
117
{
118
*
this
= rhs;
119
}
120
121
MediaControlContents::MediaControl
&
122
MediaControlContents::MediaControl::operator=
(
const
MediaControl
& rhs)
123
{
124
if
(
this
!= &rhs)
125
{
126
mGeneralErrors = rhs.mGeneralErrors;
127
mVCPrimitives = rhs.mVCPrimitives;
128
}
129
return
*
this
;
130
}
131
132
void
133
MediaControlContents::MediaControl::VCPrimitive::parseVCPrimitive
(
XMLCursor
& xml)
134
{
135
if
(xml.
firstChild
())
136
{
137
do
138
{
139
if
(xml.
getTag
().
caseInsensitiveTokenCompare
(
Data
(
"to_encoder"
)))
140
{
141
if
(xml.
firstChild
())
142
{
143
do
144
{
145
if
(xml.
getTag
().
caseInsensitiveTokenCompare
(
Data
(
"picture_fast_update"
)))
146
{
147
mPictureFastUpdate =
true
;
148
}
149
else
150
{
151
DebugLog
(<<
"Unknown element: "
<< xml.
getTag
());
152
}
153
}
154
while
(xml.
nextSibling
());
155
xml.
parent
();
156
}
157
}
158
else
if
(xml.
getTag
().
caseInsensitiveTokenCompare
(
Data
(
"stream_id"
)))
159
{
160
xml.
firstChild
();
161
mStreamIDs.insert(xml.
getValue
());
162
xml.
parent
();
163
}
164
else
165
{
166
DebugLog
(<<
"Unknown element: "
<< xml.
getTag
());
167
}
168
}
while
(xml.
nextSibling
());
169
xml.
parent
();
170
}
171
}
172
173
void
174
MediaControlContents::MediaControl::parseMediaControl
(
XMLCursor
& xml)
175
{
176
if
(xml.
firstChild
())
177
{
178
do
179
{
180
if
(xml.
getTag
().
caseInsensitiveTokenCompare
(
Data
(
"vc_primitive"
)))
181
{
182
VCPrimitive
p;
183
p.
parseVCPrimitive
(xml);
184
mVCPrimitives.push_back(p);
185
}
186
else
if
(xml.
getTag
().
caseInsensitiveTokenCompare
(
Data
(
"general_error"
)))
187
{
188
xml.
firstChild
();
189
mGeneralErrors.push_back(xml.
getValue
());
190
xml.
parent
();
191
}
192
else
193
{
194
DebugLog
(<<
"Unknown element: "
<< xml.
getTag
());
195
}
196
}
while
(xml.
nextSibling
());
197
}
198
}
199
200
void
201
MediaControlContents::MediaControl::parse
(
ParseBuffer
& pb)
202
{
203
XMLCursor
xml(pb);
204
if
(!xml.
atLeaf
())
205
{
206
do
207
{
208
if
(xml.
getTag
().
caseInsensitiveTokenCompare
(
Data
(
"media_control"
)))
209
{
210
parseMediaControl(xml);
211
}
212
else
213
{
214
DebugLog
(<<
"Unknown root element: "
<< xml.
getTag
());
215
}
216
}
while
(xml.
nextSibling
());
217
}
218
}
219
220
EncodeStream
&
221
MediaControlContents::MediaControl::VCPrimitive::encode
(EncodeStream& s)
const
222
{
223
s <<
"<vc_primitive>"
;
224
if
(mPictureFastUpdate)
225
{
226
s <<
"<to_encoder><picture_fast_update></picture_fast_update></to_encoder>"
;
227
}
228
StreamIDList::const_iterator it = mStreamIDs.cbegin();
229
for
(; it != mStreamIDs.cend(); it++)
230
{
231
s <<
"<stream_id>"
<< *it <<
"</stream_id>"
;
232
}
233
s <<
"</vc_primitive>"
;
234
return
s;
235
}
236
237
EncodeStream
&
238
MediaControlContents::MediaControl::encode
(EncodeStream& s)
const
239
{
240
s <<
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
;
241
s <<
"<media_control>"
;
242
if
(isError())
243
{
244
GeneralErrorList::const_iterator it = mGeneralErrors.cbegin();
245
for
( ; it != mGeneralErrors.cend(); it++)
246
{
247
s <<
"<general_error>"
<< *it <<
"</general_error>"
;
248
}
249
}
250
else
251
{
252
VCPrimitiveList::const_iterator it = mVCPrimitives.cbegin();
253
for
( ; it != mVCPrimitives.cend(); it++)
254
{
255
it->encode(s);
256
}
257
}
258
s <<
"</media_control>"
;
259
return
s;
260
}
261
262
/* ====================================================================
263
*
264
* Copyright (c) 2021, Daniel Pocock, https://danielpocock.com
265
* Copyright (c) 2021, Software Freedom Institute LLC, https://softwarefreedom.institute
266
*
267
* Redistribution and use in source and binary forms, with or without
268
* modification, are permitted provided that the following conditions
269
* are met:
270
*
271
* 1. Redistributions of source code must retain the above copyright
272
* notice, this list of conditions and the following disclaimer.
273
*
274
* 2. Redistributions in binary form must reproduce the above copyright
275
* notice, this list of conditions and the following disclaimer in
276
* the documentation and/or other materials provided with the
277
* distribution.
278
*
279
* 3. Neither the name of the author(s) nor the names of any contributors
280
* may be used to endorse or promote products derived from this software
281
* without specific prior written permission.
282
*
283
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
284
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
285
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
286
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
287
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
288
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
289
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
290
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
292
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
293
* SUCH DAMAGE.
294
*
295
* ====================================================================
296
*
297
*
298
*/
299
DataStream.hxx
Helper.hxx
Logger.hxx
DebugLog
#define DebugLog(args_)
Definition
Logger.hxx:128
MediaControlContents.hxx
ParseBuffer.hxx
SdpContents.hxx
Symbols.hxx
WinLeakCheck.hxx
resip::ContentsFactory
Definition
ContentsFactory.hxx:16
resip::Contents
Base class for all SIP body types.
Definition
Contents.hxx:51
resip::Contents::operator=
Contents & operator=(const Contents &rhs)
Assignment operator.
Definition
Contents.cxx:71
resip::Data
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition
Data.hxx:90
resip::Data::caseInsensitiveTokenCompare
bool caseInsensitiveTokenCompare(const Data &rhs) const
Definition
Data.hxx:997
resip::HeaderFieldValue
Definition
HeaderFieldValue.hxx:21
resip::MediaControlContents::MediaControl::VCPrimitive
Definition
MediaControlContents.hxx:29
resip::MediaControlContents::MediaControl::VCPrimitive::encode
EncodeStream & encode(EncodeStream &) const
Definition
MediaControlContents.cxx:221
resip::MediaControlContents::MediaControl::VCPrimitive::parseVCPrimitive
void parseVCPrimitive(XMLCursor &xml)
Definition
MediaControlContents.cxx:133
resip::MediaControlContents::MediaControl::VCPrimitive::VCPrimitive
VCPrimitive()
Definition
MediaControlContents.hxx:33
resip::MediaControlContents::MediaControl::VCPrimitive::StreamIDList
std::set< Data > StreamIDList
Definition
MediaControlContents.hxx:31
resip::MediaControlContents::MediaControl::VCPrimitive::operator=
VCPrimitive & operator=(const VCPrimitive &rhs)
Definition
MediaControlContents.cxx:91
resip::MediaControlContents::MediaControl
Definition
MediaControlContents.hxx:25
resip::MediaControlContents::MediaControl::MediaControl
MediaControl()
Definition
MediaControlContents.cxx:112
resip::MediaControlContents::MediaControl::parseMediaControl
void parseMediaControl(XMLCursor &xml)
Definition
MediaControlContents.cxx:174
resip::MediaControlContents::MediaControl::generalErrors
const GeneralErrorList & generalErrors() const
Definition
MediaControlContents.hxx:69
resip::MediaControlContents::MediaControl::GeneralErrorList
std::vector< Data > GeneralErrorList
Definition
MediaControlContents.hxx:53
resip::MediaControlContents::MediaControl::operator=
MediaControl & operator=(const MediaControl &rhs)
Definition
MediaControlContents.cxx:122
resip::MediaControlContents::MediaControl::parse
void parse(ParseBuffer &pb)
Definition
MediaControlContents.cxx:201
resip::MediaControlContents::MediaControl::encode
EncodeStream & encode(EncodeStream &) const
Definition
MediaControlContents.cxx:238
resip::MediaControlContents
Definition
MediaControlContents.hxx:20
resip::MediaControlContents::clone
virtual Contents * clone() const
duplicate an MediaControlContents object
Definition
MediaControlContents.cxx:54
resip::MediaControlContents::parse
virtual void parse(ParseBuffer &pb)
Definition
MediaControlContents.cxx:60
resip::MediaControlContents::~MediaControlContents
virtual ~MediaControlContents()
Definition
MediaControlContents.cxx:38
resip::MediaControlContents::MediaControlContents
MediaControlContents()
Definition
MediaControlContents.cxx:29
resip::MediaControlContents::operator=
MediaControlContents & operator=(const MediaControlContents &rhs)
Definition
MediaControlContents.cxx:43
resip::MediaControlContents::encodeParsed
virtual EncodeStream & encodeParsed(EncodeStream &str) const
Definition
MediaControlContents.cxx:66
resip::MediaControlContents::getStaticType
static const Mime & getStaticType()
Definition
MediaControlContents.cxx:73
resip::MediaControlContents::init
static bool init()
Definition
MediaControlContents.cxx:22
resip::Mime
Represents the "media-type" element in the RFC 3261 grammar.
Definition
Mime.hxx:20
resip::ParseBuffer
Provides string-parsing functionality with protection from buffer overflow.
Definition
ParseBuffer.hxx:18
resip::XMLCursor
Definition
XMLCursor.hxx:99
resip::XMLCursor::getValue
const Data & getValue() const
Definition
XMLCursor.cxx:418
resip::XMLCursor::nextSibling
bool nextSibling()
Definition
XMLCursor.cxx:253
resip::XMLCursor::firstChild
bool firstChild()
Definition
XMLCursor.cxx:280
resip::XMLCursor::atLeaf
bool atLeaf() const
Definition
XMLCursor.cxx:330
resip::XMLCursor::getTag
const Data & getTag() const
Definition
XMLCursor.cxx:336
resip::XMLCursor::parent
bool parent()
Definition
XMLCursor.cxx:304
resip
dcm! – add UnusedChecking(_enum) below;
Definition
AbstractFifo.hxx:16
EncodeStream
#define EncodeStream
Definition
resipfaststreams.hxx:461
resip
stack
MediaControlContents.cxx
Generated by
1.9.8