Changeset 1072 for pjproject/trunk
- Timestamp:
- Mar 15, 2007 10:05:39 PM (18 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/config.h
r978 r1072 281 281 282 282 /** 283 * This specifies the behavior of the SDP negotiator when responding to an 284 * offer, whether it should rather use the codec preference as set by 285 * remote, or should it rather use the codec preference as specified by 286 * local endpoint. 287 * 288 * For example, suppose incoming call has codec order "8 0 3", while 289 * local codec order is "3 0 8". If remote codec order is preferable, 290 * the selected codec will be 8, while if local codec order is preferable, 291 * the selected codec will be 3. 292 * 293 * If set to non-zero, the negotiator will use the codec order as specified 294 * by remote in the offer. 295 * 296 * Note that this behavior can be changed during run-time by calling 297 * pjmedia_sdp_neg_set_prefer_remote_codec_order(). 298 * 299 * Default is 1 (to maintain backward compatibility) 300 */ 301 #ifndef PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER 302 # define PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER 1 303 #endif 304 305 306 /** 283 307 * Support for sending and decoding RTCP port in SDP (RFC 3605). 284 308 * Default is yes. -
pjproject/trunk/pjmedia/include/pjmedia/sdp_neg.h
r974 r1072 355 355 356 356 /** 357 * This specifies the behavior of the SDP negotiator when responding to an 358 * offer, whether it should rather use the codec preference as set by 359 * remote, or should it rather use the codec preference as specified by 360 * local endpoint. 361 * 362 * For example, suppose incoming call has codec order "8 0 3", while 363 * local codec order is "3 0 8". If remote codec order is preferable, 364 * the selected codec will be 8, while if local codec order is preferable, 365 * the selected codec will be 3. 366 * 367 * By default, the value in PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER will 368 * be used. 369 * 370 * @param neg The SDP negotiator instance. 371 * @param prefer_remote If non-zero, the negotiator will use the codec 372 * order as specified in remote offer. If zero, it 373 * will prefer to use the local codec order. 374 */ 375 PJ_DECL(pj_status_t) 376 pjmedia_sdp_neg_set_prefer_remote_codec_order(pjmedia_sdp_neg *neg, 377 pj_bool_t prefer_remote); 378 379 380 /** 357 381 * Get SDP negotiator state. 358 382 * -
pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c
r1070 r1072 32 32 { 33 33 pjmedia_sdp_neg_state state; /**< Negotiator state. */ 34 pj_bool_t prefer_remote_codec_order; 34 35 pj_bool_t has_remote_answer; 35 36 pj_bool_t answer_was_remote; … … 87 88 88 89 neg->state = PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER; 90 neg->prefer_remote_codec_order = PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER; 89 91 neg->initial_sdp = pjmedia_sdp_session_clone(pool, local); 90 92 neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, local); … … 120 122 PJ_ASSERT_RETURN(neg != NULL, PJ_ENOMEM); 121 123 124 neg->prefer_remote_codec_order = PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER; 122 125 neg->neg_remote_sdp = pjmedia_sdp_session_clone(pool, remote); 123 126 … … 140 143 return PJ_SUCCESS; 141 144 } 145 146 147 /* 148 * Set codec order preference. 149 */ 150 PJ_DEF(pj_status_t) 151 pjmedia_sdp_neg_set_prefer_remote_codec_order(pjmedia_sdp_neg *neg, 152 pj_bool_t prefer_remote) 153 { 154 PJ_ASSERT_RETURN(neg, PJ_EINVAL); 155 neg->prefer_remote_codec_order = prefer_remote; 156 return PJ_SUCCESS; 157 } 158 142 159 143 160 /* … … 668 685 static pj_status_t match_offer(pj_pool_t *pool, 669 686 const pjmedia_sdp_media *offer, 670 const pjmedia_sdp_media *local, 687 const pjmedia_sdp_media *preanswer, 688 const pjmedia_sdp_media *orig_local, 671 689 pjmedia_sdp_media **p_answer) 672 690 { … … 711 729 712 730 /* Find matching codec in local descriptor. */ 713 for (j=0; j< local->desc.fmt_count; ++j) {731 for (j=0; j<preanswer->desc.fmt_count; ++j) { 714 732 unsigned p; 715 p = pj_strtoul(& local->desc.fmt[j]);716 if (p == pt && pj_isdigit(* local->desc.fmt[j].ptr)) {733 p = pj_strtoul(&preanswer->desc.fmt[j]); 734 if (p == pt && pj_isdigit(*preanswer->desc.fmt[j].ptr)) { 717 735 found_matching_codec = 1; 718 pt_answer[pt_answer_count++] = local->desc.fmt[j];736 pt_answer[pt_answer_count++] = preanswer->desc.fmt[j]; 719 737 break; 720 738 } … … 754 772 * encoding name and clock rate. 755 773 */ 756 for (j=0; j< local->desc.fmt_count; ++j) {757 a = pjmedia_sdp_media_find_attr2( local, "rtpmap",758 & local->desc.fmt[j]);774 for (j=0; j<preanswer->desc.fmt_count; ++j) { 775 a = pjmedia_sdp_media_find_attr2(preanswer, "rtpmap", 776 &preanswer->desc.fmt[j]); 759 777 if (a) { 760 778 pjmedia_sdp_rtpmap lr; … … 774 792 else 775 793 found_matching_telephone_event = 1; 776 pt_answer[pt_answer_count++] = local->desc.fmt[j];794 pt_answer[pt_answer_count++] = preanswer->desc.fmt[j]; 777 795 break; 778 796 } … … 792 810 continue; 793 811 794 for (j=0; j< local->desc.fmt_count; ++j) {795 if (!pj_strcmp(&offer->desc.fmt[i], & local->desc.fmt[j])) {812 for (j=0; j<preanswer->desc.fmt_count; ++j) { 813 if (!pj_strcmp(&offer->desc.fmt[i], &preanswer->desc.fmt[j])) { 796 814 /* Match */ 797 815 found_matching_other = 1; 798 pt_answer[pt_answer_count++] = local->desc.fmt[j];816 pt_answer[pt_answer_count++] = preanswer->desc.fmt[j]; 799 817 break; 800 818 } … … 824 842 * to suit the offer. 825 843 */ 826 answer = pjmedia_sdp_media_clone(pool, local);844 answer = pjmedia_sdp_media_clone(pool, orig_local); 827 845 for (i=0; i<pt_answer_count; ++i) { 828 846 unsigned j; … … 868 886 /* Create complete answer for remote's offer. */ 869 887 static pj_status_t create_answer( pj_pool_t *pool, 888 pj_bool_t prefer_remote_codec_order, 870 889 const pjmedia_sdp_session *initial, 871 890 const pjmedia_sdp_session *offer, … … 915 934 { 916 935 /* See if it has matching codec. */ 917 status = match_offer(pool, om, im, &am); 936 if (prefer_remote_codec_order) { 937 status = match_offer(pool, om, im, im, &am); 938 } else { 939 status = match_offer(pool, im, om, im, &am); 940 } 941 918 942 if (status == PJ_SUCCESS) { 919 943 /* Mark media as used. */ … … 992 1016 pjmedia_sdp_session *answer = NULL; 993 1017 994 status = create_answer(pool, neg->neg_local_sdp, neg->neg_remote_sdp, 1018 status = create_answer(pool, neg->prefer_remote_codec_order, 1019 neg->neg_local_sdp, neg->neg_remote_sdp, 995 1020 &answer); 996 1021 if (status == PJ_SUCCESS) {
Note: See TracChangeset
for help on using the changeset viewer.