Changeset 1950


Ignore:
Timestamp:
May 7, 2008 3:30:34 PM (16 years ago)
Author:
nanang
Message:

Ticket #527: Commited ticket527.2.patch

Location:
pjproject/trunk/pjmedia/src
Files:
3 edited

Legend:

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

    r1810 r1950  
    225225                                    const pjmedia_sdp_session *local) 
    226226{ 
     227    pjmedia_sdp_session *new_offer; 
     228    pjmedia_sdp_session *old_offer; 
     229    char media_used[PJMEDIA_MAX_SDP_MEDIA]; 
     230    unsigned oi; /* old offer media index */ 
     231    pj_status_t status; 
     232 
    227233    /* Check arguments are valid. */ 
    228234    PJ_ASSERT_RETURN(pool && neg && local, PJ_EINVAL); 
     
    232238                     PJMEDIA_SDPNEG_EINSTATE); 
    233239 
     240    /* Validate the new offer */ 
     241    status = pjmedia_sdp_validate(local); 
     242    if (status != PJ_SUCCESS) 
     243        return status; 
     244 
    234245    /* Change state to STATE_LOCAL_OFFER */ 
    235246    neg->state = PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER; 
    236     neg->initial_sdp = pjmedia_sdp_session_clone(pool, local); 
    237     neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, local); 
     247 
     248    /* Init vars */ 
     249    pj_bzero(media_used, sizeof(media_used)); 
     250    old_offer = neg->active_local_sdp; 
     251    new_offer = pjmedia_sdp_session_clone(pool, local); 
     252 
     253    /* RFC 3264 Section 8: When issuing an offer that modifies the session, 
     254     * the "o=" line of the new SDP MUST be identical to that in the 
     255     * previous SDP, except that the version in the origin field MUST 
     256     * increment by one from the previous SDP. 
     257     */ 
     258    pj_strdup(pool, &new_offer->origin.user, &old_offer->origin.user); 
     259    new_offer->origin.id = old_offer->origin.id; 
     260    new_offer->origin.version = old_offer->origin.version + 1; 
     261    pj_strdup(pool, &new_offer->origin.net_type, &old_offer->origin.net_type); 
     262    pj_strdup(pool, &new_offer->origin.addr_type,&old_offer->origin.addr_type); 
     263    pj_strdup(pool, &new_offer->origin.addr, &old_offer->origin.addr); 
     264 
     265    /* Generating the new offer, in the case media lines doesn't match the 
     266     * active SDP (e.g. current/active SDP's have m=audio and m=video lines,  
     267     * and the new offer only has m=audio line), the negotiator will fix  
     268     * the new offer by reordering and adding the missing media line with  
     269     * port number set to zero. 
     270     */ 
     271    for (oi = 0; oi < old_offer->media_count; ++oi) { 
     272        pjmedia_sdp_media *om; 
     273        pjmedia_sdp_media *nm; 
     274        unsigned ni; /* new offer media index */ 
     275        pj_bool_t found = PJ_FALSE; 
     276 
     277        om = old_offer->media[oi]; 
     278        for (ni = oi; ni < new_offer->media_count; ++ni) { 
     279            nm = new_offer->media[ni]; 
     280            if (pj_strcmp(&nm->desc.media, &om->desc.media) == 0) { 
     281                if (ni != oi) { 
     282                    /* The same media found but the position unmatched to the  
     283                     * old offer, so let's put this media in the right place,  
     284                     * and keep the order of the rest. 
     285                     */ 
     286                    pj_array_insert(new_offer->media,            /* array    */ 
     287                                    sizeof(new_offer->media[0]), /* elmt size*/ 
     288                                    ni,                          /* count    */ 
     289                                    oi,                          /* pos      */ 
     290                                    &nm);                        /* new elmt */ 
     291                } 
     292                found = PJ_TRUE; 
     293                break; 
     294            } 
     295        } 
     296        if (!found) { 
     297            pjmedia_sdp_media *m; 
     298 
     299            m = pjmedia_sdp_media_clone(pool, om); 
     300            m->desc.port = 0; 
     301 
     302            pj_array_insert(new_offer->media, sizeof(new_offer->media[0]), 
     303                            new_offer->media_count++, oi, &m); 
     304        } 
     305    } 
     306 
     307    /* New_offer fixed */ 
     308    neg->initial_sdp = new_offer; 
     309    neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, new_offer); 
    238310 
    239311    return PJ_SUCCESS; 
     
    649721                                  pjmedia_sdp_session **p_active) 
    650722{ 
    651     unsigned mi; 
     723    unsigned omi = 0; /* Offer media index */ 
     724    unsigned ami = 0; /* Answer media index */ 
    652725    pj_bool_t has_active = PJ_FALSE; 
    653726    pj_status_t status; 
     
    657730 
    658731    /* Check that media count match between offer and answer */ 
    659     if (offer->media_count != answer->media_count) 
    660         return PJMEDIA_SDPNEG_EMISMEDIA; 
     732    // Ticket #527, different media count is allowed for more interoperability, 
     733    // however, the media order must be same between offer and answer. 
     734    // if (offer->media_count != answer->media_count) 
     735    //     return PJMEDIA_SDPNEG_EMISMEDIA; 
    661736 
    662737    /* 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], 
     738    for (; omi<offer->media_count; ++omi) { 
     739        if (ami == answer->media_count) { 
     740            /* No answer media to be negotiated */ 
     741            offer->media[omi]->desc.port = 0; 
     742            continue; 
     743        } 
     744 
     745        status = process_m_answer(pool, offer->media[omi], answer->media[ami], 
    665746                                  allow_asym); 
     747 
     748        /* If media type is mismatched, just disable the media. */ 
     749        if (status == PJMEDIA_SDPNEG_EINVANSMEDIA) { 
     750            offer->media[omi]->desc.port = 0; 
     751            continue; 
     752        } 
     753 
    666754        if (status != PJ_SUCCESS) 
    667755            return status; 
    668756 
    669         if (offer->media[mi]->desc.port != 0) 
     757        if (offer->media[omi]->desc.port != 0) 
    670758            has_active = PJ_TRUE; 
     759 
     760        ++ami; 
    671761    } 
    672762 
     
    9461036             * Reject the offer by setting the port to zero in the answer. 
    9471037             */ 
    948             pjmedia_sdp_attr *a; 
     1038            //pjmedia_sdp_attr *a; 
    9491039 
    9501040            /* For simplicity in the construction of the answer, we'll 
     
    9561046            am->desc.port = 0; 
    9571047 
     1048            // Just set port zero to disable stream without set it to inactive. 
    9581049            /* Remove direction attribute, and replace with inactive */ 
    9591050            remove_all_media_directions(am); 
    960  
    961             a = pjmedia_sdp_attr_create(pool, "inactive", NULL); 
    962             pjmedia_sdp_media_add_attr(am, a); 
     1051            //a = pjmedia_sdp_attr_create(pool, "inactive", NULL); 
     1052            //pjmedia_sdp_media_add_attr(am, a); 
     1053 
     1054            /* Then update direction */ 
     1055            update_media_direction(pool, om, am); 
    9631056 
    9641057        } else { 
  • pjproject/trunk/pjmedia/src/test/sdp_neg_test.c

    r974 r1950  
    321321    }, 
    322322 
     323#if 0 
     324    // this test is commented, this causes error:  
     325    // No suitable codec for remote offer (PJMEDIA_SDPNEG_NOANSCODEC), 
     326    // since currently the negotiator always answer with one codec,  
     327    // PCMU in this case, while PCMU is not included in the second offer. 
     328 
    323329    /* test 3: */ 
    324330    { 
     
    394400        } 
    395401    }, 
     402#endif 
    396403 
    397404    /* test 4: */ 
     
    752759            "m=audio 49172 RTP/AVP 97 8 99\r\n" 
    753760            "a=rtpmap:97 iLBC/8000\r\n" 
    754             "a=rtpmap:99 telephone-event/8000\r\n" 
    755             "a=recvonly\r\n", 
     761            "a=rtpmap:99 telephone-event/8000\r\n", 
    756762            /* Bob's answer should be: */ 
    757763            "v=0\r\n" 
     
    868874            "a=rtpmap:97 iLBC/8000\r\n" 
    869875            "a=rtpmap:101 telephone-event/8000\r\n", 
     876          } 
     877        } 
     878    }, 
     879 
     880    /* test 12: */ 
     881    { 
     882        /********************************************************************* 
     883         * Ticket #527: More lenient SDP negotiator. 
     884         */ 
     885 
     886        "Ticket #527 scenario #1: Partial answer", 
     887        1, 
     888        { 
     889          { 
     890            LOCAL_OFFER, 
     891            /* Alice sends offer audio and video: */ 
     892            "v=0\r\n" 
     893            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     894            "s=alice\r\n" 
     895            "c=IN IP4 host.atlanta.example.com\r\n" 
     896            "t=0 0\r\n" 
     897            "m=audio 49170 RTP/AVP 0\r\n" 
     898            "a=rtpmap:0 PCMU/8000\r\n" 
     899            "m=video 4000 RTP/AVP 31\r\n" 
     900            "a=rtpmap:31 H261/90000\r\n", 
     901            /* Receive Bob's answer only audio: */ 
     902            "v=0\r\n" 
     903            "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n" 
     904            "s=bob\r\n" 
     905            "c=IN IP4 host.biloxi.example.com\r\n" 
     906            "t=0 0\r\n" 
     907            "m=audio 49170 RTP/AVP 0\r\n" 
     908            "a=rtpmap:0 PCMU/8000\r\n", 
     909            /* Alice's local SDP should be: */ 
     910            "v=0\r\n" 
     911            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     912            "s=alice\r\n" 
     913            "c=IN IP4 host.atlanta.example.com\r\n" 
     914            "t=0 0\r\n" 
     915            "m=audio 49170 RTP/AVP 0\r\n" 
     916            "a=rtpmap:0 PCMU/8000\r\n" 
     917            "m=video 0 RTP/AVP 31\r\n" 
     918            "a=rtpmap:31 H261/90000\r\n" 
     919            "", 
     920          } 
     921        } 
     922    }, 
     923 
     924    /* test 13: */ 
     925    { 
     926        /********************************************************************* 
     927         * Ticket #527: More lenient SDP negotiator. 
     928         */ 
     929 
     930        "Ticket #527 scenario #1: Media mismatch in answer", 
     931        1, 
     932        { 
     933          { 
     934            LOCAL_OFFER, 
     935            /* Alice sends offer audio and video: */ 
     936            "v=0\r\n" 
     937            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     938            "s=alice\r\n" 
     939            "c=IN IP4 host.atlanta.example.com\r\n" 
     940            "t=0 0\r\n" 
     941            "m=audio 3000 RTP/AVP 0\r\n" 
     942            "a=rtpmap:0 PCMU/8000\r\n" 
     943            "m=video 4000 RTP/AVP 31\r\n" 
     944            "a=rtpmap:31 H261/90000\r\n", 
     945            /* Receive Bob's answer two audio: */ 
     946            "v=0\r\n" 
     947            "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n" 
     948            "s=bob\r\n" 
     949            "c=IN IP4 host.biloxi.example.com\r\n" 
     950            "t=0 0\r\n" 
     951            "m=audio 49170 RTP/AVP 0\r\n" 
     952            "a=rtpmap:0 PCMU/8000\r\n" 
     953            "m=audio 49172 RTP/AVP 0\r\n" 
     954            "a=rtpmap:0 PCMU/8000\r\n", 
     955            /* Alice's local SDP should be: */ 
     956            "v=0\r\n" 
     957            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     958            "s=alice\r\n" 
     959            "c=IN IP4 host.atlanta.example.com\r\n" 
     960            "t=0 0\r\n" 
     961            "m=audio 3000 RTP/AVP 0\r\n" 
     962            "a=rtpmap:0 PCMU/8000\r\n" 
     963            "m=video 0 RTP/AVP 31\r\n" 
     964            "a=rtpmap:31 H261/90000\r\n" 
     965            "", 
     966          } 
     967        } 
     968    }, 
     969 
     970    /* test 14: */ 
     971    { 
     972        /********************************************************************* 
     973         * Ticket #527: More lenient SDP negotiator. 
     974         */ 
     975 
     976        "Ticket #527 scenario #2: Modify offer - partial streams", 
     977        2, 
     978        { 
     979          { 
     980            LOCAL_OFFER, 
     981            /* Alice sends offer: */ 
     982            "v=0\r\n" 
     983            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     984            "s=alice\r\n" 
     985            "c=IN IP4 host.atlanta.example.com\r\n" 
     986            "t=0 0\r\n" 
     987            "m=audio 3000 RTP/AVP 0\r\n" 
     988            "a=rtpmap:0 PCMU/8000\r\n" 
     989            "m=audio 3100 RTP/AVP 0\r\n" 
     990            "a=rtpmap:0 PCMU/8000\r\n" 
     991            "m=video 3200 RTP/AVP 31\r\n" 
     992            "a=rtpmap:31 H261/90000\r\n" 
     993            "", 
     994            /* Receive Bob's answer: */ 
     995            "v=0\r\n" 
     996            "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n" 
     997            "s=bob\r\n" 
     998            "c=IN IP4 host.biloxi.example.com\r\n" 
     999            "t=0 0\r\n" 
     1000            "m=audio 4000 RTP/AVP 0\r\n" 
     1001            "a=rtpmap:0 PCMU/8000\r\n" 
     1002            "m=audio 4100 RTP/AVP 0\r\n" 
     1003            "a=rtpmap:0 PCMU/8000\r\n" 
     1004            "m=video 4200 RTP/AVP 31\r\n" 
     1005            "a=rtpmap:31 H261/90000\r\n" 
     1006            "", 
     1007            /* Alice's local SDP should be: */ 
     1008            "v=0\r\n" 
     1009            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     1010            "s=alice\r\n" 
     1011            "c=IN IP4 host.atlanta.example.com\r\n" 
     1012            "t=0 0\r\n" 
     1013            "m=audio 3000 RTP/AVP 0\r\n" 
     1014            "a=rtpmap:0 PCMU/8000\r\n" 
     1015            "m=audio 3100 RTP/AVP 0\r\n" 
     1016            "a=rtpmap:0 PCMU/8000\r\n" 
     1017            "m=video 3200 RTP/AVP 31\r\n" 
     1018            "a=rtpmap:31 H261/90000\r\n" 
     1019            "", 
     1020          }, 
     1021          { 
     1022            LOCAL_OFFER, 
     1023            /* Alice modifies offer with only specify one audio: */ 
     1024            "v=0\r\n" 
     1025            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     1026            "s=alice\r\n" 
     1027            "c=IN IP4 host.atlanta.example.com\r\n" 
     1028            "t=0 0\r\n" 
     1029            "m=audio 5200 RTP/AVP 0\r\n" 
     1030            "a=rtpmap:0 PCMU/8000\r\n" 
     1031            "", 
     1032            /* Receive Bob's answer: */ 
     1033            "v=0\r\n" 
     1034            "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n" 
     1035            "s=bob\r\n" 
     1036            "c=IN IP4 host.biloxi.example.com\r\n" 
     1037            "t=0 0\r\n" 
     1038            "m=audio 7000 RTP/AVP 0\r\n" 
     1039            "a=rtpmap:0 PCMU/8000\r\n" 
     1040            "m=audio 0 RTP/AVP 0\r\n" 
     1041            "a=rtpmap:0 PCMU/8000\r\n" 
     1042            "m=video 0 RTP/AVP 31\r\n" 
     1043            "a=rtpmap:31 H261/90000\r\n" 
     1044            "", 
     1045            /* Alice's local SDP should be: */ 
     1046            "v=0\r\n" 
     1047            "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n" 
     1048            "s=alice\r\n" 
     1049            "c=IN IP4 host.atlanta.example.com\r\n" 
     1050            "t=0 0\r\n" 
     1051            "m=audio 5200 RTP/AVP 0\r\n" 
     1052            "a=rtpmap:0 PCMU/8000\r\n" 
     1053            "m=audio 0 RTP/AVP 0\r\n" 
     1054            "a=rtpmap:0 PCMU/8000\r\n" 
     1055            "m=video 0 RTP/AVP 31\r\n" 
     1056            "a=rtpmap:31 H261/90000\r\n" 
     1057            "", 
     1058          } 
     1059        } 
     1060    }, 
     1061 
     1062    /* test 15: */ 
     1063    { 
     1064        /********************************************************************* 
     1065         * Ticket #527: More lenient SDP negotiator. 
     1066         */ 
     1067 
     1068        "Ticket #527 scenario #2: Modify offer - unordered m= lines", 
     1069        2, 
     1070        { 
     1071          { 
     1072            LOCAL_OFFER, 
     1073            /* Alice sends offer: */ 
     1074            "v=0\r\n" 
     1075            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     1076            "s=alice\r\n" 
     1077            "c=IN IP4 host.atlanta.example.com\r\n" 
     1078            "t=0 0\r\n" 
     1079            "m=audio 3000 RTP/AVP 0\r\n" 
     1080            "a=rtpmap:0 PCMU/8000\r\n" 
     1081            "m=video 3200 RTP/AVP 31\r\n" 
     1082            "a=rtpmap:31 H261/90000\r\n" 
     1083            "", 
     1084            /* Receive Bob's answer: */ 
     1085            "v=0\r\n" 
     1086            "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n" 
     1087            "s=bob\r\n" 
     1088            "c=IN IP4 host.biloxi.example.com\r\n" 
     1089            "t=0 0\r\n" 
     1090            "m=audio 4000 RTP/AVP 0\r\n" 
     1091            "a=rtpmap:0 PCMU/8000\r\n" 
     1092            "m=video 4200 RTP/AVP 31\r\n" 
     1093            "a=rtpmap:31 H261/90000\r\n" 
     1094            "", 
     1095            /* Alice's local SDP should be: */ 
     1096            "v=0\r\n" 
     1097            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     1098            "s=alice\r\n" 
     1099            "c=IN IP4 host.atlanta.example.com\r\n" 
     1100            "t=0 0\r\n" 
     1101            "m=audio 3000 RTP/AVP 0\r\n" 
     1102            "a=rtpmap:0 PCMU/8000\r\n" 
     1103            "m=video 3200 RTP/AVP 31\r\n" 
     1104            "a=rtpmap:31 H261/90000\r\n" 
     1105            "", 
     1106          }, 
     1107          { 
     1108            LOCAL_OFFER, 
     1109            /* Alice modifies offer with unordered m= lines: */ 
     1110            "v=0\r\n" 
     1111            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     1112            "s=alice\r\n" 
     1113            "c=IN IP4 host.atlanta.example.com\r\n" 
     1114            "t=0 0\r\n" 
     1115            "m=video 5000 RTP/AVP 31\r\n" 
     1116            "a=rtpmap:31 H261/90000\r\n" 
     1117            "m=audio 5200 RTP/AVP 0\r\n" 
     1118            "a=rtpmap:0 PCMU/8000\r\n" 
     1119            "", 
     1120            /* Receive Bob's answer: */ 
     1121            "v=0\r\n" 
     1122            "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n" 
     1123            "s=bob\r\n" 
     1124            "c=IN IP4 host.biloxi.example.com\r\n" 
     1125            "t=0 0\r\n" 
     1126            "m=audio 7000 RTP/AVP 0\r\n" 
     1127            "a=rtpmap:0 PCMU/8000\r\n" 
     1128            "m=video 2000 RTP/AVP 31\r\n" 
     1129            "a=rtpmap:31 H261/90000\r\n" 
     1130            "", 
     1131            /* Alice's local SDP should be: */ 
     1132            "v=0\r\n" 
     1133            "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n" 
     1134            "s=alice\r\n" 
     1135            "c=IN IP4 host.atlanta.example.com\r\n" 
     1136            "t=0 0\r\n" 
     1137            "m=audio 5200 RTP/AVP 0\r\n" 
     1138            "a=rtpmap:0 PCMU/8000\r\n" 
     1139            "m=video 5000 RTP/AVP 31\r\n" 
     1140            "a=rtpmap:31 H261/90000\r\n" 
     1141            "", 
     1142          } 
     1143        } 
     1144    }, 
     1145 
     1146    /* test 16: */ 
     1147    { 
     1148        /********************************************************************* 
     1149         * Ticket #527: More lenient SDP negotiator. 
     1150         */ 
     1151 
     1152        "Ticket #527 scenario #2: Modify offer - partial & unordered streams", 
     1153        2, 
     1154        { 
     1155          { 
     1156            LOCAL_OFFER, 
     1157            /* Alice sends offer: */ 
     1158            "v=0\r\n" 
     1159            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     1160            "s=alice\r\n" 
     1161            "c=IN IP4 host.atlanta.example.com\r\n" 
     1162            "t=0 0\r\n" 
     1163            "m=audio 3000 RTP/AVP 0\r\n" 
     1164            "a=rtpmap:0 PCMU/8000\r\n" 
     1165            "m=audio 3200 RTP/AVP 0\r\n" 
     1166            "a=rtpmap:0 PCMU/8000\r\n" 
     1167            "m=video 3400 RTP/AVP 31\r\n" 
     1168            "a=rtpmap:31 H261/90000\r\n" 
     1169            "", 
     1170            /* Receive Bob's answer: */ 
     1171            "v=0\r\n" 
     1172            "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n" 
     1173            "s=bob\r\n" 
     1174            "c=IN IP4 host.biloxi.example.com\r\n" 
     1175            "t=0 0\r\n" 
     1176            "m=audio 4000 RTP/AVP 0\r\n" 
     1177            "a=rtpmap:0 PCMU/8000\r\n" 
     1178            "m=audio 4200 RTP/AVP 0\r\n" 
     1179            "a=rtpmap:0 PCMU/8000\r\n" 
     1180            "m=video 4400 RTP/AVP 31\r\n" 
     1181            "a=rtpmap:31 H261/90000\r\n" 
     1182            "", 
     1183            /* Alice's local SDP should be: */ 
     1184            "v=0\r\n" 
     1185            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     1186            "s=alice\r\n" 
     1187            "c=IN IP4 host.atlanta.example.com\r\n" 
     1188            "t=0 0\r\n" 
     1189            "m=audio 3000 RTP/AVP 0\r\n" 
     1190            "a=rtpmap:0 PCMU/8000\r\n" 
     1191            "m=audio 3200 RTP/AVP 0\r\n" 
     1192            "a=rtpmap:0 PCMU/8000\r\n" 
     1193            "m=video 3400 RTP/AVP 31\r\n" 
     1194            "a=rtpmap:31 H261/90000\r\n" 
     1195            "", 
     1196          }, 
     1197          { 
     1198            LOCAL_OFFER, 
     1199            /* Alice modifies offer by specifying partial and unordered media: */ 
     1200            "v=0\r\n" 
     1201            "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" 
     1202            "s=alice\r\n" 
     1203            "c=IN IP4 host.atlanta.example.com\r\n" 
     1204            "t=0 0\r\n" 
     1205            "m=video 5000 RTP/AVP 31\r\n" 
     1206            "a=rtpmap:31 H261/90000\r\n" 
     1207            "m=audio 7000 RTP/AVP 0\r\n" 
     1208            "a=rtpmap:0 PCMU/8000\r\n" 
     1209            "", 
     1210            /* Receive Bob's answer: */ 
     1211            "v=0\r\n" 
     1212            "o=bob 2808844564 2808844563 IN IP4 host.biloxi.example.com\r\n" 
     1213            "s=bob\r\n" 
     1214            "c=IN IP4 host.biloxi.example.com\r\n" 
     1215            "t=0 0\r\n" 
     1216            "m=audio 4000 RTP/AVP 0\r\n" 
     1217            "a=rtpmap:0 PCMU/8000\r\n" 
     1218            "m=audio 0 RTP/AVP 0\r\n" 
     1219            "a=rtpmap:0 PCMU/8000\r\n" 
     1220            "m=video 4400 RTP/AVP 31\r\n" 
     1221            "a=rtpmap:31 H261/90000\r\n" 
     1222            "", 
     1223            /* Alice's local SDP should be: */ 
     1224            "v=0\r\n" 
     1225            "o=alice 2890844526 2890844527 IN IP4 host.atlanta.example.com\r\n" 
     1226            "s=alice\r\n" 
     1227            "c=IN IP4 host.atlanta.example.com\r\n" 
     1228            "t=0 0\r\n" 
     1229            "m=audio 7000 RTP/AVP 0\r\n" 
     1230            "a=rtpmap:0 PCMU/8000\r\n" 
     1231            "m=audio 0 RTP/AVP 0\r\n" 
     1232            "a=rtpmap:0 PCMU/8000\r\n" 
     1233            "m=video 5000 RTP/AVP 31\r\n" 
     1234            "a=rtpmap:31 H261/90000\r\n" 
     1235            "", 
    8701236          } 
    8711237        } 
     
    10761442         */ 
    10771443 
    1078         pjmedia_sdp_session *sdp2, *sdp3; 
     1444        pjmedia_sdp_session *sdp2 = NULL, *sdp3; 
    10791445        const pjmedia_sdp_session *answer; 
    10801446 
    1081         if (neg == NULL) { 
     1447        if (oa->sdp2) { 
    10821448            /* Parse and validate initial local capability */ 
    10831449            status = pjmedia_sdp_parse(pool, oa->sdp2, pj_native_strlen(oa->sdp2), 
     
    10931459                return -210; 
    10941460            } 
    1095  
     1461        } else if (neg) { 
     1462            status = pjmedia_sdp_neg_get_active_local(neg, &sdp2); 
     1463            if (status != PJ_SUCCESS) { 
     1464                app_perror(status,  
     1465                           "   error: pjmedia_sdp_neg_get_active_local"); 
     1466                return -215; 
     1467            } 
     1468        } 
     1469 
     1470        if (neg == NULL) { 
    10961471            /* Create negotiator with remote offer. */ 
    10971472            status = pjmedia_sdp_neg_create_w_remote_offer(pool, sdp2, sdp1, &neg); 
     
    11091484                return -230; 
    11101485            } 
     1486 
     1487            status = pjmedia_sdp_neg_set_local_answer(pool, neg, sdp2); 
     1488            if (status != PJ_SUCCESS) { 
     1489                app_perror(status, "   error: pjmedia_sdp_neg_set_local_answer"); 
     1490                return -235; 
     1491            } 
    11111492        } 
    11121493 
  • pjproject/trunk/pjmedia/src/test/test.c

    r1895 r1950  
    5555    mem = &caching_pool.factory; 
    5656 
    57     //DO_TEST(sdp_neg_test()); 
     57    sdp_neg_test(); 
    5858    //sdp_test (&caching_pool.factory); 
    5959    //rtp_test(&caching_pool.factory); 
    6060    //session_test (&caching_pool.factory); 
    61     jbuf_main(); 
     61    //jbuf_main(); 
    6262 
    6363    PJ_LOG(3,(THIS_FILE," ")); 
Note: See TracChangeset for help on using the changeset viewer.