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/experiments.h" | 16 #include "webrtc/experiments.h" |
17 #include "webrtc/modules/pacing/include/paced_sender.h" | 17 #include "webrtc/modules/pacing/include/paced_sender.h" |
18 #include "webrtc/modules/pacing/include/packet_router.h" | 18 #include "webrtc/modules/pacing/include/packet_router.h" |
19 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.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/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" |
28 #include "webrtc/video_engine/vie_encoder.h" | 29 #include "webrtc/video_engine/vie_encoder.h" |
29 #include "webrtc/video_engine/vie_remb.h" | 30 #include "webrtc/video_engine/vie_remb.h" |
30 #include "webrtc/voice_engine/include/voe_video_sync.h" | 31 #include "webrtc/voice_engine/include/voe_video_sync.h" |
31 | 32 |
32 namespace webrtc { | 33 namespace webrtc { |
33 namespace { | 34 namespace { |
34 | 35 |
35 static const uint32_t kTimeOffsetSwitchThreshold = 30; | 36 static const uint32_t kTimeOffsetSwitchThreshold = 30; |
36 | 37 |
37 class WrappingBitrateEstimator : public RemoteBitrateEstimator { | 38 class WrappingBitrateEstimator : public RemoteBitrateEstimator { |
38 public: | 39 public: |
39 WrappingBitrateEstimator(RemoteBitrateObserver* observer, | 40 WrappingBitrateEstimator(RemoteBitrateObserver* observer, |
40 Clock* clock, | 41 Clock* clock, |
41 const Config& config) | 42 const Config& config) |
42 : observer_(observer), | 43 : observer_(observer), |
43 clock_(clock), | 44 clock_(clock), |
44 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 45 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
45 min_bitrate_bps_(config.Get<RemoteBitrateEstimatorMinRate>().min_rate), | 46 min_bitrate_bps_(config.Get<RemoteBitrateEstimatorMinRate>().min_rate), |
46 rbe_(RemoteBitrateEstimatorFactory().Create(observer_, | 47 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, |
47 clock_, | 48 clock_, |
48 kAimdControl, | |
49 min_bitrate_bps_)), | 49 min_bitrate_bps_)), |
50 using_absolute_send_time_(false), | 50 using_absolute_send_time_(false), |
51 packets_since_absolute_send_time_(0) { | 51 packets_since_absolute_send_time_(0) {} |
52 } | |
53 | 52 |
54 virtual ~WrappingBitrateEstimator() {} | 53 virtual ~WrappingBitrateEstimator() {} |
55 | 54 |
56 void IncomingPacket(int64_t arrival_time_ms, | 55 void IncomingPacket(int64_t arrival_time_ms, |
57 size_t payload_size, | 56 size_t payload_size, |
58 const RTPHeader& header, | 57 const RTPHeader& header, |
59 bool was_paced) override { | 58 bool was_paced) override { |
60 CriticalSectionScoped cs(crit_sect_.get()); | 59 CriticalSectionScoped cs(crit_sect_.get()); |
61 PickEstimatorFromHeader(header); | 60 PickEstimatorFromHeader(header); |
62 rbe_->IncomingPacket(arrival_time_ms, payload_size, header, was_paced); | 61 rbe_->IncomingPacket(arrival_time_ms, payload_size, header, was_paced); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 using_absolute_send_time_ = false; | 114 using_absolute_send_time_ = false; |
116 PickEstimator(); | 115 PickEstimator(); |
117 } | 116 } |
118 } | 117 } |
119 } | 118 } |
120 } | 119 } |
121 | 120 |
122 // Instantiate RBE for Time Offset or Absolute Send Time extensions. | 121 // Instantiate RBE for Time Offset or Absolute Send Time extensions. |
123 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()) { | 122 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()) { |
124 if (using_absolute_send_time_) { | 123 if (using_absolute_send_time_) { |
125 rbe_.reset(AbsoluteSendTimeRemoteBitrateEstimatorFactory().Create( | 124 rbe_.reset(new RemoteBitrateEstimatorAbsSendTime(observer_, clock_, |
126 observer_, clock_, kAimdControl, min_bitrate_bps_)); | 125 min_bitrate_bps_)); |
127 } else { | 126 } else { |
128 rbe_.reset(RemoteBitrateEstimatorFactory().Create( | 127 rbe_.reset(new RemoteBitrateEstimatorSingleStream(observer_, clock_, |
129 observer_, clock_, kAimdControl, min_bitrate_bps_)); | 128 min_bitrate_bps_)); |
130 } | 129 } |
131 } | 130 } |
132 | 131 |
133 RemoteBitrateObserver* observer_; | 132 RemoteBitrateObserver* observer_; |
134 Clock* clock_; | 133 Clock* clock_; |
135 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; | 134 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; |
136 const uint32_t min_bitrate_bps_; | 135 const uint32_t min_bitrate_bps_; |
137 rtc::scoped_ptr<RemoteBitrateEstimator> rbe_; | 136 rtc::scoped_ptr<RemoteBitrateEstimator> rbe_; |
138 bool using_absolute_send_time_; | 137 bool using_absolute_send_time_; |
139 uint32_t packets_since_absolute_send_time_; | 138 uint32_t packets_since_absolute_send_time_; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 pad_up_to_bitrate_bps += | 478 pad_up_to_bitrate_bps += |
480 encoder.second->GetPaddingNeededBps(target_bitrate_bps); | 479 encoder.second->GetPaddingNeededBps(target_bitrate_bps); |
481 } | 480 } |
482 } | 481 } |
483 pacer_->UpdateBitrate( | 482 pacer_->UpdateBitrate( |
484 target_bitrate_bps / 1000, | 483 target_bitrate_bps / 1000, |
485 PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000, | 484 PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000, |
486 pad_up_to_bitrate_bps / 1000); | 485 pad_up_to_bitrate_bps / 1000); |
487 } | 486 } |
488 } // namespace webrtc | 487 } // namespace webrtc |
OLD | NEW |