- Timestamp:
- Mar 22, 2007 11:59:03 AM (18 years ago)
- Location:
- pjproject/trunk/pjnath
- Files:
-
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/build/pjnath_test.dsp
r1093 r1095 88 88 # Begin Source File 89 89 90 SOURCE="..\src\pjnath-test\ice .c"90 SOURCE="..\src\pjnath-test\ice_test.c" 91 91 # End Source File 92 92 # Begin Source File -
pjproject/trunk/pjnath/src/pjnath-test/ice_test.c
r1094 r1095 30 30 unsigned rx_rtcp_cnt; 31 31 32 char rx_rtp_data[32]; 33 char rx_rtcp_data[32]; 32 unsigned rx_rtp_count; 33 char last_rx_rtp_data[32]; 34 unsigned rx_rtcp_count; 35 char last_rx_rtcp_data[32]; 34 36 }; 35 37 … … 55 57 56 58 id->rx_rtp_cnt++; 57 pj_memcpy(id->rx_rtp_data, pkt, size); 59 pj_memcpy(id->last_rx_rtp_data, pkt, size); 60 id->last_rx_rtp_data[size] = '\0'; 58 61 59 62 PJ_UNUSED_ARG(src_addr); … … 70 73 71 74 id->rx_rtcp_cnt++; 72 pj_memcpy(id->rx_rtcp_data, pkt, size); 75 pj_memcpy(id->last_rx_rtcp_data, pkt, size); 76 id->last_rx_rtcp_data[size] = '\0'; 73 77 74 78 PJ_UNUSED_ARG(src_addr); … … 103 107 pj_bzero(&icemt_cb, sizeof(icemt_cb)); 104 108 icemt_cb.on_ice_complete = &on_ice_complete; 105 icemt_cb.on_rx_rt cp = &on_rx_rtp;109 icemt_cb.on_rx_rtp = &on_rx_rtp; 106 110 icemt_cb.on_rx_rtcp = &on_rx_rtcp; 107 111 … … 153 157 * acand Additional candidates to be added to answerer 154 158 * 155 * The additional candidates are invalid candidates, meaning they156 * won't be reachable by the agents. They are used to "confuse"159 * The additional candidates are normally invalid candidates, meaning 160 * they won't be reachable by the agents. They are used to "confuse" 157 161 * ICE processing. 158 162 */ 159 163 static int perform_ice_test(const char *title, 164 unsigned wait_before_send, 165 unsigned max_total_time, 160 166 unsigned ocand_cnt, 161 167 const pj_ice_cand ocand[], … … 168 174 pj_timestamp t_start, t_end; 169 175 pj_ice_cand *rcand; 176 pj_str_t data_from_offerer, data_from_answerer; 170 177 unsigned i; 171 178 pj_status_t status; … … 175 182 pj_bzero(&icemt_cb, sizeof(icemt_cb)); 176 183 icemt_cb.on_ice_complete = &on_ice_complete; 177 icemt_cb.on_rx_rt cp = &on_rx_rtp;184 icemt_cb.on_rx_rtp = &on_rx_rtp; 178 185 icemt_cb.on_rx_rtcp = &on_rx_rtcp; 179 186 … … 253 260 #endif 254 261 262 /* Poll for wait_before_send msecs before we send the first data */ 263 for (;;) { 264 pj_timestamp t_now; 265 266 handle_events(1); 267 268 pj_get_timestamp(&t_now); 269 if (pj_elapsed_msec(&t_start, &t_now) >= wait_before_send) 270 break; 271 } 272 273 /* Send data. It must be successful! */ 274 data_from_offerer = pj_str("from offerer"); 275 status = pj_ice_send_data(im1->ice, 1, data_from_offerer.ptr, data_from_offerer.slen); 276 if (status != PJ_SUCCESS) 277 return -47; 278 279 data_from_answerer = pj_str("from answerer"); 280 status = pj_ice_send_data(im2->ice, 1, data_from_answerer.ptr, data_from_answerer.slen); 281 if (status != PJ_SUCCESS) 282 return -48; 283 284 /* Poll to allow data to be received */ 285 for (;;) { 286 pj_timestamp t_now; 287 handle_events(1); 288 pj_get_timestamp(&t_now); 289 if (pj_elapsed_msec(&t_start, &t_now) >= (wait_before_send + 200)) 290 break; 291 } 292 293 255 294 /* Just wait until both completes, or timed out */ 256 295 while (!id1->complete || !id2->complete) { … … 260 299 261 300 pj_get_timestamp(&t_now); 262 if (pj_elapsed_msec(&t_start, &t_now) >= 10000) {301 if (pj_elapsed_msec(&t_start, &t_now) >= max_total_time) { 263 302 PJ_LOG(3,(THIS_FILE, "....error: timed-out")); 264 303 return -50; … … 289 328 } 290 329 330 /* Check that data is received in offerer */ 331 if (id1->rx_rtp_cnt != 1) { 332 PJ_LOG(3,(THIS_FILE, "....error: data not received in offerer")); 333 return -80; 334 } 335 if (pj_strcmp2(&data_from_answerer, id1->last_rx_rtp_data) != 0) { 336 PJ_LOG(3,(THIS_FILE, "....error: data mismatch in offerer")); 337 return -82; 338 } 339 340 /* And the same in answerer */ 341 if (id2->rx_rtp_cnt != 1) { 342 PJ_LOG(3,(THIS_FILE, "....error: data not received in answerer")); 343 return -84; 344 } 345 if (pj_strcmp2(&data_from_offerer, id2->last_rx_rtp_data) != 0) { 346 PJ_LOG(3,(THIS_FILE, "....error: data mismatch in answerer")); 347 return -82; 348 } 349 350 291 351 /* Done */ 292 352 PJ_LOG(3,(THIS_FILE, "....success: ICE completed in %d msec", … … 299 359 300 360 pj_get_timestamp(&t_now); 301 if (pj_elapsed_msec(&t_ end, &t_now) > 10000)361 if (pj_elapsed_msec(&t_start, &t_now) > max_total_time) 302 362 break; 303 363 … … 336 396 337 397 /* Direct communication */ 338 rc = perform_ice_test("Direct connection", 0, NULL, 0, NULL);398 rc = perform_ice_test("Direct connection", 500, 1000, 0, NULL, 0, NULL); 339 399 if (rc != 0) 340 400 goto on_return; … … 348 408 ocand[0].type = PJ_ICE_CAND_TYPE_HOST; 349 409 350 rc = perform_ice_test("Direct connection with 1 invalid address", 1, ocand, 0, NULL);410 rc = perform_ice_test("Direct connection with 1 invalid address", 500, 1000, 1, ocand, 0, NULL); 351 411 if (rc != 0) 352 412 goto on_return; 413 414 /* Direct communication with two components */ 415 rc = perform_ice_test("Direct connection with two components", 500, 1000, 0, NULL, 0, NULL); 416 if (rc != 0) 417 goto on_return; 418 353 419 354 420 -
pjproject/trunk/pjnath/src/pjnath-test/main.c
r1094 r1095 51 51 if (argc == 2 && pj_ansi_strcmp(argv[1], "-i")==0) { 52 52 char buf[10]; 53 54 puts("Press <ENTER> to exit"); 53 55 fgets(buf, sizeof(buf), stdin); 54 56 } -
pjproject/trunk/pjnath/src/pjnath/ice_mt.c
r1093 r1095 271 271 pj_icemt *icemt = (pj_icemt*)ice->user_data; 272 272 273 if (comp_id == RTP_COMP_ID ) {273 if (comp_id == RTP_COMP_ID && icemt->cb.on_rx_rtp) { 274 274 (*icemt->cb.on_rx_rtp)(icemt, pkt, size, src_addr, src_addr_len); 275 } else if (comp_id == RTCP_COMP_ID ) {275 } else if (comp_id == RTCP_COMP_ID && icemt->cb.on_rx_rtcp) { 276 276 (*icemt->cb.on_rx_rtcp)(icemt, pkt, size, src_addr, src_addr_len); 277 } else { 278 pj_assert(!"Invalid comp_id"); 279 return -1; 280 } 281 282 return PJ_SUCCESS; 283 } 284 285 277 } 278 return PJ_SUCCESS; 279 } 280 281
Note: See TracChangeset
for help on using the changeset viewer.