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/vie_remb.h" | 11 #include "webrtc/video/vie_remb.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 | 14 |
15 #include <algorithm> | 15 #include <algorithm> |
16 | 16 |
17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
18 #include "webrtc/modules/utility/include/process_thread.h" | 18 #include "webrtc/modules/utility/include/process_thread.h" |
19 #include "webrtc/system_wrappers/include/tick_util.h" | 19 #include "webrtc/system_wrappers/include/tick_util.h" |
20 #include "webrtc/system_wrappers/include/trace.h" | 20 #include "webrtc/system_wrappers/include/trace.h" |
21 | 21 |
22 namespace webrtc { | 22 namespace webrtc { |
23 | 23 |
24 const int kRembSendIntervalMs = 200; | 24 const int kRembSendIntervalMs = 200; |
25 | 25 |
26 // % threshold for if we should send a new REMB asap. | 26 // % threshold for if we should send a new REMB asap. |
27 const unsigned int kSendThresholdPercent = 97; | 27 const uint32_t kSendThresholdPercent = 97; |
28 | 28 |
29 VieRemb::VieRemb(Clock* clock) | 29 VieRemb::VieRemb(Clock* clock) |
30 : clock_(clock), | 30 : clock_(clock), |
31 last_remb_time_(clock_->TimeInMilliseconds()), | 31 last_remb_time_(clock_->TimeInMilliseconds()), |
32 last_send_bitrate_(0), | 32 last_send_bitrate_(0), |
33 bitrate_(0) {} | 33 bitrate_(0) {} |
34 | 34 |
35 VieRemb::~VieRemb() {} | 35 VieRemb::~VieRemb() {} |
36 | 36 |
37 void VieRemb::AddReceiveChannel(RtpRtcp* rtp_rtcp) { | 37 void VieRemb::AddReceiveChannel(RtpRtcp* rtp_rtcp) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return; | 83 return; |
84 } | 84 } |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 bool VieRemb::InUse() const { | 88 bool VieRemb::InUse() const { |
89 rtc::CritScope lock(&list_crit_); | 89 rtc::CritScope lock(&list_crit_); |
90 return !receive_modules_.empty() || !rtcp_sender_.empty(); | 90 return !receive_modules_.empty() || !rtcp_sender_.empty(); |
91 } | 91 } |
92 | 92 |
93 void VieRemb::OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs, | 93 void VieRemb::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs, |
94 unsigned int bitrate) { | 94 uint32_t bitrate) { |
95 RtpRtcp* sender = NULL; | 95 RtpRtcp* sender = NULL; |
96 { | 96 { |
97 rtc::CritScope lock(&list_crit_); | 97 rtc::CritScope lock(&list_crit_); |
98 // If we already have an estimate, check if the new total estimate is below | 98 // If we already have an estimate, check if the new total estimate is below |
99 // kSendThresholdPercent of the previous estimate. | 99 // kSendThresholdPercent of the previous estimate. |
100 if (last_send_bitrate_ > 0) { | 100 if (last_send_bitrate_ > 0) { |
101 unsigned int new_remb_bitrate = last_send_bitrate_ - bitrate_ + bitrate; | 101 uint32_t new_remb_bitrate = last_send_bitrate_ - bitrate_ + bitrate; |
102 | 102 |
103 if (new_remb_bitrate < kSendThresholdPercent * last_send_bitrate_ / 100) { | 103 if (new_remb_bitrate < kSendThresholdPercent * last_send_bitrate_ / 100) { |
104 // The new bitrate estimate is less than kSendThresholdPercent % of the | 104 // The new bitrate estimate is less than kSendThresholdPercent % of the |
105 // last report. Send a REMB asap. | 105 // last report. Send a REMB asap. |
106 last_remb_time_ = clock_->TimeInMilliseconds() - kRembSendIntervalMs; | 106 last_remb_time_ = clock_->TimeInMilliseconds() - kRembSendIntervalMs; |
107 } | 107 } |
108 } | 108 } |
109 bitrate_ = bitrate; | 109 bitrate_ = bitrate; |
110 | 110 |
111 // Calculate total receive bitrate estimate. | 111 // Calculate total receive bitrate estimate. |
(...skipping 16 matching lines...) Expand all Loading... |
128 } | 128 } |
129 last_send_bitrate_ = bitrate_; | 129 last_send_bitrate_ = bitrate_; |
130 } | 130 } |
131 | 131 |
132 if (sender) { | 132 if (sender) { |
133 sender->SetREMBData(bitrate_, ssrcs); | 133 sender->SetREMBData(bitrate_, ssrcs); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 } // namespace webrtc | 137 } // namespace webrtc |
OLD | NEW |