- Timestamp:
- Dec 28, 2016 3:40:07 AM (8 years ago)
- Location:
- pjproject/branches/projects/uwp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/uwp
- Property svn:mergeinfo changed
/pjproject/trunk (added) merged: 5209,5212-5234,5237-5253,5255,5257-5292,5294-5297,5299-5332,5334-5394,5396-5438,5440-5469,5471-5496,5498-5510
- Property svn:mergeinfo changed
-
pjproject/branches/projects/uwp/pjmedia/src/pjmedia/vid_stream.c
r5101 r5513 23 23 #include <pjmedia/rtcp.h> 24 24 #include <pjmedia/jbuf.h> 25 #include <pjmedia/stream_common.h>26 25 #include <pj/array.h> 27 26 #include <pj/assert.h> … … 153 152 pjmedia_frame *rx_frames; /**< Temp. buffer for incoming 154 153 frame assembly. */ 155 156 154 pj_bool_t force_keyframe;/**< Forced to encode keyframe? */ 155 unsigned num_keyframe; /**< The number of keyframe needed 156 to be sent, after the stream 157 is created. */ 158 pj_timestamp last_keyframe_tx; 159 /**< Timestamp of the last 160 keyframe. */ 161 157 162 158 163 #if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0 … … 439 444 send_rtcp(stream, PJ_TRUE, PJ_FALSE); 440 445 446 /* Update stats in case the stream is paused */ 447 stream->rtcp.stat.rtp_tx_last_seq = pj_ntohs(stream->enc->rtp.out_hdr.seq); 448 441 449 #elif PJMEDIA_STREAM_ENABLE_KA == PJMEDIA_STREAM_KA_USER 442 450 … … 608 616 if (bytes_read < 0) { 609 617 status = (pj_status_t)-bytes_read; 618 if (status == PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK)) { 619 return; 620 } 610 621 if (stream->rtp_rx_last_err != status) { 611 622 char errmsg[PJ_ERR_MSG_SIZE]; … … 787 798 /* Check for errors */ 788 799 if (bytes_read < 0) { 789 LOGERR_((stream->cname.ptr, "RTCP recv() error", 790 (pj_status_t)-bytes_read)); 800 if (bytes_read != -PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK)) { 801 LOGERR_((stream->cname.ptr, "RTCP recv() error", 802 (pj_status_t)-bytes_read)); 803 } 791 804 return; 792 805 } … … 810 823 unsigned pkt_cnt = 0; 811 824 pj_timestamp initial_time; 825 pj_timestamp null_ts ={0}; 812 826 813 827 #if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA != 0 … … 846 860 frame_out.size = 0; 847 861 862 /* Check if need to send keyframe. */ 863 if (stream->num_keyframe && 864 (pj_cmp_timestamp(&null_ts, &stream->last_keyframe_tx) != 0)) 865 { 866 unsigned elapse_time; 867 pj_timestamp now; 868 869 pj_get_timestamp(&now); 870 871 elapse_time = pj_elapsed_msec(&stream->last_keyframe_tx, &now); 872 873 if (elapse_time > stream->info.sk_cfg.interval) 874 { 875 stream->force_keyframe = PJ_TRUE; 876 --stream->num_keyframe; 877 } 878 } 879 848 880 /* Init encoding option */ 849 881 pj_bzero(&enc_opt, sizeof(enc_opt)); … … 874 906 875 907 pj_get_timestamp(&initial_time); 908 909 if ((stream->num_keyframe) && 910 ((frame_out.bit_info & PJMEDIA_VID_FRM_KEYFRAME) 911 == PJMEDIA_VID_FRM_KEYFRAME)) 912 { 913 stream->last_keyframe_tx = initial_time; 914 } 876 915 877 916 /* Loop while we have frame to send */ … … 1385 1424 char *p; 1386 1425 pj_status_t status; 1426 pjmedia_transport_attach_param att_param; 1387 1427 1388 1428 if (!pool) { … … 1455 1495 stream->use_ka = info->use_ka; 1456 1496 #endif 1497 stream->num_keyframe = info->sk_cfg.count; 1457 1498 1458 1499 /* Build random RTCP CNAME. CNAME has user@host format */ … … 1625 1666 1626 1667 stream->out_rtcp_pkt = pj_pool_alloc(pool, stream->out_rtcp_pkt_size); 1668 att_param.stream = stream; 1669 att_param.media_type = PJMEDIA_TYPE_VIDEO; 1670 att_param.user_data = stream; 1671 pj_sockaddr_cp(&att_param.rem_addr, &info->rem_addr); 1672 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp); 1673 att_param.addr_len = pj_sockaddr_get_len(&info->rem_addr); 1674 att_param.rtp_cb = &on_rx_rtp; 1675 att_param.rtcp_cb = &on_rx_rtcp; 1627 1676 1628 1677 /* Only attach transport when stream is ready. */ 1629 status = pjmedia_transport_attach(tp, stream, &info->rem_addr, 1630 &info->rem_rtcp, 1631 pj_sockaddr_get_len(&info->rem_addr), 1632 &on_rx_rtp, &on_rx_rtcp); 1678 status = pjmedia_transport_attach2(tp, &att_param); 1633 1679 if (status != PJ_SUCCESS) 1634 1680 return status; … … 2005 2051 2006 2052 2053 /* 2054 * Initialize the video stream send keyframe with default settings. 2055 */ 2056 PJ_DEF(void) 2057 pjmedia_vid_stream_sk_config_default(pjmedia_vid_stream_sk_config *cfg) 2058 { 2059 pj_bzero(cfg, sizeof(*cfg)); 2060 cfg->count = PJMEDIA_VID_STREAM_START_KEYFRAME_CNT; 2061 cfg->interval = PJMEDIA_VID_STREAM_START_KEYFRAME_INTERVAL_MSEC; 2062 } 2063 2064 2065 /** 2066 * Get RTP session information from video stream. 2067 */ 2068 PJ_DEF(pj_status_t) 2069 pjmedia_vid_stream_get_rtp_session_info(pjmedia_vid_stream *stream, 2070 pjmedia_stream_rtp_sess_info *session_info) 2071 { 2072 session_info->rx_rtp = &stream->dec->rtp; 2073 session_info->tx_rtp = &stream->enc->rtp; 2074 session_info->rtcp = &stream->rtcp; 2075 return PJ_SUCCESS; 2076 } 2077 2078 2007 2079 #endif /* PJMEDIA_HAS_VIDEO */
Note: See TracChangeset
for help on using the changeset viewer.