|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include "timecard.h" |
|
6 |
|
7 #include "CSFLog.h" |
|
8 |
|
9 #include <string> |
|
10 |
|
11 #define GTEST_HAS_RTTI 0 |
|
12 #include "gtest/gtest.h" |
|
13 #include "gtest_utils.h" |
|
14 |
|
15 #include "nspr.h" |
|
16 #include "nss.h" |
|
17 #include "ssl.h" |
|
18 |
|
19 #include "nsThreadUtils.h" |
|
20 #include "FakeMediaStreams.h" |
|
21 #include "FakeMediaStreamsImpl.h" |
|
22 #include "PeerConnectionImpl.h" |
|
23 #include "PeerConnectionCtx.h" |
|
24 |
|
25 #include "mtransport_test_utils.h" |
|
26 MtransportTestUtils *test_utils; |
|
27 nsCOMPtr<nsIThread> gThread; |
|
28 |
|
29 extern "C" { |
|
30 #include "sdp.h" |
|
31 #include "sdp_private.h" |
|
32 } |
|
33 |
|
34 namespace test { |
|
35 |
|
36 static bool SetupGlobalThread() { |
|
37 if (!gThread) { |
|
38 nsIThread *thread; |
|
39 |
|
40 nsresult rv = NS_NewNamedThread("pseudo-main",&thread); |
|
41 if (NS_FAILED(rv)) |
|
42 return false; |
|
43 |
|
44 gThread = thread; |
|
45 sipcc::PeerConnectionCtx::InitializeGlobal(gThread, |
|
46 test_utils->sts_target()); |
|
47 } |
|
48 return true; |
|
49 } |
|
50 |
|
51 class SdpTest : public ::testing::Test { |
|
52 public: |
|
53 SdpTest() : sdp_ptr_(nullptr) { |
|
54 sdp_media_e supported_media[] = { |
|
55 SDP_MEDIA_AUDIO, |
|
56 SDP_MEDIA_VIDEO, |
|
57 SDP_MEDIA_APPLICATION, |
|
58 SDP_MEDIA_DATA, |
|
59 SDP_MEDIA_CONTROL, |
|
60 SDP_MEDIA_NAS_RADIUS, |
|
61 SDP_MEDIA_NAS_TACACS, |
|
62 SDP_MEDIA_NAS_DIAMETER, |
|
63 SDP_MEDIA_NAS_L2TP, |
|
64 SDP_MEDIA_NAS_LOGIN, |
|
65 SDP_MEDIA_NAS_NONE, |
|
66 SDP_MEDIA_IMAGE, |
|
67 }; |
|
68 |
|
69 config_p_ = sdp_init_config(); |
|
70 unsigned int i; |
|
71 for (i = 0; i < sizeof(supported_media) / sizeof(sdp_media_e); i++) { |
|
72 sdp_media_supported(config_p_, supported_media[i], true); |
|
73 } |
|
74 sdp_nettype_supported(config_p_, SDP_NT_INTERNET, true); |
|
75 sdp_addrtype_supported(config_p_, SDP_AT_IP4, true); |
|
76 sdp_addrtype_supported(config_p_, SDP_AT_IP6, true); |
|
77 sdp_transport_supported(config_p_, SDP_TRANSPORT_RTPSAVPF, true); |
|
78 sdp_transport_supported(config_p_, SDP_TRANSPORT_UDPTL, true); |
|
79 sdp_require_session_name(config_p_, false); |
|
80 } |
|
81 |
|
82 static void SetUpTestCase() { |
|
83 ASSERT_TRUE(SetupGlobalThread()); |
|
84 } |
|
85 |
|
86 void SetUp() { |
|
87 final_level_ = 0; |
|
88 sdp_ptr_ = nullptr; |
|
89 } |
|
90 |
|
91 static void TearDownTestCase() { |
|
92 gThread = nullptr; |
|
93 } |
|
94 |
|
95 void ResetSdp() { |
|
96 if (!sdp_ptr_) { |
|
97 sdp_free_description(sdp_ptr_); |
|
98 } |
|
99 sdp_ptr_ = sdp_init_description("BogusPeerConnectionId", config_p_); |
|
100 } |
|
101 |
|
102 void ParseSdp(const std::string &sdp_str) { |
|
103 char *bufp = const_cast<char *>(sdp_str.data()); |
|
104 ResetSdp(); |
|
105 ASSERT_EQ(sdp_parse(sdp_ptr_, &bufp, sdp_str.size()), SDP_SUCCESS); |
|
106 } |
|
107 |
|
108 void InitLocalSdp() { |
|
109 ResetSdp(); |
|
110 ASSERT_EQ(sdp_set_version(sdp_ptr_, 0), SDP_SUCCESS); |
|
111 ASSERT_EQ(sdp_set_owner_username(sdp_ptr_, "-"), SDP_SUCCESS); |
|
112 ASSERT_EQ(sdp_set_owner_sessionid(sdp_ptr_, "132954853"), SDP_SUCCESS); |
|
113 ASSERT_EQ(sdp_set_owner_version(sdp_ptr_, "0"), SDP_SUCCESS); |
|
114 ASSERT_EQ(sdp_set_owner_network_type(sdp_ptr_, SDP_NT_INTERNET), |
|
115 SDP_SUCCESS); |
|
116 ASSERT_EQ(sdp_set_owner_address_type(sdp_ptr_, SDP_AT_IP4), SDP_SUCCESS); |
|
117 ASSERT_EQ(sdp_set_owner_address(sdp_ptr_, "198.51.100.7"), SDP_SUCCESS); |
|
118 ASSERT_EQ(sdp_set_session_name(sdp_ptr_, "SDP Unit Test"), SDP_SUCCESS); |
|
119 ASSERT_EQ(sdp_set_time_start(sdp_ptr_, "0"), SDP_SUCCESS); |
|
120 ASSERT_EQ(sdp_set_time_stop(sdp_ptr_, "0"), SDP_SUCCESS); |
|
121 } |
|
122 |
|
123 std::string SerializeSdp() { |
|
124 flex_string fs; |
|
125 flex_string_init(&fs); |
|
126 EXPECT_EQ(sdp_build(sdp_ptr_, &fs), SDP_SUCCESS); |
|
127 std::string body(fs.buffer); |
|
128 flex_string_free(&fs); |
|
129 return body; |
|
130 } |
|
131 |
|
132 // Returns "level" for new media section |
|
133 int AddNewMedia(sdp_media_e type) { |
|
134 final_level_++; |
|
135 EXPECT_EQ(sdp_insert_media_line(sdp_ptr_, final_level_), SDP_SUCCESS); |
|
136 EXPECT_EQ(sdp_set_conn_nettype(sdp_ptr_, final_level_, SDP_NT_INTERNET), |
|
137 SDP_SUCCESS); |
|
138 EXPECT_EQ(sdp_set_conn_addrtype(sdp_ptr_, final_level_, SDP_AT_IP4), |
|
139 SDP_SUCCESS); |
|
140 EXPECT_EQ(sdp_set_conn_address(sdp_ptr_, final_level_, "198.51.100.7"), |
|
141 SDP_SUCCESS); |
|
142 EXPECT_EQ(sdp_set_media_type(sdp_ptr_, final_level_, SDP_MEDIA_VIDEO), |
|
143 SDP_SUCCESS); |
|
144 EXPECT_EQ(sdp_set_media_transport(sdp_ptr_, final_level_, |
|
145 SDP_TRANSPORT_RTPAVP), |
|
146 SDP_SUCCESS); |
|
147 EXPECT_EQ(sdp_set_media_portnum(sdp_ptr_, final_level_, 12345, 0), |
|
148 SDP_SUCCESS); |
|
149 EXPECT_EQ(sdp_add_media_payload_type(sdp_ptr_, final_level_, 120, |
|
150 SDP_PAYLOAD_NUMERIC), |
|
151 SDP_SUCCESS); |
|
152 return final_level_; |
|
153 } |
|
154 |
|
155 u16 AddNewRtcpFbAck(int level, sdp_rtcp_fb_ack_type_e type, |
|
156 u16 payload = SDP_ALL_PAYLOADS) { |
|
157 u16 inst_num = 0; |
|
158 EXPECT_EQ(sdp_add_new_attr(sdp_ptr_, level, 0, SDP_ATTR_RTCP_FB, |
|
159 &inst_num), SDP_SUCCESS); |
|
160 EXPECT_EQ(sdp_attr_set_rtcp_fb_ack(sdp_ptr_, level, payload, inst_num, |
|
161 type), SDP_SUCCESS); |
|
162 return inst_num; |
|
163 } |
|
164 |
|
165 u16 AddNewRtcpFbNack(int level, sdp_rtcp_fb_nack_type_e type, |
|
166 u16 payload = SDP_ALL_PAYLOADS) { |
|
167 u16 inst_num = 0; |
|
168 EXPECT_EQ(sdp_add_new_attr(sdp_ptr_, level, 0, SDP_ATTR_RTCP_FB, |
|
169 &inst_num), SDP_SUCCESS); |
|
170 EXPECT_EQ(sdp_attr_set_rtcp_fb_nack(sdp_ptr_, level, payload, inst_num, |
|
171 type), SDP_SUCCESS); |
|
172 return inst_num; |
|
173 } |
|
174 |
|
175 u16 AddNewRtcpFbTrrInt(int level, u32 interval, |
|
176 u16 payload = SDP_ALL_PAYLOADS) { |
|
177 u16 inst_num = 0; |
|
178 EXPECT_EQ(sdp_add_new_attr(sdp_ptr_, level, 0, SDP_ATTR_RTCP_FB, |
|
179 &inst_num), SDP_SUCCESS); |
|
180 EXPECT_EQ(sdp_attr_set_rtcp_fb_trr_int(sdp_ptr_, level, payload, inst_num, |
|
181 interval), SDP_SUCCESS); |
|
182 return inst_num; |
|
183 } |
|
184 |
|
185 u16 AddNewRtcpFbCcm(int level, sdp_rtcp_fb_ccm_type_e type, |
|
186 u16 payload = SDP_ALL_PAYLOADS) { |
|
187 u16 inst_num = 0; |
|
188 EXPECT_EQ(sdp_add_new_attr(sdp_ptr_, level, 0, SDP_ATTR_RTCP_FB, |
|
189 &inst_num), SDP_SUCCESS); |
|
190 EXPECT_EQ(sdp_attr_set_rtcp_fb_ccm(sdp_ptr_, level, payload, inst_num, |
|
191 type), SDP_SUCCESS); |
|
192 return inst_num; |
|
193 } |
|
194 u16 AddNewExtMap(int level, const char* uri) { |
|
195 u16 inst_num = 0; |
|
196 EXPECT_EQ(sdp_add_new_attr(sdp_ptr_, level, 0, SDP_ATTR_EXTMAP, |
|
197 &inst_num), SDP_SUCCESS); |
|
198 EXPECT_EQ(sdp_attr_set_extmap(sdp_ptr_, level, inst_num, |
|
199 uri, inst_num), SDP_SUCCESS); |
|
200 return inst_num; |
|
201 } |
|
202 |
|
203 u16 AddNewFmtpMaxFs(int level, u32 max_fs) { |
|
204 u16 inst_num = 0; |
|
205 EXPECT_EQ(sdp_add_new_attr(sdp_ptr_, level, 0, SDP_ATTR_FMTP, |
|
206 &inst_num), SDP_SUCCESS); |
|
207 EXPECT_EQ(sdp_attr_set_fmtp_payload_type(sdp_ptr_, level, 0, inst_num, |
|
208 120), SDP_SUCCESS); |
|
209 EXPECT_EQ(sdp_attr_set_fmtp_max_fs(sdp_ptr_, level, 0, inst_num, max_fs), |
|
210 SDP_SUCCESS); |
|
211 return inst_num; |
|
212 } |
|
213 |
|
214 u16 AddNewFmtpMaxFr(int level, u32 max_fr) { |
|
215 u16 inst_num = 0; |
|
216 EXPECT_EQ(sdp_add_new_attr(sdp_ptr_, level, 0, SDP_ATTR_FMTP, |
|
217 &inst_num), SDP_SUCCESS); |
|
218 EXPECT_EQ(sdp_attr_set_fmtp_payload_type(sdp_ptr_, level, 0, inst_num, |
|
219 120), SDP_SUCCESS); |
|
220 EXPECT_EQ(sdp_attr_set_fmtp_max_fr(sdp_ptr_, level, 0, inst_num, max_fr), |
|
221 SDP_SUCCESS); |
|
222 return inst_num; |
|
223 } |
|
224 |
|
225 u16 AddNewFmtpMaxFsFr(int level, u32 max_fs, u32 max_fr) { |
|
226 u16 inst_num = 0; |
|
227 EXPECT_EQ(sdp_add_new_attr(sdp_ptr_, level, 0, SDP_ATTR_FMTP, |
|
228 &inst_num), SDP_SUCCESS); |
|
229 EXPECT_EQ(sdp_attr_set_fmtp_payload_type(sdp_ptr_, level, 0, inst_num, |
|
230 120), SDP_SUCCESS); |
|
231 EXPECT_EQ(sdp_attr_set_fmtp_max_fs(sdp_ptr_, level, 0, inst_num, max_fs), |
|
232 SDP_SUCCESS); |
|
233 EXPECT_EQ(sdp_attr_set_fmtp_max_fr(sdp_ptr_, level, 0, inst_num, max_fr), |
|
234 SDP_SUCCESS); |
|
235 return inst_num; |
|
236 } |
|
237 |
|
238 protected: |
|
239 int final_level_; |
|
240 void *config_p_; |
|
241 sdp_t *sdp_ptr_; |
|
242 }; |
|
243 |
|
244 static const std::string kVideoSdp = |
|
245 "v=0\r\n" |
|
246 "o=- 137331303 2 IN IP4 127.0.0.1\r\n" |
|
247 "s=SIP Call\r\n" |
|
248 "t=0 0\r\n" |
|
249 "m=video 56436 RTP/SAVPF 120\r\n" |
|
250 "c=IN IP4 198.51.100.7\r\n" |
|
251 "a=rtpmap:120 VP8/90000\r\n"; |
|
252 |
|
253 TEST_F(SdpTest, parseRtcpFbAckRpsi) { |
|
254 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ack rpsi\r\n"); |
|
255 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 1), |
|
256 SDP_RTCP_FB_ACK_RPSI); |
|
257 } |
|
258 |
|
259 TEST_F(SdpTest, parseRtcpFbAckApp) { |
|
260 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ack app\r\n"); |
|
261 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 1), SDP_RTCP_FB_ACK_APP); |
|
262 } |
|
263 |
|
264 TEST_F(SdpTest, parseRtcpFbAckAppFoo) { |
|
265 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ack app foo\r\n"); |
|
266 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 1), SDP_RTCP_FB_ACK_APP); |
|
267 } |
|
268 |
|
269 TEST_F(SdpTest, parseRtcpFbAckFooBar) { |
|
270 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ack foo bar\r\n"); |
|
271 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 1), |
|
272 SDP_RTCP_FB_ACK_UNKNOWN); |
|
273 } |
|
274 |
|
275 TEST_F(SdpTest, parseRtcpFbAckFooBarBaz) { |
|
276 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ack foo bar baz\r\n"); |
|
277 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 1), |
|
278 SDP_RTCP_FB_ACK_UNKNOWN); |
|
279 } |
|
280 |
|
281 TEST_F(SdpTest, parseRtcpFbNack) { |
|
282 ParseSdp(kVideoSdp + "a=rtcp-fb:120 nack\r\n"); |
|
283 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 1), |
|
284 SDP_RTCP_FB_NACK_BASIC); |
|
285 } |
|
286 |
|
287 TEST_F(SdpTest, parseRtcpFbNackPli) { |
|
288 ParseSdp(kVideoSdp + "a=rtcp-fb:120 nack pli\r\n"); |
|
289 } |
|
290 |
|
291 TEST_F(SdpTest, parseRtcpFbNackSli) { |
|
292 ParseSdp(kVideoSdp + "a=rtcp-fb:120 nack sli\r\n"); |
|
293 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 1), |
|
294 SDP_RTCP_FB_NACK_SLI); |
|
295 } |
|
296 |
|
297 TEST_F(SdpTest, parseRtcpFbNackRpsi) { |
|
298 ParseSdp(kVideoSdp + "a=rtcp-fb:120 nack rpsi\r\n"); |
|
299 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 1), |
|
300 SDP_RTCP_FB_NACK_RPSI); |
|
301 } |
|
302 |
|
303 TEST_F(SdpTest, parseRtcpFbNackApp) { |
|
304 ParseSdp(kVideoSdp + "a=rtcp-fb:120 nack app\r\n"); |
|
305 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 1), |
|
306 SDP_RTCP_FB_NACK_APP); |
|
307 } |
|
308 |
|
309 TEST_F(SdpTest, parseRtcpFbNackAppFoo) { |
|
310 ParseSdp(kVideoSdp + "a=rtcp-fb:120 nack app foo\r\n"); |
|
311 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 1), |
|
312 SDP_RTCP_FB_NACK_APP); |
|
313 } |
|
314 |
|
315 TEST_F(SdpTest, parseRtcpFbNackAppFooBar) { |
|
316 ParseSdp(kVideoSdp + "a=rtcp-fb:120 nack app foo bar\r\n"); |
|
317 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 1), |
|
318 SDP_RTCP_FB_NACK_APP); |
|
319 } |
|
320 |
|
321 TEST_F(SdpTest, parseRtcpFbNackFooBarBaz) { |
|
322 ParseSdp(kVideoSdp + "a=rtcp-fb:120 nack foo bar baz\r\n"); |
|
323 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 1), |
|
324 SDP_RTCP_FB_NACK_UNKNOWN); |
|
325 } |
|
326 |
|
327 TEST_F(SdpTest, parseRtcpFbTrrInt0) { |
|
328 ParseSdp(kVideoSdp + "a=rtcp-fb:120 trr-int 0\r\n"); |
|
329 ASSERT_EQ(sdp_attr_get_rtcp_fb_trr_int(sdp_ptr_, 1, 120, 1), 0U); |
|
330 } |
|
331 |
|
332 TEST_F(SdpTest, parseRtcpFbTrrInt123) { |
|
333 ParseSdp(kVideoSdp + "a=rtcp-fb:120 trr-int 123\r\n"); |
|
334 ASSERT_EQ(sdp_attr_get_rtcp_fb_trr_int(sdp_ptr_, 1, 120, 1), 123U); |
|
335 } |
|
336 |
|
337 TEST_F(SdpTest, parseRtcpFbCcmFir) { |
|
338 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ccm fir\r\n"); |
|
339 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 1), SDP_RTCP_FB_CCM_FIR); |
|
340 } |
|
341 |
|
342 TEST_F(SdpTest, parseRtcpFbCcmTmmbr) { |
|
343 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ccm tmmbr\r\n"); |
|
344 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 1), |
|
345 SDP_RTCP_FB_CCM_TMMBR); |
|
346 } |
|
347 |
|
348 TEST_F(SdpTest, parseRtcpFbCcmTmmbrSmaxpr) { |
|
349 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ccm tmmbr smaxpr=456\r\n"); |
|
350 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 1), |
|
351 SDP_RTCP_FB_CCM_TMMBR); |
|
352 } |
|
353 |
|
354 TEST_F(SdpTest, parseRtcpFbCcmTstr) { |
|
355 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ccm tstr\r\n"); |
|
356 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 1), |
|
357 SDP_RTCP_FB_CCM_TSTR); |
|
358 } |
|
359 |
|
360 TEST_F(SdpTest, parseRtcpFbCcmVbcm) { |
|
361 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ccm vbcm 123 456 789\r\n"); |
|
362 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 1), |
|
363 SDP_RTCP_FB_CCM_VBCM); |
|
364 // We don't currently parse out VBCM submessage types, since we don't have |
|
365 // any use for them. |
|
366 } |
|
367 |
|
368 TEST_F(SdpTest, parseRtcpFbCcmFoo) { |
|
369 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ccm foo\r\n"); |
|
370 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 1), |
|
371 SDP_RTCP_FB_CCM_UNKNOWN); |
|
372 } |
|
373 |
|
374 TEST_F(SdpTest, parseRtcpFbCcmFooBarBaz) { |
|
375 ParseSdp(kVideoSdp + "a=rtcp-fb:120 ccm foo bar baz\r\n"); |
|
376 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 1), |
|
377 SDP_RTCP_FB_CCM_UNKNOWN); |
|
378 } |
|
379 |
|
380 TEST_F(SdpTest, parseRtcpFbFoo) { |
|
381 ParseSdp(kVideoSdp + "a=rtcp-fb:120 foo\r\n"); |
|
382 } |
|
383 |
|
384 TEST_F(SdpTest, parseRtcpFbFooBar) { |
|
385 ParseSdp(kVideoSdp + "a=rtcp-fb:120 foo bar\r\n"); |
|
386 } |
|
387 |
|
388 TEST_F(SdpTest, parseRtcpFbFooBarBaz) { |
|
389 ParseSdp(kVideoSdp + "a=rtcp-fb:120 foo bar baz\r\n"); |
|
390 } |
|
391 |
|
392 |
|
393 TEST_F(SdpTest, parseRtcpFbKitchenSink) { |
|
394 ParseSdp(kVideoSdp + |
|
395 "a=rtcp-fb:120 ack rpsi\r\n" |
|
396 "a=rtcp-fb:120 ack app\r\n" |
|
397 "a=rtcp-fb:120 ack app foo\r\n" |
|
398 "a=rtcp-fb:120 ack foo bar\r\n" |
|
399 "a=rtcp-fb:120 ack foo bar baz\r\n" |
|
400 "a=rtcp-fb:120 nack\r\n" |
|
401 "a=rtcp-fb:120 nack pli\r\n" |
|
402 "a=rtcp-fb:120 nack sli\r\n" |
|
403 "a=rtcp-fb:120 nack rpsi\r\n" |
|
404 "a=rtcp-fb:120 nack app\r\n" |
|
405 "a=rtcp-fb:120 nack app foo\r\n" |
|
406 "a=rtcp-fb:120 nack app foo bar\r\n" |
|
407 "a=rtcp-fb:120 nack foo bar baz\r\n" |
|
408 "a=rtcp-fb:120 trr-int 0\r\n" |
|
409 "a=rtcp-fb:120 trr-int 123\r\n" |
|
410 "a=rtcp-fb:120 ccm fir\r\n" |
|
411 "a=rtcp-fb:120 ccm tmmbr\r\n" |
|
412 "a=rtcp-fb:120 ccm tmmbr smaxpr=456\r\n" |
|
413 "a=rtcp-fb:120 ccm tstr\r\n" |
|
414 "a=rtcp-fb:120 ccm vbcm 123 456 789\r\n" |
|
415 "a=rtcp-fb:120 ccm foo\r\n" |
|
416 "a=rtcp-fb:120 ccm foo bar baz\r\n" |
|
417 "a=rtcp-fb:120 foo\r\n" |
|
418 "a=rtcp-fb:120 foo bar\r\n" |
|
419 "a=rtcp-fb:120 foo bar baz\r\n"); |
|
420 |
|
421 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 1), SDP_RTCP_FB_ACK_RPSI); |
|
422 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 2), SDP_RTCP_FB_ACK_APP); |
|
423 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 3), SDP_RTCP_FB_ACK_APP); |
|
424 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 4), |
|
425 SDP_RTCP_FB_ACK_UNKNOWN); |
|
426 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 5), |
|
427 SDP_RTCP_FB_ACK_UNKNOWN); |
|
428 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, 120, 6), |
|
429 SDP_RTCP_FB_ACK_NOT_FOUND); |
|
430 |
|
431 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 1), |
|
432 SDP_RTCP_FB_NACK_BASIC); |
|
433 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 2), |
|
434 SDP_RTCP_FB_NACK_PLI); |
|
435 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 3), |
|
436 SDP_RTCP_FB_NACK_SLI); |
|
437 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 4), |
|
438 SDP_RTCP_FB_NACK_RPSI); |
|
439 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 5), |
|
440 SDP_RTCP_FB_NACK_APP); |
|
441 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 6), |
|
442 SDP_RTCP_FB_NACK_APP); |
|
443 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 7), |
|
444 SDP_RTCP_FB_NACK_APP); |
|
445 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 8), |
|
446 SDP_RTCP_FB_NACK_UNKNOWN); |
|
447 ASSERT_EQ(sdp_attr_get_rtcp_fb_nack(sdp_ptr_, 1, 120, 9), |
|
448 SDP_RTCP_FB_NACK_NOT_FOUND); |
|
449 |
|
450 ASSERT_EQ(sdp_attr_get_rtcp_fb_trr_int(sdp_ptr_, 1, 120, 1), 0U); |
|
451 ASSERT_EQ(sdp_attr_get_rtcp_fb_trr_int(sdp_ptr_, 1, 120, 2), 123U); |
|
452 ASSERT_EQ(sdp_attr_get_rtcp_fb_trr_int(sdp_ptr_, 1, 120, 3), 0xFFFFFFFF); |
|
453 |
|
454 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 1), SDP_RTCP_FB_CCM_FIR); |
|
455 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 2), |
|
456 SDP_RTCP_FB_CCM_TMMBR); |
|
457 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 3), |
|
458 SDP_RTCP_FB_CCM_TMMBR); |
|
459 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 4), |
|
460 SDP_RTCP_FB_CCM_TSTR); |
|
461 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 5), |
|
462 SDP_RTCP_FB_CCM_VBCM); |
|
463 // We don't currently parse out VBCM submessage types, since we don't have |
|
464 // any use for them. |
|
465 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 6), |
|
466 SDP_RTCP_FB_CCM_UNKNOWN); |
|
467 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 7), |
|
468 SDP_RTCP_FB_CCM_UNKNOWN); |
|
469 ASSERT_EQ(sdp_attr_get_rtcp_fb_ccm(sdp_ptr_, 1, 120, 8), |
|
470 SDP_RTCP_FB_CCM_NOT_FOUND); |
|
471 } |
|
472 |
|
473 TEST_F(SdpTest, addRtcpFbAckRpsi) { |
|
474 InitLocalSdp(); |
|
475 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
476 AddNewRtcpFbAck(level, SDP_RTCP_FB_ACK_RPSI, 120); |
|
477 std::string body = SerializeSdp(); |
|
478 ASSERT_NE(body.find("a=rtcp-fb:120 ack rpsi\r\n"), std::string::npos); |
|
479 } |
|
480 |
|
481 TEST_F(SdpTest, addRtcpFbAckRpsiAllPt) { |
|
482 InitLocalSdp(); |
|
483 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
484 AddNewRtcpFbAck(level, SDP_RTCP_FB_ACK_RPSI); |
|
485 std::string body = SerializeSdp(); |
|
486 ASSERT_NE(body.find("a=rtcp-fb:* ack rpsi\r\n"), std::string::npos); |
|
487 } |
|
488 |
|
489 TEST_F(SdpTest, addRtcpFbAckApp) { |
|
490 InitLocalSdp(); |
|
491 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
492 AddNewRtcpFbAck(level, SDP_RTCP_FB_ACK_APP, 120); |
|
493 std::string body = SerializeSdp(); |
|
494 ASSERT_NE(body.find("a=rtcp-fb:120 ack app\r\n"), std::string::npos); |
|
495 } |
|
496 |
|
497 TEST_F(SdpTest, addRtcpFbAckAppAllPt) { |
|
498 InitLocalSdp(); |
|
499 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
500 AddNewRtcpFbAck(level, SDP_RTCP_FB_ACK_APP); |
|
501 std::string body = SerializeSdp(); |
|
502 ASSERT_NE(body.find("a=rtcp-fb:* ack app\r\n"), std::string::npos); |
|
503 } |
|
504 |
|
505 TEST_F(SdpTest, addRtcpFbNack) { |
|
506 InitLocalSdp(); |
|
507 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
508 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_BASIC, 120); |
|
509 std::string body = SerializeSdp(); |
|
510 ASSERT_NE(body.find("a=rtcp-fb:120 nack\r\n"), std::string::npos); |
|
511 } |
|
512 |
|
513 TEST_F(SdpTest, addRtcpFbNackAllPt) { |
|
514 InitLocalSdp(); |
|
515 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
516 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_BASIC); |
|
517 std::string body = SerializeSdp(); |
|
518 ASSERT_NE(body.find("a=rtcp-fb:* nack\r\n"), std::string::npos); |
|
519 } |
|
520 |
|
521 TEST_F(SdpTest, addRtcpFbNackSli) { |
|
522 InitLocalSdp(); |
|
523 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
524 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_SLI, 120); |
|
525 std::string body = SerializeSdp(); |
|
526 ASSERT_NE(body.find("a=rtcp-fb:120 nack sli\r\n"), std::string::npos); |
|
527 } |
|
528 |
|
529 TEST_F(SdpTest, addRtcpFbNackSliAllPt) { |
|
530 InitLocalSdp(); |
|
531 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
532 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_SLI); |
|
533 std::string body = SerializeSdp(); |
|
534 ASSERT_NE(body.find("a=rtcp-fb:* nack sli\r\n"), std::string::npos); |
|
535 } |
|
536 |
|
537 TEST_F(SdpTest, addRtcpFbNackPli) { |
|
538 InitLocalSdp(); |
|
539 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
540 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_PLI, 120); |
|
541 std::string body = SerializeSdp(); |
|
542 ASSERT_NE(body.find("a=rtcp-fb:120 nack pli\r\n"), std::string::npos); |
|
543 } |
|
544 |
|
545 TEST_F(SdpTest, addRtcpFbNackPliAllPt) { |
|
546 InitLocalSdp(); |
|
547 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
548 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_PLI); |
|
549 std::string body = SerializeSdp(); |
|
550 ASSERT_NE(body.find("a=rtcp-fb:* nack pli\r\n"), std::string::npos); |
|
551 } |
|
552 |
|
553 TEST_F(SdpTest, addRtcpFbNackRpsi) { |
|
554 InitLocalSdp(); |
|
555 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
556 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_RPSI, 120); |
|
557 std::string body = SerializeSdp(); |
|
558 ASSERT_NE(body.find("a=rtcp-fb:120 nack rpsi\r\n"), std::string::npos); |
|
559 } |
|
560 |
|
561 TEST_F(SdpTest, addRtcpFbNackRpsiAllPt) { |
|
562 InitLocalSdp(); |
|
563 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
564 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_RPSI); |
|
565 std::string body = SerializeSdp(); |
|
566 ASSERT_NE(body.find("a=rtcp-fb:* nack rpsi\r\n"), std::string::npos); |
|
567 } |
|
568 |
|
569 TEST_F(SdpTest, addRtcpFbNackApp) { |
|
570 InitLocalSdp(); |
|
571 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
572 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_APP, 120); |
|
573 std::string body = SerializeSdp(); |
|
574 ASSERT_NE(body.find("a=rtcp-fb:120 nack app\r\n"), std::string::npos); |
|
575 } |
|
576 |
|
577 TEST_F(SdpTest, addRtcpFbNackAppAllPt) { |
|
578 InitLocalSdp(); |
|
579 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
580 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_APP); |
|
581 std::string body = SerializeSdp(); |
|
582 ASSERT_NE(body.find("a=rtcp-fb:* nack app\r\n"), std::string::npos); |
|
583 } |
|
584 |
|
585 TEST_F(SdpTest, addRtcpFbNackRai) { |
|
586 InitLocalSdp(); |
|
587 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
588 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_RAI, 120); |
|
589 std::string body = SerializeSdp(); |
|
590 ASSERT_NE(body.find("a=rtcp-fb:120 nack rai\r\n"), std::string::npos); |
|
591 } |
|
592 |
|
593 TEST_F(SdpTest, addRtcpFbNackRaiAllPt) { |
|
594 InitLocalSdp(); |
|
595 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
596 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_RAI); |
|
597 std::string body = SerializeSdp(); |
|
598 ASSERT_NE(body.find("a=rtcp-fb:* nack rai\r\n"), std::string::npos); |
|
599 } |
|
600 |
|
601 TEST_F(SdpTest, addRtcpFbNackTllei) { |
|
602 InitLocalSdp(); |
|
603 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
604 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_TLLEI, 120); |
|
605 std::string body = SerializeSdp(); |
|
606 ASSERT_NE(body.find("a=rtcp-fb:120 nack tllei\r\n"), std::string::npos); |
|
607 } |
|
608 |
|
609 TEST_F(SdpTest, addRtcpFbNackTlleiAllPt) { |
|
610 InitLocalSdp(); |
|
611 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
612 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_TLLEI); |
|
613 std::string body = SerializeSdp(); |
|
614 ASSERT_NE(body.find("a=rtcp-fb:* nack tllei\r\n"), std::string::npos); |
|
615 } |
|
616 |
|
617 TEST_F(SdpTest, addRtcpFbNackPslei) { |
|
618 InitLocalSdp(); |
|
619 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
620 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_PSLEI, 120); |
|
621 std::string body = SerializeSdp(); |
|
622 ASSERT_NE(body.find("a=rtcp-fb:120 nack pslei\r\n"), std::string::npos); |
|
623 } |
|
624 |
|
625 TEST_F(SdpTest, addRtcpFbNackPsleiAllPt) { |
|
626 InitLocalSdp(); |
|
627 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
628 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_PSLEI); |
|
629 std::string body = SerializeSdp(); |
|
630 ASSERT_NE(body.find("a=rtcp-fb:* nack pslei\r\n"), std::string::npos); |
|
631 } |
|
632 |
|
633 TEST_F(SdpTest, addRtcpFbNackEcn) { |
|
634 InitLocalSdp(); |
|
635 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
636 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_ECN, 120); |
|
637 std::string body = SerializeSdp(); |
|
638 ASSERT_NE(body.find("a=rtcp-fb:120 nack ecn\r\n"), std::string::npos); |
|
639 } |
|
640 |
|
641 TEST_F(SdpTest, addRtcpFbNackEcnAllPt) { |
|
642 InitLocalSdp(); |
|
643 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
644 AddNewRtcpFbNack(level, SDP_RTCP_FB_NACK_ECN); |
|
645 std::string body = SerializeSdp(); |
|
646 ASSERT_NE(body.find("a=rtcp-fb:* nack ecn\r\n"), std::string::npos); |
|
647 } |
|
648 |
|
649 TEST_F(SdpTest, addRtcpFbTrrInt) { |
|
650 InitLocalSdp(); |
|
651 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
652 AddNewRtcpFbTrrInt(level, 12345, 120); |
|
653 std::string body = SerializeSdp(); |
|
654 ASSERT_NE(body.find("a=rtcp-fb:120 trr-int 12345\r\n"), std::string::npos); |
|
655 } |
|
656 |
|
657 TEST_F(SdpTest, addRtcpFbNackTrrIntAllPt) { |
|
658 InitLocalSdp(); |
|
659 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
660 AddNewRtcpFbTrrInt(level, 0); |
|
661 std::string body = SerializeSdp(); |
|
662 ASSERT_NE(body.find("a=rtcp-fb:* trr-int 0\r\n"), std::string::npos); |
|
663 } |
|
664 |
|
665 TEST_F(SdpTest, addRtcpFbCcmFir) { |
|
666 InitLocalSdp(); |
|
667 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
668 AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_FIR, 120); |
|
669 std::string body = SerializeSdp(); |
|
670 ASSERT_NE(body.find("a=rtcp-fb:120 ccm fir\r\n"), std::string::npos); |
|
671 } |
|
672 |
|
673 TEST_F(SdpTest, addRtcpFbCcmFirAllPt) { |
|
674 InitLocalSdp(); |
|
675 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
676 AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_FIR); |
|
677 std::string body = SerializeSdp(); |
|
678 ASSERT_NE(body.find("a=rtcp-fb:* ccm fir\r\n"), std::string::npos); |
|
679 } |
|
680 |
|
681 TEST_F(SdpTest, addRtcpFbCcmTmmbr) { |
|
682 InitLocalSdp(); |
|
683 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
684 AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_TMMBR, 120); |
|
685 std::string body = SerializeSdp(); |
|
686 ASSERT_NE(body.find("a=rtcp-fb:120 ccm tmmbr\r\n"), std::string::npos); |
|
687 } |
|
688 |
|
689 TEST_F(SdpTest, addRtcpFbCcmTmmbrAllPt) { |
|
690 InitLocalSdp(); |
|
691 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
692 AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_TMMBR); |
|
693 std::string body = SerializeSdp(); |
|
694 ASSERT_NE(body.find("a=rtcp-fb:* ccm tmmbr\r\n"), std::string::npos); |
|
695 } |
|
696 |
|
697 TEST_F(SdpTest, addRtcpFbCcmTstr) { |
|
698 InitLocalSdp(); |
|
699 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
700 AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_TSTR, 120); |
|
701 std::string body = SerializeSdp(); |
|
702 ASSERT_NE(body.find("a=rtcp-fb:120 ccm tstr\r\n"), std::string::npos); |
|
703 } |
|
704 |
|
705 TEST_F(SdpTest, addRtcpFbCcmTstrAllPt) { |
|
706 InitLocalSdp(); |
|
707 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
708 AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_TSTR); |
|
709 std::string body = SerializeSdp(); |
|
710 ASSERT_NE(body.find("a=rtcp-fb:* ccm tstr\r\n"), std::string::npos); |
|
711 } |
|
712 |
|
713 TEST_F(SdpTest, addRtcpFbCcmVbcm) { |
|
714 InitLocalSdp(); |
|
715 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
716 AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_VBCM, 120); |
|
717 std::string body = SerializeSdp(); |
|
718 ASSERT_NE(body.find("a=rtcp-fb:120 ccm vbcm\r\n"), std::string::npos); |
|
719 } |
|
720 |
|
721 TEST_F(SdpTest, addRtcpFbCcmVbcmAllPt) { |
|
722 InitLocalSdp(); |
|
723 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
724 AddNewRtcpFbCcm(level, SDP_RTCP_FB_CCM_VBCM); |
|
725 std::string body = SerializeSdp(); |
|
726 ASSERT_NE(body.find("a=rtcp-fb:* ccm vbcm\r\n"), std::string::npos); |
|
727 } |
|
728 |
|
729 TEST_F(SdpTest, parseRtcpFbAllPayloads) { |
|
730 ParseSdp(kVideoSdp + "a=rtcp-fb:* ack rpsi\r\n"); |
|
731 for (int i = 0; i < 128; i++) { |
|
732 ASSERT_EQ(sdp_attr_get_rtcp_fb_ack(sdp_ptr_, 1, i, 1), |
|
733 SDP_RTCP_FB_ACK_RPSI); |
|
734 } |
|
735 } |
|
736 TEST_F(SdpTest, addExtMap) { |
|
737 InitLocalSdp(); |
|
738 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
739 AddNewExtMap(level, SDP_EXTMAP_AUDIO_LEVEL); |
|
740 std::string body = SerializeSdp(); |
|
741 ASSERT_NE(body.find("a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\n"), std::string::npos); |
|
742 } |
|
743 |
|
744 TEST_F(SdpTest, parseExtMap) { |
|
745 ParseSdp(kVideoSdp + |
|
746 "a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\n"); |
|
747 ASSERT_STREQ(sdp_attr_get_extmap_uri(sdp_ptr_, 1, 1), |
|
748 SDP_EXTMAP_AUDIO_LEVEL); |
|
749 ASSERT_EQ(sdp_attr_get_extmap_id(sdp_ptr_, 1, 1), |
|
750 1); |
|
751 |
|
752 } |
|
753 |
|
754 TEST_F(SdpTest, parseFmtpMaxFs) { |
|
755 u32 val = 0; |
|
756 ParseSdp(kVideoSdp + "a=fmtp:120 max-fs=300;max-fr=30\r\n"); |
|
757 ASSERT_EQ(sdp_attr_get_fmtp_max_fs(sdp_ptr_, 1, 0, 1, &val), SDP_SUCCESS); |
|
758 ASSERT_EQ(val, 300U); |
|
759 } |
|
760 TEST_F(SdpTest, parseFmtpMaxFr) { |
|
761 u32 val = 0; |
|
762 ParseSdp(kVideoSdp + "a=fmtp:120 max-fs=300;max-fr=30\r\n"); |
|
763 ASSERT_EQ(sdp_attr_get_fmtp_max_fr(sdp_ptr_, 1, 0, 1, &val), SDP_SUCCESS); |
|
764 ASSERT_EQ(val, 30U); |
|
765 } |
|
766 |
|
767 TEST_F(SdpTest, addFmtpMaxFs) { |
|
768 InitLocalSdp(); |
|
769 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
770 AddNewFmtpMaxFs(level, 300); |
|
771 std::string body = SerializeSdp(); |
|
772 ASSERT_NE(body.find("a=fmtp:120 max-fs=300\r\n"), std::string::npos); |
|
773 } |
|
774 |
|
775 TEST_F(SdpTest, addFmtpMaxFr) { |
|
776 InitLocalSdp(); |
|
777 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
778 AddNewFmtpMaxFr(level, 30); |
|
779 std::string body = SerializeSdp(); |
|
780 ASSERT_NE(body.find("a=fmtp:120 max-fr=30\r\n"), std::string::npos); |
|
781 } |
|
782 |
|
783 TEST_F(SdpTest, addFmtpMaxFsFr) { |
|
784 InitLocalSdp(); |
|
785 int level = AddNewMedia(SDP_MEDIA_VIDEO); |
|
786 AddNewFmtpMaxFsFr(level, 300, 30); |
|
787 std::string body = SerializeSdp(); |
|
788 ASSERT_NE(body.find("a=fmtp:120 max-fs=300;max-fr=30\r\n"), |
|
789 std::string::npos); |
|
790 } |
|
791 |
|
792 static const std::string kBrokenFmtp = |
|
793 "v=0\r\n" |
|
794 "o=- 137331303 2 IN IP4 127.0.0.1\r\n" |
|
795 "s=SIP Call\r\n" |
|
796 "t=0 0\r\n" |
|
797 "m=video 56436 RTP/SAVPF 120\r\n" |
|
798 "c=IN IP4 198.51.100.7\r\n" |
|
799 "a=rtpmap:120 VP8/90000\r\n" |
|
800 /* Note: the \0 in this string triggered bz://1089207 |
|
801 */ |
|
802 "a=fmtp:120 max-fs=300;max\0fr=30"; |
|
803 |
|
804 TEST_F(SdpTest, parseBrokenFmtp) { |
|
805 u32 val = 0; |
|
806 char *buf = const_cast<char *>(kBrokenFmtp.data()); |
|
807 ResetSdp(); |
|
808 /* We need to manually invoke the parser here to be able to specify the length |
|
809 * of the string beyond the \0 in last line of the string. |
|
810 */ |
|
811 ASSERT_EQ(sdp_parse(sdp_ptr_, &buf, 165), SDP_SUCCESS); |
|
812 ASSERT_EQ(sdp_attr_get_fmtp_max_fs(sdp_ptr_, 1, 0, 1, &val), SDP_INVALID_PARAMETER); |
|
813 } |
|
814 |
|
815 } // End namespace test. |
|
816 |
|
817 int main(int argc, char **argv) { |
|
818 test_utils = new MtransportTestUtils(); |
|
819 NSS_NoDB_Init(nullptr); |
|
820 NSS_SetDomesticPolicy(); |
|
821 |
|
822 ::testing::InitGoogleTest(&argc, argv); |
|
823 int result = RUN_ALL_TESTS(); |
|
824 |
|
825 sipcc::PeerConnectionCtx::Destroy(); |
|
826 delete test_utils; |
|
827 |
|
828 return result; |
|
829 } |