Changeset 5478
- Timestamp:
- Nov 3, 2016 9:39:20 AM (8 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/transport.h
r4811 r5478 242 242 243 243 /** 244 * Forward declaration for media transport attach param. 245 */ 246 typedef struct pjmedia_transport_attach_param pjmedia_transport_attach_param; 247 248 /** 244 249 * This enumeration specifies the general behaviour of media processing 245 250 */ … … 304 309 * to be used by the stream for the first time, and it tells the transport 305 310 * about remote RTP address to send the packet and some callbacks to be 306 * called for incoming packets. 311 * called for incoming packets. This function exists for backwards 312 * compatibility. Transports should implement attach2 instead. 307 313 * 308 314 * Application should call #pjmedia_transport_attach() instead of … … 434 440 */ 435 441 pj_status_t (*destroy)(pjmedia_transport *tp); 442 443 /** 444 * This function is called by the stream when the transport is about 445 * to be used by the stream for the first time, and it tells the transport 446 * about remote RTP address to send the packet and some callbacks to be 447 * called for incoming packets. 448 * 449 * Application should call #pjmedia_transport_attach2() instead of 450 * calling this function directly. 451 */ 452 pj_status_t (*attach2)(pjmedia_transport *tp, 453 pjmedia_transport_attach_param *att_param); 436 454 }; 437 455 … … 546 564 }; 547 565 566 567 /** 568 * This structure describes the data passed when calling 569 * #pjmedia_transport_attach2(). 570 */ 571 struct pjmedia_transport_attach_param 572 { 573 /** 574 * The media stream. 575 */ 576 void *stream; 577 578 /** 579 * Indicate the stream type, either it's audio (PJMEDIA_TYPE_AUDIO) 580 * or video (PJMEDIA_TYPE_VIDEO). 581 */ 582 pjmedia_type media_type; 583 584 /** 585 * Remote RTP address to send RTP packet to. 586 */ 587 pj_sockaddr rem_addr; 588 589 /** 590 * Optional remote RTCP address. If the argument is NULL 591 * or if the address is zero, the RTCP address will be 592 * calculated from the RTP address (which is RTP port plus one). 593 */ 594 pj_sockaddr rem_rtcp; 595 596 /** 597 * Length of the remote address. 598 */ 599 unsigned addr_len; 600 601 /** 602 * Arbitrary user data to be set when the callbacks are called. 603 */ 604 void *user_data; 605 606 /** 607 * Callback to be called when RTP packet is received on the transport. 608 */ 609 void (*rtp_cb)(void *user_data, void *pkt, pj_ssize_t); 610 611 /** 612 * Callback to be called when RTCP packet is received on the transport. 613 */ 614 void (*rtcp_cb)(void *user_data, void *pkt, pj_ssize_t); 615 }; 548 616 549 617 /** … … 600 668 } 601 669 return NULL; 670 } 671 672 673 /** 674 * Attach callbacks to be called on receipt of incoming RTP/RTCP packets. 675 * This is just a simple wrapper which calls <tt>attach2()</tt> member of 676 * the transport if it is implemented, otherwise it calls <tt>attach()</tt> 677 * member of the transport. 678 * 679 * @param tp The media transport. 680 * @param att_param The transport attach param. 681 * 682 * @return PJ_SUCCESS on success, or the appropriate error code. 683 */ 684 PJ_INLINE(pj_status_t) pjmedia_transport_attach2(pjmedia_transport *tp, 685 pjmedia_transport_attach_param *att_param) 686 { 687 if (tp->op->attach2) { 688 return tp->op->attach2(tp, att_param); 689 } else { 690 return tp->op->attach(tp, att_param->user_data, 691 (pj_sockaddr_t*)&att_param->rem_addr, 692 (pj_sockaddr_t*)&att_param->rem_rtcp, 693 att_param->addr_len, att_param->rtp_cb, 694 att_param->rtcp_cb); 695 } 602 696 } 603 697 -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r5434 r5478 2006 2006 char *p; 2007 2007 pj_status_t status; 2008 pjmedia_transport_attach_param att_param; 2008 2009 2009 2010 PJ_ASSERT_RETURN(endpt && info && p_stream, PJ_EINVAL); … … 2347 2348 2348 2349 stream->out_rtcp_pkt = pj_pool_alloc(pool, stream->out_rtcp_pkt_size); 2350 att_param.stream = stream; 2351 att_param.media_type = PJMEDIA_TYPE_AUDIO; 2352 att_param.user_data = stream; 2353 pj_sockaddr_cp(&att_param.rem_addr, &info->rem_addr); 2354 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp); 2355 att_param.addr_len = pj_sockaddr_get_len(&info->rem_addr); 2356 att_param.rtp_cb = &on_rx_rtp; 2357 att_param.rtcp_cb = &on_rx_rtcp; 2349 2358 2350 2359 /* Only attach transport when stream is ready. */ 2351 status = pjmedia_transport_attach(tp, stream, &info->rem_addr, 2352 &info->rem_rtcp, 2353 pj_sockaddr_get_len(&info->rem_addr), 2354 &on_rx_rtp, &on_rx_rtcp); 2360 status = pjmedia_transport_attach2(tp, &att_param); 2355 2361 if (status != PJ_SUCCESS) 2356 2362 goto err_cleanup; -
pjproject/trunk/pjmedia/src/pjmedia/transport_adapter_sample.c
r3841 r5478 27 27 static pj_status_t transport_get_info (pjmedia_transport *tp, 28 28 pjmedia_transport_info *info); 29 static pj_status_t transport_attach (pjmedia_transport *tp, 30 void *user_data, 31 const pj_sockaddr_t *rem_addr, 32 const pj_sockaddr_t *rem_rtcp, 33 unsigned addr_len, 34 void (*rtp_cb)(void*, 35 void*, 36 pj_ssize_t), 37 void (*rtcp_cb)(void*, 38 void*, 39 pj_ssize_t)); 29 static pj_status_t transport_attach2 (pjmedia_transport *tp, 30 pjmedia_transport_attach_param *att_prm); 40 31 static void transport_detach (pjmedia_transport *tp, 41 32 void *strm); … … 77 68 { 78 69 &transport_get_info, 79 &transport_attach,70 NULL, 80 71 &transport_detach, 81 72 &transport_send_rtp, … … 87 78 &transport_media_stop, 88 79 &transport_simulate_lost, 89 &transport_destroy 80 &transport_destroy, 81 &transport_attach2, 90 82 }; 91 83 … … 101 93 /* Stream information. */ 102 94 void *stream_user_data; 95 void *stream_ref; 103 96 void (*stream_rtp_cb)(void *user_data, 104 97 void *pkt, … … 191 184 } 192 185 193 194 /* 195 * attach() is called by stream to register callbacks that we should 186 /* 187 * attach2() is called by stream to register callbacks that we should 196 188 * call on receipt of RTP and RTCP packets. 197 189 */ 198 static pj_status_t transport_attach(pjmedia_transport *tp, 199 void *user_data, 200 const pj_sockaddr_t *rem_addr, 201 const pj_sockaddr_t *rem_rtcp, 202 unsigned addr_len, 203 void (*rtp_cb)(void*, 204 void*, 205 pj_ssize_t), 206 void (*rtcp_cb)(void*, 207 void*, 208 pj_ssize_t)) 190 static pj_status_t transport_attach2(pjmedia_transport *tp, 191 pjmedia_transport_attach_param *att_param) 209 192 { 210 193 struct tp_adapter *adapter = (struct tp_adapter*)tp; … … 216 199 */ 217 200 pj_assert(adapter->stream_user_data == NULL); 218 adapter->stream_user_data = user_data; 219 adapter->stream_rtp_cb = rtp_cb; 220 adapter->stream_rtcp_cb = rtcp_cb; 221 222 status = pjmedia_transport_attach(adapter->slave_tp, adapter, rem_addr, 223 rem_rtcp, addr_len, &transport_rtp_cb, 224 &transport_rtcp_cb); 201 adapter->stream_user_data = att_param->user_data; 202 adapter->stream_rtp_cb = att_param->rtp_cb; 203 adapter->stream_rtcp_cb = att_param->rtcp_cb; 204 adapter->stream_ref = att_param->stream; 205 206 att_param->rtp_cb = &transport_rtp_cb; 207 att_param->rtcp_cb = &transport_rtcp_cb; 208 att_param->user_data = adapter; 209 210 status = pjmedia_transport_attach2(adapter->slave_tp, att_param); 225 211 if (status != PJ_SUCCESS) { 226 212 adapter->stream_user_data = NULL; 227 213 adapter->stream_rtp_cb = NULL; 228 214 adapter->stream_rtcp_cb = NULL; 215 adapter->stream_ref = NULL; 229 216 return status; 230 217 } … … 248 235 adapter->stream_rtp_cb = NULL; 249 236 adapter->stream_rtcp_cb = NULL; 237 adapter->stream_ref = NULL; 250 238 } 251 239 } -
pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c
r5434 r5478 1425 1425 char *p; 1426 1426 pj_status_t status; 1427 pjmedia_transport_attach_param att_param; 1427 1428 1428 1429 if (!pool) { … … 1666 1667 1667 1668 stream->out_rtcp_pkt = pj_pool_alloc(pool, stream->out_rtcp_pkt_size); 1669 att_param.stream = stream; 1670 att_param.media_type = PJMEDIA_TYPE_VIDEO; 1671 att_param.user_data = stream; 1672 pj_sockaddr_cp(&att_param.rem_addr, &info->rem_addr); 1673 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp); 1674 att_param.addr_len = pj_sockaddr_get_len(&info->rem_addr); 1675 att_param.rtp_cb = &on_rx_rtp; 1676 att_param.rtcp_cb = &on_rx_rtcp; 1668 1677 1669 1678 /* Only attach transport when stream is ready. */ 1670 status = pjmedia_transport_attach(tp, stream, &info->rem_addr, 1671 &info->rem_rtcp, 1672 pj_sockaddr_get_len(&info->rem_addr), 1673 &on_rx_rtp, &on_rx_rtcp); 1679 status = pjmedia_transport_attach2(tp, &att_param); 1674 1680 if (status != PJ_SUCCESS) 1675 1681 return status;
Note: See TracChangeset
for help on using the changeset viewer.