Ticket #527: ticket527.patch
File ticket527.patch, 2.3 KB (added by nanang, 17 years ago) |
---|
-
pjmedia/src/pjmedia/sdp_neg.c
648 648 pj_bool_t allow_asym, 649 649 pjmedia_sdp_session **p_active) 650 650 { 651 unsigned mi; 651 unsigned omi = 0; /* Offer media index */ 652 unsigned ami = 0; /* Answer media index */ 652 653 pj_bool_t has_active = PJ_FALSE; 653 654 pj_status_t status; 654 655 … … 656 657 PJ_ASSERT_RETURN(pool && offer && answer && p_active, PJ_EINVAL); 657 658 658 659 /* Check that media count match between offer and answer */ 659 if (offer->media_count != answer->media_count) 660 // Ticket #527, different media count is allowed for more interoperability. 661 // However, number of media in answer must be <= number of media in offer, 662 // and the media order must be same between offer and answer. 663 // if (offer->media_count != answer->media_count) 664 // return PJMEDIA_SDPNEG_EMISMEDIA; 665 if (offer->media_count < answer->media_count) 660 666 return PJMEDIA_SDPNEG_EMISMEDIA; 661 667 662 668 /* Now update each media line in the offer with the answer. */ 663 for (mi=0; mi<offer->media_count; ++mi) { 664 status = process_m_answer(pool, offer->media[mi], answer->media[mi], 669 for (omi=0; omi<offer->media_count; ++omi) { 670 671 if (ami == answer->media_count) { 672 /* No answer media to be negotiated */ 673 remove_all_media_directions(offer->media[omi]); 674 pjmedia_sdp_media_deactivate(pool, offer->media[omi]); 675 continue; 676 } 677 678 status = process_m_answer(pool, offer->media[omi], answer->media[ami], 665 679 allow_asym); 680 681 /* If media type is mismatched, deactivate the media instead of return 682 * non PJ_SUCCESS. 683 */ 684 if (status == PJMEDIA_SDPNEG_EINVANSMEDIA) { 685 remove_all_media_directions(offer->media[omi]); 686 pjmedia_sdp_media_deactivate(pool, offer->media[omi]); 687 continue; 688 } 689 666 690 if (status != PJ_SUCCESS) 667 691 return status; 668 692 669 if (offer->media[ mi]->desc.port != 0)693 if (offer->media[omi]->desc.port != 0) 670 694 has_active = PJ_TRUE; 695 696 ++ami; 671 697 } 672 698 699 /* There should be unordered/ambigue answer if there is any unprocessed 700 * media of the answer. 701 */ 702 if (ami < answer->media_count) 703 return PJMEDIA_SDPNEG_EINVANSMEDIA; 704 673 705 *p_active = offer; 674 706 675 707 return has_active ? PJ_SUCCESS : PJMEDIA_SDPNEG_ENOMEDIA;