Changeset 4554 for pjproject/trunk
- Timestamp:
- Jul 9, 2013 7:17:39 AM (11 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/sdp_neg.h
r3664 r4554 314 314 315 315 /** 316 * Flags to be given to pjmedia_sdp_neg_modify_local_offer2(). 317 */ 318 typedef enum pjmedia_mod_offer_flag 319 { 320 /** 321 * Allow media type in the SDP to be changed. 322 * When generating a new offer, in the case that a media line doesn't match 323 * the active SDP, the new media line will be considered to replace the 324 * existing media at the same position. 325 */ 326 PJMEDIA_SDP_NEG_ALLOW_MEDIA_CHANGE = 1 327 328 } pjmedia_mod_offer_flag; 329 330 331 /** 316 332 * Get the state string description of the specified state. 317 333 * … … 494 510 pjmedia_sdp_neg_get_neg_local( pjmedia_sdp_neg *neg, 495 511 const pjmedia_sdp_session **local); 512 513 /** 514 * Modify local session with a new SDP and treat this as a new offer. 515 * This function can only be called in state PJMEDIA_SDP_NEG_STATE_DONE. 516 * After calling this function, application can send the SDP as offer 517 * to remote party, using signaling protocol such as SIP. 518 * The negotiator state will move to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, 519 * where it waits for SDP answer from remote. See also 520 * #pjmedia_sdp_neg_modify_local_offer2() 521 * 522 * @param pool Pool to allocate memory. The pool's lifetime needs 523 * to be valid for the duration of the negotiator. 524 * @param neg The SDP negotiator instance. 525 * @param local The new local SDP. 526 * 527 * @return PJ_SUCCESS on success, or the appropriate 528 * error code. 529 */ 530 PJ_DECL(pj_status_t) 531 pjmedia_sdp_neg_modify_local_offer( pj_pool_t *pool, 532 pjmedia_sdp_neg *neg, 533 const pjmedia_sdp_session *local); 496 534 497 535 /** … … 506 544 * to be valid for the duration of the negotiator. 507 545 * @param neg The SDP negotiator instance. 546 * @param flags Bitmask from pjmedia_mod_offer_flag. 508 547 * @param local The new local SDP. 509 548 * … … 512 551 */ 513 552 PJ_DECL(pj_status_t) 514 pjmedia_sdp_neg_modify_local_offer( pj_pool_t *pool, 515 pjmedia_sdp_neg *neg, 516 const pjmedia_sdp_session *local); 553 pjmedia_sdp_neg_modify_local_offer2( pj_pool_t *pool, 554 pjmedia_sdp_neg *neg, 555 unsigned flags, 556 const pjmedia_sdp_session *local); 517 557 518 558 /** -
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.