Changeset 3198
- Timestamp:
- Jun 4, 2010 1:41:34 PM (14 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/sdp.h
r2995 r3198 532 532 533 533 534 /** 535 * Clone SDP media description and deactivate the new SDP media. 536 * 537 * @param rhs The SDP media to clone. 538 * 539 * @return New media descrption with deactivated indication. 540 */ 541 PJ_DECL(pjmedia_sdp_media*) pjmedia_sdp_media_clone_deactivate( 542 pj_pool_t *pool, 543 const pjmedia_sdp_media *rhs); 544 545 534 546 /* ************************************************************************** 535 547 * SDP SESSION DESCRIPTION -
pjproject/trunk/pjmedia/src/pjmedia/sdp.c
r3140 r3198 1431 1431 pjmedia_sdp_media *m) 1432 1432 { 1433 pjmedia_sdp_attr *attr; 1434 static const pj_str_t ID_INACTIVE = { "inactive", 8 }; 1435 1436 if (m->attr_count >= PJMEDIA_MAX_SDP_ATTR) 1437 return PJ_ETOOMANY; 1438 1439 attr = pjmedia_sdp_attr_create(pool, ID_INACTIVE.ptr, NULL); 1440 if (NULL == attr) 1441 return PJ_ENOMEM; 1442 1443 pjmedia_sdp_media_add_attr(m, attr); 1433 PJ_ASSERT_RETURN(m, PJ_EINVAL); 1434 PJ_UNUSED_ARG(pool); 1435 1436 /* Set port to zero */ 1444 1437 m->desc.port = 0; 1445 1438 1439 /* And remove attributes */ 1440 m->attr_count = 0; 1441 1446 1442 return PJ_SUCCESS; 1447 1443 } 1444 1445 1446 PJ_DEF(pjmedia_sdp_media*) pjmedia_sdp_media_clone_deactivate( 1447 pj_pool_t *pool, 1448 const pjmedia_sdp_media *rhs) 1449 { 1450 unsigned int i; 1451 pjmedia_sdp_media *m; 1452 1453 PJ_ASSERT_RETURN(pool && rhs, NULL); 1454 1455 m = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media); 1456 pj_memcpy(m, rhs, sizeof(*m)); 1457 1458 /* Clone the media line only */ 1459 pj_strdup (pool, &m->desc.media, &rhs->desc.media); 1460 pj_strdup (pool, &m->desc.transport, &rhs->desc.transport); 1461 for (i=0; i<rhs->desc.fmt_count; ++i) 1462 pj_strdup(pool, &m->desc.fmt[i], &rhs->desc.fmt[i]); 1463 1464 if (rhs->conn) { 1465 m->conn = pjmedia_sdp_conn_clone (pool, rhs->conn); 1466 PJ_ASSERT_RETURN(m->conn != NULL, NULL); 1467 } 1468 1469 /* And deactivate it */ 1470 pjmedia_sdp_media_deactivate(pool, m); 1471 1472 return m; 1473 } -
pjproject/trunk/pjmedia/src/pjmedia/sdp_cmp.c
r2394 r3198 184 184 return PJMEDIA_SDP_ETPORTNOTEQUAL; 185 185 186 /* For zeroed port media, stop comparing here */ 187 if (sd1->desc.port == 0) 188 return PJ_SUCCESS; 189 186 190 /* Compare number of formats. */ 187 191 if (sd1->desc.fmt_count != sd2->desc.fmt_count) -
pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c
r3195 r3198 312 312 pjmedia_sdp_media *m; 313 313 314 m = pjmedia_sdp_media_clone(pool, om); 315 m->desc.port = 0; 314 m = pjmedia_sdp_media_clone_deactivate(pool, om); 316 315 317 316 pj_array_insert(new_offer->media, sizeof(new_offer->media[0]), … … 777 776 778 777 /* Remote has rejected our offer. 779 * Set our port to zero too in active SDP.778 * Deactivate our media too. 780 779 */ 781 offer->desc.port = 0;780 pjmedia_sdp_media_deactivate(pool, offer); 782 781 783 782 /* Don't need to proceed */ … … 1012 1011 1013 1012 /* Generate matching-but-disabled-media for the answer */ 1014 am = pjmedia_sdp_media_clone(pool, offer->media[omi]); 1015 am->desc.port = 0; 1013 am = pjmedia_sdp_media_clone_deactivate(pool, offer->media[omi]); 1016 1014 answer->media[answer->media_count++] = am; 1017 1015 ++ami; 1018 1016 1017 /* Deactivate our media offer too */ 1018 pjmedia_sdp_media_deactivate(pool, offer->media[omi]); 1019 1019 1020 /* No answer media to be negotiated */ 1020 offer->media[omi]->desc.port = 0;1021 1021 continue; 1022 1022 } … … 1027 1027 /* If media type is mismatched, just disable the media. */ 1028 1028 if (status == PJMEDIA_SDPNEG_EINVANSMEDIA) { 1029 offer->media[omi]->desc.port = 0;1029 pjmedia_sdp_media_deactivate(pool, offer->media[omi]); 1030 1030 continue; 1031 1031 } 1032 1033 if (status != PJ_SUCCESS) 1032 /* No common format in the answer media. */ 1033 else if (status == PJMEDIA_SDPNEG_EANSNOMEDIA) { 1034 pjmedia_sdp_media_deactivate(pool, offer->media[omi]); 1035 pjmedia_sdp_media_deactivate(pool, answer->media[ami]); 1036 } 1037 /* Return the error code, for other errors. */ 1038 else if (status != PJ_SUCCESS) { 1034 1039 return status; 1040 } 1035 1041 1036 1042 if (offer->media[omi]->desc.port != 0) … … 1065 1071 pj_str_t pt_amr_need_adapt = {NULL, 0}; 1066 1072 1067 /* If offer has zero port, just clone the offer and update direction*/1073 /* If offer has zero port, just clone the offer */ 1068 1074 if (offer->desc.port == 0) { 1069 answer = pjmedia_sdp_media_clone(pool, offer); 1070 remove_all_media_directions(answer); 1071 update_media_direction(pool, offer, answer); 1075 answer = pjmedia_sdp_media_clone_deactivate(pool, offer); 1072 1076 *p_answer = answer; 1073 1077 return PJ_SUCCESS; … … 1357 1361 * Reject the offer by setting the port to zero in the answer. 1358 1362 */ 1359 //pjmedia_sdp_attr *a;1360 1361 1363 /* For simplicity in the construction of the answer, we'll 1362 1364 * just clone the media from the offer. Anyway receiver will … … 1364 1366 * number is zero. 1365 1367 */ 1366 am = pjmedia_sdp_media_clone(pool, om); 1367 am->desc.port = 0; 1368 1369 // Just set port zero to disable stream without set it to inactive. 1370 /* Remove direction attribute, and replace with inactive */ 1371 remove_all_media_directions(am); 1372 //a = pjmedia_sdp_attr_create(pool, "inactive", NULL); 1373 //pjmedia_sdp_media_add_attr(am, a); 1374 1375 /* Then update direction */ 1376 update_media_direction(pool, om, am); 1377 1368 am = pjmedia_sdp_media_clone_deactivate(pool, om); 1378 1369 } else { 1379 1370 /* The answer is in am */ … … 1439 1430 neg->active_local_sdp = active; 1440 1431 neg->active_remote_sdp = neg->neg_remote_sdp; 1441 1442 1432 } 1443 1433 } else { -
pjproject/trunk/pjmedia/src/test/sdp_neg_test.c
r3014 r3198 97 97 "a=rtpmap:0 PCMU/8000\r\n" 98 98 "m=video 0 RTP/AVP 31\r\n" 99 "a=rtpmap:31 H261/90000\r\n"99 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */ 100 100 "m=video 53000 RTP/AVP 32\r\n" 101 101 "a=rtpmap:32 MPV/90000\r\n" … … 130 130 "a=rtpmap:0 PCMU/8000\r\n" 131 131 "m=video 0 RTP/AVP 31\r\n" 132 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary */132 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */ 133 133 "m=video 53000 RTP/AVP 32\r\n" 134 134 "a=rtpmap:32 MPV/90000\r\n" 135 135 "m=audio 0 RTP/AVP 110\r\n" 136 "a=rtpmap:110 telephone-events/8000\r\n" 137 "a=sendonly\r\n" 136 /* <-- the following attributes are not necessary (port 0) */ 137 //"a=rtpmap:110 telephone-events/8000\r\n" 138 //"a=sendonly\r\n" 138 139 } 139 140 } … … 556 557 "a=rtpmap:0 PCMU/8000\r\n" 557 558 "a=rtpmap:8 PCMA/8000\r\n" 558 "m=video 0 RTP/AVP 31\r\n" 559 "a=rtpmap:31 H261/90000\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) */ 560 563 }, 561 564 { … … 590 593 "a=rtpmap:0 PCMU/8000\r\n" 591 594 "m=video 0 RTP/AVP 31\r\n" 592 "a=rtpmap:31 H261/90000\r\n"595 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */ 593 596 } 594 597 } … … 666 669 "a=rtpmap:0 PCMU/8000\r\n" 667 670 "m=video 0 RTP/AVP 31\r\n" 668 "a=rtpmap:31 H261/90000\r\n"671 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */ 669 672 } 670 673 } … … 817 820 "t=0 0\r\n" 818 821 "m=audio 0 RTP/AVP 0\r\n" 819 "a=rtpmap:0 PCMU/8000\r\n"822 //"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */ 820 823 "m=audio 51372 RTP/AVP 97 101\r\n" 821 824 "a=rtpmap:97 iLBC/8000\r\n" … … 871 874 "t=0 0\r\n" 872 875 "m=audio 0 RTP/AVP 0\r\n" 873 "a=rtpmap:0 PCMU/8000\r\n"876 //"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */ 874 877 "m=audio 49170 RTP/AVP 97 101\r\n" 875 878 "a=rtpmap:97 iLBC/8000\r\n" … … 917 920 "a=rtpmap:0 PCMU/8000\r\n" 918 921 "m=video 0 RTP/AVP 31\r\n" 919 "a=rtpmap:31 H261/90000\r\n"922 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */ 920 923 "", 921 924 } … … 963 966 "a=rtpmap:0 PCMU/8000\r\n" 964 967 "m=video 0 RTP/AVP 31\r\n" 965 "a=rtpmap:31 H261/90000\r\n"968 //"a=rtpmap:31 H261/90000\r\n" /* <-- this is not necessary (port 0) */ 966 969 "", 967 970 } … … 1053 1056 "a=rtpmap:0 PCMU/8000\r\n" 1054 1057 "m=audio 0 RTP/AVP 0\r\n" 1055 "a=rtpmap:0 PCMU/8000\r\n"1056 "m=video 0 RTP/AVP 31\r\n" 1057 "a=rtpmap:31 H261/90000\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) */ 1058 1061 "", 1059 1062 } … … 1231 1234 "a=rtpmap:0 PCMU/8000\r\n" 1232 1235 "m=audio 0 RTP/AVP 0\r\n" 1233 "a=rtpmap:0 PCMU/8000\r\n"1236 //"a=rtpmap:0 PCMU/8000\r\n" /* <-- this is not necessary (port 0) */ 1234 1237 "m=video 5000 RTP/AVP 31\r\n" 1235 1238 "a=rtpmap:31 H261/90000\r\n" -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r3172 r3198 1302 1302 const pjmedia_sdp_media *rem_m = rem_sdp->media[i]; 1303 1303 pjmedia_sdp_media *m; 1304 const pjmedia_sdp_attr *a;1305 1304 1306 1305 if ((int)i == call->audio_idx) 1307 1306 continue; 1308 1307 1309 m = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media); 1310 pj_strdup(pool, &m->desc.media, &rem_m->desc.media); 1311 pj_strdup(pool, &m->desc.transport, &rem_m->desc.transport); 1312 m->desc.port = 0; 1313 1314 /* Add one format, copy from the offer. And copy the corresponding 1315 * rtpmap and fmtp attributes too. 1316 */ 1317 m->desc.fmt_count = 1; 1318 pj_strdup(pool, &m->desc.fmt[0], &rem_m->desc.fmt[0]); 1319 if ((a=pjmedia_sdp_attr_find2(rem_m->attr_count, rem_m->attr, 1320 "rtpmap", &m->desc.fmt[0])) != NULL) 1321 { 1322 m->attr[m->attr_count++] = pjmedia_sdp_attr_clone(pool, a); 1323 } 1324 if ((a=pjmedia_sdp_attr_find2(rem_m->attr_count, rem_m->attr, 1325 "fmtp", &m->desc.fmt[0])) != NULL) 1326 { 1327 m->attr[m->attr_count++] = pjmedia_sdp_attr_clone(pool, a); 1328 } 1329 1308 m = pjmedia_sdp_media_clone_deactivate(pool, rem_m); 1330 1309 if (i==sdp->media_count) 1331 1310 sdp->media[sdp->media_count++] = m;
Note: See TracChangeset
for help on using the changeset viewer.