Chromium Code Reviews| 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/include/send_time_history.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_abs_s end_time.h" |
| 20 #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" |
| 21 #include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h" | |
| 21 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" | 22 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" |
| 22 #include "webrtc/modules/utility/interface/process_thread.h" | 23 #include "webrtc/modules/utility/interface/process_thread.h" |
| 23 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 24 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 24 #include "webrtc/system_wrappers/interface/logging.h" | 25 #include "webrtc/system_wrappers/interface/logging.h" |
| 25 #include "webrtc/video_engine/call_stats.h" | 26 #include "webrtc/video_engine/call_stats.h" |
| 26 #include "webrtc/video_engine/encoder_state_feedback.h" | 27 #include "webrtc/video_engine/encoder_state_feedback.h" |
| 27 #include "webrtc/video_engine/payload_router.h" | 28 #include "webrtc/video_engine/payload_router.h" |
| 28 #include "webrtc/video_engine/vie_channel.h" | 29 #include "webrtc/video_engine/vie_channel.h" |
| 29 #include "webrtc/video_engine/vie_encoder.h" | 30 #include "webrtc/video_engine/vie_encoder.h" |
| 30 #include "webrtc/video_engine/vie_remb.h" | 31 #include "webrtc/video_engine/vie_remb.h" |
| 31 #include "webrtc/voice_engine/include/voe_video_sync.h" | 32 #include "webrtc/voice_engine/include/voe_video_sync.h" |
| 32 | 33 |
| 33 namespace webrtc { | 34 namespace webrtc { |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 static const uint32_t kTimeOffsetSwitchThreshold = 30; | 37 static const uint32_t kTimeOffsetSwitchThreshold = 30; |
| 37 static const uint32_t kMinBitrateBps = 30000; | |
| 38 | 38 |
| 39 class WrappingBitrateEstimator : public RemoteBitrateEstimator { | 39 class WrappingBitrateEstimator : public RemoteBitrateEstimator { |
| 40 public: | 40 public: |
| 41 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock) | 41 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock) |
| 42 : observer_(observer), | 42 : observer_(observer), |
| 43 clock_(clock), | 43 clock_(clock), |
| 44 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 44 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
| 45 min_bitrate_bps_(kMinBitrateBps), | 45 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), |
| 46 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, | 46 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, |
| 47 clock_, | 47 clock_, |
| 48 min_bitrate_bps_)), | 48 min_bitrate_bps_)), |
| 49 using_absolute_send_time_(false), | 49 using_absolute_send_time_(false), |
| 50 packets_since_absolute_send_time_(0) {} | 50 packets_since_absolute_send_time_(0) {} |
| 51 | 51 |
| 52 virtual ~WrappingBitrateEstimator() {} | 52 virtual ~WrappingBitrateEstimator() {} |
| 53 | 53 |
| 54 void IncomingPacket(int64_t arrival_time_ms, | 54 void IncomingPacket(int64_t arrival_time_ms, |
| 55 size_t payload_size, | 55 size_t payload_size, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 Clock* clock_; | 132 Clock* clock_; |
| 133 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; | 133 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; |
| 134 const uint32_t min_bitrate_bps_; | 134 const uint32_t min_bitrate_bps_; |
| 135 rtc::scoped_ptr<RemoteBitrateEstimator> rbe_; | 135 rtc::scoped_ptr<RemoteBitrateEstimator> rbe_; |
| 136 bool using_absolute_send_time_; | 136 bool using_absolute_send_time_; |
| 137 uint32_t packets_since_absolute_send_time_; | 137 uint32_t packets_since_absolute_send_time_; |
| 138 | 138 |
| 139 DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator); | 139 DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator); |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 static const int64_t kSendTimeHistoryWindowMs = 2000; | |
| 143 | |
| 144 } // namespace | 142 } // namespace |
| 145 | 143 |
| 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 PacketInfo info(0, send_time, sequence_number, 0, false); | |
| 153 SendTimeHistory::AddAndRemoveOld(info); | |
| 154 } | |
| 155 }; | |
| 156 | |
| 157 ChannelGroup::ChannelGroup(ProcessThread* process_thread) | 144 ChannelGroup::ChannelGroup(ProcessThread* process_thread) |
| 158 : remb_(new VieRemb()), | 145 : remb_(new VieRemb()), |
| 159 bitrate_allocator_(new BitrateAllocator()), | 146 bitrate_allocator_(new BitrateAllocator()), |
| 160 call_stats_(new CallStats()), | 147 call_stats_(new CallStats()), |
| 161 encoder_state_feedback_(new EncoderStateFeedback()), | 148 encoder_state_feedback_(new EncoderStateFeedback()), |
| 162 packet_router_(new PacketRouter()), | 149 packet_router_(new PacketRouter()), |
| 163 pacer_(new PacedSender(Clock::GetRealTimeClock(), | 150 pacer_(new PacedSender(Clock::GetRealTimeClock(), |
| 164 packet_router_.get(), | 151 packet_router_.get(), |
| 165 BitrateController::kDefaultStartBitrateKbps, | 152 BitrateController::kDefaultStartBitrateKbps, |
| 166 PacedSender::kDefaultPaceMultiplier * | 153 PacedSender::kDefaultPaceMultiplier * |
| 167 BitrateController::kDefaultStartBitrateKbps, | 154 BitrateController::kDefaultStartBitrateKbps, |
| 168 0)), | 155 0)), |
| 169 process_thread_(process_thread), | 156 process_thread_(process_thread), |
| 170 pacer_thread_(ProcessThread::Create()), | 157 pacer_thread_(ProcessThread::Create()), |
| 171 // Constructed last as this object calls the provided callback on | 158 // Constructed last as this object calls the provided callback on |
| 172 // construction. | 159 // construction. |
| 173 bitrate_controller_( | 160 bitrate_controller_( |
| 174 BitrateController::CreateBitrateController(Clock::GetRealTimeClock(), | 161 BitrateController::CreateBitrateController(Clock::GetRealTimeClock(), |
| 175 this)), | 162 this)) { |
| 176 send_time_history_(new AdaptedSendTimeHistory()) { | |
| 177 remote_bitrate_estimator_.reset(new WrappingBitrateEstimator( | 163 remote_bitrate_estimator_.reset(new WrappingBitrateEstimator( |
| 178 remb_.get(), Clock::GetRealTimeClock())); | 164 remb_.get(), Clock::GetRealTimeClock())); |
| 179 | 165 |
| 180 call_stats_->RegisterStatsObserver(remote_bitrate_estimator_.get()); | 166 call_stats_->RegisterStatsObserver(remote_bitrate_estimator_.get()); |
| 181 | 167 |
| 182 pacer_thread_->RegisterModule(pacer_.get()); | 168 pacer_thread_->RegisterModule(pacer_.get()); |
| 183 pacer_thread_->Start(); | 169 pacer_thread_->Start(); |
| 184 | 170 |
| 185 process_thread->RegisterModule(remote_bitrate_estimator_.get()); | 171 process_thread->RegisterModule(remote_bitrate_estimator_.get()); |
| 186 process_thread->RegisterModule(call_stats_.get()); | 172 process_thread->RegisterModule(call_stats_.get()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 bool ChannelGroup::CreateChannel(int channel_id, | 229 bool ChannelGroup::CreateChannel(int channel_id, |
| 244 int engine_id, | 230 int engine_id, |
| 245 Transport* transport, | 231 Transport* transport, |
| 246 int number_of_cores, | 232 int number_of_cores, |
| 247 ViEEncoder* vie_encoder, | 233 ViEEncoder* vie_encoder, |
| 248 size_t max_rtp_streams, | 234 size_t max_rtp_streams, |
| 249 bool sender) { | 235 bool sender) { |
| 250 rtc::scoped_ptr<ViEChannel> channel(new ViEChannel( | 236 rtc::scoped_ptr<ViEChannel> channel(new ViEChannel( |
| 251 channel_id, engine_id, number_of_cores, transport, process_thread_, | 237 channel_id, engine_id, number_of_cores, transport, process_thread_, |
| 252 encoder_state_feedback_->GetRtcpIntraFrameObserver(), | 238 encoder_state_feedback_->GetRtcpIntraFrameObserver(), |
| 253 bitrate_controller_->CreateRtcpBandwidthObserver(), | 239 bitrate_controller_->CreateRtcpBandwidthObserver(), nullptr, |
|
stefan-webrtc
2015/09/10 11:10:02
This on purpose not wired up yet?
sprang_webrtc
2015/09/11 12:33:48
Yep. Will be in the follow-up cl.
| |
| 254 send_time_history_.get(), remote_bitrate_estimator_.get(), | 240 remote_bitrate_estimator_.get(), call_stats_->rtcp_rtt_stats(), |
| 255 call_stats_->rtcp_rtt_stats(), pacer_.get(), packet_router_.get(), | 241 pacer_.get(), packet_router_.get(), max_rtp_streams, sender)); |
| 256 max_rtp_streams, sender)); | |
| 257 if (channel->Init() != 0) { | 242 if (channel->Init() != 0) { |
| 258 return false; | 243 return false; |
| 259 } | 244 } |
| 260 | 245 |
| 261 // Register the channel to receive stats updates. | 246 // Register the channel to receive stats updates. |
| 262 call_stats_->RegisterStatsObserver(channel->GetStatsObserver()); | 247 call_stats_->RegisterStatsObserver(channel->GetStatsObserver()); |
| 263 | 248 |
| 264 // Store the channel, add it to the channel group and save the vie_encoder. | 249 // Store the channel, add it to the channel group and save the vie_encoder. |
| 265 channel_map_[channel_id] = channel.release(); | 250 channel_map_[channel_id] = channel.release(); |
| 266 if (vie_encoder) { | 251 if (vie_encoder) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 rtc::CritScope lock(&encoder_map_crit_); | 368 rtc::CritScope lock(&encoder_map_crit_); |
| 384 for (const auto& encoder : vie_encoder_map_) | 369 for (const auto& encoder : vie_encoder_map_) |
| 385 pad_up_to_bitrate_bps += encoder.second->GetPaddingNeededBps(); | 370 pad_up_to_bitrate_bps += encoder.second->GetPaddingNeededBps(); |
| 386 } | 371 } |
| 387 pacer_->UpdateBitrate( | 372 pacer_->UpdateBitrate( |
| 388 target_bitrate_bps / 1000, | 373 target_bitrate_bps / 1000, |
| 389 PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000, | 374 PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000, |
| 390 pad_up_to_bitrate_bps / 1000); | 375 pad_up_to_bitrate_bps / 1000); |
| 391 } | 376 } |
| 392 } // namespace webrtc | 377 } // namespace webrtc |
| OLD | NEW |