- Timestamp:
- Jan 17, 2008 5:29:36 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/users/nanang/pjmedia/src/pjmedia/transport_ice.c
r1656 r1698 52 52 * These are media transport operations. 53 53 */ 54 static pj_status_t tp_get_info(pjmedia_transport *tp, 55 pjmedia_sock_info *info); 56 static pj_status_t tp_attach( pjmedia_transport *tp, 57 void *stream, 58 const pj_sockaddr_t *rem_addr, 59 const pj_sockaddr_t *rem_rtcp, 60 unsigned addr_len, 61 void (*rtp_cb)(void*, 62 const void*, 63 pj_ssize_t), 64 void (*rtcp_cb)(void*, 65 const void*, 66 pj_ssize_t)); 67 static void tp_detach( pjmedia_transport *tp, 68 void *strm); 69 static pj_status_t tp_send_rtp( pjmedia_transport *tp, 70 const void *pkt, 71 pj_size_t size); 72 static pj_status_t tp_send_rtcp( pjmedia_transport *tp, 73 const void *pkt, 74 pj_size_t size); 54 static pj_status_t transport_get_info (pjmedia_transport *tp, 55 pjmedia_sock_info *info); 56 static pj_status_t transport_attach (pjmedia_transport *tp, 57 void *user_data, 58 const pj_sockaddr_t *rem_addr, 59 const pj_sockaddr_t *rem_rtcp, 60 unsigned addr_len, 61 void (*rtp_cb)(void*, 62 const void*, 63 pj_ssize_t), 64 void (*rtcp_cb)(void*, 65 const void*, 66 pj_ssize_t)); 67 static void transport_detach (pjmedia_transport *tp, 68 void *strm); 69 static pj_status_t transport_send_rtp( pjmedia_transport *tp, 70 const void *pkt, 71 pj_size_t size); 72 static pj_status_t transport_send_rtcp(pjmedia_transport *tp, 73 const void *pkt, 74 pj_size_t size); 75 static pj_status_t transport_media_create(pjmedia_transport *tp, 76 pj_pool_t *pool, 77 pjmedia_sdp_session *sdp_local, 78 const pjmedia_sdp_session *sdp_remote); 79 static pj_status_t transport_media_start (pjmedia_transport *tp, 80 pj_pool_t *pool, 81 pjmedia_sdp_session *sdp_local, 82 const pjmedia_sdp_session *sdp_remote, 83 unsigned media_index); 84 static pj_status_t transport_media_stop(pjmedia_transport *tp); 85 static pj_status_t transport_simulate_lost(pjmedia_transport *tp, 86 pjmedia_dir dir, 87 unsigned pct_lost); 88 static pj_status_t transport_destroy (pjmedia_transport *tp); 75 89 76 90 /* … … 85 99 86 100 87 static pjmedia_transport_op tp_ice_op = 88 { 89 &tp_get_info, 90 &tp_attach, 91 &tp_detach, 92 &tp_send_rtp, 93 &tp_send_rtcp, 94 &pjmedia_ice_destroy 101 static pjmedia_transport_op transport_ice_op = 102 { 103 &transport_get_info, 104 &transport_attach, 105 &transport_detach, 106 &transport_send_rtp, 107 &transport_send_rtcp, 108 &transport_media_create, 109 &transport_media_start, 110 &transport_media_stop, 111 &transport_simulate_lost, 112 &transport_destroy 95 113 }; 96 114 … … 133 151 tp_ice->ice_st = ice_st; 134 152 pj_ansi_strcpy(tp_ice->base.name, ice_st->obj_name); 135 tp_ice->base.op = &t p_ice_op;153 tp_ice->base.op = &transport_ice_op; 136 154 tp_ice->base.type = PJMEDIA_TRANSPORT_TYPE_ICE; 137 155 … … 144 162 if (p_tp) 145 163 *p_tp = &tp_ice->base; 146 147 return PJ_SUCCESS;148 }149 150 151 /*152 * Destroy ICE media transport.153 */154 PJ_DEF(pj_status_t) pjmedia_ice_destroy(pjmedia_transport *tp)155 {156 struct transport_ice *tp_ice = (struct transport_ice*)tp;157 158 if (tp_ice->ice_st) {159 pj_ice_strans_destroy(tp_ice->ice_st);160 /*Must not touch tp_ice after ice_st is destroyed!161 (it has the pool)162 tp_ice->ice_st = NULL;163 */164 }165 164 166 165 return PJ_SUCCESS; … … 231 230 comp, PJ_EINVAL); 232 231 233 pj_memcpy(comp, tp_ice->ice_st->comp[comp_id-1], sizeof(pj_ice_strans_comp)); 232 pj_memcpy(comp, tp_ice->ice_st->comp[comp_id-1], 233 sizeof(pj_ice_strans_comp)); 234 234 return PJ_SUCCESS; 235 235 } … … 247 247 { 248 248 struct transport_ice *tp_ice = (struct transport_ice*)tp; 249 return pj_ice_strans_init_ice(tp_ice->ice_st, role, local_ufrag, local_passwd); 249 return pj_ice_strans_init_ice(tp_ice->ice_st, role, local_ufrag, 250 local_passwd); 250 251 } 251 252 … … 255 256 * This will add ICE attributes to the SDP. 256 257 */ 257 PJ_DEF(pj_status_t) pjmedia_ice_modify_sdp(pjmedia_transport *tp, 258 pj_pool_t *pool, 259 pjmedia_sdp_session *sdp) 258 static pj_status_t transport_media_create(pjmedia_transport *tp, 259 pj_pool_t *pool, 260 pjmedia_sdp_session *sdp_local, 261 const pjmedia_sdp_session *sdp_remote) 260 262 { 261 263 struct transport_ice *tp_ice = (struct transport_ice*)tp; … … 265 267 unsigned i, cand_cnt; 266 268 269 PJ_UNUSED_ARG(sdp_remote); 270 267 271 buffer = (char*) pj_pool_alloc(pool, MAXLEN); 268 272 … … 270 274 attr = pjmedia_sdp_attr_create(pool, "ice-ufrag", 271 275 &tp_ice->ice_st->ice->rx_ufrag); 272 sdp ->attr[sdp->attr_count++] = attr;276 sdp_local->attr[sdp_local->attr_count++] = attr; 273 277 274 278 /* Create ice-pwd attribute */ 275 279 attr = pjmedia_sdp_attr_create(pool, "ice-pwd", 276 280 &tp_ice->ice_st->ice->rx_pass); 277 sdp ->attr[sdp->attr_count++] = attr;281 sdp_local->attr[sdp_local->attr_count++] = attr; 278 282 279 283 /* Add all candidates (to media level) */ … … 330 334 value = pj_str(buffer); 331 335 attr = pjmedia_sdp_attr_create(pool, "candidate", &value); 332 sdp ->media[0]->attr[sdp->media[0]->attr_count++] = attr;336 sdp_local->media[0]->attr[sdp_local->media[0]->attr_count++] = attr; 333 337 } 334 338 … … 457 461 PJ_LOG(4,(tp_ice->ice_st->obj_name, 458 462 "Disabling local ICE, reason=%s", reason)); 459 pjmedia_ice_stop_ice(&tp_ice->base);463 transport_media_stop(&tp_ice->base); 460 464 } 461 465 … … 464 468 * Start ICE checks when both offer and answer are available. 465 469 */ 466 PJ_DEF(pj_status_t) pjmedia_ice_start_ice(pjmedia_transport *tp, 467 pj_pool_t *pool, 468 const pjmedia_sdp_session *rem_sdp, 469 unsigned media_index) 470 static pj_status_t transport_media_start(pjmedia_transport *tp, 471 pj_pool_t *pool, 472 pjmedia_sdp_session *sdp_local, 473 const pjmedia_sdp_session *sdp_remote, 474 unsigned media_index) 470 475 { 471 476 struct transport_ice *tp_ice = (struct transport_ice*)tp; … … 482 487 pj_status_t status; 483 488 484 PJ_ASSERT_RETURN(tp && pool && rem_sdp, PJ_EINVAL); 485 PJ_ASSERT_RETURN(media_index < rem_sdp->media_count, PJ_EINVAL); 486 487 sdp_med = rem_sdp->media[media_index]; 489 PJ_UNUSED_ARG(sdp_local); 490 491 PJ_ASSERT_RETURN(tp && pool && sdp_remote, PJ_EINVAL); 492 PJ_ASSERT_RETURN(media_index < sdp_remote->media_count, PJ_EINVAL); 493 494 sdp_med = sdp_remote->media[media_index]; 488 495 489 496 /* Get the SDP connection for the media stream. … … 493 500 conn = sdp_med->conn; 494 501 if (conn == NULL) 495 conn = rem_sdp->conn;502 conn = sdp_remote->conn; 496 503 497 504 if (conn == NULL) { … … 508 515 if (attr == NULL) { 509 516 /* Find ice-ufrag attribute in session descriptor */ 510 attr = pjmedia_sdp_attr_find2( rem_sdp->attr_count, rem_sdp->attr,517 attr = pjmedia_sdp_attr_find2(sdp_remote->attr_count, sdp_remote->attr, 511 518 "ice-ufrag", NULL); 512 519 if (attr == NULL) { … … 522 529 if (attr == NULL) { 523 530 /* Find ice-pwd attribute in session descriptor */ 524 attr = pjmedia_sdp_attr_find2( rem_sdp->attr_count, rem_sdp->attr,531 attr = pjmedia_sdp_attr_find2(sdp_remote->attr_count, sdp_remote->attr, 525 532 "ice-pwd", NULL); 526 533 if (attr == NULL) { … … 609 616 610 617 611 PJ_DEF(pj_status_t) pjmedia_ice_stop_ice(pjmedia_transport *tp)618 static pj_status_t transport_media_stop(pjmedia_transport *tp) 612 619 { 613 620 struct transport_ice *tp_ice = (struct transport_ice*)tp; … … 616 623 617 624 618 static pj_status_t t p_get_info(pjmedia_transport *tp,619 625 static pj_status_t transport_get_info(pjmedia_transport *tp, 626 pjmedia_sock_info *info) 620 627 { 621 628 struct transport_ice *tp_ice = (struct transport_ice*)tp; … … 649 656 650 657 651 static pj_status_t t p_attach(pjmedia_transport *tp,652 void *stream,653 const pj_sockaddr_t *rem_addr,654 const pj_sockaddr_t *rem_rtcp,655 unsigned addr_len,656 void (*rtp_cb)(void*,657 const void*,658 pj_ssize_t),659 void (*rtcp_cb)(void*,660 const void*,661 pj_ssize_t))658 static pj_status_t transport_attach (pjmedia_transport *tp, 659 void *stream, 660 const pj_sockaddr_t *rem_addr, 661 const pj_sockaddr_t *rem_rtcp, 662 unsigned addr_len, 663 void (*rtp_cb)(void*, 664 const void*, 665 pj_ssize_t), 666 void (*rtcp_cb)(void*, 667 const void*, 668 pj_ssize_t)) 662 669 { 663 670 struct transport_ice *tp_ice = (struct transport_ice*)tp; … … 674 681 675 682 676 static void t p_detach(pjmedia_transport *tp,677 683 static void transport_detach(pjmedia_transport *tp, 684 void *strm) 678 685 { 679 686 struct transport_ice *tp_ice = (struct transport_ice*)tp; … … 687 694 688 695 689 static pj_status_t t p_send_rtp(pjmedia_transport *tp,690 691 696 static pj_status_t transport_send_rtp(pjmedia_transport *tp, 697 const void *pkt, 698 pj_size_t size) 692 699 { 693 700 struct transport_ice *tp_ice = (struct transport_ice*)tp; … … 709 716 710 717 711 static pj_status_t t p_send_rtcp(pjmedia_transport *tp,712 713 718 static pj_status_t transport_send_rtcp(pjmedia_transport *tp, 719 const void *pkt, 720 pj_size_t size) 714 721 { 715 722 struct transport_ice *tp_ice = (struct transport_ice*)tp; … … 799 806 800 807 /* Simulate lost */ 801 PJ_DEF(pj_status_t) pjmedia_ice_simulate_lost(pjmedia_transport *tp,802 803 808 static pj_status_t transport_simulate_lost(pjmedia_transport *tp, 809 pjmedia_dir dir, 810 unsigned pct_lost) 804 811 { 805 812 struct transport_ice *ice = (struct transport_ice*) tp; … … 816 823 } 817 824 825 826 /* 827 * Destroy ICE media transport. 828 */ 829 static pj_status_t transport_destroy(pjmedia_transport *tp) 830 { 831 struct transport_ice *tp_ice = (struct transport_ice*)tp; 832 833 if (tp_ice->ice_st) { 834 pj_ice_strans_destroy(tp_ice->ice_st); 835 /*Must not touch tp_ice after ice_st is destroyed! 836 (it has the pool) 837 tp_ice->ice_st = NULL; 838 */ 839 } 840 841 return PJ_SUCCESS; 842 } 843
Note: See TracChangeset
for help on using the changeset viewer.