Ignore:
Timestamp:
Jun 4, 2010 1:41:34 PM (14 years ago)
Author:
nanang
Message:

Re #668:

  • Fixed process_answer() of SDP negotiation, when no common format in a media, instead of returning error, it should just deactivate the media (offer & answer) and continue negotiating next media.
  • Generalized the way of deactivating media: set port to 0 and remove all attributes.
  • Added new API pjmedia_sdp_media_clone_deactivate() to clone media and deactivate the newly cloned media.
  • Updated PJMEDIA SDP negotiation test.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c

    r3195 r3198  
    312312            pjmedia_sdp_media *m; 
    313313 
    314             m = pjmedia_sdp_media_clone(pool, om); 
    315             m->desc.port = 0; 
     314            m = pjmedia_sdp_media_clone_deactivate(pool, om); 
    316315 
    317316            pj_array_insert(new_offer->media, sizeof(new_offer->media[0]), 
     
    777776         
    778777        /* Remote has rejected our offer.  
    779          * Set our port to zero too in active SDP. 
     778         * Deactivate our media too. 
    780779         */ 
    781         offer->desc.port = 0; 
     780        pjmedia_sdp_media_deactivate(pool, offer); 
    782781 
    783782        /* Don't need to proceed */ 
     
    10121011 
    10131012            /* Generate matching-but-disabled-media for the answer */ 
    1014             am = pjmedia_sdp_media_clone(pool, offer->media[omi]); 
    1015             am->desc.port = 0; 
     1013            am = pjmedia_sdp_media_clone_deactivate(pool, offer->media[omi]); 
    10161014            answer->media[answer->media_count++] = am; 
    10171015            ++ami; 
    10181016 
     1017            /* Deactivate our media offer too */ 
     1018            pjmedia_sdp_media_deactivate(pool, offer->media[omi]); 
     1019 
    10191020            /* No answer media to be negotiated */ 
    1020             offer->media[omi]->desc.port = 0; 
    10211021            continue; 
    10221022        } 
     
    10271027        /* If media type is mismatched, just disable the media. */ 
    10281028        if (status == PJMEDIA_SDPNEG_EINVANSMEDIA) { 
    1029             offer->media[omi]->desc.port = 0; 
     1029            pjmedia_sdp_media_deactivate(pool, offer->media[omi]); 
    10301030            continue; 
    10311031        } 
    1032  
    1033         if (status != PJ_SUCCESS) 
     1032        /* No common format in the answer media. */ 
     1033        else if (status == PJMEDIA_SDPNEG_EANSNOMEDIA) { 
     1034            pjmedia_sdp_media_deactivate(pool, offer->media[omi]); 
     1035            pjmedia_sdp_media_deactivate(pool, answer->media[ami]); 
     1036        }  
     1037        /* Return the error code, for other errors. */ 
     1038        else if (status != PJ_SUCCESS) { 
    10341039            return status; 
     1040        } 
    10351041 
    10361042        if (offer->media[omi]->desc.port != 0) 
     
    10651071    pj_str_t pt_amr_need_adapt = {NULL, 0}; 
    10661072 
    1067     /* If offer has zero port, just clone the offer and update direction */ 
     1073    /* If offer has zero port, just clone the offer */ 
    10681074    if (offer->desc.port == 0) { 
    1069         answer = pjmedia_sdp_media_clone(pool, offer); 
    1070         remove_all_media_directions(answer); 
    1071         update_media_direction(pool, offer, answer); 
     1075        answer = pjmedia_sdp_media_clone_deactivate(pool, offer); 
    10721076        *p_answer = answer; 
    10731077        return PJ_SUCCESS; 
     
    13571361             * Reject the offer by setting the port to zero in the answer. 
    13581362             */ 
    1359             //pjmedia_sdp_attr *a; 
    1360  
    13611363            /* For simplicity in the construction of the answer, we'll 
    13621364             * just clone the media from the offer. Anyway receiver will 
     
    13641366             * number is zero. 
    13651367             */ 
    1366             am = pjmedia_sdp_media_clone(pool, om); 
    1367             am->desc.port = 0; 
    1368  
    1369             // Just set port zero to disable stream without set it to inactive. 
    1370             /* Remove direction attribute, and replace with inactive */ 
    1371             remove_all_media_directions(am); 
    1372             //a = pjmedia_sdp_attr_create(pool, "inactive", NULL); 
    1373             //pjmedia_sdp_media_add_attr(am, a); 
    1374  
    1375             /* Then update direction */ 
    1376             update_media_direction(pool, om, am); 
    1377  
     1368            am = pjmedia_sdp_media_clone_deactivate(pool, om); 
    13781369        } else { 
    13791370            /* The answer is in am */ 
     
    14391430            neg->active_local_sdp = active; 
    14401431            neg->active_remote_sdp = neg->neg_remote_sdp; 
    1441  
    14421432        } 
    14431433    } else { 
Note: See TracChangeset for help on using the changeset viewer.