| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
| 11 #include "webrtc/video_engine/vie_channel_group.h" | 11 #include "webrtc/video_engine/vie_channel_group.h" |
| 12 | 12 |
| 13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/thread_annotations.h" | 14 #include "webrtc/base/thread_annotations.h" |
| 15 #include "webrtc/common.h" | 15 #include "webrtc/common.h" |
| 16 #include "webrtc/modules/pacing/include/paced_sender.h" | 16 #include "webrtc/modules/pacing/include/paced_sender.h" |
| 17 #include "webrtc/modules/pacing/include/packet_router.h" | 17 #include "webrtc/modules/pacing/include/packet_router.h" |
| 18 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" |
| 18 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s
end_time.h" | 19 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s
end_time.h" |
| 19 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" | 20 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" |
| 20 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" | 21 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" |
| 21 #include "webrtc/modules/utility/interface/process_thread.h" | 22 #include "webrtc/modules/utility/interface/process_thread.h" |
| 22 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 23 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 23 #include "webrtc/system_wrappers/interface/logging.h" | 24 #include "webrtc/system_wrappers/interface/logging.h" |
| 24 #include "webrtc/video_engine/call_stats.h" | 25 #include "webrtc/video_engine/call_stats.h" |
| 25 #include "webrtc/video_engine/encoder_state_feedback.h" | 26 #include "webrtc/video_engine/encoder_state_feedback.h" |
| 26 #include "webrtc/video_engine/payload_router.h" | 27 #include "webrtc/video_engine/payload_router.h" |
| 27 #include "webrtc/video_engine/vie_channel.h" | 28 #include "webrtc/video_engine/vie_channel.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 RemoteBitrateObserver* observer_; | 131 RemoteBitrateObserver* observer_; |
| 131 Clock* clock_; | 132 Clock* clock_; |
| 132 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; | 133 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; |
| 133 const uint32_t min_bitrate_bps_; | 134 const uint32_t min_bitrate_bps_; |
| 134 rtc::scoped_ptr<RemoteBitrateEstimator> rbe_; | 135 rtc::scoped_ptr<RemoteBitrateEstimator> rbe_; |
| 135 bool using_absolute_send_time_; | 136 bool using_absolute_send_time_; |
| 136 uint32_t packets_since_absolute_send_time_; | 137 uint32_t packets_since_absolute_send_time_; |
| 137 | 138 |
| 138 DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator); | 139 DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator); |
| 139 }; | 140 }; |
| 141 |
| 142 static const int64_t kSendTimeHistoryWindowMs = 2000; |
| 143 |
| 140 } // namespace | 144 } // namespace |
| 141 | 145 |
| 146 class AdaptedSendTimeHistory : public SendTimeHistory, public SendTimeObserver { |
| 147 public: |
| 148 AdaptedSendTimeHistory() : SendTimeHistory(kSendTimeHistoryWindowMs) {} |
| 149 virtual ~AdaptedSendTimeHistory() {} |
| 150 |
| 151 void OnPacketSent(uint16_t sequence_number, int64_t send_time) override { |
| 152 SendTimeHistory::AddAndRemoveOldSendTimes(sequence_number, send_time); |
| 153 } |
| 154 }; |
| 155 |
| 142 ChannelGroup::ChannelGroup(ProcessThread* process_thread) | 156 ChannelGroup::ChannelGroup(ProcessThread* process_thread) |
| 143 : remb_(new VieRemb()), | 157 : remb_(new VieRemb()), |
| 144 bitrate_allocator_(new BitrateAllocator()), | 158 bitrate_allocator_(new BitrateAllocator()), |
| 145 call_stats_(new CallStats()), | 159 call_stats_(new CallStats()), |
| 146 encoder_state_feedback_(new EncoderStateFeedback()), | 160 encoder_state_feedback_(new EncoderStateFeedback()), |
| 147 packet_router_(new PacketRouter()), | 161 packet_router_(new PacketRouter()), |
| 148 pacer_(new PacedSender(Clock::GetRealTimeClock(), | 162 pacer_(new PacedSender(Clock::GetRealTimeClock(), |
| 149 packet_router_.get(), | 163 packet_router_.get(), |
| 150 BitrateController::kDefaultStartBitrateKbps, | 164 BitrateController::kDefaultStartBitrateKbps, |
| 151 PacedSender::kDefaultPaceMultiplier * | 165 PacedSender::kDefaultPaceMultiplier * |
| 152 BitrateController::kDefaultStartBitrateKbps, | 166 BitrateController::kDefaultStartBitrateKbps, |
| 153 0)), | 167 0)), |
| 154 process_thread_(process_thread), | 168 process_thread_(process_thread), |
| 155 pacer_thread_(ProcessThread::Create()), | 169 pacer_thread_(ProcessThread::Create()), |
| 156 // Constructed last as this object calls the provided callback on | 170 // Constructed last as this object calls the provided callback on |
| 157 // construction. | 171 // construction. |
| 158 bitrate_controller_( | 172 bitrate_controller_( |
| 159 BitrateController::CreateBitrateController(Clock::GetRealTimeClock(), | 173 BitrateController::CreateBitrateController(Clock::GetRealTimeClock(), |
| 160 this)) { | 174 this)), |
| 175 send_time_history_(new AdaptedSendTimeHistory()) { |
| 161 remote_bitrate_estimator_.reset(new WrappingBitrateEstimator( | 176 remote_bitrate_estimator_.reset(new WrappingBitrateEstimator( |
| 162 remb_.get(), Clock::GetRealTimeClock())); | 177 remb_.get(), Clock::GetRealTimeClock())); |
| 163 | 178 |
| 164 call_stats_->RegisterStatsObserver(remote_bitrate_estimator_.get()); | 179 call_stats_->RegisterStatsObserver(remote_bitrate_estimator_.get()); |
| 165 | 180 |
| 166 pacer_thread_->RegisterModule(pacer_.get()); | 181 pacer_thread_->RegisterModule(pacer_.get()); |
| 167 pacer_thread_->Start(); | 182 pacer_thread_->Start(); |
| 168 | 183 |
| 169 process_thread->RegisterModule(remote_bitrate_estimator_.get()); | 184 process_thread->RegisterModule(remote_bitrate_estimator_.get()); |
| 170 process_thread->RegisterModule(call_stats_.get()); | 185 process_thread->RegisterModule(call_stats_.get()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 int engine_id, | 243 int engine_id, |
| 229 Transport* transport, | 244 Transport* transport, |
| 230 int number_of_cores, | 245 int number_of_cores, |
| 231 ViEEncoder* vie_encoder, | 246 ViEEncoder* vie_encoder, |
| 232 size_t max_rtp_streams, | 247 size_t max_rtp_streams, |
| 233 bool sender) { | 248 bool sender) { |
| 234 rtc::scoped_ptr<ViEChannel> channel(new ViEChannel( | 249 rtc::scoped_ptr<ViEChannel> channel(new ViEChannel( |
| 235 channel_id, engine_id, number_of_cores, transport, process_thread_, | 250 channel_id, engine_id, number_of_cores, transport, process_thread_, |
| 236 encoder_state_feedback_->GetRtcpIntraFrameObserver(), | 251 encoder_state_feedback_->GetRtcpIntraFrameObserver(), |
| 237 bitrate_controller_->CreateRtcpBandwidthObserver(), | 252 bitrate_controller_->CreateRtcpBandwidthObserver(), |
| 238 remote_bitrate_estimator_.get(), call_stats_->rtcp_rtt_stats(), | 253 send_time_history_.get(), remote_bitrate_estimator_.get(), |
| 239 pacer_.get(), packet_router_.get(), max_rtp_streams, sender)); | 254 call_stats_->rtcp_rtt_stats(), pacer_.get(), packet_router_.get(), |
| 255 max_rtp_streams, sender)); |
| 240 if (channel->Init() != 0) { | 256 if (channel->Init() != 0) { |
| 241 return false; | 257 return false; |
| 242 } | 258 } |
| 243 | 259 |
| 244 // Register the channel to receive stats updates. | 260 // Register the channel to receive stats updates. |
| 245 call_stats_->RegisterStatsObserver(channel->GetStatsObserver()); | 261 call_stats_->RegisterStatsObserver(channel->GetStatsObserver()); |
| 246 | 262 |
| 247 // Store the channel, add it to the channel group and save the vie_encoder. | 263 // Store the channel, add it to the channel group and save the vie_encoder. |
| 248 channel_map_[channel_id] = channel.release(); | 264 channel_map_[channel_id] = channel.release(); |
| 249 if (vie_encoder) { | 265 if (vie_encoder) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 rtc::CritScope lock(&encoder_map_crit_); | 382 rtc::CritScope lock(&encoder_map_crit_); |
| 367 for (const auto& encoder : vie_encoder_map_) | 383 for (const auto& encoder : vie_encoder_map_) |
| 368 pad_up_to_bitrate_bps += encoder.second->GetPaddingNeededBps(); | 384 pad_up_to_bitrate_bps += encoder.second->GetPaddingNeededBps(); |
| 369 } | 385 } |
| 370 pacer_->UpdateBitrate( | 386 pacer_->UpdateBitrate( |
| 371 target_bitrate_bps / 1000, | 387 target_bitrate_bps / 1000, |
| 372 PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000, | 388 PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000, |
| 373 pad_up_to_bitrate_bps / 1000); | 389 pad_up_to_bitrate_bps / 1000); |
| 374 } | 390 } |
| 375 } // namespace webrtc | 391 } // namespace webrtc |
| OLD | NEW |