- Timestamp:
- Mar 15, 2007 9:56:33 PM (18 years ago)
- Location:
- pjproject/branches/pjproject-0.5-stable/pjmedia
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/pjproject-0.5-stable/pjmedia/include/pjmedia/config.h
r997 r1071 277 277 278 278 /** 279 * This specifies the behavior of the SDP negotiator when responding to an 280 * offer, whether it should rather use the codec preference as set by 281 * remote, or should it rather use the codec preference as specified by 282 * local endpoint. 283 * 284 * For example, suppose incoming call has codec order "8 0 3", while 285 * local codec order is "3 0 8". If remote codec order is preferable, 286 * the selected codec will be 8, while if local codec order is preferable, 287 * the selected codec will be 3. 288 * 289 * If set to non-zero, the negotiator will use the codec order as specified 290 * by remote in the offer. 291 * 292 * Note that this behavior can be changed during run-time by calling 293 * pjmedia_sdp_neg_set_prefer_remote_codec_order(). 294 * 295 * Default is 1 (to maintain backward compatibility) 296 */ 297 #ifndef PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER 298 # define PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER 1 299 #endif 300 301 302 /** 279 303 * Support for sending and decoding RTCP port in SDP (RFC 3605). 280 304 * Default is yes. -
pjproject/branches/pjproject-0.5-stable/pjmedia/include/pjmedia/sdp_neg.h
r974 r1071 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/branches/pjproject-0.5-stable/pjmedia/src/pjmedia/sdp_neg.c
r1069 r1071 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.