- Timestamp:
- Sep 15, 2007 8:55:00 AM (17 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/transport_ice.h
r1435 r1436 217 217 218 218 219 /** 220 * Simulate packet lost in the specified direction (for testing purposes). 221 * When enabled, the transport will randomly drop packets to the specified 222 * direction. 223 * 224 * @param tp The ICE media transport. 225 * @param dir Media direction to which packets will be randomly dropped. 226 * @param pct_lost Percent lost (0-100). Set to zero to disable packet 227 * lost simulation. 228 * 229 * @return PJ_SUCCESS on success. 230 */ 231 PJ_DECL(pj_status_t) pjmedia_ice_simulate_lost(pjmedia_transport *tp, 232 pjmedia_dir dir, 233 unsigned pct_lost); 234 219 235 220 236 -
pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c
r1435 r1436 21 21 #include <pj/assert.h> 22 22 #include <pj/log.h> 23 #include <pj/rand.h> 24 23 25 24 26 struct transport_ice … … 33 35 pj_sockaddr_in remote_rtp; 34 36 pj_sockaddr_in remote_rtcp; 37 38 unsigned tx_drop_pct; /**< Percent of tx pkts to drop. */ 39 unsigned rx_drop_pct; /**< Percent of rx pkts to drop. */ 35 40 36 41 void (*rtp_cb)(void*, … … 651 656 { 652 657 struct transport_ice *tp_ice = (struct transport_ice*)tp; 658 659 /* Simulate packet lost on TX direction */ 660 if (tp_ice->tx_drop_pct) { 661 if ((pj_rand() % 100) <= (int)tp_ice->tx_drop_pct) { 662 PJ_LOG(5,(tp_ice->ice_st->obj_name, 663 "TX RTP packet dropped because of pkt lost " 664 "simulation")); 665 return PJ_SUCCESS; 666 } 667 } 668 653 669 return pj_ice_strans_sendto(tp_ice->ice_st, 1, 654 670 pkt, size, &tp_ice->remote_rtp, … … 679 695 struct transport_ice *tp_ice = (struct transport_ice*) ice_st->user_data; 680 696 681 if (comp_id==1 && tp_ice->rtp_cb) 697 if (comp_id==1 && tp_ice->rtp_cb) { 698 699 /* Simulate packet lost on RX direction */ 700 if (tp_ice->rx_drop_pct) { 701 if ((pj_rand() % 100) <= (int)tp_ice->rx_drop_pct) { 702 PJ_LOG(5,(ice_st->obj_name, 703 "RX RTP packet dropped because of pkt lost " 704 "simulation")); 705 return; 706 } 707 } 708 682 709 (*tp_ice->rtp_cb)(tp_ice->stream, pkt, size); 683 else if (comp_id==2 && tp_ice->rtcp_cb) 710 711 } else if (comp_id==2 && tp_ice->rtcp_cb) 684 712 (*tp_ice->rtcp_cb)(tp_ice->stream, pkt, size); 685 713 … … 734 762 735 763 764 /* Simulate lost */ 765 PJ_DEF(pj_status_t) pjmedia_ice_simulate_lost( pjmedia_transport *tp, 766 pjmedia_dir dir, 767 unsigned pct_lost) 768 { 769 struct transport_ice *ice = (struct transport_ice*) tp; 770 771 PJ_ASSERT_RETURN(tp && pct_lost <= 100, PJ_EINVAL); 772 773 if (dir & PJMEDIA_DIR_ENCODING) 774 ice->tx_drop_pct = pct_lost; 775 776 if (dir & PJMEDIA_DIR_DECODING) 777 ice->rx_drop_pct = pct_lost; 778 779 return PJ_SUCCESS; 780 } 781 -
pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c
r1417 r1436 700 700 struct transport_udp *udp = (struct transport_udp*)tp; 701 701 702 PJ_ASSERT_RETURN(tp && 703 (dir==PJMEDIA_DIR_ENCODING||dir==PJMEDIA_DIR_DECODING) && 704 pct_lost <= 100, PJ_EINVAL); 705 706 if (dir == PJMEDIA_DIR_ENCODING) 702 PJ_ASSERT_RETURN(tp && pct_lost <= 100, PJ_EINVAL); 703 704 if (dir & PJMEDIA_DIR_ENCODING) 707 705 udp->tx_drop_pct = pct_lost; 708 else if (dir == PJMEDIA_DIR_DECODING) 706 707 if (dir & PJMEDIA_DIR_DECODING) 709 708 udp->rx_drop_pct = pct_lost; 710 else711 return PJ_EINVAL;712 709 713 710 return PJ_SUCCESS; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r1435 r1436 612 612 goto on_error; 613 613 } 614 615 pjmedia_ice_simulate_lost(pjsua_var.calls[i].med_tp, 616 PJMEDIA_DIR_ENCODING, 617 pjsua_var.media_cfg.tx_drop_pct); 618 619 pjmedia_ice_simulate_lost(pjsua_var.calls[i].med_tp, 620 PJMEDIA_DIR_DECODING, 621 pjsua_var.media_cfg.rx_drop_pct); 614 622 615 623 status = pjmedia_ice_start_init(pjsua_var.calls[i].med_tp, 0, &addr,
Note: See TracChangeset
for help on using the changeset viewer.