1
/* $Id: sdp_neg_test.c 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms oa the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 oa the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty oa
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy oa the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#include <pjmedia/sdp.h>
21
#include <pjmedia/sdp_neg.h>
25
#define THIS_FILE "sdp_neg_test.c"
36
enum session_type type; /* LOCAL_OFFER: REMOTE_OFFER: */
37
char *sdp1; /* local offer remote offer */
38
char *sdp2; /* remote answer initial local */
39
char *sdp3; /* local active media local answer */
45
unsigned offer_answer_count;
46
struct offer_answer offer_answer[4];
51
/*********************************************************************
52
* RFC 3264 examples, section 10.1 (Alice's view)
54
* Difference from the example:
55
* - Bob's port number of the third media stream in the first answer
56
* is changed (make it different than Alice's)
57
* - in the second offer/answer exchange, Alice can't accept the
58
* additional line since she didn't specify the capability
59
* in the initial negotiator creation.
62
"RFC 3264 example 10.1 (Alice's view)",
67
/* Alice sends offer: */
69
"o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
71
"c=IN IP4 host.anywhere.com\r\n"
73
"m=audio 49170 RTP/AVP 0\r\n"
74
"a=rtpmap:0 PCMU/8000\r\n"
75
"m=video 51372 RTP/AVP 31\r\n"
76
"a=rtpmap:31 H261/90000\r\n"
77
"m=video 53000 RTP/AVP 32\r\n"
78
"a=rtpmap:32 MPV/90000\r\n",
79
/* Received Bob's answer: */
81
"o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n"
83
"c=IN IP4 host.example.com\r\n"
85
"m=audio 49920 RTP/AVP 0\r\n"
86
"a=rtpmap:0 PCMU/8000\r\n"
87
"m=video 0 RTP/AVP 31\r\n"
88
"m=video 53002 RTP/AVP 32\r\n"
89
"a=rtpmap:32 MPV/90000\r\n",
90
/* Alice's SDP now: */
92
"o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
94
"c=IN IP4 host.anywhere.com\r\n"
96
"m=audio 49170 RTP/AVP 0\r\n"
97
"a=rtpmap:0 PCMU/8000\r\n"
98
"m=video 0 RTP/AVP 31\r\n"
99
//"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
100
"m=video 53000 RTP/AVP 32\r\n"
101
"a=rtpmap:32 MPV/90000\r\n"
105
/* Bob wants to change his local SDP
106
* (change local port for the first stream and add new stream)
107
* Received SDP from Bob:
110
"o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n"
112
"c=IN IP4 host.example.com\r\n"
114
"m=audio 65422 RTP/AVP 0\r\n"
115
"a=rtpmap:0 PCMU/8000\r\n"
116
"m=video 0 RTP/AVP 31\r\n"
117
"m=video 53002 RTP/AVP 32\r\n"
118
"a=rtpmap:32 MPV/90000\r\n"
119
"m=audio 51434 RTP/AVP 110\r\n"
120
"a=rtpmap:110 telephone-events/8000\r\n"
123
/* Alice's SDP now */
125
"o=alice 2890844526 2890844527 IN IP4 host.anywhere.com\r\n"
127
"c=IN IP4 host.anywhere.com\r\n"
129
"m=audio 49170 RTP/AVP 0\r\n"
130
"a=rtpmap:0 PCMU/8000\r\n"
131
"m=video 0 RTP/AVP 31\r\n"
132
//"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
133
"m=video 53000 RTP/AVP 32\r\n"
134
"a=rtpmap:32 MPV/90000\r\n"
135
"m=audio 0 RTP/AVP 110\r\n"
136
/* <-- the following attributes are not necessary (port 0) */
137
//"a=rtpmap:110 telephone-events/8000\r\n"
145
/*********************************************************************
146
* RFC 3264 examples, section 10.1. (Bob's view)
149
* - the SDP version in Bob's capability is changed to ver-1.
152
"RFC 3264 example 10.1 (Bob's view)",
157
/* Remote offer from Alice: */
159
"o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
161
"c=IN IP4 host.anywhere.com\r\n"
163
"m=audio 49170 RTP/AVP 0\r\n"
164
"a=rtpmap:0 PCMU/8000\r\n"
165
"m=video 51372 RTP/AVP 31\r\n"
166
"a=rtpmap:31 H261/90000\r\n"
167
"m=video 53000 RTP/AVP 32\r\n"
168
"a=rtpmap:32 MPV/90000\r\n",
169
/* Bob's capability: */
171
"o=bob 2890844730 2890844729 IN IP4 host.example.com\r\n"
173
"c=IN IP4 host.example.com\r\n"
175
"m=audio 49920 RTP/AVP 0\r\n"
176
"a=rtpmap:0 PCMU/8000\r\n"
177
"m=video 0 RTP/AVP 31\r\n"
178
"m=video 53000 RTP/AVP 32\r\n"
179
"a=rtpmap:32 MPV/90000\r\n",
180
/* This's how Bob's answer should look like: */
182
"o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n"
184
"c=IN IP4 host.example.com\r\n"
186
"m=audio 49920 RTP/AVP 0\r\n"
187
"a=rtpmap:0 PCMU/8000\r\n"
188
"m=video 0 RTP/AVP 31\r\n"
189
"m=video 53000 RTP/AVP 32\r\n"
190
"a=rtpmap:32 MPV/90000\r\n"
194
/* Bob wants to change his local SDP
195
* (change local port for the first stream and add new stream)
198
"o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n"
200
"c=IN IP4 host.example.com\r\n"
202
"m=audio 65422 RTP/AVP 0\r\n"
203
"a=rtpmap:0 PCMU/8000\r\n"
204
"m=video 0 RTP/AVP 31\r\n"
205
"m=video 53000 RTP/AVP 32\r\n"
206
"a=rtpmap:32 MPV/90000\r\n"
207
"m=audio 51434 RTP/AVP 110\r\n"
208
"a=rtpmap:110 telephone-events/8000\r\n"
210
/* Got answer from Alice */
212
"o=alice 2890844526 2890844527 IN IP4 host.anywhere.com\r\n"
214
"c=IN IP4 host.anywhere.com\r\n"
216
"m=audio 49170 RTP/AVP 0\r\n"
217
"a=rtpmap:0 PCMU/8000\r\n"
218
"m=video 0 RTP/AVP 31\r\n"
219
"a=rtpmap:31 H261/90000\r\n"
220
"m=video 53000 RTP/AVP 32\r\n"
221
"a=rtpmap:32 MPV/90000\r\n"
222
"m=audio 53122 RTP/AVP 110\r\n"
223
"a=rtpmap:110 telephone-events/8000\r\n"
225
/* This is how Bob's SDP should look like after negotiation */
227
"o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n"
229
"c=IN IP4 host.example.com\r\n"
231
"m=audio 65422 RTP/AVP 0\r\n"
232
"a=rtpmap:0 PCMU/8000\r\n"
233
"m=video 0 RTP/AVP 31\r\n"
234
"m=video 53000 RTP/AVP 32\r\n"
235
"a=rtpmap:32 MPV/90000\r\n"
236
"m=audio 51434 RTP/AVP 110\r\n"
237
"a=rtpmap:110 telephone-events/8000\r\n"
245
/*********************************************************************
246
* RFC 3264 examples, section 10.2.
247
* This is from Alice's point of view.
250
"RFC 3264 example 10.2 (Alice's view)",
255
/* The initial offer from Alice to Bob indicates a single audio
256
* stream with the three audio codecs that are available in the
257
* DSP. The stream is marked as inactive,
260
"o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
262
"c=IN IP4 host.anywhere.com\r\n"
264
"m=audio 62986 RTP/AVP 0 4 18\r\n"
265
"a=rtpmap:0 PCMU/8000\r\n"
266
"a=rtpmap:4 G723/8000\r\n"
267
"a=rtpmap:18 G729/8000\r\n"
269
/* Bob can support dynamic switching between PCMU and G.723. So,
270
* he sends the following answer:
273
"o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n"
275
"c=IN IP4 host.example.com\r\n"
277
"m=audio 54344 RTP/AVP 0 4\r\n"
278
"a=rtpmap:0 PCMU/8000\r\n"
279
"a=rtpmap:4 G723/8000\r\n"
281
/* This is how Alice's media should look like after negotiation */
283
"o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
285
"c=IN IP4 host.anywhere.com\r\n"
287
"m=audio 62986 RTP/AVP 0 4\r\n"
288
"a=rtpmap:0 PCMU/8000\r\n"
289
"a=rtpmap:4 G723/8000\r\n"
294
/* Alice sends an updated offer with a sendrecv stream: */
296
"o=alice 2890844526 2890844527 IN IP4 host.anywhere.com\r\n"
298
"c=IN IP4 host.anywhere.com\r\n"
300
"m=audio 62986 RTP/AVP 4\r\n"
301
"a=rtpmap:4 G723/8000\r\n"
303
/* Bob accepts the single codec: */
305
"o=bob 2890844730 2890844732 IN IP4 host.example.com\r\n"
307
"c=IN IP4 host.example.com\r\n"
309
"m=audio 54344 RTP/AVP 4\r\n"
310
"a=rtpmap:4 G723/8000\r\n"
312
/* This is how Alice's media should look like after negotiation */
314
"o=alice 2890844526 2890844527 IN IP4 host.anywhere.com\r\n"
316
"c=IN IP4 host.anywhere.com\r\n"
318
"m=audio 62986 RTP/AVP 4\r\n"
319
"a=rtpmap:4 G723/8000\r\n"
326
// this test is commented, this causes error:
327
// No suitable codec for remote offer (PJMEDIA_SDPNEG_NOANSCODEC),
328
// since currently the negotiator always answer with one codec,
329
// PCMU in this case, while PCMU is not included in the second offer.
333
/*********************************************************************
334
* RFC 3264 examples, section 10.2.
335
* This is from Bob's point of view.
338
* - The SDP version number in Bob's initial capability is ver-1
341
"RFC 3264 example 10.2 (Bob's view)",
346
/* Bob received offer from Alice:
349
"o=alice 2890844526 2890844526 IN IP4 host.anywhere.com\r\n"
351
"c=IN IP4 host.anywhere.com\r\n"
353
"m=audio 62986 RTP/AVP 0 4 18\r\n"
354
"a=rtpmap:0 PCMU/8000\r\n"
355
"a=rtpmap:4 G723/8000\r\n"
356
"a=rtpmap:18 G729/8000\r\n"
361
"o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n"
363
"c=IN IP4 host.example.com\r\n"
365
"m=audio 54344 RTP/AVP 0 4\r\n"
366
"a=rtpmap:0 PCMU/8000\r\n"
367
"a=rtpmap:4 G723/8000\r\n"
369
/* This is how Bob's media should look like after negotiation */
371
"o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n"
373
"c=IN IP4 host.example.com\r\n"
375
"m=audio 54344 RTP/AVP 0\r\n"
376
"a=rtpmap:0 PCMU/8000\r\n"
381
/* Received updated Alice's SDP: offer with a sendrecv stream: */
383
"o=alice 2890844526 2890844527 IN IP4 host.anywhere.com\r\n"
385
"c=IN IP4 host.anywhere.com\r\n"
387
"m=audio 62986 RTP/AVP 4\r\n"
388
"a=rtpmap:4 G723/8000\r\n"
390
/* Bob accepts the single codec: */
392
/* This is how Bob's media should look like after negotiation */
394
"o=bob 2890844730 2890844732 IN IP4 host.example.com\r\n"
396
"c=IN IP4 host.example.com\r\n"
398
"m=audio 54344 RTP/AVP 4\r\n"
399
"a=rtpmap:4 G723/8000\r\n"
408
/*********************************************************************
409
* RFC 4317 Sample 2.1: Audio and Video 1 (Alice's view)
411
* This common scenario shows a video and audio session in which
412
* multiple codecs are offered but only one is accepted. As a result of
413
* the exchange shown below, Alice and Bob may send only PCMU audio and
414
* MPV video. Note: Dynamic payload type 97 is used for iLBC codec
416
"RFC 4317 section 2.1: Audio and Video 1 (Alice's view)",
421
/* Alice's local offer: */
423
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
425
"c=IN IP4 host.atlanta.example.com\r\n"
427
"m=audio 49170 RTP/AVP 0 8 97\r\n"
428
"a=rtpmap:0 PCMU/8000\r\n"
429
"a=rtpmap:8 PCMA/8000\r\n"
430
"a=rtpmap:97 iLBC/8000\r\n"
431
"m=video 51372 RTP/AVP 31 32\r\n"
432
"a=rtpmap:31 H261/90000\r\n"
433
"a=rtpmap:32 MPV/90000\r\n",
434
/* Received answer from Bob: */
436
"o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
438
"c=IN IP4 host.biloxi.example.com\r\n"
440
"m=audio 49174 RTP/AVP 0\r\n"
441
"a=rtpmap:0 PCMU/8000\r\n"
442
"m=video 49170 RTP/AVP 32\r\n"
443
"a=rtpmap:32 MPV/90000\r\n",
444
/* This is how Alice's media should look like now: */
446
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
448
"c=IN IP4 host.atlanta.example.com\r\n"
450
"m=audio 49170 RTP/AVP 0\r\n"
451
"a=rtpmap:0 PCMU/8000\r\n"
452
"m=video 51372 RTP/AVP 32\r\n"
453
"a=rtpmap:32 MPV/90000\r\n"
460
/*********************************************************************
461
* RFC 4317 Sample 2.1: Audio and Video 1 (Bob's view)
463
* This common scenario shows a video and audio session in which
464
* multiple codecs are offered but only one is accepted. As a result of
465
* the exchange shown below, Alice and Bob may send only PCMU audio and
466
* MPV video. Note: Dynamic payload type 97 is used for iLBC codec
469
* - Bob's initial capability version number
471
"RFC 4317 section 2.1: Audio and Video 1 (Bob's view)",
476
/* Received Alice's local offer: */
478
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
480
"c=IN IP4 host.atlanta.example.com\r\n"
482
"m=audio 49170 RTP/AVP 0 8 97\r\n"
483
"a=rtpmap:0 PCMU/8000\r\n"
484
"a=rtpmap:8 PCMA/8000\r\n"
485
"a=rtpmap:97 iLBC/8000\r\n"
486
"m=video 51372 RTP/AVP 31 32\r\n"
487
"a=rtpmap:31 H261/90000\r\n"
488
"a=rtpmap:32 MPV/90000\r\n",
489
/* Bob's capability: */
491
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
493
"c=IN IP4 host.biloxi.example.com\r\n"
495
"m=audio 49174 RTP/AVP 0\r\n"
496
"a=rtpmap:0 PCMU/8000\r\n"
497
"m=video 49170 RTP/AVP 32\r\n"
498
"a=rtpmap:32 MPV/90000\r\n",
499
/* This is how Bob's media should look like now: */
501
"o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
503
"c=IN IP4 host.biloxi.example.com\r\n"
505
"m=audio 49174 RTP/AVP 0\r\n"
506
"a=rtpmap:0 PCMU/8000\r\n"
507
"m=video 49170 RTP/AVP 32\r\n"
508
"a=rtpmap:32 MPV/90000\r\n"
515
/*********************************************************************
516
* RFC 4317 Sample 2.2: Audio and Video 2 (Alice's view)
519
* - Bob's initial capability version number
521
"RFC 4317 section 2.2: Audio and Video 2 (Alice's view)",
526
/* Alice sends offer: */
528
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
530
"c=IN IP4 host.atlanta.example.com\r\n"
532
"m=audio 49170 RTP/AVP 0 8 97\r\n"
533
"a=rtpmap:0 PCMU/8000\r\n"
534
"a=rtpmap:8 PCMA/8000\r\n"
535
"a=rtpmap:97 iLBC/8000\r\n"
536
"m=video 51372 RTP/AVP 31 32\r\n"
537
"a=rtpmap:31 H261/90000\r\n"
538
"a=rtpmap:32 MPV/90000\r\n",
541
"o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
543
"c=IN IP4 host.biloxi.example.com\r\n"
545
"m=audio 49172 RTP/AVP 0 8\r\n"
546
"a=rtpmap:0 PCMU/8000\r\n"
547
"a=rtpmap:8 PCMA/8000\r\n"
548
"m=video 0 RTP/AVP 31\r\n"
549
"a=rtpmap:31 H261/90000\r\n",
550
/* This is how Alice's media should look like now: */
552
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
554
"c=IN IP4 host.atlanta.example.com\r\n"
556
"m=audio 49170 RTP/AVP 0 8\r\n"
557
"a=rtpmap:0 PCMU/8000\r\n"
558
"a=rtpmap:8 PCMA/8000\r\n"
559
// By #1088, the formats won't be negotiated when the media has port 0.
560
//"m=video 0 RTP/AVP 31\r\n"
561
"m=video 0 RTP/AVP 31 32\r\n"
562
//"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
566
/* Alice sends updated offer: */
568
"o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
570
"c=IN IP4 host.atlanta.example.com\r\n"
572
"m=audio 51372 RTP/AVP 0\r\n"
573
"a=rtpmap:0 PCMU/8000\r\n"
574
"m=video 0 RTP/AVP 31\r\n"
575
"a=rtpmap:31 H261/90000\r\n",
578
"o=bob 2808844564 2808844565 IN IP4 host.biloxi.example.com\r\n"
580
"c=IN IP4 host.biloxi.example.com\r\n"
582
"m=audio 49172 RTP/AVP 0\r\n"
583
"a=rtpmap:0 PCMU/8000\r\n"
584
"m=video 0 RTP/AVP 31\r\n"
585
"a=rtpmap:31 H261/90000\r\n",
586
/* This is how Alice's SDP should look like: */
588
"o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
590
"c=IN IP4 host.atlanta.example.com\r\n"
592
"m=audio 51372 RTP/AVP 0\r\n"
593
"a=rtpmap:0 PCMU/8000\r\n"
594
"m=video 0 RTP/AVP 31\r\n"
595
//"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
602
/*********************************************************************
603
* RFC 4317 Sample 2.2: Audio and Video 2 (Bob's view)
606
* - Bob's initial capability version number
608
"RFC 4317 section 2.2: Audio and Video 2 (Bob's view)",
613
/* Received offer from alice: */
615
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
617
"c=IN IP4 host.atlanta.example.com\r\n"
619
"m=audio 49170 RTP/AVP 0 8 97\r\n"
620
"a=rtpmap:0 PCMU/8000\r\n"
621
"a=rtpmap:8 PCMA/8000\r\n"
622
"a=rtpmap:97 iLBC/8000\r\n"
623
"m=video 51372 RTP/AVP 31 32\r\n"
624
"a=rtpmap:31 H261/90000\r\n"
625
"a=rtpmap:32 MPV/90000\r\n",
626
/* Bob's initial capability: */
628
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
630
"c=IN IP4 host.biloxi.example.com\r\n"
632
"m=audio 49172 RTP/AVP 0 8\r\n"
633
"a=rtpmap:0 PCMU/8000\r\n"
634
"a=rtpmap:8 PCMA/8000\r\n"
635
"m=video 0 RTP/AVP 31\r\n"
636
"a=rtpmap:31 H261/90000\r\n",
637
/* This is how Bob's answer should look like now: */
639
"o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
641
"c=IN IP4 host.biloxi.example.com\r\n"
643
"m=audio 49172 RTP/AVP 0\r\n"
644
"a=rtpmap:0 PCMU/8000\r\n"
645
"m=video 0 RTP/AVP 31\r\n"
646
"a=rtpmap:31 H261/90000\r\n"
650
/* Received updated offer from Alice: */
652
"o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
654
"c=IN IP4 host.atlanta.example.com\r\n"
656
"m=audio 51372 RTP/AVP 0\r\n"
657
"a=rtpmap:0 PCMU/8000\r\n"
658
"m=video 0 RTP/AVP 31\r\n"
659
"a=rtpmap:31 H261/90000\r\n",
662
/* This is how Bob's answer should look like: */
664
"o=bob 2808844564 2808844565 IN IP4 host.biloxi.example.com\r\n"
666
"c=IN IP4 host.biloxi.example.com\r\n"
668
"m=audio 49172 RTP/AVP 0\r\n"
669
"a=rtpmap:0 PCMU/8000\r\n"
670
"m=video 0 RTP/AVP 31\r\n"
671
//"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
678
/*********************************************************************
679
* RFC 4317 Sample 2.4: Audio and Telephone-Events (Alice's view)
683
"RFC 4317 section 2.4: Audio and Telephone-Events (Alice's view)",
688
/* Alice sends offer: */
690
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
692
"c=IN IP4 host.atlanta.example.com\r\n"
694
"m=audio 49170 RTP/AVP 0 97\r\n"
695
"a=rtpmap:0 PCMU/8000\r\n"
696
"a=rtpmap:97 iLBC/8000\r\n"
697
"m=audio 49172 RTP/AVP 98\r\n"
698
"a=rtpmap:98 telephone-event/8000\r\n"
700
/* Received Bob's answer: */
702
"o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
704
"c=IN IP4 host.biloxi.example.com\r\n"
706
"m=audio 49172 RTP/AVP 97\r\n"
707
"a=rtpmap:97 iLBC/8000\r\n"
708
"m=audio 49174 RTP/AVP 98\r\n"
709
"a=rtpmap:98 telephone-event/8000\r\n"
711
/* Alice's SDP now: */
713
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
715
"c=IN IP4 host.atlanta.example.com\r\n"
717
"m=audio 49170 RTP/AVP 97\r\n"
718
"a=rtpmap:97 iLBC/8000\r\n"
719
"m=audio 49172 RTP/AVP 98\r\n"
720
"a=rtpmap:98 telephone-event/8000\r\n"
729
/*********************************************************************
730
* RFC 4317 Sample 2.4: Audio and Telephone-Events (Bob's view)
733
* - Bob's initial SDP version number
734
* - Bob's capability are added with more formats, and the
735
* stream order is interchanged to test the negotiator.
738
"RFC 4317 section 2.4: Audio and Telephone-Events (Bob's view)",
743
/* Received Alice's offer: */
745
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
747
"c=IN IP4 host.atlanta.example.com\r\n"
749
"m=audio 49170 RTP/AVP 0 97\r\n"
750
"a=rtpmap:0 PCMU/8000\r\n"
751
"a=rtpmap:97 iLBC/8000\r\n"
752
"m=audio 49172 RTP/AVP 98\r\n"
753
"a=rtpmap:98 telephone-event/8000\r\n"
755
/* Bob's initial capability: */
757
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
759
"c=IN IP4 host.biloxi.example.com\r\n"
761
"m=audio 49174 RTP/AVP 4 98\r\n"
762
"a=rtpmap:98 telephone-event/8000\r\n"
763
"m=audio 49172 RTP/AVP 97 8 99\r\n"
764
"a=rtpmap:97 iLBC/8000\r\n"
765
"a=rtpmap:99 telephone-event/8000\r\n",
766
/* Bob's answer should be: */
768
"o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
770
"c=IN IP4 host.biloxi.example.com\r\n"
772
"m=audio 49172 RTP/AVP 97\r\n"
773
"a=rtpmap:97 iLBC/8000\r\n"
774
"m=audio 49174 RTP/AVP 98\r\n"
775
"a=rtpmap:98 telephone-event/8000\r\n"
783
/*********************************************************************
784
* RFC 4317 Sample 2.6: Audio with Telephone-Events (Alice's view)
788
"RFC 4317 section 2.6: Audio with Telephone-Events (Alice's view)",
793
/* Alice sends offer: */
795
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
797
"c=IN IP4 host.atlanta.example.com\r\n"
799
"m=audio 49170 RTP/AVP 0\r\n"
800
"a=rtpmap:0 PCMU/8000\r\n"
801
"m=audio 51372 RTP/AVP 97 101\r\n"
802
"a=rtpmap:97 iLBC/8000\r\n"
803
"a=rtpmap:101 telephone-event/8000\r\n",
804
/* Received bob's answer: */
806
"o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
808
"c=IN IP4 host.biloxi.example.com\r\n"
810
"m=audio 0 RTP/AVP 0\r\n"
811
"a=rtpmap:0 PCMU/8000\r\n"
812
"m=audio 49170 RTP/AVP 97 101\r\n"
813
"a=rtpmap:97 iLBC/8000\r\n"
814
"a=rtpmap:101 telephone-event/8000\r\n",
815
/* Alice's local SDP should be: */
817
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
819
"c=IN IP4 host.atlanta.example.com\r\n"
821
"m=audio 0 RTP/AVP 0\r\n"
822
//"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */
823
"m=audio 51372 RTP/AVP 97 101\r\n"
824
"a=rtpmap:97 iLBC/8000\r\n"
825
"a=rtpmap:101 telephone-event/8000\r\n"
832
/*********************************************************************
833
* RFC 4317 Sample 2.6: Audio with Telephone-Events (Bob's view)
836
* - Bob's SDP version number
837
* - Bob's initial capability are expanded with multiple m lines
841
"RFC 4317 section 2.6: Audio with Telephone-Events (Bob's view)",
846
/* Received Alice's offer: */
848
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
850
"c=IN IP4 host.atlanta.example.com\r\n"
852
"m=audio 49170 RTP/AVP 0\r\n"
853
"a=rtpmap:0 PCMU/8000\r\n"
854
"m=audio 51372 RTP/AVP 97 101\r\n"
855
"a=rtpmap:97 iLBC/8000\r\n"
856
"a=rtpmap:101 telephone-event/8000\r\n",
857
/* Bob's initial capability also has video: */
859
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
861
"c=IN IP4 host.biloxi.example.com\r\n"
863
"m=audio 49170 RTP/AVP 4 97 101\r\n"
864
"a=rtpmap:4 G723/8000\r\n"
865
"a=rtpmap:97 iLBC/8000\r\n"
866
"a=rtpmap:101 telephone-event/8000\r\n"
867
"m=video 1000 RTP/AVP 31\r\n"
868
"a=rtpmap:31 H261/90000\r\n",
869
/* Bob's answer should be: */
871
"o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
873
"c=IN IP4 host.biloxi.example.com\r\n"
875
"m=audio 0 RTP/AVP 0\r\n"
876
//"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */
877
"m=audio 49170 RTP/AVP 97 101\r\n"
878
"a=rtpmap:97 iLBC/8000\r\n"
879
"a=rtpmap:101 telephone-event/8000\r\n",
886
/*********************************************************************
887
* Ticket #527: More lenient SDP negotiator.
890
"Ticket #527 scenario #1: Partial answer",
895
/* Alice sends offer audio and video: */
897
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
899
"c=IN IP4 host.atlanta.example.com\r\n"
901
"m=audio 49170 RTP/AVP 0\r\n"
902
"a=rtpmap:0 PCMU/8000\r\n"
903
"m=video 4000 RTP/AVP 31\r\n"
904
"a=rtpmap:31 H261/90000\r\n",
905
/* Receive Bob's answer only audio: */
907
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
909
"c=IN IP4 host.biloxi.example.com\r\n"
911
"m=audio 49170 RTP/AVP 0\r\n"
912
"a=rtpmap:0 PCMU/8000\r\n",
913
/* Alice's local SDP should be: */
915
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
917
"c=IN IP4 host.atlanta.example.com\r\n"
919
"m=audio 49170 RTP/AVP 0\r\n"
920
"a=rtpmap:0 PCMU/8000\r\n"
921
"m=video 0 RTP/AVP 31\r\n"
922
//"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
930
/*********************************************************************
931
* Ticket #527: More lenient SDP negotiator.
934
"Ticket #527 scenario #1: Media mismatch in answer",
939
/* Alice sends offer audio and video: */
941
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
943
"c=IN IP4 host.atlanta.example.com\r\n"
945
"m=audio 3000 RTP/AVP 0\r\n"
946
"a=rtpmap:0 PCMU/8000\r\n"
947
"m=video 4000 RTP/AVP 31\r\n"
948
"a=rtpmap:31 H261/90000\r\n",
949
/* Receive Bob's answer two audio: */
951
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
953
"c=IN IP4 host.biloxi.example.com\r\n"
955
"m=audio 49170 RTP/AVP 0\r\n"
956
"a=rtpmap:0 PCMU/8000\r\n"
957
"m=audio 49172 RTP/AVP 0\r\n"
958
"a=rtpmap:0 PCMU/8000\r\n",
959
/* Alice's local SDP should be: */
961
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
963
"c=IN IP4 host.atlanta.example.com\r\n"
965
"m=audio 3000 RTP/AVP 0\r\n"
966
"a=rtpmap:0 PCMU/8000\r\n"
967
"m=video 0 RTP/AVP 31\r\n"
968
//"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
976
/*********************************************************************
977
* Ticket #527: More lenient SDP negotiator.
980
"Ticket #527 scenario #2: Modify offer - partial streams",
985
/* Alice sends offer: */
987
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
989
"c=IN IP4 host.atlanta.example.com\r\n"
991
"m=audio 3000 RTP/AVP 0\r\n"
992
"a=rtpmap:0 PCMU/8000\r\n"
993
"m=audio 3100 RTP/AVP 0\r\n"
994
"a=rtpmap:0 PCMU/8000\r\n"
995
"m=video 3200 RTP/AVP 31\r\n"
996
"a=rtpmap:31 H261/90000\r\n"
998
/* Receive Bob's answer: */
1000
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1002
"c=IN IP4 host.biloxi.example.com\r\n"
1004
"m=audio 4000 RTP/AVP 0\r\n"
1005
"a=rtpmap:0 PCMU/8000\r\n"
1006
"m=audio 4100 RTP/AVP 0\r\n"
1007
"a=rtpmap:0 PCMU/8000\r\n"
1008
"m=video 4200 RTP/AVP 31\r\n"
1009
"a=rtpmap:31 H261/90000\r\n"
1011
/* Alice's local SDP should be: */
1013
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1015
"c=IN IP4 host.atlanta.example.com\r\n"
1017
"m=audio 3000 RTP/AVP 0\r\n"
1018
"a=rtpmap:0 PCMU/8000\r\n"
1019
"m=audio 3100 RTP/AVP 0\r\n"
1020
"a=rtpmap:0 PCMU/8000\r\n"
1021
"m=video 3200 RTP/AVP 31\r\n"
1022
"a=rtpmap:31 H261/90000\r\n"
1027
/* Alice modifies offer with only specify one audio: */
1029
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1031
"c=IN IP4 host.atlanta.example.com\r\n"
1033
"m=audio 5200 RTP/AVP 0\r\n"
1034
"a=rtpmap:0 PCMU/8000\r\n"
1036
/* Receive Bob's answer: */
1038
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1040
"c=IN IP4 host.biloxi.example.com\r\n"
1042
"m=audio 7000 RTP/AVP 0\r\n"
1043
"a=rtpmap:0 PCMU/8000\r\n"
1044
"m=audio 0 RTP/AVP 0\r\n"
1045
"a=rtpmap:0 PCMU/8000\r\n"
1046
"m=video 0 RTP/AVP 31\r\n"
1047
"a=rtpmap:31 H261/90000\r\n"
1049
/* Alice's local SDP should be: */
1051
"o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
1053
"c=IN IP4 host.atlanta.example.com\r\n"
1055
"m=audio 5200 RTP/AVP 0\r\n"
1056
"a=rtpmap:0 PCMU/8000\r\n"
1057
"m=audio 0 RTP/AVP 0\r\n"
1058
//"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */
1059
"m=video 0 RTP/AVP 31\r\n"
1060
//"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */
1068
/*********************************************************************
1069
* Ticket #527: More lenient SDP negotiator.
1072
"Ticket #527 scenario #2: Modify offer - unordered m= lines",
1077
/* Alice sends offer: */
1079
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1081
"c=IN IP4 host.atlanta.example.com\r\n"
1083
"m=audio 3000 RTP/AVP 0\r\n"
1084
"a=rtpmap:0 PCMU/8000\r\n"
1085
"m=video 3200 RTP/AVP 31\r\n"
1086
"a=rtpmap:31 H261/90000\r\n"
1088
/* Receive Bob's answer: */
1090
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1092
"c=IN IP4 host.biloxi.example.com\r\n"
1094
"m=audio 4000 RTP/AVP 0\r\n"
1095
"a=rtpmap:0 PCMU/8000\r\n"
1096
"m=video 4200 RTP/AVP 31\r\n"
1097
"a=rtpmap:31 H261/90000\r\n"
1099
/* Alice's local SDP should be: */
1101
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1103
"c=IN IP4 host.atlanta.example.com\r\n"
1105
"m=audio 3000 RTP/AVP 0\r\n"
1106
"a=rtpmap:0 PCMU/8000\r\n"
1107
"m=video 3200 RTP/AVP 31\r\n"
1108
"a=rtpmap:31 H261/90000\r\n"
1113
/* Alice modifies offer with unordered m= lines: */
1115
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1117
"c=IN IP4 host.atlanta.example.com\r\n"
1119
"m=video 5000 RTP/AVP 31\r\n"
1120
"a=rtpmap:31 H261/90000\r\n"
1121
"m=audio 5200 RTP/AVP 0\r\n"
1122
"a=rtpmap:0 PCMU/8000\r\n"
1124
/* Receive Bob's answer: */
1126
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1128
"c=IN IP4 host.biloxi.example.com\r\n"
1130
"m=audio 7000 RTP/AVP 0\r\n"
1131
"a=rtpmap:0 PCMU/8000\r\n"
1132
"m=video 2000 RTP/AVP 31\r\n"
1133
"a=rtpmap:31 H261/90000\r\n"
1135
/* Alice's local SDP should be: */
1137
"o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
1139
"c=IN IP4 host.atlanta.example.com\r\n"
1141
"m=audio 5200 RTP/AVP 0\r\n"
1142
"a=rtpmap:0 PCMU/8000\r\n"
1143
"m=video 5000 RTP/AVP 31\r\n"
1144
"a=rtpmap:31 H261/90000\r\n"
1152
/*********************************************************************
1153
* Ticket #527: More lenient SDP negotiator.
1156
"Ticket #527 scenario #2: Modify offer - partial & unordered streams",
1161
/* Alice sends offer: */
1163
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1165
"c=IN IP4 host.atlanta.example.com\r\n"
1167
"m=audio 3000 RTP/AVP 0\r\n"
1168
"a=rtpmap:0 PCMU/8000\r\n"
1169
"m=audio 3200 RTP/AVP 0\r\n"
1170
"a=rtpmap:0 PCMU/8000\r\n"
1171
"m=video 3400 RTP/AVP 31\r\n"
1172
"a=rtpmap:31 H261/90000\r\n"
1174
/* Receive Bob's answer: */
1176
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1178
"c=IN IP4 host.biloxi.example.com\r\n"
1180
"m=audio 4000 RTP/AVP 0\r\n"
1181
"a=rtpmap:0 PCMU/8000\r\n"
1182
"m=audio 4200 RTP/AVP 0\r\n"
1183
"a=rtpmap:0 PCMU/8000\r\n"
1184
"m=video 4400 RTP/AVP 31\r\n"
1185
"a=rtpmap:31 H261/90000\r\n"
1187
/* Alice's local SDP should be: */
1189
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1191
"c=IN IP4 host.atlanta.example.com\r\n"
1193
"m=audio 3000 RTP/AVP 0\r\n"
1194
"a=rtpmap:0 PCMU/8000\r\n"
1195
"m=audio 3200 RTP/AVP 0\r\n"
1196
"a=rtpmap:0 PCMU/8000\r\n"
1197
"m=video 3400 RTP/AVP 31\r\n"
1198
"a=rtpmap:31 H261/90000\r\n"
1203
/* Alice modifies offer by specifying partial and unordered media: */
1205
"o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
1207
"c=IN IP4 host.atlanta.example.com\r\n"
1209
"m=video 5000 RTP/AVP 31\r\n"
1210
"a=rtpmap:31 H261/90000\r\n"
1211
"m=audio 7000 RTP/AVP 0\r\n"
1212
"a=rtpmap:0 PCMU/8000\r\n"
1214
/* Receive Bob's answer: */
1216
"o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
1218
"c=IN IP4 host.biloxi.example.com\r\n"
1220
"m=audio 4000 RTP/AVP 0\r\n"
1221
"a=rtpmap:0 PCMU/8000\r\n"
1222
"m=audio 0 RTP/AVP 0\r\n"
1223
"a=rtpmap:0 PCMU/8000\r\n"
1224
"m=video 4400 RTP/AVP 31\r\n"
1225
"a=rtpmap:31 H261/90000\r\n"
1227
/* Alice's local SDP should be: */
1229
"o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
1231
"c=IN IP4 host.atlanta.example.com\r\n"
1233
"m=audio 7000 RTP/AVP 0\r\n"
1234
"a=rtpmap:0 PCMU/8000\r\n"
1235
"m=audio 0 RTP/AVP 0\r\n"
1236
//"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */
1237
"m=video 5000 RTP/AVP 31\r\n"
1238
"a=rtpmap:31 H261/90000\r\n"
1246
static const char *find_diff(const char *s1, const char *s2,
1250
while (*s2 && *s1) {
1261
static int compare_sdp_string(const char *cmp_title,
1263
const pjmedia_sdp_session *sdp1,
1265
const pjmedia_sdp_session *sdp2,
1266
pj_status_t logical_cmp)
1268
char sdpbuf1[1024], sdpbuf2[1024];
1269
pj_ssize_t len1, len2;
1271
len1 = pjmedia_sdp_print(sdp1, sdpbuf1, sizeof(sdpbuf1));
1273
PJ_LOG(3,(THIS_FILE," error: printing sdp1"));
1276
sdpbuf1[len1] = '\0';
1278
len2 = pjmedia_sdp_print(sdp2, sdpbuf2, sizeof(sdpbuf2));
1280
PJ_LOG(3,(THIS_FILE," error: printing sdp2"));
1283
sdpbuf2[len2] = '\0';
1285
if (logical_cmp != PJ_SUCCESS) {
1288
pjmedia_strerror(logical_cmp, errbuf, sizeof(errbuf));
1290
PJ_LOG(3,(THIS_FILE,"%s mismatch: %s\n"
1302
} else if (strcmp(sdpbuf1, sdpbuf2) != 0) {
1306
PJ_LOG(3,(THIS_FILE,"%s mismatch:\n"
1315
diff = find_diff(sdpbuf1, sdpbuf2, &line);
1316
PJ_LOG(3,(THIS_FILE,"Difference: line %d:\n"
1327
static int offer_answer_test(pj_pool_t *pool, pjmedia_sdp_neg **p_neg,
1328
struct offer_answer *oa)
1330
pjmedia_sdp_session *sdp1;
1331
pjmedia_sdp_neg *neg;
1334
status = pjmedia_sdp_parse(pool, oa->sdp1, pj_ansi_strlen(oa->sdp1),
1336
if (status != PJ_SUCCESS) {
1337
app_perror(status, " error: unexpected parse status for sdp1");
1341
status = pjmedia_sdp_validate(sdp1);
1342
if (status != PJ_SUCCESS) {
1343
app_perror(status, " error: sdp1 validation failed");
1349
if (oa->type == LOCAL_OFFER) {
1352
* Local creates offer first.
1354
pjmedia_sdp_session *sdp2, *sdp3;
1355
const pjmedia_sdp_session *active;
1358
/* Create negotiator with local offer. */
1359
status = pjmedia_sdp_neg_create_w_local_offer(pool, sdp1, &neg);
1360
if (status != PJ_SUCCESS) {
1361
app_perror(status, " error: pjmedia_sdp_neg_create_w_local_offer");
1367
/* Modify local offer */
1368
status = pjmedia_sdp_neg_modify_local_offer(pool, neg, sdp1);
1369
if (status != PJ_SUCCESS) {
1370
app_perror(status, " error: pjmedia_sdp_neg_modify_local_offer");
1375
/* Parse and validate remote answer */
1376
status = pjmedia_sdp_parse(pool, oa->sdp2, pj_ansi_strlen(oa->sdp2),
1378
if (status != PJ_SUCCESS) {
1379
app_perror(status, " error: parsing sdp2");
1383
status = pjmedia_sdp_validate(sdp2);
1384
if (status != PJ_SUCCESS) {
1385
app_perror(status, " error: sdp2 validation failed");
1389
/* Give the answer to negotiator. */
1390
status = pjmedia_sdp_neg_set_remote_answer(pool, neg, sdp2);
1391
if (status != PJ_SUCCESS) {
1392
app_perror(status, " error: pjmedia_sdp_neg_rx_remote_answer");
1396
/* Negotiate remote answer with local answer */
1397
status = pjmedia_sdp_neg_negotiate(pool, neg, 0);
1398
if (status != PJ_SUCCESS) {
1399
app_perror(status, " error: pjmedia_sdp_neg_negotiate");
1403
/* Get the local active media. */
1404
status = pjmedia_sdp_neg_get_active_local(neg, &active);
1405
if (status != PJ_SUCCESS) {
1406
app_perror(status, " error: pjmedia_sdp_neg_get_local");
1410
/* Parse and validate the correct active media. */
1411
status = pjmedia_sdp_parse(pool, oa->sdp3, pj_ansi_strlen(oa->sdp3),
1413
if (status != PJ_SUCCESS) {
1414
app_perror(status, " error: parsing sdp3");
1418
status = pjmedia_sdp_validate(sdp3);
1419
if (status != PJ_SUCCESS) {
1420
app_perror(status, " error: sdp3 validation failed");
1424
/* Compare active with sdp3 */
1425
status = pjmedia_sdp_session_cmp(active, sdp3, 0);
1426
if (status != PJ_SUCCESS) {
1427
app_perror(status, " error: active local comparison mismatch");
1428
compare_sdp_string("Logical cmp after negotiatin remote answer",
1429
"Active local sdp from negotiator", active,
1430
"The correct active local sdp", sdp3,
1435
/* Compare the string representation oa both sdps */
1436
status = compare_sdp_string("String cmp after negotiatin remote answer",
1437
"Active local sdp from negotiator", active,
1438
"The correct active local sdp", sdp3,
1445
* Remote creates offer first.
1448
pjmedia_sdp_session *sdp2 = NULL, *sdp3;
1449
const pjmedia_sdp_session *answer;
1452
/* Parse and validate initial local capability */
1453
status = pjmedia_sdp_parse(pool, oa->sdp2, pj_ansi_strlen(oa->sdp2),
1455
if (status != PJ_SUCCESS) {
1456
app_perror(status, " error: parsing sdp2");
1460
status = pjmedia_sdp_validate(sdp2);
1461
if (status != PJ_SUCCESS) {
1462
app_perror(status, " error: sdp2 validation failed");
1466
const pjmedia_sdp_session *lsdp;
1467
status = pjmedia_sdp_neg_get_active_local(neg, &lsdp);
1468
if (status != PJ_SUCCESS) {
1470
" error: pjmedia_sdp_neg_get_active_local");
1473
sdp2 = (pjmedia_sdp_session*)lsdp;
1477
/* Create negotiator with remote offer. */
1478
status = pjmedia_sdp_neg_create_w_remote_offer(pool, sdp2, sdp1, &neg);
1479
if (status != PJ_SUCCESS) {
1480
app_perror(status, " error: pjmedia_sdp_neg_create_w_remote_offer");
1486
/* Received subsequent offer from remote. */
1487
status = pjmedia_sdp_neg_set_remote_offer(pool, neg, sdp1);
1488
if (status != PJ_SUCCESS) {
1489
app_perror(status, " error: pjmedia_sdp_neg_rx_remote_offer");
1493
status = pjmedia_sdp_neg_set_local_answer(pool, neg, sdp2);
1494
if (status != PJ_SUCCESS) {
1495
app_perror(status, " error: pjmedia_sdp_neg_set_local_answer");
1501
status = pjmedia_sdp_neg_negotiate(pool, neg, 0);
1502
if (status != PJ_SUCCESS) {
1503
app_perror(status, " error: pjmedia_sdp_neg_negotiate");
1507
/* Get our answer. */
1508
status = pjmedia_sdp_neg_get_active_local(neg, &answer);
1509
if (status != PJ_SUCCESS) {
1510
app_perror(status, " error: pjmedia_sdp_neg_get_local");
1514
/* Parse the correct answer. */
1515
status = pjmedia_sdp_parse(pool, oa->sdp3, pj_ansi_strlen(oa->sdp3),
1517
if (status != PJ_SUCCESS) {
1518
app_perror(status, " error: parsing sdp3");
1522
/* Validate the correct answer. */
1523
status = pjmedia_sdp_validate(sdp3);
1524
if (status != PJ_SUCCESS) {
1525
app_perror(status, " error: sdp3 validation failed");
1529
/* Compare answer from negotiator and the correct answer */
1530
status = pjmedia_sdp_session_cmp(sdp3, answer, 0);
1531
if (status != PJ_SUCCESS) {
1532
compare_sdp_string("Logical cmp after negotiating remote offer",
1533
"Local answer from negotiator", answer,
1534
"The correct local answer", sdp3,
1540
/* Compare the string representation oa both answers */
1541
status = compare_sdp_string("String cmp after negotiating remote offer",
1542
"Local answer from negotiator", answer,
1543
"The correct local answer", sdp3,
1553
static int perform_test(pj_pool_t *pool, int test_index)
1555
pjmedia_sdp_neg *neg = NULL;
1559
for (i=0; i<test[test_index].offer_answer_count; ++i) {
1561
rc = offer_answer_test(pool, &neg, &test[test_index].offer_answer[i]);
1563
PJ_LOG(3,(THIS_FILE, " test %d offer answer %d failed with status %d",
1564
test_index, i, rc));
1577
for (i=START_TEST; i<PJ_ARRAY_SIZE(test); ++i) {
1580
pool = pj_pool_create(mem, "sdp_neg_test", 4000, 4000, NULL);
1584
PJ_LOG(3,(THIS_FILE," test %d: %s", i, test[i].title));
1585
status = perform_test(pool, i);
1587
pj_pool_release(pool);