Changeset 1860
- Timestamp:
- Mar 11, 2008 9:38:05 PM (17 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/config.h
r1859 r1860 526 526 527 527 /** 528 * Transport info (pjmedia_transport_info) contains a socket info and list 529 * of transport specific info, since transports can be chained together 530 * (for example, SRTP transport uses UDP transport as the underlying 531 * transport). This constant specifies maximum number of transport specific 532 * infos that can be held in a transport info. 533 */ 534 #ifndef PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXCNT 535 # define PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXCNT 4 536 #endif 537 538 539 /** 540 * Maximum size in bytes of storage buffer of a transport specific info. 541 */ 542 #ifndef PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE 543 # define PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE (12*sizeof(long)) 544 #endif 545 546 547 548 /** 528 549 * @} 529 550 */ -
pjproject/trunk/pjmedia/include/pjmedia/transport.h
r1810 r1860 208 208 #include <pjmedia/sdp.h> 209 209 210 210 211 /** 211 212 * Forward declaration for media transport. 212 213 */ 213 214 typedef struct pjmedia_transport pjmedia_transport; 215 216 /** 217 * Forward declaration for media transport info. 218 */ 219 typedef struct pjmedia_transport_info pjmedia_transport_info; 214 220 215 221 /** … … 229 235 } pjmedia_tranport_media_option; 230 236 237 231 238 /** 232 239 * This structure describes the operations for the stream transport. … … 240 247 */ 241 248 pj_status_t (*get_info)(pjmedia_transport *tp, 242 pjmedia_ sock_info *info);249 pjmedia_transport_info *info); 243 250 244 251 /** … … 369 376 370 377 /** Media transport using ICE */ 371 PJMEDIA_TRANSPORT_TYPE_ICE 378 PJMEDIA_TRANSPORT_TYPE_ICE, 379 380 /** 381 * Media transport SRTP, this transport is actually security adapter to be 382 * stacked with other transport to enable encryption on the underlying 383 * transport. 384 */ 385 PJMEDIA_TRANSPORT_TYPE_SRTP 372 386 373 387 } pjmedia_transport_type; … … 389 403 /** Transport's "virtual" function table. */ 390 404 pjmedia_transport_op *op; 405 }; 406 407 /** 408 * This structure describes buffer storage of transport specific info. 409 * The actual transport specific info contents will be defined by transport 410 * implementation. Note that some transport implementations do not need to 411 * provide specific info, since the general socket info is enough. 412 */ 413 typedef struct pjmedia_transport_specific_info 414 { 415 /** 416 * Specify media transport type. 417 */ 418 pjmedia_transport_type type; 419 420 /** 421 * Specify storage buffer size of transport specific info. 422 */ 423 int cbsize; 424 425 /** 426 * Storage buffer of transport specific info. 427 */ 428 char buffer[PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE]; 429 430 } pjmedia_transport_specific_info; 431 432 433 /** 434 * This structure describes transport informations, including general 435 * socket information and specific information of single transport or 436 * stacked transports (e.g: SRTP stacked on top of UDP) 437 */ 438 struct pjmedia_transport_info 439 { 440 /** 441 * General socket info. 442 */ 443 pjmedia_sock_info sock_info; 444 445 /** 446 * Specifies number of transport specific info included. 447 */ 448 int specific_info_cnt; 449 450 /** 451 * Buffer storage of transport specific info. 452 */ 453 pjmedia_transport_specific_info spc_info[PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXCNT]; 454 391 455 }; 392 456 … … 404 468 */ 405 469 PJ_INLINE(pj_status_t) pjmedia_transport_get_info(pjmedia_transport *tp, 406 pjmedia_ sock_info *info)470 pjmedia_transport_info *info) 407 471 { 408 472 if (tp->op->get_info) -
pjproject/trunk/pjmedia/include/pjmedia/transport_srtp.h
r1763 r1860 161 161 162 162 /** 163 * This structure specifies SRTP transport specific info. This will fit 164 * into \a buffer field of pjmedia_transport_specific_info. 165 */ 166 typedef struct pjmedia_srtp_info 167 { 168 /** 169 * Specify whether the SRTP transport is active for SRTP session. 170 */ 171 pj_bool_t active; 172 173 /** 174 * Specify the policy used by the SRTP session for receive direction. 175 */ 176 pjmedia_srtp_crypto rx_policy; 177 178 /** 179 * Specify the policy used by the SRTP session for transmit direction. 180 */ 181 pjmedia_srtp_crypto tx_policy; 182 183 } pjmedia_srtp_info; 184 185 186 /** 163 187 * Initialize SRTP setting with its default values. 164 188 * -
pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c
r1810 r1860 56 56 */ 57 57 static pj_status_t transport_get_info (pjmedia_transport *tp, 58 pjmedia_ sock_info *info);58 pjmedia_transport_info *info); 59 59 static pj_status_t transport_attach (pjmedia_transport *tp, 60 60 void *user_data, … … 674 674 675 675 static pj_status_t transport_get_info(pjmedia_transport *tp, 676 pjmedia_ sock_info *info)676 pjmedia_transport_info *info) 677 677 { 678 678 struct transport_ice *tp_ice = (struct transport_ice*)tp; … … 680 680 pj_ice_strans_comp *comp; 681 681 682 pj_bzero( info, sizeof(*info));683 info-> rtp_sock = info->rtcp_sock = PJ_INVALID_SOCKET;682 pj_bzero(&info->sock_info, sizeof(info->sock_info)); 683 info->sock_info.rtp_sock = info->sock_info.rtcp_sock = PJ_INVALID_SOCKET; 684 684 685 685 /* Retrieve address of default candidate for component 1 (RTP) */ 686 686 comp = ice_st->comp[0]; 687 687 pj_assert(comp->default_cand >= 0); 688 info-> rtp_sock = comp->sock;689 pj_memcpy(&info-> rtp_addr_name,688 info->sock_info.rtp_sock = comp->sock; 689 pj_memcpy(&info->sock_info.rtp_addr_name, 690 690 &comp->cand_list[comp->default_cand].addr, 691 691 sizeof(pj_sockaddr_in)); … … 695 695 comp = ice_st->comp[1]; 696 696 pj_assert(comp->default_cand >= 0); 697 info-> rtp_sock = comp->sock;698 pj_memcpy(&info-> rtcp_addr_name,697 info->sock_info.rtp_sock = comp->sock; 698 pj_memcpy(&info->sock_info.rtcp_addr_name, 699 699 &comp->cand_list[comp->default_cand].addr, 700 700 sizeof(pj_sockaddr_in)); 701 701 } 702 702 703 info->specific_info_cnt = 0; 703 704 704 705 return PJ_SUCCESS; -
pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
r1810 r1860 126 126 */ 127 127 static pj_status_t transport_get_info (pjmedia_transport *tp, 128 pjmedia_ sock_info *info);128 pjmedia_transport_info *info); 129 129 static pj_status_t transport_attach (pjmedia_transport *tp, 130 130 void *user_data, … … 552 552 553 553 static pj_status_t transport_get_info(pjmedia_transport *tp, 554 pjmedia_ sock_info *info)554 pjmedia_transport_info *info) 555 555 { 556 556 transport_srtp *srtp = (transport_srtp*) tp; 557 558 /* put SRTP info as well? */ 559 return pjmedia_transport_get_info(srtp->real_tp, info); 557 pjmedia_srtp_info srtp_info; 558 int spc_info_idx; 559 pj_status_t status; 560 561 PJ_ASSERT_RETURN(tp && info, PJ_EINVAL); 562 PJ_ASSERT_RETURN(info->specific_info_cnt < 563 PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXCNT, PJ_ETOOMANY); 564 PJ_ASSERT_RETURN(sizeof(pjmedia_srtp_info) <= 565 PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE, PJ_ENOMEM); 566 567 status = pjmedia_transport_get_info(srtp->real_tp, info); 568 if (status != PJ_SUCCESS) 569 return status; 570 571 srtp_info.active = srtp->session_inited; 572 srtp_info.rx_policy = srtp->rx_policy; 573 srtp_info.tx_policy = srtp->tx_policy; 574 575 spc_info_idx = info->specific_info_cnt++; 576 info->spc_info[spc_info_idx].type = PJMEDIA_TRANSPORT_TYPE_SRTP; 577 info->spc_info[spc_info_idx].cbsize = sizeof(srtp_info); 578 pj_memcpy(&info->spc_info[spc_info_idx].buffer, &srtp_info, 579 sizeof(srtp_info)); 580 581 return PJ_SUCCESS; 560 582 } 561 583 -
pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c
r1810 r1860 102 102 */ 103 103 static pj_status_t transport_get_info (pjmedia_transport *tp, 104 pjmedia_ sock_info *info);104 pjmedia_transport_info *info); 105 105 static pj_status_t transport_attach (pjmedia_transport *tp, 106 106 void *user_data, … … 585 585 /* Called to get the transport info */ 586 586 static pj_status_t transport_get_info(pjmedia_transport *tp, 587 pjmedia_ sock_info *info)587 pjmedia_transport_info *info) 588 588 { 589 589 struct transport_udp *udp = (struct transport_udp*)tp; 590 590 PJ_ASSERT_RETURN(tp && info, PJ_EINVAL); 591 591 592 info->rtp_sock = udp->rtp_sock; 593 info->rtp_addr_name = udp->rtp_addr_name; 594 info->rtcp_sock = udp->rtcp_sock; 595 info->rtcp_addr_name = udp->rtcp_addr_name; 592 info->sock_info.rtp_sock = udp->rtp_sock; 593 info->sock_info.rtp_addr_name = udp->rtp_addr_name; 594 info->sock_info.rtcp_sock = udp->rtcp_sock; 595 info->sock_info.rtcp_addr_name = udp->rtcp_addr_name; 596 info->specific_info_cnt = 0; 596 597 597 598 return PJ_SUCCESS; -
pjproject/trunk/pjsip-apps/src/samples/simpleua.c
r1851 r1860 82 82 83 83 static pjmedia_endpt *g_med_endpt; /* Media endpoint. */ 84 static pjmedia_ sock_info g_med_skinfo;/* Socket info for media */84 static pjmedia_transport_info g_med_tpinfo; /* Socket info for media */ 85 85 static pjmedia_transport *g_med_transport;/* Media stream transport */ 86 86 … … 302 302 * the SDP). 303 303 */ 304 pjmedia_transport_get_info(g_med_transport, &g_med_ skinfo);304 pjmedia_transport_get_info(g_med_transport, &g_med_tpinfo); 305 305 306 306 … … 365 365 dlg->pool, /* pool. */ 366 366 1, /* # of streams */ 367 &g_med_skinfo, /* RTP sock info */ 367 &g_med_tpinfo.sock_info, 368 /* RTP sock info */ 368 369 &local_sdp); /* the SDP result */ 369 370 PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); … … 572 573 573 574 status = pjmedia_endpt_create_sdp( g_med_endpt, rdata->tp_info.pool, 1, 574 &g_med_ skinfo,575 &g_med_tpinfo.sock_info, 575 576 &local_sdp); 576 577 PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE); -
pjproject/trunk/pjsip-apps/src/samples/siprtp.c
r1780 r1860 1006 1006 pjmedia_sdp_media *m; 1007 1007 pjmedia_sdp_attr *attr; 1008 pjmedia_ sock_info tpinfo;1008 pjmedia_transport_info tpinfo; 1009 1009 struct media_stream *audio = &call->media[0]; 1010 1010 … … 1048 1048 /* Standard media info: */ 1049 1049 m->desc.media = pj_str("audio"); 1050 m->desc.port = pj_ntohs(tpinfo. rtp_addr_name.ipv4.sin_port);1050 m->desc.port = pj_ntohs(tpinfo.sock_info.rtp_addr_name.ipv4.sin_port); 1051 1051 m->desc.port_count = 1; 1052 1052 m->desc.transport = pj_str("RTP/AVP"); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r1849 r1860 2201 2201 pj_status_t status; 2202 2202 int len; 2203 pjmedia_transport_info tp_info; 2203 2204 2204 2205 PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, … … 2257 2258 *p++ = '\n'; 2258 2259 *p = '\0'; 2260 } 2261 2262 /* Get SRTP status */ 2263 pjmedia_transport_get_info(call->med_tp, &tp_info); 2264 if (tp_info.specific_info_cnt > 0) { 2265 int i; 2266 for (i = 0; i < tp_info.specific_info_cnt; ++i) { 2267 if (tp_info.spc_info[i].type == PJMEDIA_TRANSPORT_TYPE_SRTP) 2268 { 2269 pjmedia_srtp_info *srtp_info = 2270 (pjmedia_srtp_info*) tp_info.spc_info[i].buffer; 2271 2272 len = pj_ansi_snprintf(p, end-p, 2273 "%s SRTP status: %s Crypto-suite: %s", 2274 indent, 2275 (srtp_info->active?"Active":"Not active"), 2276 srtp_info->tx_policy.name.ptr); 2277 if (len > 0 && len < end-p) { 2278 p += len; 2279 *p++ = '\n'; 2280 *p = '\0'; 2281 } 2282 break; 2283 } 2284 } 2259 2285 } 2260 2286 … … 2443 2469 { 2444 2470 pjmedia_sdp_session *local_sdp; 2445 pjmedia_ sock_info si;2446 2447 call->med_tp->op->get_info(call->med_tp, &si);2471 pjmedia_transport_info ti; 2472 2473 pjmedia_transport_get_info(call->med_tp, &ti); 2448 2474 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, tdata->pool, 2449 1, & si, &local_sdp);2475 1, &ti.sock_info, &local_sdp); 2450 2476 if (status == PJ_SUCCESS) { 2451 2477 pjsip_create_sdp_body(tdata->pool, local_sdp, … … 2552 2578 pjmedia_sdp_conn *conn; 2553 2579 pjmedia_sdp_attr *attr; 2554 pjmedia_ sock_info skinfo;2580 pjmedia_transport_info tp_info; 2555 2581 pjmedia_sdp_session *sdp; 2556 2582 2557 2583 /* Get media socket info */ 2558 pjmedia_transport_get_info(call->med_tp, & skinfo);2584 pjmedia_transport_get_info(call->med_tp, &tp_info); 2559 2585 2560 2586 /* Create new offer */ 2561 2587 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, pjsua_var.pool, 1, 2562 & skinfo, &sdp);2588 &tp_info.sock_info, &sdp); 2563 2589 if (status != PJ_SUCCESS) { 2564 2590 pjsua_perror(THIS_FILE, "Unable to create local SDP", status); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r1855 r1860 261 261 pjsip_tx_data *tdata; 262 262 pjsip_response_addr res_addr; 263 pjmedia_ sock_info skinfo;263 pjmedia_transport_info tpinfo; 264 264 pjmedia_sdp_session *sdp; 265 265 const pjsip_hdr *cap_hdr; … … 321 321 322 322 /* Get media socket info */ 323 pjmedia_transport_get_info(pjsua_var.calls[0].med_tp, & skinfo);323 pjmedia_transport_get_info(pjsua_var.calls[0].med_tp, &tpinfo); 324 324 325 325 /* Add SDP body, using call0's RTP address */ 326 326 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, tdata->pool, 1, 327 & skinfo, &sdp);327 &tpinfo.sock_info, &sdp); 328 328 if (status == PJ_SUCCESS) { 329 329 pjsip_create_sdp_body(tdata->pool, sdp, &tdata->msg->body); … … 2061 2061 for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) { 2062 2062 pjsua_call *call = &pjsua_var.calls[i]; 2063 pjmedia_ sock_info skinfo;2063 pjmedia_transport_info tpinfo; 2064 2064 char addr_buf[80]; 2065 2065 2066 /* MSVC complains about skinfo not being initialized */2067 pj_bzero(& skinfo, sizeof(skinfo));2068 2069 pjmedia_transport_get_info(call->med_tp, & skinfo);2066 /* MSVC complains about tpinfo not being initialized */ 2067 pj_bzero(&tpinfo, sizeof(tpinfo)); 2068 2069 pjmedia_transport_get_info(call->med_tp, &tpinfo); 2070 2070 2071 2071 PJ_LOG(3,(THIS_FILE, " %s: %s", 2072 2072 (pjsua_var.media_cfg.enable_ice ? "ICE" : "UDP"), 2073 pj_sockaddr_print(& skinfo.rtp_addr_name, addr_buf,2073 pj_sockaddr_print(&tpinfo.sock_info.rtp_addr_name, addr_buf, 2074 2074 sizeof(addr_buf), 3))); 2075 2075 } -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r1855 r1860 815 815 enum { MAX_MEDIA = 1, MEDIA_IDX = 0 }; 816 816 pjmedia_sdp_session *sdp; 817 pjmedia_ sock_info skinfo;817 pjmedia_transport_info tpinfo; 818 818 pjsua_call *call = &pjsua_var.calls[call_id]; 819 819 pj_status_t status; … … 827 827 828 828 /* Get media socket info */ 829 pjmedia_transport_get_info(call->med_tp, & skinfo);829 pjmedia_transport_get_info(call->med_tp, &tpinfo); 830 830 831 831 /* Create SDP */ 832 832 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, pool, MAX_MEDIA, 833 & skinfo, &sdp);833 &tpinfo.sock_info, &sdp); 834 834 if (status != PJ_SUCCESS) { 835 835 if (sip_status_code) *sip_status_code = 500;
Note: See TracChangeset
for help on using the changeset viewer.