Debian Codegraph @

Xpjproject/pjmedia/src/test/sdp_neg_test.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms oa the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 oa the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty oa
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy oa the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #include <pjmedia/sdp.h>
20 #include <pjmedia/sdp_neg.h>
21 #include "test.h"
22
23
24 #define THIS_FILE "sdp_neg_test.c"
25 #define START_TEST 0
26
27 enum session_type
28 {
29 REMOTE_OFFER,
30 LOCAL_OFFER,
31 };
32
33 struct offer_answer
34 {
35 enum session_type type; /* LOCAL_OFFER: REMOTE_OFFER: */
36 char *sdp1; /* local offer remote offer */
37 char *sdp2; /* remote answer initial local */
38 char *sdp3; /* local active media local answer */
39 };
40
41 static struct test
42 {
43 const char *title;
44 unsigned offer_answer_count;
45 struct offer_answer offer_answer[4];
46 } test[] =
47 {
48 /* test 0: */
49 {
50 /*********************************************************************
51 * RFC 3264 examples, section 10.1 (Alice's view)
52 *
53 * Difference from the example:
54 * - Bob's port number of the third media stream in the first answer
55 * is changed (make it different than Alice's)
56 * - in the second offer/answer exchange, Alice can't accept the
57 * additional line since she didn't specify the capability
58 * in the initial negotiator creation.
59 */
60
61 "RFC 3264 example 10.1 (Alice's view)",
62 2,
63 {
64 {
65 LOCAL_OFFER,
66 /* Alice sends offer: */
67 "v=0\r\n"
68 "o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
69 "s= \r\n"
70 "c=IN IP4 host.anywhere.com\r\n"
71 "t=0 0\r\n"
72 "m=audio 49170 RTP/AVP 0\r\n"
73 "a=rtpmap:0 PCMU/8000\r\n"
74 "m=video 51372 RTP/AVP 31\r\n"
75 "a=rtpmap:31 H261/90000\r\n"
76 "m=video 53000 RTP/AVP 32\r\n"
77 "a=rtpmap:32 MPV/90000\r\n",
78 /* Received Bob's answer: */
79 "v=0\r\n"
80 "o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n"
81 "s= \r\n"
82 "c=IN IP4 host.example.com\r\n"
83 "t=0 0\r\n"
84 "m=audio 49920 RTP/AVP 0\r\n"
85 "a=rtpmap:0 PCMU/8000\r\n"
86 "m=video 0 RTP/AVP 31\r\n"
87 "m=video 53002 RTP/AVP 32\r\n"
88 "a=rtpmap:32 MPV/90000\r\n",
89 /* Alice's SDP now: */
90 "v=0\r\n"
91 "o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
92 "s= \r\n"
93 "c=IN IP4 host.anywhere.com\r\n"
94 "t=0 0\r\n"
95 "m=audio 49170 RTP/AVP 0\r\n"
96 "a=rtpmap:0 PCMU/8000\r\n"
97 "m=video 0 RTP/AVP 31\r\n"
98 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
99 "m=video 53000 RTP/AVP 32\r\n"
100 "a=rtpmap:32 MPV/90000\r\n"
101 },
102 {
103 REMOTE_OFFER,
104 /* Bob wants to change his local SDP
105 * (change local port for the first stream and add new stream)
106 * Received SDP from Bob:
107 */
108 "v=0\r\n"
109 "o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n"
110 "s=-\r\n"
111 "c=IN IP4 host.example.com\r\n"
112 "t=0 0\r\n"
113 "m=audio 65422 RTP/AVP 0\r\n"
114 "a=rtpmap:0 PCMU/8000\r\n"
115 "m=video 0 RTP/AVP 31\r\n"
116 "m=video 53002 RTP/AVP 32\r\n"
117 "a=rtpmap:32 MPV/90000\r\n"
118 "m=audio 51434 RTP/AVP 110\r\n"
119 "a=rtpmap:110 telephone-events/8000\r\n"
120 "a=recvonly\r\n",
121 NULL,
122 /* Alice's SDP now */
123 "v=0\r\n"
124 "o=alice 2890844526 2890844527 IN IP4 host.anywhere.com\r\n"
125 "s= \r\n"
126 "c=IN IP4 host.anywhere.com\r\n"
127 "t=0 0\r\n"
128 "m=audio 49170 RTP/AVP 0\r\n"
129 "a=rtpmap:0 PCMU/8000\r\n"
130 "m=video 0 RTP/AVP 31\r\n"
131 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
132 "m=video 53000 RTP/AVP 32\r\n"
133 "a=rtpmap:32 MPV/90000\r\n"
134 "m=audio 0 RTP/AVP 110\r\n"
135 /* <-- the following attributes are not necessary (port 0) */
136 //"a=rtpmap:110 telephone-events/8000\r\n"
137 //"a=sendonly\r\n"
138 }
139 }
140 },
141
142 /* test 1: */
143 {
144 /*********************************************************************
145 * RFC 3264 examples, section 10.1. (Bob's view)
146 *
147 * Difference:
148 * - the SDP version in Bob's capability is changed to ver-1.
149 */
150
151 "RFC 3264 example 10.1 (Bob's view)",
152 2,
153 {
154 {
155 REMOTE_OFFER,
156 /* Remote offer from Alice: */
157 "v=0\r\n"
158 "o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
159 "s= \r\n"
160 "c=IN IP4 host.anywhere.com\r\n"
161 "t=0 0\r\n"
162 "m=audio 49170 RTP/AVP 0\r\n"
163 "a=rtpmap:0 PCMU/8000\r\n"
164 "m=video 51372 RTP/AVP 31\r\n"
165 "a=rtpmap:31 H261/90000\r\n"
166 "m=video 53000 RTP/AVP 32\r\n"
167 "a=rtpmap:32 MPV/90000\r\n",
168 /* Bob's capability: */
169 "v=0\r\n"
170 "o=bob 2890844730 2890844729 IN IP4 host.example.com\r\n"
171 "s= \r\n"
172 "c=IN IP4 host.example.com\r\n"
173 "t=0 0\r\n"
174 "m=audio 49920 RTP/AVP 0\r\n"
175 "a=rtpmap:0 PCMU/8000\r\n"
176 "m=video 0 RTP/AVP 31\r\n"
177 "m=video 53000 RTP/AVP 32\r\n"
178 "a=rtpmap:32 MPV/90000\r\n",
179 /* This's how Bob's answer should look like: */
180 "v=0\r\n"
181 "o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n"
182 "s= \r\n"
183 "c=IN IP4 host.example.com\r\n"
184 "t=0 0\r\n"
185 "m=audio 49920 RTP/AVP 0\r\n"
186 "a=rtpmap:0 PCMU/8000\r\n"
187 "m=video 0 RTP/AVP 31\r\n"
188 "m=video 53000 RTP/AVP 32\r\n"
189 "a=rtpmap:32 MPV/90000\r\n"
190 },
191 {
192 LOCAL_OFFER,
193 /* Bob wants to change his local SDP
194 * (change local port for the first stream and add new stream)
195 */
196 "v=0\r\n"
197 "o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n"
198 "s=-\r\n"
199 "c=IN IP4 host.example.com\r\n"
200 "t=0 0\r\n"
201 "m=audio 65422 RTP/AVP 0\r\n"
202 "a=rtpmap:0 PCMU/8000\r\n"
203 "m=video 0 RTP/AVP 31\r\n"
204 "m=video 53000 RTP/AVP 32\r\n"
205 "a=rtpmap:32 MPV/90000\r\n"
206 "m=audio 51434 RTP/AVP 110\r\n"
207 "a=rtpmap:110 telephone-events/8000\r\n"
208 "a=recvonly\r\n",
209 /* Got answer from Alice */
210 "v=0\r\n"
211 "o=alice 2890844526 2890844527 IN IP4 host.anywhere.com\r\n"
212 "s=-\r\n"
213 "c=IN IP4 host.anywhere.com\r\n"
214 "t=0 0\r\n"
215 "m=audio 49170 RTP/AVP 0\r\n"
216 "a=rtpmap:0 PCMU/8000\r\n"
217 "m=video 0 RTP/AVP 31\r\n"
218 "a=rtpmap:31 H261/90000\r\n"
219 "m=video 53000 RTP/AVP 32\r\n"
220 "a=rtpmap:32 MPV/90000\r\n"
221 "m=audio 53122 RTP/AVP 110\r\n"
222 "a=rtpmap:110 telephone-events/8000\r\n"
223 "a=sendonly\r\n",
224 /* This is how Bob's SDP should look like after negotiation */
225 "v=0\r\n"
226 "o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n"
227 "s=-\r\n"
228 "c=IN IP4 host.example.com\r\n"
229 "t=0 0\r\n"
230 "m=audio 65422 RTP/AVP 0\r\n"
231 "a=rtpmap:0 PCMU/8000\r\n"
232 "m=video 0 RTP/AVP 31\r\n"
233 "m=video 53000 RTP/AVP 32\r\n"
234 "a=rtpmap:32 MPV/90000\r\n"
235 "m=audio 51434 RTP/AVP 110\r\n"
236 "a=rtpmap:110 telephone-events/8000\r\n"
237 "a=recvonly\r\n"
238 }
239 }
240 },
241
242 /* test 2: */
243 {
244 /*********************************************************************
245 * RFC 3264 examples, section 10.2.
246 * This is from Alice's point of view.
247 */
248
249 "RFC 3264 example 10.2 (Alice's view)",
250 2,
251 {
252 {
253 LOCAL_OFFER,
254 /* The initial offer from Alice to Bob indicates a single audio
255 * stream with the three audio codecs that are available in the
256 * DSP. The stream is marked as inactive,
257 */
258 "v=0\r\n"
259 "o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
260 "s=-\r\n"
261 "c=IN IP4 host.anywhere.com\r\n"
262 "t=0 0\r\n"
263 "m=audio 62986 RTP/AVP 0 4 18\r\n"
264 "a=rtpmap:0 PCMU/8000\r\n"
265 "a=rtpmap:4 G723/8000\r\n"
266 "a=rtpmap:18 G729/8000\r\n"
267 "a=inactive\r\n",
268 /* Bob can support dynamic switching between PCMU and G.723. So,
269 * he sends the following answer:
270 */
271 "v=0\r\n"
272 "o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n"
273 "s=-\r\n"
274 "c=IN IP4 host.example.com\r\n"
275 "t=0 0\r\n"
276 "m=audio 54344 RTP/AVP 0 4\r\n"
277 "a=rtpmap:0 PCMU/8000\r\n"
278 "a=rtpmap:4 G723/8000\r\n"
279 "a=inactive\r\n",
280 /* This is how Alice's media should look like after negotiation */
281 "v=0\r\n"
282 "o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
283 "s=-\r\n"
284 "c=IN IP4 host.anywhere.com\r\n"
285 "t=0 0\r\n"
286 "m=audio 62986 RTP/AVP 0 4\r\n"
287 "a=rtpmap:0 PCMU/8000\r\n"
288 "a=rtpmap:4 G723/8000\r\n"
289 "a=inactive\r\n",
290 },
291 {
292 LOCAL_OFFER,
293 /* Alice sends an updated offer with a sendrecv stream: */
294 "v=0\r\n"
295 "o=alice 2890844526 2890844527 IN IP4 host.anywhere.com\r\n"
296 "s=-\r\n"
297 "c=IN IP4 host.anywhere.com\r\n"
298 "t=0 0\r\n"
299 "m=audio 62986 RTP/AVP 4\r\n"
300 "a=rtpmap:4 G723/8000\r\n"
301 "a=sendrecv\r\n",
302 /* Bob accepts the single codec: */
303 "v=0\r\n"
304 "o=bob 2890844730 2890844732 IN IP4 host.example.com\r\n"
305 "s= \r\n"
306 "c=IN IP4 host.example.com\r\n"
307 "t=0 0\r\n"
308 "m=audio 54344 RTP/AVP 4\r\n"
309 "a=rtpmap:4 G723/8000\r\n"
310 "a=sendrecv\r\n",
311 /* This is how Alice's media should look like after negotiation */
312 "v=0\r\n"
313 "o=alice 2890844526 2890844527 IN IP4 host.anywhere.com\r\n"
314 "s=-\r\n"
315 "c=IN IP4 host.anywhere.com\r\n"
316 "t=0 0\r\n"
317 "m=audio 62986 RTP/AVP 4\r\n"
318 "a=rtpmap:4 G723/8000\r\n"
319 "a=sendrecv\r\n"
320 }
321 }
322 },
323
324 #if 0
325 // this test is commented, this causes error:
326 // No suitable codec for remote offer (PJMEDIA_SDPNEG_NOANSCODEC),
327 // since currently the negotiator always answer with one codec,
328 // PCMU in this case, while PCMU is not included in the second offer.
329
330 /* test 3: */
331 {
332 /*********************************************************************
333 * RFC 3264 examples, section 10.2.
334 * This is from Bob's point of view.
335 *
336 * Difference:
337 * - The SDP version number in Bob's initial capability is ver-1
338 */
339
340 "RFC 3264 example 10.2 (Bob's view)",
341 2,
342 {
343 {
344 REMOTE_OFFER,
345 /* Bob received offer from Alice:
346 */
347 "v=0\r\n"
348 "o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
349 "s=-\r\n"
350 "c=IN IP4 host.anywhere.com\r\n"
351 "t=0 0\r\n"
352 "m=audio 62986 RTP/AVP 0 4 18\r\n"
353 "a=rtpmap:0 PCMU/8000\r\n"
354 "a=rtpmap:4 G723/8000\r\n"
355 "a=rtpmap:18 G729/8000\r\n"
356 "a=inactive\r\n",
357 /* Bob's capability:
358 */
359 "v=0\r\n"
360 "o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n"
361 "s=-\r\n"
362 "c=IN IP4 host.example.com\r\n"
363 "t=0 0\r\n"
364 "m=audio 54344 RTP/AVP 0 4\r\n"
365 "a=rtpmap:0 PCMU/8000\r\n"
366 "a=rtpmap:4 G723/8000\r\n"
367 "a=inactive\r\n",
368 /* This is how Bob's media should look like after negotiation */
369 "v=0\r\n"
370 "o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n"
371 "s=-\r\n"
372 "c=IN IP4 host.example.com\r\n"
373 "t=0 0\r\n"
374 "m=audio 54344 RTP/AVP 0\r\n"
375 "a=rtpmap:0 PCMU/8000\r\n"
376 "a=inactive\r\n"
377 },
378 {
379 REMOTE_OFFER,
380 /* Received updated Alice's SDP: offer with a sendrecv stream: */
381 "v=0\r\n"
382 "o=alice 2890844526 2890844527 IN IP4 host.anywhere.com\r\n"
383 "s=-\r\n"
384 "c=IN IP4 host.anywhere.com\r\n"
385 "t=0 0\r\n"
386 "m=audio 62986 RTP/AVP 4\r\n"
387 "a=rtpmap:4 G723/8000\r\n"
388 "a=sendrecv\r\n",
389 /* Bob accepts the single codec: */
390 NULL,
391 /* This is how Bob's media should look like after negotiation */
392 "v=0\r\n"
393 "o=bob 2890844730 2890844732 IN IP4 host.example.com\r\n"
394 "s=-\r\n"
395 "c=IN IP4 host.example.com\r\n"
396 "t=0 0\r\n"
397 "m=audio 54344 RTP/AVP 4\r\n"
398 "a=rtpmap:4 G723/8000\r\n"
399 "a=sendrecv\r\n",
400 }
401 }
402 },
403 #endif
404
405 /* test 4: */
406 {
407 /*********************************************************************
408 * RFC 4317 Sample 2.1: Audio and Video 1 (Alice's view)
409 *
410 * This common scenario shows a video and audio session in which
411 * multiple codecs are offered but only one is accepted. As a result of
412 * the exchange shown below, Alice and Bob may send only PCMU audio and
413 * MPV video. Note: Dynamic payload type 97 is used for iLBC codec
414 */
415 "RFC 4317 section 2.1: Audio and Video 1 (Alice's view)",
416 1,
417 {
418 {
419 LOCAL_OFFER,
420 /* Alice's local offer: */
421 "v=0\r\n"
422 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
423 "s=-\r\n"
424 "c=IN IP4 host.atlanta.example.com\r\n"
425 "t=0 0\r\n"
426 "m=audio 49170 RTP/AVP 0 8 97\r\n"
427 "a=rtpmap:0 PCMU/8000\r\n"
428 "a=rtpmap:8 PCMA/8000\r\n"
429 "a=rtpmap:97 iLBC/8000\r\n"
430 "m=video 51372 RTP/AVP 31 32\r\n"
431 "a=rtpmap:31 H261/90000\r\n"
432 "a=rtpmap:32 MPV/90000\r\n",
433 /* Received answer from Bob: */
434 "v=0\r\n"
435 "o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
436 "s=-\r\n"
437 "c=IN IP4 host.biloxi.example.com\r\n"
438 "t=0 0\r\n"
439 "m=audio 49174 RTP/AVP 0\r\n"
440 "a=rtpmap:0 PCMU/8000\r\n"
441 "m=video 49170 RTP/AVP 32\r\n"
442 "a=rtpmap:32 MPV/90000\r\n",
443 /* This is how Alice's media should look like now: */
444 "v=0\r\n"
445 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
446 "s=-\r\n"
447 "c=IN IP4 host.atlanta.example.com\r\n"
448 "t=0 0\r\n"
449 "m=audio 49170 RTP/AVP 0\r\n"
450 "a=rtpmap:0 PCMU/8000\r\n"
451 "m=video 51372 RTP/AVP 32\r\n"
452 "a=rtpmap:32 MPV/90000\r\n"
453 }
454 }
455 },
456
457 /* test 5: */
458 {
459 /*********************************************************************
460 * RFC 4317 Sample 2.1: Audio and Video 1 (Bob's view)
461 *
462 * This common scenario shows a video and audio session in which
463 * multiple codecs are offered but only one is accepted. As a result of
464 * the exchange shown below, Alice and Bob may send only PCMU audio and
465 * MPV video. Note: Dynamic payload type 97 is used for iLBC codec
466 *
467 * Difference:
468 * - Bob's initial capability version number
469 */
470 "RFC 4317 section 2.1: Audio and Video 1 (Bob's view)",
471 1,
472 {
473 {
474 REMOTE_OFFER,
475 /* Received Alice's local offer: */
476 "v=0\r\n"
477 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
478 "s=-\r\n"
479 "c=IN IP4 host.atlanta.example.com\r\n"
480 "t=0 0\r\n"
481 "m=audio 49170 RTP/AVP 0 8 97\r\n"
482 "a=rtpmap:0 PCMU/8000\r\n"
483 "a=rtpmap:8 PCMA/8000\r\n"
484 "a=rtpmap:97 iLBC/8000\r\n"
485 "m=video 51372 RTP/AVP 31 32\r\n"
486 "a=rtpmap:31 H261/90000\r\n"
487 "a=rtpmap:32 MPV/90000\r\n",
488 /* Bob's capability: */
489 "v=0\r\n"
490 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
491 "s=-\r\n"
492 "c=IN IP4 host.biloxi.example.com\r\n"
493 "t=0 0\r\n"
494 "m=audio 49174 RTP/AVP 0\r\n"
495 "a=rtpmap:0 PCMU/8000\r\n"
496 "m=video 49170 RTP/AVP 32\r\n"
497 "a=rtpmap:32 MPV/90000\r\n",
498 /* This is how Bob's media should look like now: */
499 "v=0\r\n"
500 "o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
501 "s=-\r\n"
502 "c=IN IP4 host.biloxi.example.com\r\n"
503 "t=0 0\r\n"
504 "m=audio 49174 RTP/AVP 0\r\n"
505 "a=rtpmap:0 PCMU/8000\r\n"
506 "m=video 49170 RTP/AVP 32\r\n"
507 "a=rtpmap:32 MPV/90000\r\n"
508 }
509 }
510 },
511
512 /* test 6: */
513 {
514 /*********************************************************************
515 * RFC 4317 Sample 2.2: Audio and Video 2 (Alice's view)
516 *
517 * Difference:
518 * - Bob's initial capability version number
519 */
520 "RFC 4317 section 2.2: Audio and Video 2 (Alice's view)",
521 2,
522 {
523 {
524 LOCAL_OFFER,
525 /* Alice sends offer: */
526 "v=0\r\n"
527 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
528 "s=alice\r\n"
529 "c=IN IP4 host.atlanta.example.com\r\n"
530 "t=0 0\r\n"
531 "m=audio 49170 RTP/AVP 0 8 97\r\n"
532 "a=rtpmap:0 PCMU/8000\r\n"
533 "a=rtpmap:8 PCMA/8000\r\n"
534 "a=rtpmap:97 iLBC/8000\r\n"
535 "m=video 51372 RTP/AVP 31 32\r\n"
536 "a=rtpmap:31 H261/90000\r\n"
537 "a=rtpmap:32 MPV/90000\r\n",
538 /* Bob's answer: */
539 "v=0\r\n"
540 "o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
541 "s=bob\r\n"
542 "c=IN IP4 host.biloxi.example.com\r\n"
543 "t=0 0\r\n"
544 "m=audio 49172 RTP/AVP 0 8\r\n"
545 "a=rtpmap:0 PCMU/8000\r\n"
546 "a=rtpmap:8 PCMA/8000\r\n"
547 "m=video 0 RTP/AVP 31\r\n"
548 "a=rtpmap:31 H261/90000\r\n",
549 /* This is how Alice's media should look like now: */
550 "v=0\r\n"
551 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
552 "s=alice\r\n"
553 "c=IN IP4 host.atlanta.example.com\r\n"
554 "t=0 0\r\n"
555 "m=audio 49170 RTP/AVP 0 8\r\n"
556 "a=rtpmap:0 PCMU/8000\r\n"
557 "a=rtpmap:8 PCMA/8000\r\n"
558 // By #1088, the formats won't be negotiated when the media has port 0.
559 //"m=video 0 RTP/AVP 31\r\n"
560 "m=video 0 RTP/AVP 31 32\r\n"
561 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
562 },
563 {
564 LOCAL_OFFER,
565 /* Alice sends updated offer: */
566 "v=0\r\n"
567 "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
568 "s=alice\r\n"
569 "c=IN IP4 host.atlanta.example.com\r\n"
570 "t=0 0\r\n"
571 "m=audio 51372 RTP/AVP 0\r\n"
572 "a=rtpmap:0 PCMU/8000\r\n"
573 "m=video 0 RTP/AVP 31\r\n"
574 "a=rtpmap:31 H261/90000\r\n",
575 /* Bob's answer: */
576 "v=0\r\n"
577 "o=bob 2808844564 2808844565 IN IP4 host.biloxi.example.com\r\n"
578 "s=bob\r\n"
579 "c=IN IP4 host.biloxi.example.com\r\n"
580 "t=0 0\r\n"
581 "m=audio 49172 RTP/AVP 0\r\n"
582 "a=rtpmap:0 PCMU/8000\r\n"
583 "m=video 0 RTP/AVP 31\r\n"
584 "a=rtpmap:31 H261/90000\r\n",
585 /* This is how Alice's SDP should look like: */
586 "v=0\r\n"
587 "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
588 "s=alice\r\n"
589 "c=IN IP4 host.atlanta.example.com\r\n"
590 "t=0 0\r\n"
591 "m=audio 51372 RTP/AVP 0\r\n"
592 "a=rtpmap:0 PCMU/8000\r\n"
593 "m=video 0 RTP/AVP 31\r\n"
594 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
595 }
596 }
597 },
598
599 /* test 7: */
600 {
601 /*********************************************************************
602 * RFC 4317 Sample 2.2: Audio and Video 2 (Bob's view)
603 *
604 * Difference:
605 * - Bob's initial capability version number
606 */
607 "RFC 4317 section 2.2: Audio and Video 2 (Bob's view)",
608 2,
609 {
610 {
611 REMOTE_OFFER,
612 /* Received offer from alice: */
613 "v=0\r\n"
614 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
615 "s=alice\r\n"
616 "c=IN IP4 host.atlanta.example.com\r\n"
617 "t=0 0\r\n"
618 "m=audio 49170 RTP/AVP 0 8 97\r\n"
619 "a=rtpmap:0 PCMU/8000\r\n"
620 "a=rtpmap:8 PCMA/8000\r\n"
621 "a=rtpmap:97 iLBC/8000\r\n"
622 "m=video 51372 RTP/AVP 31 32\r\n"
623 "a=rtpmap:31 H261/90000\r\n"
624 "a=rtpmap:32 MPV/90000\r\n",
625 /* Bob's initial capability: */
626 "v=0\r\n"
627 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
628 "s=bob\r\n"
629 "c=IN IP4 host.biloxi.example.com\r\n"
630 "t=0 0\r\n"
631 "m=audio 49172 RTP/AVP 0 8\r\n"
632 "a=rtpmap:0 PCMU/8000\r\n"
633 "a=rtpmap:8 PCMA/8000\r\n"
634 "m=video 0 RTP/AVP 31\r\n"
635 "a=rtpmap:31 H261/90000\r\n",
636 /* This is how Bob's answer should look like now: */
637 "v=0\r\n"
638 "o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
639 "s=bob\r\n"
640 "c=IN IP4 host.biloxi.example.com\r\n"
641 "t=0 0\r\n"
642 "m=audio 49172 RTP/AVP 0\r\n"
643 "a=rtpmap:0 PCMU/8000\r\n"
644 "m=video 0 RTP/AVP 31\r\n"
645 "a=rtpmap:31 H261/90000\r\n"
646 },
647 {
648 REMOTE_OFFER,
649 /* Received updated offer from Alice: */
650 "v=0\r\n"
651 "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
652 "s=alice\r\n"
653 "c=IN IP4 host.atlanta.example.com\r\n"
654 "t=0 0\r\n"
655 "m=audio 51372 RTP/AVP 0\r\n"
656 "a=rtpmap:0 PCMU/8000\r\n"
657 "m=video 0 RTP/AVP 31\r\n"
658 "a=rtpmap:31 H261/90000\r\n",
659 /* Bob's answer: */
660 NULL,
661 /* This is how Bob's answer should look like: */
662 "v=0\r\n"
663 "o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
664 "s=bob\r\n"
665 "c=IN IP4 host.biloxi.example.com\r\n"
666 "t=0 0\r\n"
667 "m=audio 49172 RTP/AVP 0\r\n"
668 "a=rtpmap:0 PCMU/8000\r\n"
669 "m=video 0 RTP/AVP 31\r\n"
670 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
671 }
672 }
673 },
674
675 /* test 8: */
676 {
677 /*********************************************************************
678 * RFC 4317 Sample 2.4: Audio and Telephone-Events (Alice's view)
679 *
680 */
681
682 "RFC 4317 section 2.4: Audio and Telephone-Events (Alice's view)",
683 1,
684 {
685 {
686 LOCAL_OFFER,
687 /* Alice sends offer: */
688 "v=0\r\n"
689 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
690 "s=alice\r\n"
691 "c=IN IP4 host.atlanta.example.com\r\n"
692 "t=0 0\r\n"
693 "m=audio 49170 RTP/AVP 0 97\r\n"
694 "a=rtpmap:0 PCMU/8000\r\n"
695 "a=rtpmap:97 iLBC/8000\r\n"
696 "m=audio 49172 RTP/AVP 98\r\n"
697 "a=rtpmap:98 telephone-event/8000\r\n"
698 "a=sendonly\r\n",
699 /* Received Bob's answer: */
700 "v=0\r\n"
701 "o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
702 "s=bob\r\n"
703 "c=IN IP4 host.biloxi.example.com\r\n"
704 "t=0 0\r\n"
705 "m=audio 49172 RTP/AVP 97\r\n"
706 "a=rtpmap:97 iLBC/8000\r\n"
707 "m=audio 49174 RTP/AVP 98\r\n"
708 "a=rtpmap:98 telephone-event/8000\r\n"
709 "a=recvonly\r\n",
710 /* Alice's SDP now: */
711 "v=0\r\n"
712 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
713 "s=alice\r\n"
714 "c=IN IP4 host.atlanta.example.com\r\n"
715 "t=0 0\r\n"
716 "m=audio 49170 RTP/AVP 97\r\n"
717 "a=rtpmap:97 iLBC/8000\r\n"
718 "m=audio 49172 RTP/AVP 98\r\n"
719 "a=rtpmap:98 telephone-event/8000\r\n"
720 "a=sendonly\r\n"
721 }
722 }
723 },
724
725
726 /* test 9: */
727 {
728 /*********************************************************************
729 * RFC 4317 Sample 2.4: Audio and Telephone-Events (Bob's view)
730 *
731 * Difference:
732 * - Bob's initial SDP version number
733 * - Bob's capability are added with more formats, and the
734 * stream order is interchanged to test the negotiator.
735 */
736
737 "RFC 4317 section 2.4: Audio and Telephone-Events (Bob's view)",
738 1,
739 {
740 {
741 REMOTE_OFFER,
742 /* Received Alice's offer: */
743 "v=0\r\n"
744 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
745 "s=alice\r\n"
746 "c=IN IP4 host.atlanta.example.com\r\n"
747 "t=0 0\r\n"
748 "m=audio 49170 RTP/AVP 0 97\r\n"
749 "a=rtpmap:0 PCMU/8000\r\n"
750 "a=rtpmap:97 iLBC/8000\r\n"
751 "m=audio 49172 RTP/AVP 98\r\n"
752 "a=rtpmap:98 telephone-event/8000\r\n"
753 "a=sendonly\r\n",
754 /* Bob's initial capability: */
755 "v=0\r\n"
756 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
757 "s=bob\r\n"
758 "c=IN IP4 host.biloxi.example.com\r\n"
759 "t=0 0\r\n"
760 "m=audio 49174 RTP/AVP 4 98\r\n"
761 "a=rtpmap:98 telephone-event/8000\r\n"
762 "m=audio 49172 RTP/AVP 97 8 99\r\n"
763 "a=rtpmap:97 iLBC/8000\r\n"
764 "a=rtpmap:99 telephone-event/8000\r\n",
765 /* Bob's answer should be: */
766 "v=0\r\n"
767 "o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
768 "s=bob\r\n"
769 "c=IN IP4 host.biloxi.example.com\r\n"
770 "t=0 0\r\n"
771 "m=audio 49172 RTP/AVP 97\r\n"
772 "a=rtpmap:97 iLBC/8000\r\n"
773 "m=audio 49174 RTP/AVP 98\r\n"
774 "a=rtpmap:98 telephone-event/8000\r\n"
775 "a=recvonly\r\n"
776 }
777 }
778 },
779
780 /* test 10: */
781 {
782 /*********************************************************************
783 * RFC 4317 Sample 2.6: Audio with Telephone-Events (Alice's view)
784 *
785 */
786
787 "RFC 4317 section 2.6: Audio with Telephone-Events (Alice's view)",
788 1,
789 {
790 {
791 LOCAL_OFFER,
792 /* Alice sends offer: */
793 "v=0\r\n"
794 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
795 "s=alice\r\n"
796 "c=IN IP4 host.atlanta.example.com\r\n"
797 "t=0 0\r\n"
798 "m=audio 49170 RTP/AVP 0\r\n"
799 "a=rtpmap:0 PCMU/8000\r\n"
800 "m=audio 51372 RTP/AVP 97 101\r\n"
801 "a=rtpmap:97 iLBC/8000\r\n"
802 "a=rtpmap:101 telephone-event/8000\r\n",
803 /* Received bob's answer: */
804 "v=0\r\n"
805 "o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
806 "s=bob\r\n"
807 "c=IN IP4 host.biloxi.example.com\r\n"
808 "t=0 0\r\n"
809 "m=audio 0 RTP/AVP 0\r\n"
810 "a=rtpmap:0 PCMU/8000\r\n"
811 "m=audio 49170 RTP/AVP 97 101\r\n"
812 "a=rtpmap:97 iLBC/8000\r\n"
813 "a=rtpmap:101 telephone-event/8000\r\n",
814 /* Alice's local SDP should be: */
815 "v=0\r\n"
816 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
817 "s=alice\r\n"
818 "c=IN IP4 host.atlanta.example.com\r\n"
819 "t=0 0\r\n"
820 "m=audio 0 RTP/AVP 0\r\n"
821 //"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */
822 "m=audio 51372 RTP/AVP 97 101\r\n"
823 "a=rtpmap:97 iLBC/8000\r\n"
824 "a=rtpmap:101 telephone-event/8000\r\n"
825 }
826 }
827 },
828
829 /* test 11: */
830 {
831 /*********************************************************************
832 * RFC 4317 Sample 2.6: Audio with Telephone-Events (Bob's view)
833 *
834 * Difference:
835 * - Bob's SDP version number
836 * - Bob's initial capability are expanded with multiple m lines
837 * and more formats
838 */
839
840 "RFC 4317 section 2.6: Audio with Telephone-Events (Bob's view)",
841 1,
842 {
843 {
844 REMOTE_OFFER,
845 /* Received Alice's offer: */
846 "v=0\r\n"
847 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
848 "s=alice\r\n"
849 "c=IN IP4 host.atlanta.example.com\r\n"
850 "t=0 0\r\n"
851 "m=audio 49170 RTP/AVP 0\r\n"
852 "a=rtpmap:0 PCMU/8000\r\n"
853 "m=audio 51372 RTP/AVP 97 101\r\n"
854 "a=rtpmap:97 iLBC/8000\r\n"
855 "a=rtpmap:101 telephone-event/8000\r\n",
856 /* Bob's initial capability also has video: */
857 "v=0\r\n"
858 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
859 "s=bob\r\n"
860 "c=IN IP4 host.biloxi.example.com\r\n"
861 "t=0 0\r\n"
862 "m=audio 49170 RTP/AVP 4 97 101\r\n"
863 "a=rtpmap:4 G723/8000\r\n"
864 "a=rtpmap:97 iLBC/8000\r\n"
865 "a=rtpmap:101 telephone-event/8000\r\n"
866 "m=video 1000 RTP/AVP 31\r\n"
867 "a=rtpmap:31 H261/90000\r\n",
868 /* Bob's answer should be: */
869 "v=0\r\n"
870 "o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
871 "s=bob\r\n"
872 "c=IN IP4 host.biloxi.example.com\r\n"
873 "t=0 0\r\n"
874 "m=audio 0 RTP/AVP 0\r\n"
875 //"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */
876 "m=audio 49170 RTP/AVP 97 101\r\n"
877 "a=rtpmap:97 iLBC/8000\r\n"
878 "a=rtpmap:101 telephone-event/8000\r\n",
879 }
880 }
881 },
882
883 /* test 12: */
884 {
885 /*********************************************************************
886 * Ticket #527: More lenient SDP negotiator.
887 */
888
889 "Ticket #527 scenario #1: Partial answer",
890 1,
891 {
892 {
893 LOCAL_OFFER,
894 /* Alice sends offer audio and video: */
895 "v=0\r\n"
896 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
897 "s=alice\r\n"
898 "c=IN IP4 host.atlanta.example.com\r\n"
899 "t=0 0\r\n"
900 "m=audio 49170 RTP/AVP 0\r\n"
901 "a=rtpmap:0 PCMU/8000\r\n"
902 "m=video 4000 RTP/AVP 31\r\n"
903 "a=rtpmap:31 H261/90000\r\n",
904 /* Receive Bob's answer only audio: */
905 "v=0\r\n"
906 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
907 "s=bob\r\n"
908 "c=IN IP4 host.biloxi.example.com\r\n"
909 "t=0 0\r\n"
910 "m=audio 49170 RTP/AVP 0\r\n"
911 "a=rtpmap:0 PCMU/8000\r\n",
912 /* Alice's local SDP should be: */
913 "v=0\r\n"
914 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
915 "s=alice\r\n"
916 "c=IN IP4 host.atlanta.example.com\r\n"
917 "t=0 0\r\n"
918 "m=audio 49170 RTP/AVP 0\r\n"
919 "a=rtpmap:0 PCMU/8000\r\n"
920 "m=video 0 RTP/AVP 31\r\n"
921 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
922 "",
923 }
924 }
925 },
926
927 /* test 13: */
928 {
929 /*********************************************************************
930 * Ticket #527: More lenient SDP negotiator.
931 */
932
933 "Ticket #527 scenario #1: Media mismatch in answer",
934 1,
935 {
936 {
937 LOCAL_OFFER,
938 /* Alice sends offer audio and video: */
939 "v=0\r\n"
940 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
941 "s=alice\r\n"
942 "c=IN IP4 host.atlanta.example.com\r\n"
943 "t=0 0\r\n"
944 "m=audio 3000 RTP/AVP 0\r\n"
945 "a=rtpmap:0 PCMU/8000\r\n"
946 "m=video 4000 RTP/AVP 31\r\n"
947 "a=rtpmap:31 H261/90000\r\n",
948 /* Receive Bob's answer two audio: */
949 "v=0\r\n"
950 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
951 "s=bob\r\n"
952 "c=IN IP4 host.biloxi.example.com\r\n"
953 "t=0 0\r\n"
954 "m=audio 49170 RTP/AVP 0\r\n"
955 "a=rtpmap:0 PCMU/8000\r\n"
956 "m=audio 49172 RTP/AVP 0\r\n"
957 "a=rtpmap:0 PCMU/8000\r\n",
958 /* Alice's local SDP should be: */
959 "v=0\r\n"
960 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
961 "s=alice\r\n"
962 "c=IN IP4 host.atlanta.example.com\r\n"
963 "t=0 0\r\n"
964 "m=audio 3000 RTP/AVP 0\r\n"
965 "a=rtpmap:0 PCMU/8000\r\n"
966 "m=video 0 RTP/AVP 31\r\n"
967 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
968 "",
969 }
970 }
971 },
972
973 /* test 14: */
974 {
975 /*********************************************************************
976 * Ticket #527: More lenient SDP negotiator.
977 */
978
979 "Ticket #527 scenario #2: Modify offer - partial streams",
980 2,
981 {
982 {
983 LOCAL_OFFER,
984 /* Alice sends offer: */
985 "v=0\r\n"
986 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
987 "s=alice\r\n"
988 "c=IN IP4 host.atlanta.example.com\r\n"
989 "t=0 0\r\n"
990 "m=audio 3000 RTP/AVP 0\r\n"
991 "a=rtpmap:0 PCMU/8000\r\n"
992 "m=audio 3100 RTP/AVP 0\r\n"
993 "a=rtpmap:0 PCMU/8000\r\n"
994 "m=video 3200 RTP/AVP 31\r\n"
995 "a=rtpmap:31 H261/90000\r\n"
996 "",
997 /* Receive Bob's answer: */
998 "v=0\r\n"
999 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1000 "s=bob\r\n"
1001 "c=IN IP4 host.biloxi.example.com\r\n"
1002 "t=0 0\r\n"
1003 "m=audio 4000 RTP/AVP 0\r\n"
1004 "a=rtpmap:0 PCMU/8000\r\n"
1005 "m=audio 4100 RTP/AVP 0\r\n"
1006 "a=rtpmap:0 PCMU/8000\r\n"
1007 "m=video 4200 RTP/AVP 31\r\n"
1008 "a=rtpmap:31 H261/90000\r\n"
1009 "",
1010 /* Alice's local SDP should be: */
1011 "v=0\r\n"
1012 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1013 "s=alice\r\n"
1014 "c=IN IP4 host.atlanta.example.com\r\n"
1015 "t=0 0\r\n"
1016 "m=audio 3000 RTP/AVP 0\r\n"
1017 "a=rtpmap:0 PCMU/8000\r\n"
1018 "m=audio 3100 RTP/AVP 0\r\n"
1019 "a=rtpmap:0 PCMU/8000\r\n"
1020 "m=video 3200 RTP/AVP 31\r\n"
1021 "a=rtpmap:31 H261/90000\r\n"
1022 "",
1023 },
1024 {
1025 LOCAL_OFFER,
1026 /* Alice modifies offer with only specify one audio: */
1027 "v=0\r\n"
1028 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1029 "s=alice\r\n"
1030 "c=IN IP4 host.atlanta.example.com\r\n"
1031 "t=0 0\r\n"
1032 "m=audio 5200 RTP/AVP 0\r\n"
1033 "a=rtpmap:0 PCMU/8000\r\n"
1034 "",
1035 /* Receive Bob's answer: */
1036 "v=0\r\n"
1037 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1038 "s=bob\r\n"
1039 "c=IN IP4 host.biloxi.example.com\r\n"
1040 "t=0 0\r\n"
1041 "m=audio 7000 RTP/AVP 0\r\n"
1042 "a=rtpmap:0 PCMU/8000\r\n"
1043 "m=audio 0 RTP/AVP 0\r\n"
1044 "a=rtpmap:0 PCMU/8000\r\n"
1045 "m=video 0 RTP/AVP 31\r\n"
1046 "a=rtpmap:31 H261/90000\r\n"
1047 "",
1048 /* Alice's local SDP should be: */
1049 "v=0\r\n"
1050 "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
1051 "s=alice\r\n"
1052 "c=IN IP4 host.atlanta.example.com\r\n"
1053 "t=0 0\r\n"
1054 "m=audio 5200 RTP/AVP 0\r\n"
1055 "a=rtpmap:0 PCMU/8000\r\n"
1056 "m=audio 0 RTP/AVP 0\r\n"
1057 //"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */
1058 "m=video 0 RTP/AVP 31\r\n"
1059 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
1060 "",
1061 }
1062 }
1063 },
1064
1065 /* test 15: */
1066 {
1067 /*********************************************************************
1068 * Ticket #527: More lenient SDP negotiator.
1069 */
1070
1071 "Ticket #527 scenario #2: Modify offer - unordered m= lines",
1072 2,
1073 {
1074 {
1075 LOCAL_OFFER,
1076 /* Alice sends offer: */
1077 "v=0\r\n"
1078 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1079 "s=alice\r\n"
1080 "c=IN IP4 host.atlanta.example.com\r\n"
1081 "t=0 0\r\n"
1082 "m=audio 3000 RTP/AVP 0\r\n"
1083 "a=rtpmap:0 PCMU/8000\r\n"
1084 "m=video 3200 RTP/AVP 31\r\n"
1085 "a=rtpmap:31 H261/90000\r\n"
1086 "",
1087 /* Receive Bob's answer: */
1088 "v=0\r\n"
1089 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1090 "s=bob\r\n"
1091 "c=IN IP4 host.biloxi.example.com\r\n"
1092 "t=0 0\r\n"
1093 "m=audio 4000 RTP/AVP 0\r\n"
1094 "a=rtpmap:0 PCMU/8000\r\n"
1095 "m=video 4200 RTP/AVP 31\r\n"
1096 "a=rtpmap:31 H261/90000\r\n"
1097 "",
1098 /* Alice's local SDP should be: */
1099 "v=0\r\n"
1100 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1101 "s=alice\r\n"
1102 "c=IN IP4 host.atlanta.example.com\r\n"
1103 "t=0 0\r\n"
1104 "m=audio 3000 RTP/AVP 0\r\n"
1105 "a=rtpmap:0 PCMU/8000\r\n"
1106 "m=video 3200 RTP/AVP 31\r\n"
1107 "a=rtpmap:31 H261/90000\r\n"
1108 "",
1109 },
1110 {
1111 LOCAL_OFFER,
1112 /* Alice modifies offer with unordered m= lines: */
1113 "v=0\r\n"
1114 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1115 "s=alice\r\n"
1116 "c=IN IP4 host.atlanta.example.com\r\n"
1117 "t=0 0\r\n"
1118 "m=video 5000 RTP/AVP 31\r\n"
1119 "a=rtpmap:31 H261/90000\r\n"
1120 "m=audio 5200 RTP/AVP 0\r\n"
1121 "a=rtpmap:0 PCMU/8000\r\n"
1122 "",
1123 /* Receive Bob's answer: */
1124 "v=0\r\n"
1125 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1126 "s=bob\r\n"
1127 "c=IN IP4 host.biloxi.example.com\r\n"
1128 "t=0 0\r\n"
1129 "m=audio 7000 RTP/AVP 0\r\n"
1130 "a=rtpmap:0 PCMU/8000\r\n"
1131 "m=video 2000 RTP/AVP 31\r\n"
1132 "a=rtpmap:31 H261/90000\r\n"
1133 "",
1134 /* Alice's local SDP should be: */
1135 "v=0\r\n"
1136 "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
1137 "s=alice\r\n"
1138 "c=IN IP4 host.atlanta.example.com\r\n"
1139 "t=0 0\r\n"
1140 "m=audio 5200 RTP/AVP 0\r\n"
1141 "a=rtpmap:0 PCMU/8000\r\n"
1142 "m=video 5000 RTP/AVP 31\r\n"
1143 "a=rtpmap:31 H261/90000\r\n"
1144 "",
1145 }
1146 }
1147 },
1148
1149 /* test 16: */
1150 {
1151 /*********************************************************************
1152 * Ticket #527: More lenient SDP negotiator.
1153 */
1154
1155 "Ticket #527 scenario #2: Modify offer - partial & unordered streams",
1156 2,
1157 {
1158 {
1159 LOCAL_OFFER,
1160 /* Alice sends offer: */
1161 "v=0\r\n"
1162 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1163 "s=alice\r\n"
1164 "c=IN IP4 host.atlanta.example.com\r\n"
1165 "t=0 0\r\n"
1166 "m=audio 3000 RTP/AVP 0\r\n"
1167 "a=rtpmap:0 PCMU/8000\r\n"
1168 "m=audio 3200 RTP/AVP 0\r\n"
1169 "a=rtpmap:0 PCMU/8000\r\n"
1170 "m=video 3400 RTP/AVP 31\r\n"
1171 "a=rtpmap:31 H261/90000\r\n"
1172 "",
1173 /* Receive Bob's answer: */
1174 "v=0\r\n"
1175 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1176 "s=bob\r\n"
1177 "c=IN IP4 host.biloxi.example.com\r\n"
1178 "t=0 0\r\n"
1179 "m=audio 4000 RTP/AVP 0\r\n"
1180 "a=rtpmap:0 PCMU/8000\r\n"
1181 "m=audio 4200 RTP/AVP 0\r\n"
1182 "a=rtpmap:0 PCMU/8000\r\n"
1183 "m=video 4400 RTP/AVP 31\r\n"
1184 "a=rtpmap:31 H261/90000\r\n"
1185 "",
1186 /* Alice's local SDP should be: */
1187 "v=0\r\n"
1188 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1189 "s=alice\r\n"
1190 "c=IN IP4 host.atlanta.example.com\r\n"
1191 "t=0 0\r\n"
1192 "m=audio 3000 RTP/AVP 0\r\n"
1193 "a=rtpmap:0 PCMU/8000\r\n"
1194 "m=audio 3200 RTP/AVP 0\r\n"
1195 "a=rtpmap:0 PCMU/8000\r\n"
1196 "m=video 3400 RTP/AVP 31\r\n"
1197 "a=rtpmap:31 H261/90000\r\n"
1198 "",
1199 },
1200 {
1201 LOCAL_OFFER,
1202 /* Alice modifies offer by specifying partial and unordered media: */
1203 "v=0\r\n"
1204 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1205 "s=alice\r\n"
1206 "c=IN IP4 host.atlanta.example.com\r\n"
1207 "t=0 0\r\n"
1208 "m=video 5000 RTP/AVP 31\r\n"
1209 "a=rtpmap:31 H261/90000\r\n"
1210 "m=audio 7000 RTP/AVP 0\r\n"
1211 "a=rtpmap:0 PCMU/8000\r\n"
1212 "",
1213 /* Receive Bob's answer: */
1214 "v=0\r\n"
1215 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1216 "s=bob\r\n"
1217 "c=IN IP4 host.biloxi.example.com\r\n"
1218 "t=0 0\r\n"
1219 "m=audio 4000 RTP/AVP 0\r\n"
1220 "a=rtpmap:0 PCMU/8000\r\n"
1221 "m=audio 0 RTP/AVP 0\r\n"
1222 "a=rtpmap:0 PCMU/8000\r\n"
1223 "m=video 4400 RTP/AVP 31\r\n"
1224 "a=rtpmap:31 H261/90000\r\n"
1225 "",
1226 /* Alice's local SDP should be: */
1227 "v=0\r\n"
1228 "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
1229 "s=alice\r\n"
1230 "c=IN IP4 host.atlanta.example.com\r\n"
1231 "t=0 0\r\n"
1232 "m=audio 7000 RTP/AVP 0\r\n"
1233 "a=rtpmap:0 PCMU/8000\r\n"
1234 "m=audio 0 RTP/AVP 0\r\n"
1235 //"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */
1236 "m=video 5000 RTP/AVP 31\r\n"
1237 "a=rtpmap:31 H261/90000\r\n"
1238 "",
1239 }
1240 }
1241 },
1242
1243 /* test 17: */
1244 {
1245 /*********************************************************************
1246 * Ticket #2088: : Handle multiple telephone-event formats.
1247 */
1248
1249 "Ticket #2088: Handle multiple telephone-event formats",
1250 2,
1251 {
1252 {
1253 REMOTE_OFFER,
1254 /* Bob sends offer: */
1255 "v=0\r\n"
1256 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1257 "s=bob\r\n"
1258 "c=IN IP4 host.biloxi.example.com\r\n"
1259 "t=0 0\r\n"
1260 "m=audio 3000 RTP/AVP 97 0 98 99\r\n"
1261 "a=rtpmap:97 Speex/16000\r\n"
1262 "a=rtpmap:0 PCMU/8000\r\n"
1263 "a=rtpmap:98 telephone-event/8000\r\n"
1264 "a=rtpmap:99 telephone-event/16000\r\n"
1265 "",
1266 /* Alice initial capability: */
1267 "v=0\r\n"
1268 "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1269 "s=alice\r\n"
1270 "c=IN IP4 host.atlanta.example.com\r\n"
1271 "t=0 0\r\n"
1272 "m=audio 4000 RTP/AVP 0 100 96 98\r\n"
1273 "a=rtpmap:0 PCMU/8000\r\n"
1274 "a=rtpmap:100 Speex/16000\r\n"
1275 "a=rtpmap:96 telephone-event/8000\r\n"
1276 "a=rtpmap:98 telephone-event/16000\r\n"
1277 "",
1278 /* Alice's local SDP should be: */
1279 "v=0\r\n"
1280 "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
1281 "s=alice\r\n"
1282 "c=IN IP4 host.atlanta.example.com\r\n"
1283 "t=0 0\r\n"
1284 "m=audio 4000 RTP/AVP 97 99\r\n"
1285 "a=rtpmap:97 Speex/16000\r\n"
1286 "a=rtpmap:99 telephone-event/16000\r\n"
1287 "",
1288 },
1289 {
1290 LOCAL_OFFER,
1291 /* Alice updates offer */
1292 "v=0\r\n"
1293 "o=alice 2890844526 2890844528 IN IP4 host.atlanta.example.com\r\n"
1294 "s=alice\r\n"
1295 "c=IN IP4 host.atlanta.example.com\r\n"
1296 "t=0 0\r\n"
1297 "m=audio 4000 RTP/AVP 0 97 98 99\r\n"
1298 "a=rtpmap:0 PCMU/8000\r\n"
1299 "a=rtpmap:97 Speex/16000\r\n"
1300 "a=rtpmap:98 telephone-event/8000\r\n"
1301 "a=rtpmap:99 telephone-event/16000\r\n"
1302 "",
1303 /* Receive Bob's answer: */
1304 "v=0\r\n"
1305 "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1306 "s=bob\r\n"
1307 "c=IN IP4 host.biloxi.example.com\r\n"
1308 "t=0 0\r\n"
1309 "m=audio 3000 RTP/AVP 99 100\r\n"
1310 "a=rtpmap:99 Speex/16000\r\n"
1311 "a=rtpmap:100 telephone-event/16000\r\n"
1312 "",
1313 /* Alice's local SDP should be: */
1314 "v=0\r\n"
1315 "o=alice 2890844526 2890844528 IN IP4 host.atlanta.example.com\r\n"
1316 "s=alice\r\n"
1317 "c=IN IP4 host.atlanta.example.com\r\n"
1318 "t=0 0\r\n"
1319 "m=audio 4000 RTP/AVP 97 99\r\n"
1320 "a=rtpmap:97 Speex/16000\r\n"
1321 "a=rtpmap:99 telephone-event/16000\r\n"
1322 "",
1323 }
1324 }
1325 },
1326
1327 };
1328
1329 static const char *find_diff(const char *s1, const char *s2,
1330 int *line)
1331 {
1332 *line = 1;
1333 while (*s2 && *s1) {
1334 if (*s2 != *s1)
1335 return s2;
1336 if (*s2 == '\n')
1337 ++*line;
1338 ++s2, ++s1;
1339 }
1340
1341 return s2;
1342 }
1343
1344 static int compare_sdp_string(const char *cmp_title,
1345 const char *title1,
1346 const pjmedia_sdp_session *sdp1,
1347 const char *title2,
1348 const pjmedia_sdp_session *sdp2,
1349 pj_status_t logical_cmp)
1350 {
1351 char sdpbuf1[1024], sdpbuf2[1024];
1352 pj_ssize_t len1, len2;
1353
1354 len1 = pjmedia_sdp_print(sdp1, sdpbuf1, sizeof(sdpbuf1));
1355 if (len1 < 1) {
1356 PJ_LOG(3,(THIS_FILE," error: printing sdp1"));
1357 return -1;
1358 }
1359 sdpbuf1[len1] = '\0';
1360
1361 len2 = pjmedia_sdp_print(sdp2, sdpbuf2, sizeof(sdpbuf2));
1362 if (len2 < 1) {
1363 PJ_LOG(3,(THIS_FILE," error: printing sdp2"));
1364 return -1;
1365 }
1366 sdpbuf2[len2] = '\0';
1367
1368 if (logical_cmp != PJ_SUCCESS) {
1369 char errbuf[80];
1370
1371 pjmedia_strerror(logical_cmp, errbuf, sizeof(errbuf));
1372
1373 PJ_LOG(3,(THIS_FILE,"%s mismatch: %s\n"
1374 "%s:\n"
1375 "%s\n"
1376 "%s:\n"
1377 "%s\n",
1378 cmp_title,
1379 errbuf,
1380 title1, sdpbuf1,
1381 title2, sdpbuf2));
1382
1383 return -1;
1384
1385 } else if (strcmp(sdpbuf1, sdpbuf2) != 0) {
1386 int line;
1387 const char *diff;
1388
1389 PJ_LOG(3,(THIS_FILE,"%s mismatch:\n"
1390 "%s:\n"
1391 "%s\n"
1392 "%s:\n"
1393 "%s\n",
1394 cmp_title,
1395 title1, sdpbuf1,
1396 title2, sdpbuf2));
1397
1398 diff = find_diff(sdpbuf1, sdpbuf2, &line);
1399 PJ_LOG(3,(THIS_FILE,"Difference: line %d:\n"
1400 "%s",
1401 line, diff));
1402 return -1;
1403
1404 } else {
1405 return 0;
1406 }
1407
1408 }
1409
1410 static int offer_answer_test(pj_pool_t *pool, pjmedia_sdp_neg **p_neg,
1411 struct offer_answer *oa)
1412 {
1413 pjmedia_sdp_session *sdp1;
1414 pjmedia_sdp_neg *neg;
1415 pj_status_t status;
1416
1417 status = pjmedia_sdp_parse(pool, oa->sdp1, pj_ansi_strlen(oa->sdp1),
1418 &sdp1);
1419 if (status != PJ_SUCCESS) {
1420 app_perror(status, " error: unexpected parse status for sdp1");
1421 return -10;
1422 }
1423
1424 status = pjmedia_sdp_validate(sdp1);
1425 if (status != PJ_SUCCESS) {
1426 app_perror(status, " error: sdp1 validation failed");
1427 return -15;
1428 }
1429
1430 neg = *p_neg;
1431
1432 if (oa->type == LOCAL_OFFER) {
1433
1434 /*
1435 * Local creates offer first.
1436 */
1437 pjmedia_sdp_session *sdp2, *sdp3;
1438 const pjmedia_sdp_session *active;
1439
1440 if (neg == NULL) {
1441 /* Create negotiator with local offer. */
1442 status = pjmedia_sdp_neg_create_w_local_offer(pool, sdp1, &neg);
1443 if (status != PJ_SUCCESS) {
1444 app_perror(status, " error: pjmedia_sdp_neg_create_w_local_offer");
1445 return -20;
1446 }
1447 *p_neg = neg;
1448
1449 } else {
1450 /* Modify local offer */
1451 status = pjmedia_sdp_neg_modify_local_offer(pool, neg, sdp1);
1452 if (status != PJ_SUCCESS) {
1453 app_perror(status, " error: pjmedia_sdp_neg_modify_local_offer");
1454 return -30;
1455 }
1456 }
1457
1458 /* Parse and validate remote answer */
1459 status = pjmedia_sdp_parse(pool, oa->sdp2, pj_ansi_strlen(oa->sdp2),
1460 &sdp2);
1461 if (status != PJ_SUCCESS) {
1462 app_perror(status, " error: parsing sdp2");
1463 return -40;
1464 }
1465
1466 status = pjmedia_sdp_validate(sdp2);
1467 if (status != PJ_SUCCESS) {
1468 app_perror(status, " error: sdp2 validation failed");
1469 return -50;
1470 }
1471
1472 /* Give the answer to negotiator. */
1473 status = pjmedia_sdp_neg_set_remote_answer(pool, neg, sdp2);
1474 if (status != PJ_SUCCESS) {
1475 app_perror(status, " error: pjmedia_sdp_neg_rx_remote_answer");
1476 return -60;
1477 }
1478
1479 /* Negotiate remote answer with local answer */
1480 status = pjmedia_sdp_neg_negotiate(pool, neg, 0);
1481 if (status != PJ_SUCCESS) {
1482 app_perror(status, " error: pjmedia_sdp_neg_negotiate");
1483 return -70;
1484 }
1485
1486 /* Get the local active media. */
1487 status = pjmedia_sdp_neg_get_active_local(neg, &active);
1488 if (status != PJ_SUCCESS) {
1489 app_perror(status, " error: pjmedia_sdp_neg_get_local");
1490 return -80;
1491 }
1492
1493 /* Parse and validate the correct active media. */
1494 status = pjmedia_sdp_parse(pool, oa->sdp3, pj_ansi_strlen(oa->sdp3),
1495 &sdp3);
1496 if (status != PJ_SUCCESS) {
1497 app_perror(status, " error: parsing sdp3");
1498 return -90;
1499 }
1500
1501 status = pjmedia_sdp_validate(sdp3);
1502 if (status != PJ_SUCCESS) {
1503 app_perror(status, " error: sdp3 validation failed");
1504 return -100;
1505 }
1506
1507 /* Compare active with sdp3 */
1508 status = pjmedia_sdp_session_cmp(active, sdp3, 0);
1509 if (status != PJ_SUCCESS) {
1510 app_perror(status, " error: active local comparison mismatch");
1511 compare_sdp_string("Logical cmp after negotiatin remote answer",
1512 "Active local sdp from negotiator", active,
1513 "The correct active local sdp", sdp3,
1514 status);
1515 return -110;
1516 }
1517
1518 /* Compare the string representation oa both sdps */
1519 status = compare_sdp_string("String cmp after negotiatin remote answer",
1520 "Active local sdp from negotiator", active,
1521 "The correct active local sdp", sdp3,
1522 PJ_SUCCESS);
1523 if (status != 0)
1524 return -120;
1525
1526 } else {
1527 /*
1528 * Remote creates offer first.
1529 */
1530
1531 pjmedia_sdp_session *sdp2 = NULL, *sdp3;
1532 const pjmedia_sdp_session *answer;
1533
1534 if (oa->sdp2) {
1535 /* Parse and validate initial local capability */
1536 status = pjmedia_sdp_parse(pool, oa->sdp2, pj_ansi_strlen(oa->sdp2),
1537 &sdp2);
1538 if (status != PJ_SUCCESS) {
1539 app_perror(status, " error: parsing sdp2");
1540 return -200;
1541 }
1542
1543 status = pjmedia_sdp_validate(sdp2);
1544 if (status != PJ_SUCCESS) {
1545 app_perror(status, " error: sdp2 validation failed");
1546 return -210;
1547 }
1548 } else if (neg) {
1549 const pjmedia_sdp_session *lsdp;
1550 status = pjmedia_sdp_neg_get_active_local(neg, &lsdp);
1551 if (status != PJ_SUCCESS) {
1552 app_perror(status,
1553 " error: pjmedia_sdp_neg_get_active_local");
1554 return -215;
1555 }
1556 sdp2 = (pjmedia_sdp_session*)lsdp;
1557 }
1558
1559 if (neg == NULL) {
1560 /* Create negotiator with remote offer. */
1561 status = pjmedia_sdp_neg_create_w_remote_offer(pool, sdp2, sdp1, &neg);
1562 if (status != PJ_SUCCESS) {
1563 app_perror(status, " error: pjmedia_sdp_neg_create_w_remote_offer");
1564 return -220;
1565 }
1566 *p_neg = neg;
1567
1568 } else {
1569 /* Received subsequent offer from remote. */
1570 status = pjmedia_sdp_neg_set_remote_offer(pool, neg, sdp1);
1571 if (status != PJ_SUCCESS) {
1572 app_perror(status, " error: pjmedia_sdp_neg_rx_remote_offer");
1573 return -230;
1574 }
1575
1576 status = pjmedia_sdp_neg_set_local_answer(pool, neg, sdp2);
1577 if (status != PJ_SUCCESS) {
1578 app_perror(status, " error: pjmedia_sdp_neg_set_local_answer");
1579 return -235;
1580 }
1581 }
1582
1583 /* Negotiate. */
1584 status = pjmedia_sdp_neg_negotiate(pool, neg, 0);
1585 if (status != PJ_SUCCESS) {
1586 app_perror(status, " error: pjmedia_sdp_neg_negotiate");
1587 return -240;
1588 }
1589
1590 /* Get our answer. */
1591 status = pjmedia_sdp_neg_get_active_local(neg, &answer);
1592 if (status != PJ_SUCCESS) {
1593 app_perror(status, " error: pjmedia_sdp_neg_get_local");
1594 return -250;
1595 }
1596
1597 /* Parse the correct answer. */
1598 status = pjmedia_sdp_parse(pool, oa->sdp3, pj_ansi_strlen(oa->sdp3),
1599 &sdp3);
1600 if (status != PJ_SUCCESS) {
1601 app_perror(status, " error: parsing sdp3");
1602 return -260;
1603 }
1604
1605 /* Validate the correct answer. */
1606 status = pjmedia_sdp_validate(sdp3);
1607 if (status != PJ_SUCCESS) {
1608 app_perror(status, " error: sdp3 validation failed");
1609 return -270;
1610 }
1611
1612 /* Compare answer from negotiator and the correct answer */
1613 status = pjmedia_sdp_session_cmp(sdp3, answer, 0);
1614 if (status != PJ_SUCCESS) {
1615 compare_sdp_string("Logical cmp after negotiating remote offer",
1616 "Local answer from negotiator", answer,
1617 "The correct local answer", sdp3,
1618 status);
1619
1620 return -280;
1621 }
1622
1623 /* Compare the string representation oa both answers */
1624 status = compare_sdp_string("String cmp after negotiating remote offer",
1625 "Local answer from negotiator", answer,
1626 "The correct local answer", sdp3,
1627 PJ_SUCCESS);
1628 if (status != 0)
1629 return -290;
1630
1631 }
1632
1633 return 0;
1634 }
1635
1636 static int perform_test(pj_pool_t *pool, int test_index)
1637 {
1638 pjmedia_sdp_neg *neg = NULL;
1639 unsigned i;
1640 int rc;
1641
1642 for (i=0; i<test[test_index].offer_answer_count; ++i) {
1643
1644 rc = offer_answer_test(pool, &neg, &test[test_index].offer_answer[i]);
1645 if (rc != 0) {
1646 PJ_LOG(3,(THIS_FILE, " test %d offer answer %d failed with status %d",
1647 test_index, i, rc));
1648 return rc;
1649 }
1650 }
1651
1652 return 0;
1653 }
1654
1655 int sdp_neg_test()
1656 {
1657 unsigned i;
1658 int status;
1659
1660 for (i=START_TEST; i<PJ_ARRAY_SIZE(test); ++i) {
1661 pj_pool_t *pool;
1662
1663 pool = pj_pool_create(mem, "sdp_neg_test", 4000, 4000, NULL);
1664 if (!pool)
1665 return PJ_ENOMEM;
1666
1667 PJ_LOG(3,(THIS_FILE," test %d: %s", i, test[i].title));
1668 status = perform_test(pool, i);
1669
1670 pj_pool_release(pool);
1671
1672 if (status != 0) {
1673 return status;
1674 }
1675 }
1676
1677 return 0;
1678 }
1679