- Timestamp:
- Sep 15, 2007 8:30:16 AM (17 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/transport_ice.h
r1112 r1435 39 39 PJ_BEGIN_DECL 40 40 41 42 /** 43 * Structure containing callbacks to receive ICE notifications. 44 */ 45 typedef struct pjmedia_ice_cb 46 { 47 /** 48 * This callback will be called when ICE negotiation completes. 49 * 50 * @param tp PJMEDIA ICE transport. 51 * @param status ICE negotiation result, PJ_SUCCESS on success. 52 */ 53 void (*on_ice_complete)(pjmedia_transport *tp, 54 pj_status_t status); 55 56 } pjmedia_ice_cb; 41 57 42 58 /** … … 48 64 * @param comp_cnt Number of components to be created. 49 65 * @param stun_cfg Pointer to STUN configuration settings. 66 * @param cb Optional callbacks. 50 67 * @param p_tp Pointer to receive the media transport instance. 51 68 * … … 56 73 unsigned comp_cnt, 57 74 pj_stun_config *stun_cfg, 75 const pjmedia_ice_cb *cb, 58 76 pjmedia_transport **p_tp); 59 77 -
pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c
r1266 r1435 26 26 pjmedia_transport base; 27 27 pj_ice_strans *ice_st; 28 pjmedia_ice_cb cb; 28 29 29 30 pj_time_val start_ice; … … 96 97 unsigned comp_cnt, 97 98 pj_stun_config *stun_cfg, 99 const pjmedia_ice_cb *cb, 98 100 pjmedia_transport **p_tp) 99 101 { … … 123 125 tp_ice->base.op = &tp_ice_op; 124 126 tp_ice->base.type = PJMEDIA_TRANSPORT_TYPE_ICE; 127 128 if (cb) 129 pj_memcpy(&tp_ice->cb, cb, sizeof(pjmedia_ice_cb)); 125 130 126 131 ice_st->user_data = (void*)tp_ice; … … 687 692 688 693 static void ice_on_ice_complete(pj_ice_strans *ice_st, 689 pj_status_t status)694 pj_status_t result) 690 695 { 691 696 struct transport_ice *tp_ice = (struct transport_ice*) ice_st->user_data; … … 699 704 PJ_TIME_VAL_SUB(end_ice, tp_ice->start_ice); 700 705 701 if ( status!= PJ_SUCCESS) {706 if (result != PJ_SUCCESS) { 702 707 char errmsg[PJ_ERR_MSG_SIZE]; 703 pj_strerror( status, errmsg, sizeof(errmsg));708 pj_strerror(result, errmsg, sizeof(errmsg)); 704 709 PJ_LOG(1,(ice_st->obj_name, 705 710 "ICE negotiation failed after %d:%03ds: %s", 706 711 (int)end_ice.sec, (int)end_ice.msec, 707 712 errmsg)); 708 return; 709 } 710 711 check = &ice_st->ice->valid_list.checks[0]; 713 } else { 714 check = &ice_st->ice->valid_list.checks[0]; 712 715 713 lcand = check->lcand; 714 rcand = check->rcand; 715 716 pj_ansi_strcpy(src_addr, pj_inet_ntoa(lcand->addr.ipv4.sin_addr)); 717 pj_ansi_strcpy(dst_addr, pj_inet_ntoa(rcand->addr.ipv4.sin_addr)); 718 719 PJ_LOG(3,(ice_st->obj_name, 720 "ICE negotiation completed in %d.%03ds. Sending from " 721 "%s:%d to %s:%d", 722 (int)end_ice.sec, (int)end_ice.msec, 723 src_addr, pj_ntohs(lcand->addr.ipv4.sin_port), 724 dst_addr, pj_ntohs(rcand->addr.ipv4.sin_port))); 725 } 726 727 716 lcand = check->lcand; 717 rcand = check->rcand; 718 719 pj_ansi_strcpy(src_addr, pj_inet_ntoa(lcand->addr.ipv4.sin_addr)); 720 pj_ansi_strcpy(dst_addr, pj_inet_ntoa(rcand->addr.ipv4.sin_addr)); 721 722 PJ_LOG(4,(ice_st->obj_name, 723 "ICE negotiation completed in %d.%03ds. Sending from " 724 "%s:%d to %s:%d", 725 (int)end_ice.sec, (int)end_ice.msec, 726 src_addr, pj_ntohs(lcand->addr.ipv4.sin_port), 727 dst_addr, pj_ntohs(rcand->addr.ipv4.sin_port))); 728 } 729 730 /* Notify application */ 731 if (tp_ice->cb.on_ice_complete) 732 (*tp_ice->cb.on_ice_complete)(&tp_ice->base, result); 733 } 734 735 -
pjproject/trunk/pjnath/include/pjnath/ice_session.h
r1374 r1435 465 465 pj_bool_t is_complete; /**< Complete? */ 466 466 pj_status_t ice_status; /**< Error status. */ 467 pj_timer_entry completion_timer; /**< To call callback. */ 467 468 pj_ice_sess_cb cb; /**< Callback. */ 468 469 -
pjproject/trunk/pjnath/src/pjnath/ice_session.c
r1410 r1435 337 337 } 338 338 339 if (ice->completion_timer.id) { 340 pj_timer_heap_cancel(ice->stun_cfg.timer_heap, 341 &ice->completion_timer); 342 ice->completion_timer.id = PJ_FALSE; 343 } 344 339 345 for (i=0; i<ice->comp_cnt; ++i) { 340 346 if (ice->comp[i].stun_sess) { … … 946 952 } 947 953 954 /* Timer callback to call on_ice_complete() callback */ 955 static void on_completion_timer(pj_timer_heap_t *th, 956 pj_timer_entry *te) 957 { 958 pj_ice_sess *ice = (pj_ice_sess*) te->user_data; 959 960 PJ_UNUSED_ARG(th); 961 962 te->id = PJ_FALSE; 963 964 if (ice->cb.on_ice_complete) 965 (*ice->cb.on_ice_complete)(ice, ice->ice_status); 966 } 967 948 968 /* This function is called when ICE processing completes */ 949 969 static void on_ice_complete(pj_ice_sess *ice, pj_status_t status) … … 963 983 /* Call callback */ 964 984 if (ice->cb.on_ice_complete) { 965 (*ice->cb.on_ice_complete)(ice, status); 985 pj_time_val delay = {0, 0}; 986 987 ice->completion_timer.cb = &on_completion_timer; 988 ice->completion_timer.user_data = (void*) ice; 989 ice->completion_timer.id = PJ_TRUE; 990 991 pj_timer_heap_schedule(ice->stun_cfg.timer_heap, 992 &ice->completion_timer, 993 &delay); 966 994 } 967 995 } -
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r1426 r1435 1676 1676 "Media for call %d is suspended (hold) by remote", 1677 1677 call_id)); 1678 } else if (call_info.media_status == PJSUA_CALL_MEDIA_ERROR) { 1679 pj_str_t reason = pj_str("ICE negotiation failed"); 1680 1681 PJ_LOG(1,(THIS_FILE, 1682 "Media has reported error, disconnecting call")); 1683 1684 pjsua_call_hangup(call_id, 500, &reason, NULL); 1685 1678 1686 } else { 1679 1687 PJ_LOG(3,(THIS_FILE, -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r1430 r1435 2376 2376 PJSUA_CALL_MEDIA_REMOTE_HOLD, 2377 2377 2378 /** The media has reported error (e.g. ICE negotiation) */ 2379 PJSUA_CALL_MEDIA_ERROR 2380 2378 2381 } pjsua_call_media_status; 2379 2382 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r1417 r1435 538 538 539 539 540 /* This callback is called when ICE negotiation completes */ 541 static void on_ice_complete(pjmedia_transport *tp, pj_status_t result) 542 { 543 unsigned id, c; 544 pj_bool_t found = PJ_FALSE; 545 546 /* We're only interested with failure case */ 547 if (result == PJ_SUCCESS) 548 return; 549 550 /* Find call which has this media transport */ 551 552 PJSUA_LOCK(); 553 554 for (id=0, c=0; id<PJSUA_MAX_CALLS && c<pjsua_var.call_cnt; ++id) { 555 pjsua_call *call = &pjsua_var.calls[id]; 556 if (call->inv) { 557 ++c; 558 559 if (call->med_tp == tp) { 560 call->media_st = PJSUA_CALL_MEDIA_ERROR; 561 call->media_dir = PJMEDIA_DIR_NONE; 562 found = PJ_TRUE; 563 break; 564 } 565 } 566 } 567 568 PJSUA_UNLOCK(); 569 570 if (found && pjsua_var.ua_cfg.cb.on_call_media_state) { 571 pjsua_var.ua_cfg.cb.on_call_media_state(id); 572 } 573 } 574 575 540 576 /* Create ICE media transports (when ice is enabled) */ 541 577 static pj_status_t create_ice_media_transports(pjsua_transport_config *cfg) … … 557 593 for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) { 558 594 pj_ice_strans_comp comp; 595 pjmedia_ice_cb ice_cb; 559 596 int next_port; 560 597 #if PJMEDIA_ADVERTISE_RTCP … … 564 601 #endif 565 602 603 pj_bzero(&ice_cb, sizeof(pjmedia_ice_cb)); 604 ice_cb.on_ice_complete = &on_ice_complete; 605 566 606 status = pjmedia_ice_create(pjsua_var.med_endpt, NULL, COMP_CNT, 567 &pjsua_var.stun_cfg, 607 &pjsua_var.stun_cfg, &ice_cb, 568 608 &pjsua_var.calls[i].med_tp); 569 609 if (status != PJ_SUCCESS) {
Note: See TracChangeset
for help on using the changeset viewer.