Changeset 6103 for pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c
- Timestamp:
- Nov 8, 2019 10:17:16 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c
r5828 r6103 1071 1071 pjmedia_sdp_media *answer; 1072 1072 const pjmedia_sdp_media *master, *slave; 1073 unsigned nclockrate = 0, clockrate[PJMEDIA_MAX_SDP_FMT]; 1073 1074 1074 1075 /* If offer has zero port, just clone the offer */ … … 1131 1132 p = pj_strtoul(&slave->desc.fmt[j]); 1132 1133 if (p == pt && pj_isdigit(*slave->desc.fmt[j].ptr)) { 1134 unsigned k; 1135 1133 1136 found_matching_codec = 1; 1134 1137 pt_offer[pt_answer_count] = slave->desc.fmt[j]; 1135 1138 pt_answer[pt_answer_count++] = slave->desc.fmt[j]; 1139 1140 /* Take note of clock rate for tel-event. Note: for 1141 * static PT, we assume the clock rate is 8000. 1142 */ 1143 for (k=0; k<nclockrate; ++k) 1144 if (clockrate[k] == 8000) 1145 break; 1146 if (k == nclockrate) 1147 clockrate[nclockrate++] = 8000; 1136 1148 break; 1137 1149 } … … 1145 1157 const pjmedia_sdp_attr *a; 1146 1158 pjmedia_sdp_rtpmap or_; 1147 pj_bool_t is_codec ;1159 pj_bool_t is_codec = 0; 1148 1160 1149 1161 /* Get the rtpmap for the payload type in the master. */ … … 1156 1168 pjmedia_sdp_attr_get_rtpmap(a, &or_); 1157 1169 1158 if (!pj_stricmp2(&or_.enc_name, "telephone-event")) { 1159 if (found_matching_telephone_event) 1160 continue; 1161 is_codec = 0; 1162 } else { 1170 if (pj_stricmp2(&or_.enc_name, "telephone-event")) { 1163 1171 master_has_codec = 1; 1164 1172 if (!answer_with_multiple_codecs && found_matching_codec) … … 1192 1200 pjmedia_sdp_media *o_med, *a_med; 1193 1201 unsigned o_fmt_idx, a_fmt_idx; 1202 unsigned k; 1194 1203 1195 1204 o_med = (pjmedia_sdp_media*)offer; … … 1208 1217 } 1209 1218 found_matching_codec = 1; 1219 1220 /* Take note of clock rate for tel-event */ 1221 for (k=0; k<nclockrate; ++k) 1222 if (clockrate[k] == or_.clock_rate) 1223 break; 1224 if (k == nclockrate) 1225 clockrate[nclockrate++] = or_.clock_rate; 1210 1226 } else { 1211 1227 found_matching_telephone_event = 1; … … 1270 1286 } 1271 1287 1272 /* Seems like everything is in order. 1273 * Build the answer by cloning from preanswer, but rearrange the payload 1288 /* Seems like everything is in order. */ 1289 1290 /* Remove unwanted telephone-event formats. */ 1291 if (found_matching_telephone_event) { 1292 pj_str_t first_televent_offer = {0}; 1293 pj_str_t first_televent_answer = {0}; 1294 unsigned matched_cnt = 0; 1295 1296 for (i=0; i<pt_answer_count; ) { 1297 const pjmedia_sdp_attr *a; 1298 pjmedia_sdp_rtpmap r; 1299 unsigned j; 1300 1301 /* Skip static PT, as telephone-event uses dynamic PT */ 1302 if (!pj_isdigit(*pt_answer[i].ptr) || pj_strtol(&pt_answer[i])<96) 1303 { 1304 ++i; 1305 continue; 1306 } 1307 1308 /* Get the rtpmap for format. */ 1309 a = pjmedia_sdp_media_find_attr2(preanswer, "rtpmap", 1310 &pt_answer[i]); 1311 pj_assert(a); 1312 pjmedia_sdp_attr_get_rtpmap(a, &r); 1313 1314 /* Only care for telephone-event format */ 1315 if (pj_stricmp2(&r.enc_name, "telephone-event")) { 1316 ++i; 1317 continue; 1318 } 1319 1320 if (first_televent_offer.slen == 0) { 1321 first_televent_offer = pt_offer[i]; 1322 first_televent_answer = pt_answer[i]; 1323 } 1324 1325 for (j=0; j<nclockrate; ++j) { 1326 if (r.clock_rate==clockrate[j]) 1327 break; 1328 } 1329 1330 /* This tel-event's clockrate is unwanted, remove the tel-event */ 1331 if (j==nclockrate) { 1332 pj_array_erase(pt_answer, sizeof(pt_answer[0]), 1333 pt_answer_count, i); 1334 pj_array_erase(pt_offer, sizeof(pt_offer[0]), 1335 pt_answer_count, i); 1336 pt_answer_count--; 1337 } else { 1338 ++matched_cnt; 1339 ++i; 1340 } 1341 } 1342 1343 /* Tel-event is wanted, but no matched clock rate (to the selected 1344 * audio codec), just put back any first matched tel-event formats. 1345 */ 1346 if (!matched_cnt) { 1347 pt_offer[pt_answer_count] = first_televent_offer; 1348 pt_answer[pt_answer_count++] = first_televent_answer; 1349 } 1350 } 1351 1352 /* Build the answer by cloning from preanswer, and reorder the payload 1274 1353 * to suit the offer. 1275 1354 */
Note: See TracChangeset
for help on using the changeset viewer.