Changeset 4043 for pjproject/trunk
- Timestamp:
- Apr 12, 2012 1:41:50 PM (13 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/vid_stream.h
r4012 r4043 72 72 * #pjmedia_vid stream_info from local and remote SDP session descriptors. 73 73 */ 74 75 76 /** 77 * Enumeration of video stream sending rate control. 78 */ 79 typedef enum pjmedia_vid_stream_rc_method 80 { 81 /** 82 * No sending rate control. All outgoing RTP packets will be transmitted 83 * immediately right after encoding process is done. 84 */ 85 PJMEDIA_VID_STREAM_RC_NONE = 0, 86 87 /** 88 * Simple blocking. Each outgoing RTP packet transmission may be delayed 89 * to avoid peak bandwidth that is much higher than specified. The thread 90 * invoking the video stream put_frame(), e.g: video capture device thread, 91 * will be blocked whenever transmission delay takes place. 92 */ 93 PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING = 1 94 95 } pjmedia_vid_stream_rc_method; 96 97 98 /** 99 * Structure of configuration settings for video stream sending rate control. 100 */ 101 typedef struct pjmedia_vid_stream_rc_config 102 { 103 /** 104 * Rate control method. 105 * 106 * Default: PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING. 107 */ 108 pjmedia_vid_stream_rc_method method; 109 110 /** 111 * Upstream/outgoing bandwidth. If this is set to zero, the video stream 112 * will use codec maximum bitrate setting. 113 * 114 * Default: 0 (follow codec maximum bitrate). 115 */ 116 unsigned bandwidth; 117 118 } pjmedia_vid_stream_rc_config; 74 119 75 120 … … 118 163 /**< Disable automatic sending of RTCP 119 164 SDES and BYE. */ 165 166 pjmedia_vid_stream_rc_config rc_cfg; 167 /**< Stream send rate control settings. */ 120 168 } pjmedia_vid_stream_info; 121 169 … … 144 192 const pjmedia_sdp_session *remote, 145 193 unsigned stream_idx); 194 195 196 /** 197 * Initialize the video stream rate control with default settings. 198 * 199 * @param cfg Video stream rate control structure to be initialized. 200 */ 201 PJ_DECL(void) 202 pjmedia_vid_stream_rc_config_default(pjmedia_vid_stream_rc_config *cfg); 146 203 147 204 -
pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c
r4022 r4043 154 154 155 155 pjmedia_vid_codec *codec; /**< Codec instance being used. */ 156 pj_uint32_t last_dec_ts; /**< Last decoded timestamp. */ 157 int last_dec_seq; /**< Last decoded sequence. */ 156 pj_uint32_t last_dec_ts; /**< Last decoded timestamp. */ 157 int last_dec_seq; /**< Last decoded sequence. */ 158 159 160 pj_timestamp ts_freq; /**< Timestamp frequency. */ 158 161 }; 159 162 … … 769 772 pj_size_t total_sent = 0; 770 773 pjmedia_vid_encode_opt enc_opt; 774 unsigned pkt_cnt = 0; 775 pj_timestamp initial_time; 771 776 772 777 #if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA != 0 … … 827 832 return status; 828 833 } 834 835 pj_get_timestamp(&initial_time); 829 836 830 837 /* Loop while we have frame to send */ … … 865 872 pjmedia_rtcp_tx_rtp(&stream->rtcp, frame_out.size); 866 873 total_sent += frame_out.size; 874 pkt_cnt++; 867 875 868 876 if (!has_more_data) … … 886 894 break; 887 895 } 888 } 896 897 /* Send rate control */ 898 if (stream->info.rc_cfg.method==PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING) 899 { 900 pj_timestamp now, next_send_ts, total_send_ts; 901 902 total_send_ts.u64 = total_sent * stream->ts_freq.u64 * 8 / 903 stream->info.rc_cfg.bandwidth; 904 next_send_ts = initial_time; 905 pj_add_timestamp(&next_send_ts, &total_send_ts); 906 907 pj_get_timestamp(&now); 908 if (pj_cmp_timestamp(&now, &next_send_ts) < 0) { 909 unsigned ms_sleep; 910 ms_sleep = pj_elapsed_msec(&now, &next_send_ts); 911 912 if (ms_sleep > 10) 913 ms_sleep = 10; 914 915 pj_thread_sleep(ms_sleep); 916 } 917 } 918 } 919 920 #if 0 921 /* Trace log for rate control */ 922 { 923 pj_timestamp end_time; 924 pj_get_timestamp(&end_time); 925 PJ_LOG(5, (stream->name.ptr, "total pkt=%d size=%d sleep=%d", 926 pkt_cnt, total_sent, 927 pj_elapsed_msec(&initial_time, &end_time))); 928 } 929 #endif 889 930 890 931 /* Check if now is the time to transmit RTCP SR/RR report. … … 1414 1455 vfd_enc->fps.denum / vfd_enc->fps.num; 1415 1456 1457 /* Initialize send rate states */ 1458 pj_get_timestamp_freq(&stream->ts_freq); 1459 if (info->rc_cfg.bandwidth == 0) 1460 info->rc_cfg.bandwidth = vfd_enc->max_bps * 150 / 100; 1461 1416 1462 /* Override the initial framerate in the decoding direction. This initial 1417 1463 * value will be used by the renderer to configure its clock, and setting … … 1868 1914 1869 1915 1916 /* 1917 * Initialize the video stream rate control with default settings. 1918 */ 1919 PJ_DEF(void) 1920 pjmedia_vid_stream_rc_config_default(pjmedia_vid_stream_rc_config *cfg) 1921 { 1922 pj_bzero(cfg, sizeof(*cfg)); 1923 cfg->method = PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING; 1924 } 1925 1926 1870 1927 #endif /* PJMEDIA_HAS_VIDEO */ -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r4016 r4043 2883 2883 2884 2884 /** 2885 * Specify the send rate control for video stream. 2886 * 2887 * Default: see #pjmedia_vid_stream_rc_config 2888 */ 2889 pjmedia_vid_stream_rc_config vid_stream_rc_cfg; 2890 2891 /** 2885 2892 * Media transport config. 2886 2893 */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r4001 r4043 219 219 cfg->vid_cap_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 220 220 cfg->vid_rend_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV; 221 pjmedia_vid_stream_rc_config_default(&cfg->vid_stream_rc_cfg); 221 222 pjsua_transport_config_default(&cfg->rtp_cfg); 222 223 cfg->use_srtp = pjsua_var.ua_cfg.use_srtp; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c
r4028 r4043 747 747 si->rtp_seq = call_med->rtp_tx_seq; 748 748 si->rtp_seq_ts_set = call_med->rtp_tx_seq_ts_set; 749 750 /* Set rate control config from account setting */ 751 si->rc_cfg = acc->cfg.vid_stream_rc_cfg; 749 752 750 753 #if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0
Note: See TracChangeset
for help on using the changeset viewer.