Changeset 3187
- Timestamp:
- May 26, 2010 5:23:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c
r3160 r3187 816 816 817 817 } else { 818 /* Offer format priority based on answer format index/priority */ 819 unsigned offer_fmt_prior[PJMEDIA_MAX_SDP_FMT]; 820 818 821 /* Remove all format in the offer that has no matching answer */ 819 822 for (i=0; i<offer->desc.fmt_count;) { … … 908 911 909 912 } else { 913 offer_fmt_prior[i] = j; 910 914 ++i; 911 915 } … … 917 921 } 918 922 919 /* Arrange format in the offer so the order match the priority 920 * in the answer 923 /* Post process: 924 * - Resort offer formats so the order match to the answer. 925 * - Remove answer formats that unmatches to the offer. 921 926 */ 922 for (i=0; i<answer->desc.fmt_count; ++i) { 927 928 /* Resort offer formats */ 929 for (i=0; i<offer->desc.fmt_count; ++i) { 923 930 unsigned j; 924 pj_str_t *fmt = &answer->desc.fmt[i]; 925 926 for (j=i; j<offer->desc.fmt_count; ++j) { 927 if (pj_strcmp(fmt, &offer->desc.fmt[j])==0) { 931 for (j=i+1; j<offer->desc.fmt_count; ++j) { 932 if (offer_fmt_prior[i] > offer_fmt_prior[j]) { 933 unsigned tmp = offer_fmt_prior[i]; 934 offer_fmt_prior[i] = offer_fmt_prior[j]; 935 offer_fmt_prior[j] = tmp; 928 936 str_swap(&offer->desc.fmt[i], &offer->desc.fmt[j]); 929 break;930 937 } 931 938 } 932 933 /* If this answer format has no matching format, let's remove it 934 * from the answer. 935 */ 936 if (j >= offer->desc.fmt_count) { 937 pjmedia_sdp_attr *a; 938 939 /* Remove rtpmap associated with this format */ 940 a = pjmedia_sdp_media_find_attr2(answer, "rtpmap", fmt); 941 if (a) 942 pjmedia_sdp_media_remove_attr(answer, a); 943 944 /* Remove fmtp associated with this format */ 945 a = pjmedia_sdp_media_find_attr2(answer, "fmtp", fmt); 946 if (a) 947 pjmedia_sdp_media_remove_attr(answer, a); 948 949 /* Remove this format from answer's array */ 950 pj_array_erase(answer->desc.fmt, sizeof(answer->desc.fmt[0]), 951 answer->desc.fmt_count, i); 952 --answer->desc.fmt_count; 939 } 940 941 /* Remove unmatched answer formats */ 942 { 943 unsigned del_cnt = 0; 944 for (i=0; i<answer->desc.fmt_count;) { 945 /* The offer is ordered now, also the offer_fmt_prior */ 946 if (i >= offer->desc.fmt_count || 947 offer_fmt_prior[i]-del_cnt != i) 948 { 949 pj_str_t *fmt = &answer->desc.fmt[i]; 950 pjmedia_sdp_attr *a; 951 952 /* Remove rtpmap associated with this format */ 953 a = pjmedia_sdp_media_find_attr2(answer, "rtpmap", fmt); 954 if (a) 955 pjmedia_sdp_media_remove_attr(answer, a); 956 957 /* Remove fmtp associated with this format */ 958 a = pjmedia_sdp_media_find_attr2(answer, "fmtp", fmt); 959 if (a) 960 pjmedia_sdp_media_remove_attr(answer, a); 961 962 /* Remove this format from answer's array */ 963 pj_array_erase(answer->desc.fmt, 964 sizeof(answer->desc.fmt[0]), 965 answer->desc.fmt_count, i); 966 --answer->desc.fmt_count; 967 968 ++del_cnt; 969 } else { 970 ++i; 971 } 953 972 } 954 973 }
Note: See TracChangeset
for help on using the changeset viewer.