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
10#include "rutil/Logger.hxx"
13
14#define RESIPROCATE_SUBSYSTEM resip::Subsystem::SDP
15
16using namespace resip;
17using namespace std;
18
19//const MediaControlContents MediaControlContents::Empty;
20
21bool
23{
25 (void)factory;
26 return true;
27}
28
32
34 : Contents(hfv, contentTypes)
35{
36}
37
41
44{
45 if (this != &rhs)
46 {
48 mMediaControl = rhs.mMediaControl;
49 }
50 return *this;
51}
52
55{
56 return new MediaControlContents(*this);
57}
58
59void
61{
62 mMediaControl.parse(pb);
63}
64
67{
68 mMediaControl.encode(s);
69 return s;
70}
71
72const Mime&
74{
75 static Mime type("application", "media_control+xml");
76 return type;
77}
78
80 : mStreamIDs(streamIDs),
81 mPictureFastUpdate(pictureFastUpdate)
82{
83}
84
89
92{
93 if (this != &rhs)
94 {
95 mStreamIDs = rhs.mStreamIDs;
96 mPictureFastUpdate = rhs.mPictureFastUpdate;
97 }
98 return *this;
99}
100
102{
103 VCPrimitive p(streamIDs, pictureFastUpdate);
104 mVCPrimitives.push_back(p);
105}
106
111
115
120
123{
124 if (this != &rhs)
125 {
126 mGeneralErrors = rhs.mGeneralErrors;
127 mVCPrimitives = rhs.mVCPrimitives;
128 }
129 return *this;
130}
131
132void
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
173void
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
200void
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
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
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
#define DebugLog(args_)
Definition Logger.hxx:128
Base class for all SIP body types.
Definition Contents.hxx:51
Contents & operator=(const Contents &rhs)
Assignment operator.
Definition Contents.cxx:71
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
bool caseInsensitiveTokenCompare(const Data &rhs) const
Definition Data.hxx:997
const GeneralErrorList & generalErrors() const
MediaControl & operator=(const MediaControl &rhs)
EncodeStream & encode(EncodeStream &) const
virtual Contents * clone() const
duplicate an MediaControlContents object
virtual void parse(ParseBuffer &pb)
MediaControlContents & operator=(const MediaControlContents &rhs)
virtual EncodeStream & encodeParsed(EncodeStream &str) const
static const Mime & getStaticType()
Represents the "media-type" element in the RFC 3261 grammar.
Definition Mime.hxx:20
Provides string-parsing functionality with protection from buffer overflow.
const Data & getValue() const
bool atLeaf() const
const Data & getTag() const
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream