Changeset 483
- Timestamp:
- Jun 1, 2006 11:37:30 AM (17 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/transport_udp.h
r452 r483 30 30 31 31 /** 32 * Create UDP stream transport. 32 * Options that can be specified when creating UDP transport. 33 */ 34 enum pjmedia_transport_udp_options 35 { 36 /** 37 * Normally the UDP transport will continuously check the source address 38 * of incoming packets to see if it is different than the configured 39 * remote address, and switch the remote address to the source address 40 * of the packet if they are different after several packets are 41 * received. 42 * Specifying this option will disable this feature. 43 */ 44 PJMEDIA_UDP_NO_SRC_ADDR_CHECKING = 1, 45 }; 46 47 48 /** 49 * Create an RTP and RTCP sockets and bind RTP the socket to the specified 50 * port to create media transport. 51 * 52 * @param endpt The media endpoint instance. 53 * @param name Optional name to be assigned to the transport. 54 * @param port UDP port number for the RTP socket. The RTCP port number 55 * will be set to one above RTP port. 56 * @param options Options, bitmask of #pjmedia_transport_udp_options. 57 * @param p_tp Pointer to receive the transport instance. 58 * 59 * @return PJ_SUCCESS on success. 33 60 */ 34 61 PJ_DECL(pj_status_t) pjmedia_transport_udp_create(pjmedia_endpt *endpt, 35 62 const char *name, 36 63 int port, 64 unsigned options, 37 65 pjmedia_transport **p_tp); 38 66 39 67 40 68 /** 41 * Create UDP stream transport from existing socket info. 69 * Create UDP stream transport from existing sockets. Use this function when 70 * the sockets have previously been created. 71 * 72 * @param endpt The media endpoint instance. 73 * @param name Optional name to be assigned to the transport. 74 * @param si Media socket info containing the RTP and RTCP sockets. 75 * @param options Options, bitmask of #pjmedia_transport_udp_options. 76 * @param p_tp Pointer to receive the transport instance. 77 * 78 * @return PJ_SUCCESS on success. 42 79 */ 43 80 PJ_DECL(pj_status_t) pjmedia_transport_udp_attach(pjmedia_endpt *endpt, 44 81 const char *name, 45 82 const pjmedia_sock_info *si, 83 unsigned options, 46 84 pjmedia_transport **p_tp); 47 85 48 86 49 87 /** 50 * Close UDP transport. 88 * Close UDP transport. Application can also use the "destroy" member of 89 * media transport interface to close the UDP transport. 51 90 */ 52 91 PJ_DECL(pj_status_t) pjmedia_transport_udp_close(pjmedia_transport *tp); -
pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c
r479 r483 37 37 38 38 pj_pool_t *pool; /**< Memory pool */ 39 39 unsigned options; /**< Transport options. */ 40 40 pjmedia_stream *stream; /**< Stream user (may be NULL) */ 41 41 pj_sockaddr_in rem_rtp_addr; /**< Remote RTP address */ … … 109 109 const char *name, 110 110 int port, 111 unsigned options, 111 112 pjmedia_transport **p_tp) 112 113 { … … 153 154 154 155 /* Create UDP transport by attaching socket info */ 155 return pjmedia_transport_udp_attach( endpt, name, &si, p_tp);156 return pjmedia_transport_udp_attach( endpt, name, &si, options, p_tp); 156 157 157 158 … … 171 172 const char *name, 172 173 const pjmedia_sock_info *si, 174 unsigned options, 173 175 pjmedia_transport **p_tp) 174 176 { … … 199 201 tp = pj_pool_zalloc(pool, sizeof(struct transport_udp)); 200 202 tp->pool = pool; 203 tp->options = options; 201 204 pj_ansi_strcpy(tp->base.name, name); 202 205 tp->base.op = &transport_udp_op; … … 320 323 321 324 /* See if source address of RTP packet is different than the 322 * configured address. 325 * configured address, and switch RTP remote address to 326 * source packet address after several consecutive packets 327 * have been received. 323 328 */ 324 if ((udp->rem_rtp_addr.sin_addr.s_addr != 325 udp->rtp_src_addr.sin_addr.s_addr) || 326 (udp->rem_rtp_addr.sin_port != 327 udp->rtp_src_addr.sin_port)) 328 { 329 udp->rtp_src_cnt++; 330 331 if (udp->rtp_src_cnt >= PJMEDIA_RTP_NAT_PROBATION_CNT) { 332 333 udp->rem_rtp_addr = udp->rtp_src_addr; 334 udp->rtp_src_cnt = 0; 335 336 PJ_LOG(4,(udp->base.name, 337 "Remote RTP address switched to %s:%d", 338 pj_inet_ntoa(udp->rtp_src_addr.sin_addr), 339 pj_ntohs(udp->rtp_src_addr.sin_port))); 329 if ((udp->options & PJMEDIA_UDP_NO_SRC_ADDR_CHECKING)==0) { 330 if ((udp->rem_rtp_addr.sin_addr.s_addr != 331 udp->rtp_src_addr.sin_addr.s_addr) || 332 (udp->rem_rtp_addr.sin_port != 333 udp->rtp_src_addr.sin_port)) 334 { 335 udp->rtp_src_cnt++; 336 337 if (udp->rtp_src_cnt >= PJMEDIA_RTP_NAT_PROBATION_CNT) { 338 339 pj_uint16_t port; 340 341 /* Set remote RTP address to source address */ 342 udp->rem_rtp_addr = udp->rtp_src_addr; 343 344 /* Also update remote RTCP address */ 345 pj_memcpy(&udp->rem_rtcp_addr, &udp->rem_rtp_addr, 346 sizeof(pj_sockaddr_in)); 347 port = (pj_uint16_t) 348 (pj_ntohs(udp->rem_rtp_addr.sin_port)+1); 349 udp->rem_rtcp_addr.sin_port = pj_htons(port); 350 351 /* Reset counter */ 352 udp->rtp_src_cnt = 0; 353 354 PJ_LOG(4,(udp->base.name, 355 "Remote RTP address switched to %s:%d", 356 pj_inet_ntoa(udp->rtp_src_addr.sin_addr), 357 pj_ntohs(udp->rtp_src_addr.sin_port))); 358 } 340 359 } 341 360 } -
pjproject/trunk/pjsip-apps/src/samples/simpleua.c
r452 r483 284 284 /* Create media transport */ 285 285 status = pjmedia_transport_udp_attach(g_med_endpt, NULL, &g_med_skinfo, 286 &g_med_transport);286 0, &g_med_transport); 287 287 if (status != PJ_SUCCESS) { 288 288 app_perror(THIS_FILE, "Unable to create media transport", status); -
pjproject/trunk/pjsip-apps/src/samples/streamutil.c
r464 r483 133 133 /* Create media transport */ 134 134 status = pjmedia_transport_udp_create(med_endpt, NULL, local_port, 135 &transport);135 0, &transport); 136 136 if (status != PJ_SUCCESS) 137 137 return status;
Note: See TracChangeset
for help on using the changeset viewer.