Changeset 1436 for pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c
- Timestamp:
- Sep 15, 2007 8:55:00 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.