Changeset 3982 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c
- Timestamp:
- Mar 22, 2012 9:56:52 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c
r3956 r3982 20 20 #include <pjsua-lib/pjsua_internal.h> 21 21 22 #if defined(PJSUA_MEDIA_HAS_PJMEDIA) && PJSUA_MEDIA_HAS_PJMEDIA != 0 23 22 24 #define THIS_FILE "pjsua_vid.c" 23 25 … … 668 670 } 669 671 672 /* Initialize video call media */ 673 pj_status_t pjsua_vid_channel_init(pjsua_call_media *call_med) 674 { 675 pjsua_acc *acc = &pjsua_var.acc[call_med->call->acc_id]; 676 677 call_med->strm.v.rdr_dev = acc->cfg.vid_rend_dev; 678 call_med->strm.v.cap_dev = acc->cfg.vid_cap_dev; 679 if (call_med->strm.v.rdr_dev == PJMEDIA_VID_DEFAULT_RENDER_DEV) { 680 pjmedia_vid_dev_info info; 681 pjmedia_vid_dev_get_info(call_med->strm.v.rdr_dev, &info); 682 call_med->strm.v.rdr_dev = info.id; 683 } 684 if (call_med->strm.v.cap_dev == PJMEDIA_VID_DEFAULT_CAPTURE_DEV) { 685 pjmedia_vid_dev_info info; 686 pjmedia_vid_dev_get_info(call_med->strm.v.cap_dev, &info); 687 call_med->strm.v.cap_dev = info.id; 688 } 689 690 return PJ_SUCCESS; 691 } 670 692 671 693 /* Internal function: update video channel after SDP negotiation */ 672 pj_status_t video_channel_update(pjsua_call_media *call_med, 673 pj_pool_t *tmp_pool, 674 const pjmedia_sdp_session *local_sdp, 675 const pjmedia_sdp_session *remote_sdp) 694 pj_status_t pjsua_vid_channel_update(pjsua_call_media *call_med, 695 pj_pool_t *tmp_pool, 696 pjmedia_vid_stream_info *si, 697 const pjmedia_sdp_session *local_sdp, 698 const pjmedia_sdp_session *remote_sdp) 676 699 { 677 700 pjsua_call *call = call_med->call; 678 701 pjsua_acc *acc = &pjsua_var.acc[call->acc_id]; 679 pjmedia_vid_stream_info the_si, *si = &the_si;680 702 pjmedia_port *media_port; 681 unsigned strm_idx = call_med->idx;682 703 pj_status_t status; 683 704 … … 685 706 pj_log_push_indent(); 686 707 687 status = pjmedia_vid_stream_info_from_sdp(si, tmp_pool, pjsua_var.med_endpt,688 local_sdp, remote_sdp, strm_idx);689 if (status != PJ_SUCCESS)690 goto on_error;691 692 708 /* Check if no media is active */ 693 if (si->dir == PJMEDIA_DIR_NONE) { 694 /* Call media state */ 695 call_med->state = PJSUA_CALL_MEDIA_NONE; 696 697 /* Call media direction */ 698 call_med->dir = PJMEDIA_DIR_NONE; 699 700 } else { 701 pjmedia_transport_info tp_info; 702 703 /* Start/restart media transport */ 704 status = pjmedia_transport_media_start(call_med->tp, 705 tmp_pool, local_sdp, 706 remote_sdp, strm_idx); 707 if (status != PJ_SUCCESS) 708 goto on_error; 709 710 set_media_tp_state(call_med, PJSUA_MED_TP_RUNNING); 711 712 /* Get remote SRTP usage policy */ 713 pjmedia_transport_info_init(&tp_info); 714 pjmedia_transport_get_info(call_med->tp, &tp_info); 715 if (tp_info.specific_info_cnt > 0) { 716 unsigned i; 717 for (i = 0; i < tp_info.specific_info_cnt; ++i) { 718 if (tp_info.spc_info[i].type == PJMEDIA_TRANSPORT_TYPE_SRTP) 719 { 720 pjmedia_srtp_info *srtp_info = 721 (pjmedia_srtp_info*) tp_info.spc_info[i].buffer; 722 723 call_med->rem_srtp_use = srtp_info->peer_use; 724 break; 725 } 726 } 727 } 728 709 if (si->dir != PJMEDIA_DIR_NONE) { 729 710 /* Optionally, application may modify other stream settings here 730 711 * (such as jitter buffer parameters, codec ptime, etc.) … … 926 907 } 927 908 928 /* Call media direction */929 call_med->dir = si->dir;930 931 /* Call media state */932 if (call->local_hold)933 call_med->state = PJSUA_CALL_MEDIA_LOCAL_HOLD;934 else if (call_med->dir == PJMEDIA_DIR_DECODING)935 call_med->state = PJSUA_CALL_MEDIA_REMOTE_HOLD;936 else937 call_med->state = PJSUA_CALL_MEDIA_ACTIVE;938 }939 940 /* Print info. */941 {942 char info[80];943 int info_len = 0;944 int len;945 const char *dir;946 947 switch (si->dir) {948 case PJMEDIA_DIR_NONE:949 dir = "inactive";950 break;951 case PJMEDIA_DIR_ENCODING:952 dir = "sendonly";953 break;954 case PJMEDIA_DIR_DECODING:955 dir = "recvonly";956 break;957 case PJMEDIA_DIR_ENCODING_DECODING:958 dir = "sendrecv";959 break;960 default:961 dir = "unknown";962 break;963 }964 len = pj_ansi_sprintf( info+info_len,965 ", stream #%d: %.*s (%s)", strm_idx,966 (int)si->codec_info.encoding_name.slen,967 si->codec_info.encoding_name.ptr,968 dir);969 if (len > 0)970 info_len += len;971 PJ_LOG(4,(THIS_FILE,"Video updated%s", info));972 909 } 973 910 … … 989 926 990 927 /* Internal function to stop video stream */ 991 void stop_video_stream(pjsua_call_media *call_med)928 void pjsua_vid_stop_stream(pjsua_call_media *call_med) 992 929 { 993 930 pjmedia_vid_stream *strm = call_med->strm.v.stream; … … 1590 1527 goto on_error; 1591 1528 1592 set_media_tp_state(call_med, PJSUA_MED_TP_INIT);1529 pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_INIT); 1593 1530 1594 1531 /* Get transport address info */ … … 1785 1722 // Don't close this here, as SDP negotiation has not been 1786 1723 // done and stream may be still active. 1787 set_media_tp_state(call_med, PJSUA_MED_TP_DISABLED);1724 pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_DISABLED); 1788 1725 1789 1726 /* Deactivate the stream */ … … 2186 2123 #endif /* PJSUA_HAS_VIDEO */ 2187 2124 2125 #endif /* PJSUA_MEDIA_HAS_PJMEDIA */
Note: See TracChangeset
for help on using the changeset viewer.