OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "webrtc/modules/pacing/paced_sender.h" | 33 #include "webrtc/modules/pacing/paced_sender.h" |
34 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 34 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
35 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 35 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
36 #include "webrtc/modules/utility/include/process_thread.h" | 36 #include "webrtc/modules/utility/include/process_thread.h" |
37 #include "webrtc/system_wrappers/include/cpu_info.h" | 37 #include "webrtc/system_wrappers/include/cpu_info.h" |
38 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 38 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
39 #include "webrtc/system_wrappers/include/metrics.h" | 39 #include "webrtc/system_wrappers/include/metrics.h" |
40 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" | 40 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" |
41 #include "webrtc/system_wrappers/include/trace.h" | 41 #include "webrtc/system_wrappers/include/trace.h" |
42 #include "webrtc/video/call_stats.h" | 42 #include "webrtc/video/call_stats.h" |
| 43 #include "webrtc/video/send_delay_stats.h" |
43 #include "webrtc/video/video_receive_stream.h" | 44 #include "webrtc/video/video_receive_stream.h" |
44 #include "webrtc/video/video_send_stream.h" | 45 #include "webrtc/video/video_send_stream.h" |
45 #include "webrtc/video/vie_remb.h" | 46 #include "webrtc/video/vie_remb.h" |
46 #include "webrtc/voice_engine/include/voe_codec.h" | 47 #include "webrtc/voice_engine/include/voe_codec.h" |
47 | 48 |
48 namespace webrtc { | 49 namespace webrtc { |
49 | 50 |
50 const int Call::Config::kDefaultStartBitrateBps = 300000; | 51 const int Call::Config::kDefaultStartBitrateBps = 300000; |
51 | 52 |
52 namespace internal { | 53 namespace internal { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // OnNetworkChanged from multiple threads. | 171 // OnNetworkChanged from multiple threads. |
171 rtc::CriticalSection bitrate_crit_; | 172 rtc::CriticalSection bitrate_crit_; |
172 int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); | 173 int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); |
173 int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); | 174 int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); |
174 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_); | 175 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_); |
175 | 176 |
176 std::map<std::string, rtc::NetworkRoute> network_routes_; | 177 std::map<std::string, rtc::NetworkRoute> network_routes_; |
177 | 178 |
178 VieRemb remb_; | 179 VieRemb remb_; |
179 const std::unique_ptr<CongestionController> congestion_controller_; | 180 const std::unique_ptr<CongestionController> congestion_controller_; |
| 181 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; |
180 | 182 |
181 RTC_DISALLOW_COPY_AND_ASSIGN(Call); | 183 RTC_DISALLOW_COPY_AND_ASSIGN(Call); |
182 }; | 184 }; |
183 } // namespace internal | 185 } // namespace internal |
184 | 186 |
185 Call* Call::Create(const Call::Config& config) { | 187 Call* Call::Create(const Call::Config& config) { |
186 return new internal::Call(config); | 188 return new internal::Call(config); |
187 } | 189 } |
188 | 190 |
189 namespace internal { | 191 namespace internal { |
(...skipping 13 matching lines...) Expand all Loading... |
203 received_video_bytes_(0), | 205 received_video_bytes_(0), |
204 received_audio_bytes_(0), | 206 received_audio_bytes_(0), |
205 received_rtcp_bytes_(0), | 207 received_rtcp_bytes_(0), |
206 first_rtp_packet_received_ms_(-1), | 208 first_rtp_packet_received_ms_(-1), |
207 last_rtp_packet_received_ms_(-1), | 209 last_rtp_packet_received_ms_(-1), |
208 first_packet_sent_ms_(-1), | 210 first_packet_sent_ms_(-1), |
209 estimated_send_bitrate_sum_kbits_(0), | 211 estimated_send_bitrate_sum_kbits_(0), |
210 pacer_bitrate_sum_kbits_(0), | 212 pacer_bitrate_sum_kbits_(0), |
211 num_bitrate_updates_(0), | 213 num_bitrate_updates_(0), |
212 remb_(clock_), | 214 remb_(clock_), |
213 congestion_controller_(new CongestionController(clock_, this, &remb_)) { | 215 congestion_controller_(new CongestionController(clock_, this, &remb_)), |
| 216 video_send_delay_stats_(new SendDelayStats(clock_)) { |
214 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 217 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
215 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 218 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
216 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 219 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
217 config.bitrate_config.min_bitrate_bps); | 220 config.bitrate_config.min_bitrate_bps); |
218 if (config.bitrate_config.max_bitrate_bps != -1) { | 221 if (config.bitrate_config.max_bitrate_bps != -1) { |
219 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 222 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
220 config.bitrate_config.start_bitrate_bps); | 223 config.bitrate_config.start_bitrate_bps); |
221 } | 224 } |
222 if (config.audio_state.get()) { | 225 if (config.audio_state.get()) { |
223 ScopedVoEInterface<VoECodec> voe_codec(voice_engine()); | 226 ScopedVoEInterface<VoECodec> voe_codec(voice_engine()); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 UpdateAggregateNetworkState(); | 399 UpdateAggregateNetworkState(); |
397 delete audio_receive_stream; | 400 delete audio_receive_stream; |
398 } | 401 } |
399 | 402 |
400 webrtc::VideoSendStream* Call::CreateVideoSendStream( | 403 webrtc::VideoSendStream* Call::CreateVideoSendStream( |
401 const webrtc::VideoSendStream::Config& config, | 404 const webrtc::VideoSendStream::Config& config, |
402 const VideoEncoderConfig& encoder_config) { | 405 const VideoEncoderConfig& encoder_config) { |
403 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); | 406 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); |
404 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 407 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
405 | 408 |
| 409 video_send_delay_stats_->AddSsrcs(config); |
406 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if | 410 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if |
407 // the call has already started. | 411 // the call has already started. |
408 VideoSendStream* send_stream = new VideoSendStream( | 412 VideoSendStream* send_stream = new VideoSendStream( |
409 num_cpu_cores_, module_process_thread_.get(), call_stats_.get(), | 413 num_cpu_cores_, module_process_thread_.get(), call_stats_.get(), |
410 congestion_controller_.get(), bitrate_allocator_.get(), &remb_, config, | 414 congestion_controller_.get(), bitrate_allocator_.get(), |
411 encoder_config, suspended_video_send_ssrcs_); | 415 video_send_delay_stats_.get(), &remb_, config, encoder_config, |
| 416 suspended_video_send_ssrcs_); |
412 { | 417 { |
413 WriteLockScoped write_lock(*send_crit_); | 418 WriteLockScoped write_lock(*send_crit_); |
414 for (uint32_t ssrc : config.rtp.ssrcs) { | 419 for (uint32_t ssrc : config.rtp.ssrcs) { |
415 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 420 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
416 video_send_ssrcs_[ssrc] = send_stream; | 421 video_send_ssrcs_[ssrc] = send_stream; |
417 } | 422 } |
418 video_send_streams_.insert(send_stream); | 423 video_send_streams_.insert(send_stream); |
419 } | 424 } |
420 send_stream->SignalNetworkState(video_network_state_); | 425 send_stream->SignalNetworkState(video_network_state_); |
421 UpdateAggregateNetworkState(); | 426 UpdateAggregateNetworkState(); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 | 659 |
655 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state=" | 660 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state=" |
656 << (aggregate_state == kNetworkUp ? "up" : "down"); | 661 << (aggregate_state == kNetworkUp ? "up" : "down"); |
657 | 662 |
658 congestion_controller_->SignalNetworkState(aggregate_state); | 663 congestion_controller_->SignalNetworkState(aggregate_state); |
659 } | 664 } |
660 | 665 |
661 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { | 666 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { |
662 if (first_packet_sent_ms_ == -1) | 667 if (first_packet_sent_ms_ == -1) |
663 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); | 668 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); |
| 669 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, |
| 670 clock_->TimeInMilliseconds()); |
664 congestion_controller_->OnSentPacket(sent_packet); | 671 congestion_controller_->OnSentPacket(sent_packet); |
665 } | 672 } |
666 | 673 |
667 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss, | 674 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss, |
668 int64_t rtt_ms) { | 675 int64_t rtt_ms) { |
669 uint32_t allocated_bitrate_bps = bitrate_allocator_->OnNetworkChanged( | 676 uint32_t allocated_bitrate_bps = bitrate_allocator_->OnNetworkChanged( |
670 target_bitrate_bps, fraction_loss, rtt_ms); | 677 target_bitrate_bps, fraction_loss, rtt_ms); |
671 | 678 |
672 int pad_up_to_bitrate_bps = 0; | 679 int pad_up_to_bitrate_bps = 0; |
673 { | 680 { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 // thread. Then this check can be enabled. | 849 // thread. Then this check can be enabled. |
843 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 850 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
844 if (RtpHeaderParser::IsRtcp(packet, length)) | 851 if (RtpHeaderParser::IsRtcp(packet, length)) |
845 return DeliverRtcp(media_type, packet, length); | 852 return DeliverRtcp(media_type, packet, length); |
846 | 853 |
847 return DeliverRtp(media_type, packet, length, packet_time); | 854 return DeliverRtp(media_type, packet, length, packet_time); |
848 } | 855 } |
849 | 856 |
850 } // namespace internal | 857 } // namespace internal |
851 } // namespace webrtc | 858 } // namespace webrtc |
OLD | NEW |