Changeset 1763
- Timestamp:
- Feb 1, 2008 2:47:31 PM (17 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/transport.h
r1748 r1763 242 242 unsigned addr_len, 243 243 void (*rtp_cb)(void *user_data, 244 constvoid *pkt,244 void *pkt, 245 245 pj_ssize_t size), 246 246 void (*rtcp_cb)(void *user_data, 247 constvoid *pkt,247 void *pkt, 248 248 pj_ssize_t size)); 249 249 … … 424 424 unsigned addr_len, 425 425 void (*rtp_cb)(void *user_data, 426 constvoid *pkt,426 void *pkt, 427 427 pj_ssize_t), 428 428 void (*rtcp_cb)(void *usr_data, 429 constvoid*pkt,429 void*pkt, 430 430 pj_ssize_t)) 431 431 { -
pjproject/trunk/pjmedia/include/pjmedia/transport_srtp.h
r1748 r1763 226 226 227 227 /** 228 * This is a utility function to decrypt SRTP packet using SRTP transport. 229 * This function is not part of SRTP transport's API, but it can be used 230 * to decrypt SRTP packets from non-network (for example, from a saved file) 231 * without having to use the transport framework. See pcaputil.c in the 232 * samples collection on how to use this function. 233 * 234 * @param tp The SRTP transport. 235 * @param is_rtp Set to non-zero if the packet is SRTP, otherwise set 236 * to zero if the packet is SRTCP. 237 * @param pkt On input, it contains SRTP or SRTCP packet. On 238 * output, it contains the decrypted RTP/RTCP packet. 239 * @param pkt_len On input, specify the length of the buffer. On 240 * output, it will be filled with the actual length 241 * of decrypted packet. 242 * 243 * @return PJ_SUCCESS on success. 244 */ 245 PJ_DECL(pj_status_t) pjmedia_transport_srtp_decrypt_pkt(pjmedia_transport *tp, 246 pj_bool_t is_rtp, 247 void *pkt, 248 int *pkt_len); 249 250 251 /** 228 252 * Query member transport of SRTP. 229 253 * -
pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c
r1735 r1763 41 41 42 42 void (*rtp_cb)(void*, 43 constvoid*,43 void*, 44 44 pj_ssize_t); 45 45 void (*rtcp_cb)(void*, 46 constvoid*,46 void*, 47 47 pj_ssize_t); 48 48 }; … … 60 60 unsigned addr_len, 61 61 void (*rtp_cb)(void*, 62 constvoid*,62 void*, 63 63 pj_ssize_t), 64 64 void (*rtcp_cb)(void*, 65 constvoid*,65 void*, 66 66 pj_ssize_t)); 67 67 static void transport_detach (pjmedia_transport *tp, … … 675 675 unsigned addr_len, 676 676 void (*rtp_cb)(void*, 677 constvoid*,677 void*, 678 678 pj_ssize_t), 679 679 void (*rtcp_cb)(void*, 680 constvoid*,680 void*, 681 681 pj_ssize_t)) 682 682 { -
pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
r1760 r1763 84 84 pj_lock_t *mutex; 85 85 char tx_buffer[MAX_BUFFER_LEN]; 86 char rx_buffer[MAX_BUFFER_LEN];87 86 88 87 pjmedia_srtp_setting setting; … … 103 102 void *user_data; 104 103 void (*rtp_cb)( void *user_data, 105 constvoid *pkt,104 void *pkt, 106 105 pj_ssize_t size); 107 106 void (*rtcp_cb)(void *user_data, 108 constvoid *pkt,107 void *pkt, 109 108 pj_ssize_t size); 110 109 … … 118 117 * This callback is called by transport when incoming rtp is received 119 118 */ 120 static void srtp_rtp_cb( void *user_data, constvoid *pkt, pj_ssize_t size);119 static void srtp_rtp_cb( void *user_data, void *pkt, pj_ssize_t size); 121 120 122 121 /* 123 122 * This callback is called by transport when incoming rtcp is received 124 123 */ 125 static void srtp_rtcp_cb( void *user_data, constvoid *pkt, pj_ssize_t size);124 static void srtp_rtcp_cb( void *user_data, void *pkt, pj_ssize_t size); 126 125 127 126 … … 137 136 unsigned addr_len, 138 137 void (*rtp_cb)(void*, 139 constvoid*,138 void*, 140 139 pj_ssize_t), 141 140 void (*rtcp_cb)(void*, 142 constvoid*,141 void*, 143 142 pj_ssize_t)); 144 143 static void transport_detach (pjmedia_transport *tp, … … 358 357 /* Initialize base pjmedia_transport */ 359 358 pj_memcpy(srtp->base.name, pool->obj_name, PJ_MAX_OBJ_NAME); 360 srtp->base.type = tp->type; 359 if (tp) 360 srtp->base.type = tp->type; 361 else 362 srtp->base.type = PJMEDIA_TRANSPORT_TYPE_UDP; 361 363 srtp->base.op = &transport_srtp_op; 362 364 … … 565 567 const pj_sockaddr_t *rem_rtcp, 566 568 unsigned addr_len, 567 void (*rtp_cb) (void*, constvoid*,569 void (*rtp_cb) (void*, void*, 568 570 pj_ssize_t), 569 void (*rtcp_cb)(void*, constvoid*,571 void (*rtcp_cb)(void*, void*, 570 572 pj_ssize_t)) 571 573 { … … 591 593 transport_srtp *srtp = (transport_srtp*) tp; 592 594 593 PJ_ASSERT_ON_FAIL(tp && srtp->real_tp, return);594 595 595 PJ_UNUSED_ARG(strm); 596 pjmedia_transport_detach(srtp->real_tp, srtp); 596 PJ_ASSERT_ON_FAIL(tp, return); 597 598 if (srtp->real_tp) { 599 pjmedia_transport_detach(srtp->real_tp, srtp); 600 } 597 601 598 602 /* Clear up application infos from transport */ … … 688 692 pjmedia_transport_detach(tp, NULL); 689 693 690 if (srtp->setting.close_member_tp ) {694 if (srtp->setting.close_member_tp && srtp->real_tp) { 691 695 pjmedia_transport_close(srtp->real_tp); 692 696 } … … 705 709 * This callback is called by transport when incoming rtp is received 706 710 */ 707 static void srtp_rtp_cb( void *user_data, constvoid *pkt, pj_ssize_t size)711 static void srtp_rtp_cb( void *user_data, void *pkt, pj_ssize_t size) 708 712 { 709 713 transport_srtp *srtp = (transport_srtp *) user_data; … … 716 720 } 717 721 718 if (size < 0 || size > sizeof(srtp->rx_buffer) ||!srtp->session_inited) {722 if (size < 0 || !srtp->session_inited) { 719 723 return; 720 724 } 721 725 726 /* Make sure buffer is 32bit aligned */ 727 PJ_ASSERT_ON_FAIL( (((long)pkt) & 0x03)==0, return ); 728 722 729 pj_lock_acquire(srtp->mutex); 723 pj_memcpy(srtp->rx_buffer, pkt, size); 724 725 err = srtp_unprotect(srtp->srtp_rx_ctx, srtp->rx_buffer, &len); 730 731 err = srtp_unprotect(srtp->srtp_rx_ctx, (pj_uint8_t*)pkt, &len); 726 732 727 733 if (err == err_status_ok) { 728 srtp->rtp_cb(srtp->user_data, srtp->rx_buffer, len);734 srtp->rtp_cb(srtp->user_data, pkt, len); 729 735 } else { 730 736 PJ_LOG(5,(srtp->pool->obj_name, … … 739 745 * This callback is called by transport when incoming rtcp is received 740 746 */ 741 static void srtp_rtcp_cb( void *user_data, constvoid *pkt, pj_ssize_t size)747 static void srtp_rtcp_cb( void *user_data, void *pkt, pj_ssize_t size) 742 748 { 743 749 transport_srtp *srtp = (transport_srtp *) user_data; … … 750 756 } 751 757 752 if (size < 0 || size > sizeof(srtp->rx_buffer) ||!srtp->session_inited) {758 if (size < 0 || !srtp->session_inited) { 753 759 return; 754 760 } 755 761 762 /* Make sure buffer is 32bit aligned */ 763 PJ_ASSERT_ON_FAIL( (((long)pkt) & 0x03)==0, return ); 764 756 765 pj_lock_acquire(srtp->mutex); 757 pj_memcpy(srtp->rx_buffer, pkt, size); 758 759 err = srtp_unprotect_rtcp(srtp->srtp_rx_ctx, srtp->rx_buffer, &len); 766 767 err = srtp_unprotect_rtcp(srtp->srtp_rx_ctx, (pj_uint8_t*)pkt, &len); 760 768 761 769 if (err == err_status_ok) { 762 srtp->rtcp_cb(srtp->user_data, srtp->rx_buffer, len);770 srtp->rtcp_cb(srtp->user_data, pkt, len); 763 771 } else { 764 772 PJ_LOG(5,(srtp->pool->obj_name, … … 1265 1273 } 1266 1274 1275 /* Utility */ 1276 PJ_DEF(pj_status_t) pjmedia_transport_srtp_decrypt_pkt(pjmedia_transport *tp, 1277 pj_bool_t is_rtp, 1278 void *pkt, 1279 int *pkt_len) 1280 { 1281 transport_srtp *srtp = (transport_srtp *)tp; 1282 err_status_t err; 1283 1284 if (srtp->bypass_srtp) 1285 return PJ_SUCCESS; 1286 1287 PJ_ASSERT_RETURN(*pkt_len>0, PJ_EINVAL); 1288 PJ_ASSERT_RETURN(srtp->session_inited, PJ_EINVALIDOP); 1289 1290 /* Make sure buffer is 32bit aligned */ 1291 PJ_ASSERT_ON_FAIL( (((long)pkt) & 0x03)==0, return PJ_EINVAL); 1292 1293 pj_lock_acquire(srtp->mutex); 1294 1295 if (is_rtp) 1296 err = srtp_unprotect(srtp->srtp_rx_ctx, pkt, pkt_len); 1297 else 1298 err = srtp_unprotect_rtcp(srtp->srtp_rx_ctx, pkt, pkt_len); 1299 1300 if (err != err_status_ok) { 1301 PJ_LOG(5,(srtp->pool->obj_name, 1302 "Failed to unprotect SRTP, pkt size=%d, err=%s", 1303 *pkt_len, get_libsrtp_errstr(err))); 1304 } 1305 1306 pj_lock_release(srtp->mutex); 1307 1308 return (err==err_status_ok) ? PJ_SUCCESS : PJMEDIA_ERRNO_FROM_LIBSRTP(err); 1309 } 1310 1267 1311 #endif 1268 1312 -
pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c
r1748 r1763 56 56 int addr_len; /**< Length of addresses. */ 57 57 void (*rtp_cb)( void*, /**< To report incoming RTP. */ 58 constvoid*,58 void*, 59 59 pj_ssize_t); 60 60 void (*rtcp_cb)( void*, /**< To report incoming RTCP. */ 61 constvoid*,61 void*, 62 62 pj_ssize_t); 63 63 … … 106 106 unsigned addr_len, 107 107 void (*rtp_cb)(void*, 108 constvoid*,108 void*, 109 109 pj_ssize_t), 110 110 void (*rtcp_cb)(void*, 111 constvoid*,111 void*, 112 112 pj_ssize_t)); 113 113 static void transport_detach (pjmedia_transport *tp, … … 420 420 421 421 do { 422 void (*cb)(void*, constvoid*,pj_ssize_t);422 void (*cb)(void*,void*,pj_ssize_t); 423 423 void *user_data; 424 424 … … 524 524 525 525 do { 526 void (*cb)(void*, constvoid*,pj_ssize_t);526 void (*cb)(void*,void*,pj_ssize_t); 527 527 void *user_data; 528 528 … … 588 588 unsigned addr_len, 589 589 void (*rtp_cb)(void*, 590 constvoid*,590 void*, 591 591 pj_ssize_t), 592 592 void (*rtcp_cb)(void*, 593 constvoid*,593 void*, 594 594 pj_ssize_t)) 595 595 {
Note: See TracChangeset
for help on using the changeset viewer.