- Timestamp:
- Mar 15, 2007 9:56:33 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.