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 23 matching lines...) Expand all Loading... |
34 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 34 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
35 #include "webrtc/modules/utility/include/process_thread.h" | 35 #include "webrtc/modules/utility/include/process_thread.h" |
36 #include "webrtc/system_wrappers/include/cpu_info.h" | 36 #include "webrtc/system_wrappers/include/cpu_info.h" |
37 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 37 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
38 #include "webrtc/system_wrappers/include/metrics.h" | 38 #include "webrtc/system_wrappers/include/metrics.h" |
39 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" | 39 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" |
40 #include "webrtc/system_wrappers/include/trace.h" | 40 #include "webrtc/system_wrappers/include/trace.h" |
41 #include "webrtc/video/call_stats.h" | 41 #include "webrtc/video/call_stats.h" |
42 #include "webrtc/video/video_receive_stream.h" | 42 #include "webrtc/video/video_receive_stream.h" |
43 #include "webrtc/video/video_send_stream.h" | 43 #include "webrtc/video/video_send_stream.h" |
| 44 #include "webrtc/video/vie_remb.h" |
44 #include "webrtc/voice_engine/include/voe_codec.h" | 45 #include "webrtc/voice_engine/include/voe_codec.h" |
45 | 46 |
46 namespace webrtc { | 47 namespace webrtc { |
47 | 48 |
48 const int Call::Config::kDefaultStartBitrateBps = 300000; | 49 const int Call::Config::kDefaultStartBitrateBps = 300000; |
49 | 50 |
50 namespace internal { | 51 namespace internal { |
51 | 52 |
52 class Call : public webrtc::Call, public PacketReceiver, | 53 class Call : public webrtc::Call, public PacketReceiver, |
53 public BitrateObserver { | 54 public BitrateObserver { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 int64_t last_rtp_packet_received_ms_; | 159 int64_t last_rtp_packet_received_ms_; |
159 int64_t first_packet_sent_ms_; | 160 int64_t first_packet_sent_ms_; |
160 | 161 |
161 // TODO(holmer): Remove this lock once BitrateController no longer calls | 162 // TODO(holmer): Remove this lock once BitrateController no longer calls |
162 // OnNetworkChanged from multiple threads. | 163 // OnNetworkChanged from multiple threads. |
163 rtc::CriticalSection bitrate_crit_; | 164 rtc::CriticalSection bitrate_crit_; |
164 int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); | 165 int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); |
165 int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); | 166 int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); |
166 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_); | 167 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_); |
167 | 168 |
| 169 VieRemb remb_; |
168 const rtc::scoped_ptr<CongestionController> congestion_controller_; | 170 const rtc::scoped_ptr<CongestionController> congestion_controller_; |
169 | 171 |
170 RTC_DISALLOW_COPY_AND_ASSIGN(Call); | 172 RTC_DISALLOW_COPY_AND_ASSIGN(Call); |
171 }; | 173 }; |
172 } // namespace internal | 174 } // namespace internal |
173 | 175 |
174 Call* Call::Create(const Call::Config& config) { | 176 Call* Call::Create(const Call::Config& config) { |
175 return new internal::Call(config); | 177 return new internal::Call(config); |
176 } | 178 } |
177 | 179 |
(...skipping 11 matching lines...) Expand all Loading... |
189 send_crit_(RWLockWrapper::CreateRWLock()), | 191 send_crit_(RWLockWrapper::CreateRWLock()), |
190 received_video_bytes_(0), | 192 received_video_bytes_(0), |
191 received_audio_bytes_(0), | 193 received_audio_bytes_(0), |
192 received_rtcp_bytes_(0), | 194 received_rtcp_bytes_(0), |
193 first_rtp_packet_received_ms_(-1), | 195 first_rtp_packet_received_ms_(-1), |
194 last_rtp_packet_received_ms_(-1), | 196 last_rtp_packet_received_ms_(-1), |
195 first_packet_sent_ms_(-1), | 197 first_packet_sent_ms_(-1), |
196 estimated_send_bitrate_sum_kbits_(0), | 198 estimated_send_bitrate_sum_kbits_(0), |
197 pacer_bitrate_sum_kbits_(0), | 199 pacer_bitrate_sum_kbits_(0), |
198 num_bitrate_updates_(0), | 200 num_bitrate_updates_(0), |
| 201 remb_(clock_), |
199 congestion_controller_( | 202 congestion_controller_( |
200 new CongestionController(module_process_thread_.get(), | 203 new CongestionController(clock_, |
| 204 module_process_thread_.get(), |
201 call_stats_.get(), | 205 call_stats_.get(), |
202 this)) { | 206 this, |
| 207 &remb_)) { |
203 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 208 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
204 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 209 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
205 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 210 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
206 config.bitrate_config.min_bitrate_bps); | 211 config.bitrate_config.min_bitrate_bps); |
207 if (config.bitrate_config.max_bitrate_bps != -1) { | 212 if (config.bitrate_config.max_bitrate_bps != -1) { |
208 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 213 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
209 config.bitrate_config.start_bitrate_bps); | 214 config.bitrate_config.start_bitrate_bps); |
210 } | 215 } |
211 if (config.audio_state.get()) { | 216 if (config.audio_state.get()) { |
212 ScopedVoEInterface<VoECodec> voe_codec(voice_engine()); | 217 ScopedVoEInterface<VoECodec> voe_codec(voice_engine()); |
213 event_log_ = voe_codec->GetEventLog(); | 218 event_log_ = voe_codec->GetEventLog(); |
214 } | 219 } |
215 | 220 |
216 Trace::CreateTrace(); | 221 Trace::CreateTrace(); |
217 module_process_thread_->Start(); | 222 module_process_thread_->Start(); |
218 module_process_thread_->RegisterModule(call_stats_.get()); | 223 module_process_thread_->RegisterModule(call_stats_.get()); |
219 | 224 |
220 congestion_controller_->SetBweBitrates( | 225 congestion_controller_->SetBweBitrates( |
221 config_.bitrate_config.min_bitrate_bps, | 226 config_.bitrate_config.min_bitrate_bps, |
222 config_.bitrate_config.start_bitrate_bps, | 227 config_.bitrate_config.start_bitrate_bps, |
223 config_.bitrate_config.max_bitrate_bps); | 228 config_.bitrate_config.max_bitrate_bps); |
224 | 229 |
225 congestion_controller_->GetBitrateController()->SetEventLog(event_log_); | 230 congestion_controller_->GetBitrateController()->SetEventLog(event_log_); |
226 } | 231 } |
227 | 232 |
228 Call::~Call() { | 233 Call::~Call() { |
| 234 RTC_DCHECK(!remb_.InUse()); |
229 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 235 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
230 UpdateSendHistograms(); | 236 UpdateSendHistograms(); |
231 UpdateReceiveHistograms(); | 237 UpdateReceiveHistograms(); |
232 RTC_CHECK(audio_send_ssrcs_.empty()); | 238 RTC_CHECK(audio_send_ssrcs_.empty()); |
233 RTC_CHECK(video_send_ssrcs_.empty()); | 239 RTC_CHECK(video_send_ssrcs_.empty()); |
234 RTC_CHECK(video_send_streams_.empty()); | 240 RTC_CHECK(video_send_streams_.empty()); |
235 RTC_CHECK(audio_receive_ssrcs_.empty()); | 241 RTC_CHECK(audio_receive_ssrcs_.empty()); |
236 RTC_CHECK(video_receive_ssrcs_.empty()); | 242 RTC_CHECK(video_receive_ssrcs_.empty()); |
237 RTC_CHECK(video_receive_streams_.empty()); | 243 RTC_CHECK(video_receive_streams_.empty()); |
238 | 244 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 webrtc::VideoSendStream* Call::CreateVideoSendStream( | 378 webrtc::VideoSendStream* Call::CreateVideoSendStream( |
373 const webrtc::VideoSendStream::Config& config, | 379 const webrtc::VideoSendStream::Config& config, |
374 const VideoEncoderConfig& encoder_config) { | 380 const VideoEncoderConfig& encoder_config) { |
375 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); | 381 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); |
376 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 382 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
377 | 383 |
378 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if | 384 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if |
379 // the call has already started. | 385 // the call has already started. |
380 VideoSendStream* send_stream = new VideoSendStream( | 386 VideoSendStream* send_stream = new VideoSendStream( |
381 num_cpu_cores_, module_process_thread_.get(), call_stats_.get(), | 387 num_cpu_cores_, module_process_thread_.get(), call_stats_.get(), |
382 congestion_controller_.get(), bitrate_allocator_.get(), config, | 388 congestion_controller_.get(), &remb_, bitrate_allocator_.get(), config, |
383 encoder_config, suspended_video_send_ssrcs_); | 389 encoder_config, suspended_video_send_ssrcs_); |
384 | 390 |
385 if (!network_enabled_) | 391 if (!network_enabled_) |
386 send_stream->SignalNetworkState(kNetworkDown); | 392 send_stream->SignalNetworkState(kNetworkDown); |
387 | 393 |
388 WriteLockScoped write_lock(*send_crit_); | 394 WriteLockScoped write_lock(*send_crit_); |
389 for (uint32_t ssrc : config.rtp.ssrcs) { | 395 for (uint32_t ssrc : config.rtp.ssrcs) { |
390 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 396 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
391 video_send_ssrcs_[ssrc] = send_stream; | 397 video_send_ssrcs_[ssrc] = send_stream; |
392 } | 398 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 436 } |
431 | 437 |
432 delete send_stream_impl; | 438 delete send_stream_impl; |
433 } | 439 } |
434 | 440 |
435 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 441 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
436 const webrtc::VideoReceiveStream::Config& config) { | 442 const webrtc::VideoReceiveStream::Config& config) { |
437 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 443 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
438 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 444 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
439 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 445 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
440 num_cpu_cores_, congestion_controller_.get(), config, | 446 num_cpu_cores_, congestion_controller_.get(), config, voice_engine(), |
441 voice_engine(), module_process_thread_.get(), call_stats_.get()); | 447 module_process_thread_.get(), call_stats_.get(), &remb_); |
442 | 448 |
443 WriteLockScoped write_lock(*receive_crit_); | 449 WriteLockScoped write_lock(*receive_crit_); |
444 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 450 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
445 video_receive_ssrcs_.end()); | 451 video_receive_ssrcs_.end()); |
446 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 452 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
447 // TODO(pbos): Configure different RTX payloads per receive payload. | 453 // TODO(pbos): Configure different RTX payloads per receive payload. |
448 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 454 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = |
449 config.rtp.rtx.begin(); | 455 config.rtp.rtx.begin(); |
450 if (it != config.rtp.rtx.end()) | 456 if (it != config.rtp.rtx.end()) |
451 video_receive_ssrcs_[it->second.ssrc] = receive_stream; | 457 video_receive_ssrcs_[it->second.ssrc] = receive_stream; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 // thread. Then this check can be enabled. | 743 // thread. Then this check can be enabled. |
738 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 744 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
739 if (RtpHeaderParser::IsRtcp(packet, length)) | 745 if (RtpHeaderParser::IsRtcp(packet, length)) |
740 return DeliverRtcp(media_type, packet, length); | 746 return DeliverRtcp(media_type, packet, length); |
741 | 747 |
742 return DeliverRtp(media_type, packet, length, packet_time); | 748 return DeliverRtp(media_type, packet, length, packet_time); |
743 } | 749 } |
744 | 750 |
745 } // namespace internal | 751 } // namespace internal |
746 } // namespace webrtc | 752 } // namespace webrtc |
OLD | NEW |