- Timestamp:
- Jan 18, 2008 6:49:29 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/users/nanang/pjsip/src/pjsua-lib/pjsua_media.c
r1700 r1709 536 536 } 537 537 538 if (pjsua_var.media_cfg.enable_srtp) { 539 pjmedia_transport *tp; 540 unsigned srtp_options = 0; 541 542 status = pjmedia_transport_udp_attach(pjsua_var.med_endpt, NULL, 543 &skinfo, 0, &tp); 544 status = pjmedia_transport_srtp_create(pjsua_var.med_endpt, tp, 545 srtp_options, 546 &pjsua_var.calls[i].med_tp); 547 } else { 548 status = pjmedia_transport_udp_attach(pjsua_var.med_endpt, NULL, 549 &skinfo, 0, 550 &pjsua_var.calls[i].med_tp); 551 } 538 status = pjmedia_transport_udp_attach(pjsua_var.med_endpt, NULL, 539 &skinfo, 0, 540 &pjsua_var.calls[i].med_tp); 552 541 if (status != PJ_SUCCESS) { 553 542 pjsua_perror(THIS_FILE, "Unable to create media transport", … … 757 746 758 747 pj_status_t pjsua_media_channel_init(pjsua_call_id call_id, 759 pjsip_role_e role) 748 pjsip_role_e role, 749 int security_level) 760 750 { 761 751 pjsua_call *call = &pjsua_var.calls[call_id]; 762 763 if (pjsua_var.media_cfg.enable_ice) { 764 pj_ice_sess_role ice_role; 765 pj_status_t status; 766 767 ice_role = (role==PJSIP_ROLE_UAC ? PJ_ICE_SESS_ROLE_CONTROLLING : 768 PJ_ICE_SESS_ROLE_CONTROLLED); 769 770 /* Restart ICE */ 771 pjmedia_transport_media_stop(call->med_tp); 772 773 status = pjmedia_ice_init_ice(call->med_tp, ice_role, NULL, NULL); 774 if (status != PJ_SUCCESS) 775 return status; 776 } 777 778 return PJ_SUCCESS; 779 } 780 781 pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id, 782 pj_pool_t *pool, 783 const pjmedia_sdp_session *rem_sdp, 784 pjmedia_sdp_session **p_sdp) 785 { 786 pjmedia_sdp_session *sdp; 787 pjmedia_sock_info skinfo; 788 pjsua_call *call = &pjsua_var.calls[call_id]; 789 pj_status_t status; 752 pjsua_acc *acc = &pjsua_var.acc[call->acc_id]; 753 pjmedia_srtp_use use_srtp; 754 755 PJ_UNUSED_ARG(role); 790 756 791 757 /* Return error if media transport has not been created yet … … 796 762 } 797 763 764 /* Stop media transport (for good measure!) */ 765 pjmedia_transport_media_stop(call->med_tp); 766 767 /* See if we need to use SRTP */ 768 use_srtp = acc->cfg.use_srtp; 769 if (use_srtp != PJMEDIA_SRTP_DISABLED) { 770 pj_status_t status; 771 pjmedia_transport *srtp; 772 773 if (security_level < acc->cfg.srtp_secure_signaling) { 774 return PJSIP_ESESSIONINSECURE; 775 } 776 777 /* Create SRTP */ 778 status = pjmedia_transport_srtp_create(pjsua_var.med_endpt, 779 call->med_tp, 780 NULL, &srtp); 781 if (status != PJ_SUCCESS) 782 return status; 783 784 /* Set SRTP as current media transport */ 785 call->med_tp = srtp; 786 } 787 788 return PJ_SUCCESS; 789 } 790 791 pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id, 792 pj_pool_t *pool, 793 const pjmedia_sdp_session *rem_sdp, 794 pjmedia_sdp_session **p_sdp) 795 { 796 enum { MAX_MEDIA = 1, MEDIA_IDX = 0 }; 797 pjmedia_sdp_session *sdp; 798 pjmedia_sock_info skinfo; 799 pjsua_call *call = &pjsua_var.calls[call_id]; 800 pj_status_t status; 801 802 /* Return error if media transport has not been created yet 803 * (e.g. application is starting) 804 */ 805 if (call->med_tp == NULL) { 806 return PJ_EBUSY; 807 } 808 798 809 /* Get media socket info */ 799 810 pjmedia_transport_get_info(call->med_tp, &skinfo); 800 811 801 812 /* Create SDP */ 802 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, pool, 1,813 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, pool, MAX_MEDIA, 803 814 &skinfo, &sdp); 804 815 if (status != PJ_SUCCESS) … … 829 840 } 830 841 831 //if (pjsua_var.media_cfg.enable_ice) { 832 //status = pjmedia_transport_media_create(call->med_tp, pool, sdp, NULL); 833 status = pjmedia_transport_media_create(call->med_tp, pool, 834 sdp, rem_sdp); 835 if (status != PJ_SUCCESS) 836 goto on_error; 837 //} 842 /* Give the SDP to media transport */ 843 status = pjmedia_transport_media_create(call->med_tp, pool, 844 sdp, rem_sdp, MEDIA_IDX); 845 if (status != PJ_SUCCESS) 846 goto on_error; 838 847 839 848 *p_sdp = sdp; … … 874 883 stop_media_session(call_id); 875 884 876 //if (pjsua_var.media_cfg.enable_ice) { 877 pjmedia_transport_media_stop(call->med_tp); 878 //} 879 885 pjmedia_transport_media_stop(call->med_tp); 886 887 if (call->med_tp != call->med_orig) { 888 pjmedia_transport_close(call->med_tp); 889 call->med_tp = call->med_orig; 890 } 880 891 return PJ_SUCCESS; 881 892 } … … 962 973 call->media_dir = PJMEDIA_DIR_NONE; 963 974 964 /* Shutdown ICE session */ 965 //if (pjsua_var.media_cfg.enable_ice) { 966 pjmedia_transport_media_stop(call->med_tp); 967 //} 975 /* Shutdown transport's session */ 976 pjmedia_transport_media_stop(call->med_tp); 968 977 969 978 /* No need because we need keepalive? */ 970 979 971 980 } else { 972 /* Start ICE */ 973 //if (pjsua_var.media_cfg.enable_ice) { 974 status = pjmedia_transport_media_start(call->med_tp, 975 call->inv->pool, 976 local_sdp, remote_sdp, 0); 977 if (status != PJ_SUCCESS) 978 return status; 979 //} 981 /* Start media transport */ 982 status = pjmedia_transport_media_start(call->med_tp, 983 call->inv->pool, 984 local_sdp, remote_sdp, 0); 985 if (status != PJ_SUCCESS) 986 return status; 980 987 981 988 /* Override ptime, if this option is specified. */
Note: See TracChangeset
for help on using the changeset viewer.