Changeset 4554 for pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c
- Timestamp:
- Jul 9, 2013 7:17:39 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c
r4537 r4554 277 277 const pjmedia_sdp_session *local) 278 278 { 279 return pjmedia_sdp_neg_modify_local_offer2(pool, neg, 0, local); 280 } 281 282 PJ_DEF(pj_status_t) pjmedia_sdp_neg_modify_local_offer2( 283 pj_pool_t *pool, 284 pjmedia_sdp_neg *neg, 285 unsigned flags, 286 const pjmedia_sdp_session *local) 287 { 279 288 pjmedia_sdp_session *new_offer; 280 289 pjmedia_sdp_session *old_offer; … … 315 324 pj_strdup(pool, &new_offer->origin.addr, &old_offer->origin.addr); 316 325 317 /* Generating the new offer, in the case media lines doesn't match the 318 * active SDP (e.g. current/active SDP's have m=audio and m=video lines, 319 * and the new offer only has m=audio line), the negotiator will fix 320 * the new offer by reordering and adding the missing media line with 321 * port number set to zero. 322 */ 323 for (oi = 0; oi < old_offer->media_count; ++oi) { 324 pjmedia_sdp_media *om; 325 pjmedia_sdp_media *nm; 326 unsigned ni; /* new offer media index */ 327 pj_bool_t found = PJ_FALSE; 328 329 om = old_offer->media[oi]; 330 for (ni = oi; ni < new_offer->media_count; ++ni) { 331 nm = new_offer->media[ni]; 332 if (pj_strcmp(&nm->desc.media, &om->desc.media) == 0) { 333 if (ni != oi) { 334 /* The same media found but the position unmatched to the 335 * old offer, so let's put this media in the right place, 336 * and keep the order of the rest. 337 */ 338 pj_array_insert(new_offer->media, /* array */ 339 sizeof(new_offer->media[0]), /* elmt size*/ 340 ni, /* count */ 341 oi, /* pos */ 342 &nm); /* new elmt */ 343 } 344 found = PJ_TRUE; 345 break; 326 if ((flags & PJMEDIA_SDP_NEG_ALLOW_MEDIA_CHANGE) == 0) { 327 /* Generating the new offer, in the case media lines doesn't match the 328 * active SDP (e.g. current/active SDP's have m=audio and m=video lines, 329 * and the new offer only has m=audio line), the negotiator will fix 330 * the new offer by reordering and adding the missing media line with 331 * port number set to zero. 332 */ 333 for (oi = 0; oi < old_offer->media_count; ++oi) { 334 pjmedia_sdp_media *om; 335 pjmedia_sdp_media *nm; 336 unsigned ni; /* new offer media index */ 337 pj_bool_t found = PJ_FALSE; 338 339 om = old_offer->media[oi]; 340 for (ni = oi; ni < new_offer->media_count; ++ni) { 341 nm = new_offer->media[ni]; 342 if (pj_strcmp(&nm->desc.media, &om->desc.media) == 0) { 343 if (ni != oi) { 344 /* The same media found but the position unmatched to 345 * the old offer, so let's put this media in the right 346 * place, and keep the order of the rest. 347 */ 348 pj_array_insert( 349 new_offer->media, /* array */ 350 sizeof(new_offer->media[0]), /* elmt size*/ 351 ni, /* count */ 352 oi, /* pos */ 353 &nm); /* new elmt */ 354 } 355 found = PJ_TRUE; 356 break; 357 } 346 358 } 347 } 348 if (!found) { 349 pjmedia_sdp_media *m; 350 351 m = sdp_media_clone_deactivate(pool, om, om, local); 359 if (!found) { 360 pjmedia_sdp_media *m; 361 362 m = sdp_media_clone_deactivate(pool, om, om, local); 363 364 pj_array_insert(new_offer->media, sizeof(new_offer->media[0]), 365 new_offer->media_count++, oi, &m); 366 } 367 } 368 } else { 369 /* If media type change is allowed, the negotiator only needs to fix 370 * the new offer by adding the missing media line(s) with port number 371 * set to zero. 372 */ 373 for (oi = new_offer->media_count; oi < old_offer->media_count; ++oi) { 374 pjmedia_sdp_media *m; 375 376 m = sdp_media_clone_deactivate(pool, old_offer->media[oi], 377 old_offer->media[oi], local); 352 378 353 379 pj_array_insert(new_offer->media, sizeof(new_offer->media[0]), 354 new_offer->media_count++, oi, &m); 355 } 380 new_offer->media_count++, oi, &m); 381 382 } 356 383 } 357 384
Note: See TracChangeset
for help on using the changeset viewer.