summaryrefslogtreecommitdiff
path: root/pjmedia/src/test/sdp_neg_test.c
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2008-05-07 15:30:34 +0000
committerNanang Izzuddin <nanang@teluu.com>2008-05-07 15:30:34 +0000
commit351f66318c3dd800bd13a3b2428417b06b710b41 (patch)
treefdadc8d7a4d069c90936376763a185de6b1005ca /pjmedia/src/test/sdp_neg_test.c
parentf81640f19e9089919f2574bbd379303fb5e5ac8f (diff)
Ticket #527: Commited ticket527.2.patch
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1950 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia/src/test/sdp_neg_test.c')
-rw-r--r--pjmedia/src/test/sdp_neg_test.c389
1 files changed, 385 insertions, 4 deletions
diff --git a/pjmedia/src/test/sdp_neg_test.c b/pjmedia/src/test/sdp_neg_test.c
index 46009b22..1f269822 100644
--- a/pjmedia/src/test/sdp_neg_test.c
+++ b/pjmedia/src/test/sdp_neg_test.c
@@ -320,6 +320,12 @@ struct test
}
},
+#if 0
+ // this test is commented, this causes error:
+ // No suitable codec for remote offer (PJMEDIA_SDPNEG_NOANSCODEC),
+ // since currently the negotiator always answer with one codec,
+ // PCMU in this case, while PCMU is not included in the second offer.
+
/* test 3: */
{
/*********************************************************************
@@ -393,6 +399,7 @@ struct test
}
}
},
+#endif
/* test 4: */
{
@@ -751,8 +758,7 @@ struct test
"a=rtpmap:98 telephone-event/8000\r\n"
"m=audio 49172 RTP/AVP 97 8 99\r\n"
"a=rtpmap:97 iLBC/8000\r\n"
- "a=rtpmap:99 telephone-event/8000\r\n"
- "a=recvonly\r\n",
+ "a=rtpmap:99 telephone-event/8000\r\n",
/* Bob's answer should be: */
"v=0\r\n"
"o=bob 2808844564 2808844564 IN IP4 host.biloxi.example.com\r\n"
@@ -871,6 +877,366 @@ struct test
}
},
+ /* test 12: */
+ {
+ /*********************************************************************
+ * Ticket #527: More lenient SDP negotiator.
+ */
+
+ "Ticket #527 scenario #1: Partial answer",
+ 1,
+ {
+ {
+ LOCAL_OFFER,
+ /* Alice sends offer audio and video: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 49170 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 4000 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n",
+ /* Receive Bob's answer only audio: */
+ "v=0\r\n"
+ "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
+ "s=bob\r\n"
+ "c=IN IP4 host.biloxi.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 49170 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n",
+ /* Alice's local SDP should be: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 49170 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 0 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ }
+ }
+ },
+
+ /* test 13: */
+ {
+ /*********************************************************************
+ * Ticket #527: More lenient SDP negotiator.
+ */
+
+ "Ticket #527 scenario #1: Media mismatch in answer",
+ 1,
+ {
+ {
+ LOCAL_OFFER,
+ /* Alice sends offer audio and video: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 3000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 4000 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n",
+ /* Receive Bob's answer two audio: */
+ "v=0\r\n"
+ "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
+ "s=bob\r\n"
+ "c=IN IP4 host.biloxi.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 49170 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 49172 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n",
+ /* Alice's local SDP should be: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 3000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 0 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ }
+ }
+ },
+
+ /* test 14: */
+ {
+ /*********************************************************************
+ * Ticket #527: More lenient SDP negotiator.
+ */
+
+ "Ticket #527 scenario #2: Modify offer - partial streams",
+ 2,
+ {
+ {
+ LOCAL_OFFER,
+ /* Alice sends offer: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 3000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 3100 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 3200 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ /* Receive Bob's answer: */
+ "v=0\r\n"
+ "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
+ "s=bob\r\n"
+ "c=IN IP4 host.biloxi.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 4000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 4100 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 4200 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ /* Alice's local SDP should be: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 3000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 3100 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 3200 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ },
+ {
+ LOCAL_OFFER,
+ /* Alice modifies offer with only specify one audio: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 5200 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "",
+ /* Receive Bob's answer: */
+ "v=0\r\n"
+ "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
+ "s=bob\r\n"
+ "c=IN IP4 host.biloxi.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 7000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 0 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 0 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ /* Alice's local SDP should be: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 5200 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 0 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 0 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ }
+ }
+ },
+
+ /* test 15: */
+ {
+ /*********************************************************************
+ * Ticket #527: More lenient SDP negotiator.
+ */
+
+ "Ticket #527 scenario #2: Modify offer - unordered m= lines",
+ 2,
+ {
+ {
+ LOCAL_OFFER,
+ /* Alice sends offer: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 3000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 3200 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ /* Receive Bob's answer: */
+ "v=0\r\n"
+ "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
+ "s=bob\r\n"
+ "c=IN IP4 host.biloxi.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 4000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 4200 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ /* Alice's local SDP should be: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 3000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 3200 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ },
+ {
+ LOCAL_OFFER,
+ /* Alice modifies offer with unordered m= lines: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=video 5000 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "m=audio 5200 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "",
+ /* Receive Bob's answer: */
+ "v=0\r\n"
+ "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
+ "s=bob\r\n"
+ "c=IN IP4 host.biloxi.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 7000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 2000 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ /* Alice's local SDP should be: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 5200 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 5000 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ }
+ }
+ },
+
+ /* test 16: */
+ {
+ /*********************************************************************
+ * Ticket #527: More lenient SDP negotiator.
+ */
+
+ "Ticket #527 scenario #2: Modify offer - partial & unordered streams",
+ 2,
+ {
+ {
+ LOCAL_OFFER,
+ /* Alice sends offer: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 3000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 3200 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 3400 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ /* Receive Bob's answer: */
+ "v=0\r\n"
+ "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
+ "s=bob\r\n"
+ "c=IN IP4 host.biloxi.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 4000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 4200 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 4400 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ /* Alice's local SDP should be: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 3000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 3200 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 3400 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ },
+ {
+ LOCAL_OFFER,
+ /* Alice modifies offer by specifying partial and unordered media: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=video 5000 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "m=audio 7000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "",
+ /* Receive Bob's answer: */
+ "v=0\r\n"
+ "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n"
+ "s=bob\r\n"
+ "c=IN IP4 host.biloxi.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 4000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 0 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 4400 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ /* Alice's local SDP should be: */
+ "v=0\r\n"
+ "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n"
+ "s=alice\r\n"
+ "c=IN IP4 host.atlanta.example.com\r\n"
+ "t=0 0\r\n"
+ "m=audio 7000 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=audio 0 RTP/AVP 0\r\n"
+ "a=rtpmap:0 PCMU/8000\r\n"
+ "m=video 5000 RTP/AVP 31\r\n"
+ "a=rtpmap:31 H261/90000\r\n"
+ "",
+ }
+ }
+ },
+
};
static const char *find_diff(const char *s1, const char *s2,
@@ -1075,10 +1441,10 @@ static int offer_answer_test(pj_pool_t *pool, pjmedia_sdp_neg **p_neg,
* Remote creates offer first.
*/
- pjmedia_sdp_session *sdp2, *sdp3;
+ pjmedia_sdp_session *sdp2 = NULL, *sdp3;
const pjmedia_sdp_session *answer;
- if (neg == NULL) {
+ if (oa->sdp2) {
/* Parse and validate initial local capability */
status = pjmedia_sdp_parse(pool, oa->sdp2, pj_native_strlen(oa->sdp2),
&sdp2);
@@ -1092,7 +1458,16 @@ static int offer_answer_test(pj_pool_t *pool, pjmedia_sdp_neg **p_neg,
app_perror(status, " error: sdp2 validation failed");
return -210;
}
+ } else if (neg) {
+ status = pjmedia_sdp_neg_get_active_local(neg, &sdp2);
+ if (status != PJ_SUCCESS) {
+ app_perror(status,
+ " error: pjmedia_sdp_neg_get_active_local");
+ return -215;
+ }
+ }
+ if (neg == NULL) {
/* Create negotiator with remote offer. */
status = pjmedia_sdp_neg_create_w_remote_offer(pool, sdp2, sdp1, &neg);
if (status != PJ_SUCCESS) {
@@ -1108,6 +1483,12 @@ static int offer_answer_test(pj_pool_t *pool, pjmedia_sdp_neg **p_neg,
app_perror(status, " error: pjmedia_sdp_neg_rx_remote_offer");
return -230;
}
+
+ status = pjmedia_sdp_neg_set_local_answer(pool, neg, sdp2);
+ if (status != PJ_SUCCESS) {
+ app_perror(status, " error: pjmedia_sdp_neg_set_local_answer");
+ return -235;
+ }
}
/* Negotiate. */