Changeset 4043 for pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c
- Timestamp:
- Apr 12, 2012 1:41:50 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 */
Note: See TracChangeset
for help on using the changeset viewer.