- Timestamp:
- Sep 23, 2019 7:24:24 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c
r6005 r6070 43 43 char buffer[PJMEDIA_MAX_MTU]; 44 44 pj_ioqueue_op_key_t op_key; 45 pj_bool_t is_pending; 45 46 } pending_write; 46 47 … … 99 100 pj_ioqueue_op_key_t *op_key, 100 101 pj_ssize_t bytes_read); 102 static void on_rtp_data_sent(pj_ioqueue_key_t *key, 103 pj_ioqueue_op_key_t *op_key, 104 pj_ssize_t bytes_sent); 101 105 static void on_rx_rtcp(pj_ioqueue_key_t *key, 102 106 pj_ioqueue_op_key_t *op_key, … … 339 343 pj_bzero(&rtp_cb, sizeof(rtp_cb)); 340 344 rtp_cb.on_read_complete = &on_rx_rtp; 345 rtp_cb.on_write_complete = &on_rtp_data_sent; 341 346 342 347 status = pj_ioqueue_register_sock(pool, ioqueue, tp->rtp_sock, tp, … … 353 358 354 359 pj_ioqueue_op_key_init(&tp->rtp_read_op, sizeof(tp->rtp_read_op)); 355 for (i=0; i<PJ_ARRAY_SIZE(tp->rtp_pending_write); ++i) 360 for (i=0; i<PJ_ARRAY_SIZE(tp->rtp_pending_write); ++i) { 361 tp->rtp_pending_write[i].is_pending = PJ_FALSE; 356 362 pj_ioqueue_op_key_init(&tp->rtp_pending_write[i].op_key, 357 363 sizeof(tp->rtp_pending_write[i].op_key)); 364 } 358 365 359 366 #if 0 // See #2097: move read op kick-off to media_start() … … 619 626 } 620 627 628 static void on_rtp_data_sent(pj_ioqueue_key_t *key, 629 pj_ioqueue_op_key_t *op_key, 630 pj_ssize_t bytes_sent) 631 { 632 struct transport_udp *udp; 633 unsigned i; 634 635 PJ_UNUSED_ARG(bytes_sent); 636 637 udp = (struct transport_udp*) pj_ioqueue_get_user_data(key); 638 639 for (i = 0; i < PJ_ARRAY_SIZE(udp->rtp_pending_write); ++i) { 640 if (&udp->rtp_pending_write[i].op_key == op_key) { 641 udp->rtp_pending_write[i].is_pending = PJ_FALSE; 642 break; 643 } 644 } 645 } 621 646 622 647 /* Notification from ioqueue about incoming RTCP packet */ … … 959 984 pj_ioqueue_post_completion(udp->rtp_key, 960 985 &udp->rtp_pending_write[i].op_key, 0); 986 udp->rtp_pending_write[i].is_pending = PJ_FALSE; 961 987 } 962 988 pj_ioqueue_post_completion(udp->rtcp_key, &udp->rtcp_write_op, 0); … … 1003 1029 id = udp->rtp_write_op_id; 1004 1030 pw = &udp->rtp_pending_write[id]; 1031 if (pw->is_pending) { 1032 /* There is still currently pending operation for this buffer. */ 1033 PJ_LOG(4,(udp->base.name, "Too many pending write operations")); 1034 return PJ_EBUSY; 1035 } 1036 pw->is_pending = PJ_TRUE; 1005 1037 1006 1038 /* We need to copy packet to our buffer because when the … … 1016 1048 &udp->rem_rtp_addr, 1017 1049 udp->addr_len); 1050 1051 if (status != PJ_EPENDING) { 1052 /* Send operation has completed immediately. Clear the flag. */ 1053 pw->is_pending = PJ_FALSE; 1054 } 1018 1055 1019 1056 udp->rtp_write_op_id = (udp->rtp_write_op_id + 1) % … … 1308 1345 #endif 1309 1346 pj_bzero(&cb, sizeof(cb)); 1310 if (is_rtp) 1347 if (is_rtp) { 1311 1348 cb.on_read_complete = &on_rx_rtp; 1312 else 1349 cb.on_write_complete = &on_rtp_data_sent; 1350 } else { 1313 1351 cb.on_read_complete = &on_rx_rtcp; 1352 } 1314 1353 1315 1354 if (is_rtp) {
Note: See TracChangeset
for help on using the changeset viewer.