Changeset 1735 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
- Timestamp:
- Jan 23, 2008 8:39:07 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r1704 r1735 535 535 goto on_error; 536 536 } 537 537 538 status = pjmedia_transport_udp_attach(pjsua_var.med_endpt, NULL, 538 539 &skinfo, 0, … … 544 545 } 545 546 546 pjmedia_transport_ udp_simulate_lost(pjsua_var.calls[i].med_tp,547 548 549 550 pjmedia_transport_ udp_simulate_lost(pjsua_var.calls[i].med_tp,551 552 547 pjmedia_transport_simulate_lost(pjsua_var.calls[i].med_tp, 548 PJMEDIA_DIR_ENCODING, 549 pjsua_var.media_cfg.tx_drop_pct); 550 551 pjmedia_transport_simulate_lost(pjsua_var.calls[i].med_tp, 552 PJMEDIA_DIR_DECODING, 553 pjsua_var.media_cfg.rx_drop_pct); 553 554 554 555 } … … 646 647 } 647 648 648 pjmedia_ ice_simulate_lost(pjsua_var.calls[i].med_tp,649 PJMEDIA_DIR_ENCODING,650 pjsua_var.media_cfg.tx_drop_pct);651 652 pjmedia_ ice_simulate_lost(pjsua_var.calls[i].med_tp,653 PJMEDIA_DIR_DECODING,654 pjsua_var.media_cfg.rx_drop_pct);649 pjmedia_transport_simulate_lost(pjsua_var.calls[i].med_tp, 650 PJMEDIA_DIR_ENCODING, 651 pjsua_var.media_cfg.tx_drop_pct); 652 653 pjmedia_transport_simulate_lost(pjsua_var.calls[i].med_tp, 654 PJMEDIA_DIR_DECODING, 655 pjsua_var.media_cfg.rx_drop_pct); 655 656 656 657 status = pjmedia_ice_start_init(pjsua_var.calls[i].med_tp, 0, &addr, … … 745 746 746 747 pj_status_t pjsua_media_channel_init(pjsua_call_id call_id, 747 pjsip_role_e role) 748 pjsip_role_e role, 749 int security_level) 748 750 { 749 751 pjsua_call *call = &pjsua_var.calls[call_id]; 750 752 751 if (pjsua_var.media_cfg.enable_ice) { 752 pj_ice_sess_role ice_role; 753 pj_status_t status; 754 755 ice_role = (role==PJSIP_ROLE_UAC ? PJ_ICE_SESS_ROLE_CONTROLLING : 756 PJ_ICE_SESS_ROLE_CONTROLLED); 757 758 /* Restart ICE */ 759 pjmedia_ice_stop_ice(call->med_tp); 760 761 status = pjmedia_ice_init_ice(call->med_tp, ice_role, NULL, NULL); 762 if (status != PJ_SUCCESS) 763 return status; 764 } 765 766 return PJ_SUCCESS; 767 } 768 769 pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id, 770 pj_pool_t *pool, 771 pjmedia_sdp_session **p_sdp) 772 { 773 pjmedia_sdp_session *sdp; 774 pjmedia_sock_info skinfo; 775 pjsua_call *call = &pjsua_var.calls[call_id]; 753 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 754 pjsua_acc *acc = &pjsua_var.acc[call->acc_id]; 755 pjmedia_srtp_setting srtp_opt; 756 pjmedia_transport *srtp; 776 757 pj_status_t status; 758 #endif 759 760 PJ_UNUSED_ARG(role); 777 761 778 762 /* Return error if media transport has not been created yet … … 783 767 } 784 768 769 /* Stop media transport (for good measure!) */ 770 pjmedia_transport_media_stop(call->med_tp); 771 772 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 773 /* Check if SRTP requires secure signaling */ 774 if (acc->cfg.use_srtp != PJMEDIA_SRTP_DISABLED) { 775 if (security_level < acc->cfg.srtp_secure_signaling) { 776 return PJSIP_ESESSIONINSECURE; 777 } 778 } 779 780 /* Always create SRTP adapter */ 781 pjmedia_srtp_setting_default(&srtp_opt); 782 srtp_opt.close_member_tp = PJ_FALSE; 783 srtp_opt.use = acc->cfg.use_srtp; 784 status = pjmedia_transport_srtp_create(pjsua_var.med_endpt, 785 call->med_tp, 786 &srtp_opt, &srtp); 787 if (status != PJ_SUCCESS) 788 return status; 789 790 /* Set SRTP as current media transport */ 791 call->med_orig = call->med_tp; 792 call->med_tp = srtp; 793 #else 794 call->med_orig = call->med_tp; 795 PJ_UNUSED_ARG(security_level); 796 #endif 797 798 return PJ_SUCCESS; 799 } 800 801 pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id, 802 pj_pool_t *pool, 803 const pjmedia_sdp_session *rem_sdp, 804 pjmedia_sdp_session **p_sdp) 805 { 806 enum { MAX_MEDIA = 1, MEDIA_IDX = 0 }; 807 pjmedia_sdp_session *sdp; 808 pjmedia_sock_info skinfo; 809 pjsua_call *call = &pjsua_var.calls[call_id]; 810 pj_status_t status; 811 812 /* Return error if media transport has not been created yet 813 * (e.g. application is starting) 814 */ 815 if (call->med_tp == NULL) { 816 return PJ_EBUSY; 817 } 818 785 819 /* Get media socket info */ 786 820 pjmedia_transport_get_info(call->med_tp, &skinfo); 787 821 788 822 /* Create SDP */ 789 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, pool, 1,823 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, pool, MAX_MEDIA, 790 824 &skinfo, &sdp); 791 825 if (status != PJ_SUCCESS) … … 816 850 } 817 851 818 if (pjsua_var.media_cfg.enable_ice) {819 status = pjmedia_ice_modify_sdp(call->med_tp, pool, sdp); 820 if (status != PJ_SUCCESS)821 goto on_error; 822 } 852 /* Give the SDP to media transport */ 853 status = pjmedia_transport_media_create(call->med_tp, pool, 854 sdp, rem_sdp, MEDIA_IDX); 855 if (status != PJ_SUCCESS) 856 goto on_error; 823 857 824 858 *p_sdp = sdp; … … 859 893 stop_media_session(call_id); 860 894 861 if (pjsua_var.media_cfg.enable_ice) { 862 pjmedia_ice_stop_ice(call->med_tp); 863 } 864 895 pjmedia_transport_media_stop(call->med_tp); 896 897 if (call->med_tp != call->med_orig) { 898 pjmedia_transport_close(call->med_tp); 899 call->med_tp = call->med_orig; 900 } 865 901 return PJ_SUCCESS; 866 902 } … … 878 914 pjsua_call_id call_id; 879 915 880 call_id = (pjsua_call_id) user_data;916 call_id = (pjsua_call_id)(long)user_data; 881 917 pjsua_var.ua_cfg.cb.on_dtmf_digit(call_id, digit); 882 918 } … … 885 921 886 922 pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, 887 constpjmedia_sdp_session *local_sdp,923 pjmedia_sdp_session *local_sdp, 888 924 const pjmedia_sdp_session *remote_sdp) 889 925 { … … 912 948 for (i=0; i < sess_info.stream_cnt; ++i) { 913 949 if (sess_info.stream_info[i].type == PJMEDIA_TYPE_AUDIO && 914 sess_info.stream_info[i].proto == PJMEDIA_TP_PROTO_RTP_AVP) 950 (sess_info.stream_info[i].proto == PJMEDIA_TP_PROTO_RTP_AVP || 951 sess_info.stream_info[i].proto == PJMEDIA_TP_PROTO_RTP_SAVP)) 915 952 { 916 953 si = &sess_info.stream_info[i]; … … 946 983 call->media_dir = PJMEDIA_DIR_NONE; 947 984 948 /* Shutdown ICE session */ 949 if (pjsua_var.media_cfg.enable_ice) { 950 pjmedia_ice_stop_ice(call->med_tp); 951 } 985 /* Shutdown transport's session */ 986 pjmedia_transport_media_stop(call->med_tp); 952 987 953 988 /* No need because we need keepalive? */ 954 989 955 990 } else { 956 /* Start ICE */ 957 if (pjsua_var.media_cfg.enable_ice) { 958 status = pjmedia_ice_start_ice(call->med_tp, call->inv->pool, 959 remote_sdp, 0); 960 if (status != PJ_SUCCESS) 961 return status; 962 } 991 /* Start media transport */ 992 status = pjmedia_transport_media_start(call->med_tp, 993 call->inv->pool, 994 local_sdp, remote_sdp, 0); 995 if (status != PJ_SUCCESS) 996 return status; 963 997 964 998 /* Override ptime, if this option is specified. */ … … 1001 1035 pjmedia_session_set_dtmf_callback(call->session, 0, 1002 1036 &dtmf_callback, 1003 (void*)( call->index));1037 (void*)(long)(call->index)); 1004 1038 } 1005 1039
Note: See TracChangeset
for help on using the changeset viewer.