/src/resiprocate/resip/stack/TrickleIceContents.cxx
Line | Count | Source (jump to first uncovered line) |
1 | | #if defined(HAVE_CONFIG_H) |
2 | | #include "config.h" |
3 | | #endif |
4 | | |
5 | | #include "resip/stack/TrickleIceContents.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 TrickleIceContents TrickleIceContents::Empty; |
20 | | |
21 | | bool |
22 | | TrickleIceContents::init() |
23 | 4 | { |
24 | 4 | static ContentsFactory<TrickleIceContents> factory; |
25 | 4 | (void)factory; |
26 | 4 | return true; |
27 | 4 | } |
28 | | |
29 | | TrickleIceContents::TrickleIceContents() : Contents(getStaticType()) |
30 | 0 | { |
31 | 0 | } |
32 | | |
33 | | TrickleIceContents::TrickleIceContents(const HeaderFieldValue& hfv, const Mime& contentTypes) |
34 | | : Contents(hfv, contentTypes) |
35 | 0 | { |
36 | 0 | } |
37 | | |
38 | | TrickleIceContents::TrickleIceContents(const TrickleIceContents& rhs) |
39 | | : Contents(rhs) |
40 | 0 | { |
41 | 0 | *this = rhs; |
42 | 0 | } |
43 | | |
44 | | TrickleIceContents::~TrickleIceContents() |
45 | 0 | { |
46 | 0 | } |
47 | | |
48 | | TrickleIceContents& |
49 | | TrickleIceContents::operator=(const TrickleIceContents& rhs) |
50 | 0 | { |
51 | 0 | if (this != &rhs) |
52 | 0 | { |
53 | 0 | Contents::operator=(rhs); |
54 | 0 | mMedia = rhs.mMedia; |
55 | 0 | mAttributeHelper = rhs.mAttributeHelper; |
56 | | |
57 | | /*for (MediumContainer::iterator i=mMedia.begin(); i != mMedia.end(); ++i) |
58 | | { |
59 | | i->setSession(this); |
60 | | }*/ |
61 | 0 | } |
62 | 0 | return *this; |
63 | 0 | } |
64 | | |
65 | | Contents* |
66 | | TrickleIceContents::clone() const |
67 | 0 | { |
68 | 0 | return new TrickleIceContents(*this); |
69 | 0 | } |
70 | | |
71 | | EncodeStream& |
72 | | TrickleIceContents::encodeParsed(EncodeStream& s) const |
73 | 0 | { |
74 | 0 | mAttributeHelper.encode(s); |
75 | 0 | for (SdpContents::Session::MediumContainer::const_iterator i = mMedia.begin(); |
76 | 0 | i != mMedia.end(); ++i) |
77 | 0 | { |
78 | 0 | i->encode(s); |
79 | 0 | } |
80 | 0 | return s; |
81 | 0 | } |
82 | | |
83 | | void |
84 | | TrickleIceContents::addMedium(const SdpContents::Session::Medium& medium) |
85 | 0 | { |
86 | 0 | mMedia.push_back(medium); |
87 | | // mMedia.back().setSession(this); |
88 | 0 | } |
89 | | |
90 | | void |
91 | | TrickleIceContents::addAttribute(const Data& key, const Data& value) |
92 | 0 | { |
93 | 0 | mAttributeHelper.addAttribute(key, value); |
94 | 0 | } |
95 | | |
96 | | const list<Data>& |
97 | | TrickleIceContents::getValues(const Data& key) const |
98 | 0 | { |
99 | 0 | checkParsed(); |
100 | 0 | if (mAttributeHelper.exists(key)) |
101 | 0 | { |
102 | 0 | return mAttributeHelper.getValues(key); |
103 | 0 | } |
104 | | //if (!mSession) |
105 | 0 | { |
106 | 0 | resip_assert(false); |
107 | 0 | static list<Data> error; |
108 | 0 | return error; |
109 | 0 | } |
110 | | //return mSession->getValues(key); |
111 | 0 | } |
112 | | |
113 | | void |
114 | | TrickleIceContents::parse(ParseBuffer& pb) |
115 | 0 | { |
116 | 0 | mAttributeHelper.parse(pb); |
117 | |
|
118 | 0 | while (!pb.eof() && *pb.position() == 'm') |
119 | 0 | { |
120 | 0 | addMedium(SdpContents::Session::Medium()); |
121 | 0 | mMedia.back().parse(pb); |
122 | 0 | } |
123 | 0 | } |
124 | | |
125 | | const Mime& |
126 | | TrickleIceContents::getStaticType() |
127 | 2 | { |
128 | 2 | static Mime type("application", "trickle-ice-sdpfrag"); |
129 | 2 | return type; |
130 | 2 | } |
131 | | |
132 | | /* ==================================================================== |
133 | | * |
134 | | * Copyright (c) 2022, Daniel Pocock, https://danielpocock.com |
135 | | * Copyright (c) 2022, Software Freedom Institute SA, https://softwarefreedom.institute |
136 | | * |
137 | | * Redistribution and use in source and binary forms, with or without |
138 | | * modification, are permitted provided that the following conditions |
139 | | * are met: |
140 | | * |
141 | | * 1. Redistributions of source code must retain the above copyright |
142 | | * notice, this list of conditions and the following disclaimer. |
143 | | * |
144 | | * 2. Redistributions in binary form must reproduce the above copyright |
145 | | * notice, this list of conditions and the following disclaimer in |
146 | | * the documentation and/or other materials provided with the |
147 | | * distribution. |
148 | | * |
149 | | * 3. Neither the name of the author(s) nor the names of any contributors |
150 | | * may be used to endorse or promote products derived from this software |
151 | | * without specific prior written permission. |
152 | | * |
153 | | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND |
154 | | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
155 | | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
156 | | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE |
157 | | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
158 | | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
159 | | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
160 | | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
161 | | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
162 | | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
163 | | * SUCH DAMAGE. |
164 | | * |
165 | | * ==================================================================== |
166 | | * |
167 | | * |
168 | | */ |
169 | | |