- Timestamp:
- Dec 3, 2007 2:38:25 PM (17 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/build.symbian/pjmediaU.def
r1589 r1615 175 175 pjmedia_transport_udp_create @ 174 NONAME 176 176 pjmedia_transport_udp_create2 @ 175 NONAME 177 pjmedia_transport_udp_get_info @ 176 NONAME 178 pjmedia_transport_udp_simulate_lost @ 177 NONAME 179 pjmedia_wav_player_port_create @ 178 NONAME 180 pjmedia_wav_player_port_get_pos @ 179 NONAME 181 pjmedia_wav_player_port_set_pos @ 180 NONAME 182 pjmedia_wav_player_set_eof_cb @ 181 NONAME 183 pjmedia_wav_playlist_create @ 182 NONAME 184 pjmedia_wav_playlist_set_eof_cb @ 183 NONAME 185 pjmedia_wav_writer_port_create @ 184 NONAME 186 pjmedia_wav_writer_port_get_pos @ 185 NONAME 187 pjmedia_wav_writer_port_set_cb @ 186 NONAME 188 pjmedia_wave_hdr_file_to_host @ 187 NONAME 189 pjmedia_wave_hdr_host_to_file @ 188 NONAME 177 pjmedia_transport_udp_create3 @ 176 NONAME 178 pjmedia_transport_udp_get_info @ 177 NONAME 179 pjmedia_transport_udp_simulate_lost @ 178 NONAME 180 pjmedia_wav_player_port_create @ 179 NONAME 181 pjmedia_wav_player_port_get_pos @ 180 NONAME 182 pjmedia_wav_player_port_set_pos @ 181 NONAME 183 pjmedia_wav_player_set_eof_cb @ 182 NONAME 184 pjmedia_wav_playlist_create @ 183 NONAME 185 pjmedia_wav_playlist_set_eof_cb @ 184 NONAME 186 pjmedia_wav_writer_port_create @ 185 NONAME 187 pjmedia_wav_writer_port_get_pos @ 186 NONAME 188 pjmedia_wav_writer_port_set_cb @ 187 NONAME 189 pjmedia_wave_hdr_file_to_host @ 188 NONAME 190 pjmedia_wave_hdr_host_to_file @ 189 NONAME -
pjproject/trunk/pjmedia/include/pjmedia/stream.h
r974 r1615 91 91 pjmedia_type type; /**< Media type (audio, video) */ 92 92 pjmedia_dir dir; /**< Media direction. */ 93 pj_sockaddr _inrem_addr; /**< Remote RTP address */94 pj_sockaddr _inrem_rtcp; /**< Optional remote RTCP address. If93 pj_sockaddr rem_addr; /**< Remote RTP address */ 94 pj_sockaddr rem_rtcp; /**< Optional remote RTCP address. If 95 95 sin_family is zero, the RTP address 96 96 will be calculated from RTP. */ -
pjproject/trunk/pjmedia/include/pjmedia/transport_udp.h
r1112 r1615 113 113 114 114 /** 115 * Another variant of #pjmedia_transport_udp_create() which allows 116 * the creation of IPv6 transport. 117 * 118 * @param endpt The media endpoint instance. 119 * @param af Address family, which can be pj_AF_INET() for IPv4 or 120 * pj_AF_INET6() for IPv6. 121 * @param name Optional name to be assigned to the transport. 122 * @param addr Optional local address to bind the sockets to. If this 123 * argument is NULL or empty, the sockets will be bound 124 * to all interface. 125 * @param port UDP port number for the RTP socket. The RTCP port number 126 * will be set to one above RTP port. 127 * @param options Options, bitmask of #pjmedia_transport_udp_options. 128 * @param p_tp Pointer to receive the transport instance. 129 * 130 * @return PJ_SUCCESS on success. 131 */ 132 PJ_DECL(pj_status_t) pjmedia_transport_udp_create3(pjmedia_endpt *endpt, 133 int af, 134 const char *name, 135 const pj_str_t *addr, 136 int port, 137 unsigned options, 138 pjmedia_transport **p_tp); 139 140 /** 115 141 * Get media socket info from the specified UDP transport. 116 142 * -
pjproject/trunk/pjmedia/include/pjmedia/types.h
r974 r1615 142 142 * with STUN). 143 143 */ 144 pj_sockaddr _inrtp_addr_name;144 pj_sockaddr rtp_addr_name; 145 145 146 146 /** The RTCP socket handle. */ … … 152 152 * with STUN). 153 153 */ 154 pj_sockaddr _inrtcp_addr_name;154 pj_sockaddr rtcp_addr_name; 155 155 156 156 } pjmedia_sock_info; -
pjproject/trunk/pjmedia/src/pjmedia/endpoint.c
r1589 r1615 35 35 static const pj_str_t STR_IN = { "IN", 2 }; 36 36 static const pj_str_t STR_IP4 = { "IP4", 3}; 37 static const pj_str_t STR_IP6 = { "IP6", 3}; 37 38 static const pj_str_t STR_RTP_AVP = { "RTP/AVP", 7 }; 38 39 static const pj_str_t STR_SDP_NAME = { "pjmedia", 7 }; … … 290 291 pj_time_val tv; 291 292 unsigned i; 293 const pj_sockaddr *addr0; 292 294 pjmedia_sdp_session *sdp; 293 295 pjmedia_sdp_media *m; … … 303 305 /* Create and initialize basic SDP session */ 304 306 sdp = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_session); 307 308 addr0 = &sock_info[0].rtp_addr_name; 305 309 306 310 pj_gettimeofday(&tv); … … 308 312 sdp->origin.version = sdp->origin.id = tv.sec + 2208988800UL; 309 313 sdp->origin.net_type = STR_IN; 310 sdp->origin.addr_type = STR_IP4; 311 pj_strdup2(pool, &sdp->origin.addr, 312 pj_inet_ntoa(sock_info[0].rtp_addr_name.sin_addr)); 314 315 if (addr0->addr.sa_family == pj_AF_INET()) { 316 sdp->origin.addr_type = STR_IP4; 317 pj_strdup2(pool, &sdp->origin.addr, 318 pj_inet_ntoa(addr0->ipv4.sin_addr)); 319 } else if (addr0->addr.sa_family == pj_AF_INET6()) { 320 char tmp_addr[PJ_INET6_ADDRSTRLEN]; 321 322 sdp->origin.addr_type = STR_IP6; 323 pj_strdup2(pool, &sdp->origin.addr, 324 pj_sockaddr_print(addr0, tmp_addr, sizeof(tmp_addr), 0)); 325 326 } else { 327 pj_assert(!"Invalid address family"); 328 return PJ_EAFNOTSUP; 329 } 330 313 331 sdp->name = STR_SDP_NAME; 314 332 … … 317 335 */ 318 336 sdp->conn = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_conn); 319 sdp->conn->net_type = STR_IN; 320 sdp->conn->addr_type = STR_IP4; 321 pj_strdup2(pool, &sdp->conn->addr, 322 pj_inet_ntoa(sock_info[0].rtp_addr_name.sin_addr)); 337 sdp->conn->net_type = sdp->origin.net_type; 338 sdp->conn->addr_type = sdp->origin.addr_type; 339 sdp->conn->addr = sdp->origin.addr; 323 340 324 341 … … 335 352 /* Standard media info: */ 336 353 pj_strdup(pool, &m->desc.media, &STR_AUDIO); 337 m->desc.port = pj_ ntohs(sock_info[0].rtp_addr_name.sin_port);354 m->desc.port = pj_sockaddr_get_port(addr0); 338 355 m->desc.port_count = 1; 339 356 pj_strdup (pool, &m->desc.transport, &STR_RTP_AVP); … … 345 362 /* Add "rtcp" attribute */ 346 363 #if defined(PJMEDIA_HAS_RTCP_IN_SDP) && PJMEDIA_HAS_RTCP_IN_SDP!=0 347 if (sock_info->rtcp_addr_name.sin_family != 0) { 364 if (sock_info->rtcp_addr_name.addr.sa_family != 0) { 365 const pj_sockaddr *rtcp_addr = &sock_info->rtcp_addr_name; 366 348 367 attr = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_attr); 349 368 attr->name = pj_str("rtcp"); 350 369 attr->value.ptr = (char*) pj_pool_alloc(pool, 80); 351 attr->value.slen = 352 pj_ansi_snprintf(attr->value.ptr, 80, 353 "%u IN IP4 %s", 354 pj_ntohs(sock_info[0].rtcp_addr_name.sin_port), 355 pj_inet_ntoa(sock_info[0].rtcp_addr_name.sin_addr)); 370 if (rtcp_addr->addr.sa_family == pj_AF_INET()) { 371 attr->value.slen = 372 pj_ansi_snprintf(attr->value.ptr, 80, 373 "%u IN IP4 %s", 374 pj_ntohs(rtcp_addr->ipv4.sin_port), 375 pj_inet_ntoa(rtcp_addr->ipv4.sin_addr)); 376 } else if (rtcp_addr->addr.sa_family == pj_AF_INET6()) { 377 char tmp_addr[PJ_INET6_ADDRSTRLEN]; 378 attr->value.slen = 379 pj_ansi_snprintf(attr->value.ptr, 80, 380 "%u IN IP6 %s", 381 pj_sockaddr_get_port(rtcp_addr), 382 pj_sockaddr_print(rtcp_addr, tmp_addr, 383 sizeof(tmp_addr), 0)); 384 385 } else { 386 pj_assert(!"Unsupported address family"); 387 return PJ_EAFNOTSUP; 388 } 356 389 pjmedia_sdp_attr_add(&m->attr_count, m->attr, attr); 357 390 } -
pjproject/trunk/pjmedia/src/pjmedia/session.c
r1448 r1615 53 53 static const pj_str_t ID_IN = { "IN", 2 }; 54 54 static const pj_str_t ID_IP4 = { "IP4", 3}; 55 static const pj_str_t ID_RTP_AVP = { "RTP/AVP", 7 }; 56 static const pj_str_t ID_SDP_NAME = { "pjmedia", 7 }; 55 static const pj_str_t ID_IP6 = { "IP6", 3}; 56 /*static const pj_str_t ID_RTP_AVP = { "RTP/AVP", 7 };*/ 57 /*static const pj_str_t ID_SDP_NAME = { "pjmedia", 7 };*/ 57 58 static const pj_str_t ID_RTPMAP = { "rtpmap", 6 }; 58 59 static const pj_str_t ID_TELEPHONE_EVENT = { "telephone-event", 15 }; … … 130 131 const pjmedia_sdp_conn *local_conn; 131 132 const pjmedia_sdp_conn *rem_conn; 133 int rem_af, local_af; 134 pj_sockaddr local_addr; 132 135 pjmedia_sdp_rtpmap *rtpmap; 133 136 int local_fmtp_mode = 0, rem_fmtp_mode = 0; … … 186 189 } 187 190 191 /* Check address family in remote SDP */ 192 rem_af = pj_AF_UNSPEC(); 193 if (pj_stricmp(&rem_conn->net_type, &ID_IN)==0) { 194 if (pj_stricmp(&rem_conn->addr_type, &ID_IP4)==0) { 195 rem_af = pj_AF_INET(); 196 } else if (pj_stricmp(&rem_conn->addr_type, &ID_IP6)==0) { 197 rem_af = pj_AF_UNSPEC(); 198 } 199 } 200 201 if (rem_af==pj_AF_UNSPEC()) { 202 /* Unsupported address family */ 203 return PJ_EAFNOTSUP; 204 } 205 206 /* Set remote address: */ 207 status = pj_sockaddr_init(rem_af, &si->rem_addr, &rem_conn->addr, 208 rem_m->desc.port); 209 if (status != PJ_SUCCESS) { 210 /* Invalid IP address. */ 211 return PJMEDIA_EINVALIDIP; 212 } 213 214 /* Check address family of local info */ 215 local_af = pj_AF_UNSPEC(); 216 if (pj_stricmp(&local_conn->net_type, &ID_IN)==0) { 217 if (pj_stricmp(&local_conn->addr_type, &ID_IP4)==0) { 218 local_af = pj_AF_INET(); 219 } else if (pj_stricmp(&local_conn->addr_type, &ID_IP6)==0) { 220 local_af = pj_AF_UNSPEC(); 221 } 222 } 223 224 if (local_af==pj_AF_UNSPEC()) { 225 /* Unsupported address family */ 226 return PJ_EAFNOTSUP; 227 } 228 229 /* Set remote address: */ 230 status = pj_sockaddr_init(local_af, &local_addr, &local_conn->addr, 231 local_m->desc.port); 232 if (status != PJ_SUCCESS) { 233 /* Invalid IP address. */ 234 return PJMEDIA_EINVALIDIP; 235 } 236 237 /* Local and remote address family must match */ 238 if (local_af != rem_af) 239 return PJ_EAFNOTSUP; 240 188 241 /* Media direction: */ 189 242 190 243 if (local_m->desc.port == 0 || 191 pj_ inet_addr(&local_conn->addr).s_addr==0||192 pj_ inet_addr(&rem_conn->addr).s_addr==0||244 pj_sockaddr_has_addr(&local_addr)==PJ_FALSE || 245 pj_sockaddr_has_addr(&si->rem_addr)==PJ_FALSE || 193 246 pjmedia_sdp_media_find_attr(local_m, &STR_INACTIVE, NULL)!=NULL) 194 247 { … … 215 268 si->dir = PJMEDIA_DIR_ENCODING_DECODING; 216 269 217 }218 219 220 /* Set remote address: */221 status = pj_sockaddr_in_init(&si->rem_addr, &rem_conn->addr,222 rem_m->desc.port);223 if (status != PJ_SUCCESS) {224 /* Invalid IP address. */225 return PJMEDIA_EINVALIDIP;226 270 } 227 271 … … 236 280 if (status == PJ_SUCCESS) { 237 281 if (rtcp.addr.slen) { 238 status = pj_sockaddr_in _init(&si->rem_rtcp, &rtcp.addr,239 282 status = pj_sockaddr_init(rem_af, &si->rem_rtcp, &rtcp.addr, 283 (pj_uint16_t)rtcp.port); 240 284 } else { 241 pj_sockaddr_in_init(&si->rem_rtcp, NULL, 242 (pj_uint16_t)rtcp.port); 243 si->rem_rtcp.sin_addr.s_addr = si->rem_addr.sin_addr.s_addr; 285 pj_sockaddr_init(rem_af, &si->rem_rtcp, NULL, 286 (pj_uint16_t)rtcp.port); 287 pj_memcpy(pj_sockaddr_get_addr(&si->rem_rtcp), 288 pj_sockaddr_get_addr(&si->rem_addr), 289 pj_sockaddr_get_addr_len(&si->rem_addr)); 244 290 } 245 291 } 246 292 } 247 293 248 if ( si->rem_rtcp.sin_addr.s_addr== 0) {294 if (!pj_sockaddr_has_addr(&si->rem_rtcp) == 0) { 249 295 int rtcp_port; 250 296 251 pj_memcpy(&si->rem_rtcp, &si->rem_addr, sizeof(pj_sockaddr _in));252 rtcp_port = pj_ ntohs(si->rem_addr.sin_port) + 1;253 si->rem_rtcp.sin_port = pj_htons((pj_uint16_t)rtcp_port);297 pj_memcpy(&si->rem_rtcp, &si->rem_addr, sizeof(pj_sockaddr)); 298 rtcp_port = pj_sockaddr_get_port(&si->rem_addr) + 1; 299 pj_sockaddr_set_port(&si->rem_rtcp, (pj_uint16_t)rtcp_port); 254 300 } 255 301 -
pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c
r1607 r1615 52 52 void *user_data; /**< Only valid when attached */ 53 53 pj_bool_t attached; /**< Has attachment? */ 54 pj_sockaddr_in rem_rtp_addr; /**< Remote RTP address */ 55 pj_sockaddr_in rem_rtcp_addr; /**< Remote RTCP address */ 54 pj_sockaddr rem_rtp_addr; /**< Remote RTP address */ 55 pj_sockaddr rem_rtcp_addr; /**< Remote RTCP address */ 56 int addr_len; /**< Length of addresses. */ 56 57 void (*rtp_cb)( void*, /**< To report incoming RTP. */ 57 58 const void*, … … 65 66 66 67 pj_sock_t rtp_sock; /**< RTP socket */ 67 pj_sockaddr _inrtp_addr_name; /**< Published RTP address. */68 pj_sockaddr rtp_addr_name; /**< Published RTP address. */ 68 69 pj_ioqueue_key_t *rtp_key; /**< RTP socket key in ioqueue */ 69 70 pj_ioqueue_op_key_t rtp_read_op; /**< Pending read operation */ 70 71 unsigned rtp_write_op_id;/**< Next write_op to use */ 71 72 pending_write rtp_pending_write[MAX_PENDING]; /**< Pending write */ 72 pj_sockaddr _inrtp_src_addr; /**< Actual packet src addr. */73 pj_sockaddr rtp_src_addr; /**< Actual packet src addr. */ 73 74 unsigned rtp_src_cnt; /**< How many pkt from this addr. */ 74 75 int rtp_addrlen; /**< Address length. */ … … 76 77 77 78 pj_sock_t rtcp_sock; /**< RTCP socket */ 78 pj_sockaddr _inrtcp_addr_name; /**< Published RTCP address. */79 pj_sockaddr _inrtcp_src_addr; /**< Actual source RTCP address. */79 pj_sockaddr rtcp_addr_name; /**< Published RTCP address. */ 80 pj_sockaddr rtcp_src_addr; /**< Actual source RTCP address. */ 80 81 int rtcp_addr_len; /**< Length of RTCP src address. */ 81 82 pj_ioqueue_key_t *rtcp_key; /**< RTCP socket key in ioqueue */ … … 151 152 pjmedia_transport **p_tp) 152 153 { 154 return pjmedia_transport_udp_create3(endpt, pj_AF_INET(), name, 155 addr, port, options, p_tp); 156 } 157 158 /** 159 * Create UDP stream transport. 160 */ 161 PJ_DEF(pj_status_t) pjmedia_transport_udp_create3(pjmedia_endpt *endpt, 162 int af, 163 const char *name, 164 const pj_str_t *addr, 165 int port, 166 unsigned options, 167 pjmedia_transport **p_tp) 168 { 153 169 pjmedia_sock_info si; 154 170 pj_status_t status; … … 163 179 164 180 /* Create RTP socket */ 165 status = pj_sock_socket( pj_AF_INET(), pj_SOCK_DGRAM(), 0, &si.rtp_sock);181 status = pj_sock_socket(af, pj_SOCK_DGRAM(), 0, &si.rtp_sock); 166 182 if (status != PJ_SUCCESS) 167 183 goto on_error; 168 184 169 185 /* Bind RTP socket */ 170 pj_sockaddr_in_init(&si.rtp_addr_name, addr, (pj_uint16_t)port); 186 status = pj_sockaddr_init(af, &si.rtp_addr_name, addr, (pj_uint16_t)port); 187 if (status != PJ_SUCCESS) 188 goto on_error; 189 171 190 status = pj_sock_bind(si.rtp_sock, &si.rtp_addr_name, 172 191 sizeof(si.rtp_addr_name)); … … 176 195 177 196 /* Create RTCP socket */ 178 status = pj_sock_socket( pj_AF_INET(), pj_SOCK_DGRAM(), 0, &si.rtcp_sock);197 status = pj_sock_socket(af, pj_SOCK_DGRAM(), 0, &si.rtcp_sock); 179 198 if (status != PJ_SUCCESS) 180 199 goto on_error; 181 200 182 201 /* Bind RTCP socket */ 183 pj_sockaddr_in_init(&si.rtcp_addr_name, addr, (pj_uint16_t)(port+1)); 202 status = pj_sockaddr_init(af, &si.rtcp_addr_name, addr, 203 (pj_uint16_t)(port+1)); 204 if (status != PJ_SUCCESS) 205 goto on_error; 206 184 207 status = pj_sock_bind(si.rtcp_sock, &si.rtcp_addr_name, 185 208 sizeof(si.rtcp_addr_name)); … … 222 245 PJ_ASSERT_RETURN(endpt && si && p_tp, PJ_EINVAL); 223 246 224 /* Check name */225 if (!name)226 name = "udpmedia";227 228 247 /* Get ioqueue instance */ 229 248 ioqueue = pjmedia_endpt_get_ioqueue(endpt); 230 231 249 232 250 /* Create transport structure */ … … 235 253 return PJ_ENOMEM; 236 254 255 if (!name) 256 name = pool->obj_name; 257 237 258 tp = PJ_POOL_ZALLOC_T(pool, struct transport_udp); 238 259 tp->pool = pool; 239 260 tp->options = options; 240 pj_ansi_str cpy(tp->base.name, name);261 pj_ansi_strncpy(tp->base.name, name, PJ_MAX_OBJ_NAME-1); 241 262 tp->base.op = &transport_udp_op; 242 263 tp->base.type = PJMEDIA_TRANSPORT_TYPE_UDP; … … 249 270 250 271 /* If address is 0.0.0.0, use host's IP address */ 251 if ( tp->rtp_addr_name.sin_addr.s_addr == 0) {272 if (!pj_sockaddr_has_addr(&tp->rtp_addr_name)) { 252 273 pj_sockaddr hostip; 253 274 254 status = pj_gethostip( pj_AF_INET(), &hostip);275 status = pj_gethostip(tp->rtp_addr_name.addr.sa_family, &hostip); 255 276 if (status != PJ_SUCCESS) 256 277 goto on_error; 257 278 258 tp->rtp_addr_name.sin_addr.s_addr = hostip.ipv4.sin_addr.s_addr; 279 pj_memcpy(pj_sockaddr_get_addr(&tp->rtp_addr_name), 280 pj_sockaddr_get_addr(&hostip), 281 pj_sockaddr_get_addr_len(&hostip)); 259 282 } 260 283 261 284 /* Same with RTCP */ 262 if (tp->rtcp_addr_name.sin_addr.s_addr == 0) { 263 tp->rtcp_addr_name.sin_addr.s_addr = tp->rtp_addr_name.sin_addr.s_addr; 285 if (!pj_sockaddr_has_addr(&tp->rtcp_addr_name)) { 286 pj_memcpy(pj_sockaddr_get_addr(&tp->rtcp_addr_name), 287 pj_sockaddr_get_addr(&tp->rtp_addr_name), 288 pj_sockaddr_get_addr_len(&tp->rtp_addr_name)); 264 289 } 265 290 … … 349 374 pj_ioqueue_unregister(udp->rtp_key); 350 375 udp->rtp_key = NULL; 376 udp->rtp_sock = PJ_INVALID_SOCKET; 351 377 } else if (udp->rtp_sock != PJ_INVALID_SOCKET) { 352 378 pj_sock_close(udp->rtp_sock); … … 357 383 pj_ioqueue_unregister(udp->rtcp_key); 358 384 udp->rtcp_key = NULL; 385 udp->rtcp_sock = PJ_INVALID_SOCKET; 359 386 } else if (udp->rtcp_sock != PJ_INVALID_SOCKET) { 360 387 pj_sock_close(udp->rtcp_sock); … … 409 436 (udp->options & PJMEDIA_UDP_NO_SRC_ADDR_CHECKING)==0) 410 437 { 411 if ((udp->rem_rtp_addr.sin_addr.s_addr != 412 udp->rtp_src_addr.sin_addr.s_addr) || 413 (udp->rem_rtp_addr.sin_port != 414 udp->rtp_src_addr.sin_port)) 415 { 438 if (pj_sockaddr_cmp(&udp->rem_rtp_addr, &udp->rtp_src_addr) != 0) { 439 416 440 udp->rtp_src_cnt++; 417 441 418 442 if (udp->rtp_src_cnt >= PJMEDIA_RTP_NAT_PROBATION_CNT) { 419 443 444 char addr_text[80]; 445 420 446 /* Set remote RTP address to source address */ 421 udp->rem_rtp_addr = udp->rtp_src_addr; 447 pj_memcpy(&udp->rem_rtp_addr, &udp->rtp_src_addr, 448 sizeof(pj_sockaddr)); 422 449 423 450 /* Reset counter */ … … 425 452 426 453 PJ_LOG(4,(udp->base.name, 427 "Remote RTP address switched to %s :%d",428 pj_ inet_ntoa(udp->rtp_src_addr.sin_addr),429 pj_ntohs(udp->rtp_src_addr.sin_port)));454 "Remote RTP address switched to %s", 455 pj_sockaddr_print(&udp->rtp_src_addr, addr_text, 456 sizeof(addr_text), 3))); 430 457 431 458 /* Also update remote RTCP address if actual RTCP source 432 459 * address is not heard yet. 433 460 */ 434 if ( udp->rtcp_src_addr.sin_addr.s_addr == 0) {461 if (!pj_sockaddr_has_addr(&udp->rtcp_src_addr)) { 435 462 pj_uint16_t port; 436 463 437 464 pj_memcpy(&udp->rem_rtcp_addr, &udp->rem_rtp_addr, 438 sizeof(pj_sockaddr_in)); 465 sizeof(pj_sockaddr)); 466 pj_sockaddr_copy_addr(&udp->rem_rtcp_addr, 467 &udp->rem_rtp_addr); 439 468 port = (pj_uint16_t) 440 (pj_ ntohs(udp->rem_rtp_addr.sin_port)+1);441 udp->rem_rtcp_addr.sin_port = pj_htons(port);469 (pj_sockaddr_get_port(&udp->rem_rtp_addr)+1); 470 pj_sockaddr_set_port(&udp->rem_rtcp_addr, port); 442 471 443 472 pj_memcpy(&udp->rtcp_src_addr, &udp->rem_rtcp_addr, 444 sizeof(pj_sockaddr _in));473 sizeof(pj_sockaddr)); 445 474 446 475 PJ_LOG(4,(udp->base.name, 447 "Remote RTCP address switched to %s:%d", 448 pj_inet_ntoa(udp->rtcp_src_addr.sin_addr), 449 pj_ntohs(udp->rtcp_src_addr.sin_port))); 476 "Remote RTCP address switched to %s", 477 pj_sockaddr_print(&udp->rtcp_src_addr, 478 addr_text, 479 sizeof(addr_text), 3))); 450 480 451 481 } … … 456 486 read_next_packet: 457 487 bytes_read = sizeof(udp->rtp_pkt); 458 udp->rtp_addrlen = sizeof( pj_sockaddr_in);488 udp->rtp_addrlen = sizeof(udp->rtp_src_addr); 459 489 status = pj_ioqueue_recvfrom(udp->rtp_key, &udp->rtp_read_op, 460 490 udp->rtp_pkt, &bytes_read, 0, … … 497 527 if (bytes_read>0 && 498 528 (udp->options & PJMEDIA_UDP_NO_SRC_ADDR_CHECKING)==0 && 499 ((udp->rem_rtcp_addr.sin_addr.s_addr != 500 udp->rtcp_src_addr.sin_addr.s_addr) || 501 (udp->rem_rtcp_addr.sin_port != 502 udp->rtcp_src_addr.sin_port))) 529 pj_sockaddr_cmp(&udp->rem_rtcp_addr, &udp->rtcp_src_addr) != 0) 503 530 { 531 char addr_text[80]; 532 504 533 pj_memcpy(&udp->rem_rtcp_addr, &udp->rtcp_src_addr, 505 sizeof(pj_sockaddr_in)); 534 sizeof(pj_sockaddr)); 535 506 536 PJ_LOG(4,(udp->base.name, 507 "Remote RTCP address switched to %s :%d",508 pj_ inet_ntoa(udp->rtcp_src_addr.sin_addr),509 pj_ntohs(udp->rtcp_src_addr.sin_port)));537 "Remote RTCP address switched to %s", 538 pj_sockaddr_print(&udp->rtcp_src_addr, addr_text, 539 sizeof(addr_text), 3))); 510 540 } 511 541 … … 553 583 { 554 584 struct transport_udp *udp = (struct transport_udp*) tp; 555 const pj_sockaddr _in*rtcp_addr;585 const pj_sockaddr *rtcp_addr; 556 586 557 587 /* Validate arguments */ … … 564 594 565 595 /* Copy remote RTP address */ 566 pj_memcpy(&udp->rem_rtp_addr, rem_addr, sizeof(pj_sockaddr_in));596 pj_memcpy(&udp->rem_rtp_addr, rem_addr, addr_len); 567 597 568 598 /* Copy remote RTP address, if one is specified. */ 569 rtcp_addr = (const pj_sockaddr _in*) rem_rtcp;570 if (rtcp_addr && rtcp_addr->sin_addr.s_addr != 0) {571 pj_memcpy(&udp->rem_rtcp_addr, rem_rtcp, sizeof(pj_sockaddr_in));599 rtcp_addr = (const pj_sockaddr*) rem_rtcp; 600 if (rtcp_addr && pj_sockaddr_has_addr(rtcp_addr)) { 601 pj_memcpy(&udp->rem_rtcp_addr, rem_rtcp, addr_len); 572 602 573 603 } else { 574 intrtcp_port;604 unsigned rtcp_port; 575 605 576 606 /* Otherwise guess the RTCP address from the RTP address */ 577 pj_memcpy(&udp->rem_rtcp_addr, rem_addr, sizeof(pj_sockaddr_in));578 rtcp_port = pj_ ntohs(udp->rem_rtp_addr.sin_port) + 1;579 udp->rem_rtcp_addr.sin_port = pj_htons((pj_uint16_t)rtcp_port);607 pj_memcpy(&udp->rem_rtcp_addr, rem_addr, addr_len); 608 rtcp_port = pj_sockaddr_get_port(&udp->rem_rtp_addr) + 1; 609 pj_sockaddr_set_port(&udp->rem_rtcp_addr, (pj_uint16_t)rtcp_port); 580 610 } 581 611 … … 584 614 udp->rtcp_cb = rtcp_cb; 585 615 udp->user_data = user_data; 616 617 /* Save address length */ 618 udp->addr_len = addr_len; 586 619 587 620 /* Last, mark transport as attached */ … … 660 693 pw->buffer, &sent, 0, 661 694 &udp->rem_rtp_addr, 662 sizeof(pj_sockaddr_in));695 udp->addr_len); 663 696 664 697 udp->rtp_write_op_id = (udp->rtp_write_op_id + 1) % … … 685 718 status = pj_ioqueue_sendto( udp->rtcp_key, &udp->rtcp_write_op, 686 719 pkt, &sent, 0, 687 &udp->rem_rtcp_addr, sizeof(pj_sockaddr_in));720 &udp->rem_rtcp_addr, udp->addr_len); 688 721 689 722 if (status==PJ_SUCCESS || status==PJ_EPENDING) -
pjproject/trunk/pjsip-apps/src/samples/siprtp.c
r1444 r1615 1028 1028 /* Standard media info: */ 1029 1029 m->desc.media = pj_str("audio"); 1030 m->desc.port = pj_ntohs(tpinfo.skinfo.rtp_addr_name. sin_port);1030 m->desc.port = pj_ntohs(tpinfo.skinfo.rtp_addr_name.ipv4.sin_port); 1031 1031 m->desc.port_count = 1; 1032 1032 m->desc.transport = pj_str("RTP/AVP"); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r1591 r1615 1825 1825 for (i=0; i<info.stream_cnt; ++i) { 1826 1826 pjmedia_rtcp_stat stat; 1827 char rem_addr_buf[80]; 1827 1828 const char *rem_addr; 1828 int rem_port;1829 1829 const char *dir; 1830 1830 char last_update[64]; … … 1833 1833 1834 1834 pjmedia_session_get_stream_stat(session, i, &stat); 1835 rem_addr = pj_ inet_ntoa(info.stream_info[i].rem_addr.sin_addr);1836 rem_port = pj_ntohs(info.stream_info[i].rem_addr.sin_port);1835 rem_addr = pj_sockaddr_print(&info.stream_info[i].rem_addr, 1836 rem_addr_buf, sizeof(rem_addr_buf), 3); 1837 1837 1838 1838 if (info.stream_info[i].dir == PJMEDIA_DIR_ENCODING) … … 1847 1847 1848 1848 len = pj_ansi_snprintf(buf, end-p, 1849 "%s #%d %.*s @%dKHz, %s, peer=%s :%d",1849 "%s #%d %.*s @%dKHz, %s, peer=%s", 1850 1850 indent, i, 1851 1851 (int)info.stream_info[i].fmt.encoding_name.slen, … … 1853 1853 info.stream_info[i].fmt.clock_rate / 1000, 1854 1854 dir, 1855 rem_addr , rem_port);1855 rem_addr); 1856 1856 if (len < 1 || len > end-p) { 1857 1857 *p = '\0'; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r1602 r1615 2015 2015 pjsua_call *call = &pjsua_var.calls[i]; 2016 2016 pjmedia_sock_info skinfo; 2017 char addr_buf[80]; 2017 2018 2018 2019 /* MSVC complains about skinfo not being initialized */ … … 2021 2022 pjmedia_transport_get_info(call->med_tp, &skinfo); 2022 2023 2023 PJ_LOG(3,(THIS_FILE, " %s: %s :%d",2024 PJ_LOG(3,(THIS_FILE, " %s: %s", 2024 2025 (pjsua_var.media_cfg.enable_ice ? "ICE" : "UDP"), 2025 pj_ inet_ntoa(skinfo.rtp_addr_name.sin_addr),2026 (int)pj_ntohs(skinfo.rtp_addr_name.sin_port)));2026 pj_sockaddr_print(&skinfo.rtp_addr_name, addr_buf, 2027 sizeof(addr_buf), 3))); 2027 2028 } 2028 2029 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r1602 r1615 221 221 pj_sockaddr_in mapped_addr[2]; 222 222 pj_status_t status = PJ_SUCCESS; 223 char addr_buf[80]; 223 224 pj_sock_t sock[2]; 224 225 … … 229 230 return status; 230 231 } 231 232 232 233 233 if (next_rtp_port == 0) … … 379 379 380 380 PJ_LOG(4,(THIS_FILE, "RTP socket reachable at %s:%d", 381 pj_ inet_ntoa(skinfo->rtp_addr_name.sin_addr),382 pj_ntohs(skinfo->rtp_addr_name.sin_port)));381 pj_sockaddr_print(&skinfo->rtp_addr_name, addr_buf, 382 sizeof(addr_buf), 3))); 383 383 PJ_LOG(4,(THIS_FILE, "RTCP socket reachable at %s:%d", 384 pj_ inet_ntoa(skinfo->rtcp_addr_name.sin_addr),385 pj_ntohs(skinfo->rtcp_addr_name.sin_port)));384 pj_sockaddr_print(&skinfo->rtcp_addr_name, addr_buf, 385 sizeof(addr_buf), 3))); 386 386 387 387 next_rtp_port += 2;
Note: See TracChangeset
for help on using the changeset viewer.