Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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/modules/remote_bitrate_estimator/remote_estimator_proxy.h" | 11 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" | 
| 12 | 12 | 
| 13 #include <limits> | 13 #include <limits> | 
| 14 #include <algorithm> | |
| 14 | 15 | 
| 15 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" | 
| 16 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" | 
| 17 #include "webrtc/system_wrappers/include/clock.h" | 18 #include "webrtc/system_wrappers/include/clock.h" | 
| 19 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | |
| 18 #include "webrtc/modules/pacing/packet_router.h" | 20 #include "webrtc/modules/pacing/packet_router.h" | 
| 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 
| 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 
| 21 | 23 | 
| 22 namespace webrtc { | 24 namespace webrtc { | 
| 23 | 25 | 
| 24 // TODO(sprang): Tune these! | 26 // TODO(sprang): Tune these! | 
| 25 const int RemoteEstimatorProxy::kDefaultProcessIntervalMs = 50; | 27 const int RemoteEstimatorProxy::kMinPacketCountRecievedBitrate = 50; | 
| 26 const int RemoteEstimatorProxy::kBackWindowMs = 500; | 28 const int RemoteEstimatorProxy::kBackWindowMs = 500; | 
| 29 const int RemoteEstimatorProxy::kMinSendIntervalMs = 50; | |
| 30 const int RemoteEstimatorProxy::kMaxSendIntervalMs = 250; | |
| 27 | 31 | 
| 28 // The maximum allowed value for a timestamp in milliseconds. This is lower | 32 // The maximum allowed value for a timestamp in milliseconds. This is lower | 
| 29 // than the numerical limit since we often convert to microseconds. | 33 // than the numerical limit since we often convert to microseconds. | 
| 30 static constexpr int64_t kMaxTimeMs = | 34 static constexpr int64_t kMaxTimeMs = | 
| 31 std::numeric_limits<int64_t>::max() / 1000; | 35 std::numeric_limits<int64_t>::max() / 1000; | 
| 32 | 36 | 
| 33 RemoteEstimatorProxy::RemoteEstimatorProxy(Clock* clock, | 37 RemoteEstimatorProxy::RemoteEstimatorProxy( | 
| 34 PacketRouter* packet_router) | 38 Clock* clock, | 
| 39 PacketRouter* packet_router, | |
| 40 BitrateController* bitrate_controller) | |
| 35 : clock_(clock), | 41 : clock_(clock), | 
| 36 packet_router_(packet_router), | 42 packet_router_(packet_router), | 
| 37 last_process_time_ms_(-1), | 43 last_process_time_ms_(-1), | 
| 38 media_ssrc_(0), | 44 media_ssrc_(0), | 
| 39 feedback_sequence_(0), | 45 feedback_sequence_(0), | 
| 40 window_start_seq_(-1) {} | 46 window_start_seq_(-1), | 
| 47 bitrate_controller_(bitrate_controller) {} | |
| 41 | 48 | 
| 42 RemoteEstimatorProxy::~RemoteEstimatorProxy() {} | 49 RemoteEstimatorProxy::~RemoteEstimatorProxy() {} | 
| 43 | 50 | 
| 44 void RemoteEstimatorProxy::IncomingPacketFeedbackVector( | 51 void RemoteEstimatorProxy::IncomingPacketFeedbackVector( | 
| 45 const std::vector<PacketInfo>& packet_feedback_vector) { | 52 const std::vector<PacketInfo>& packet_feedback_vector) { | 
| 46 rtc::CritScope cs(&lock_); | 53 rtc::CritScope cs(&lock_); | 
| 47 for (PacketInfo info : packet_feedback_vector) | 54 for (PacketInfo info : packet_feedback_vector) | 
| 48 OnPacketArrival(info.sequence_number, info.arrival_time_ms); | 55 OnPacketArrival(info.sequence_number, info.arrival_time_ms); | 
| 49 } | 56 } | 
| 50 | 57 | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 63 } | 70 } | 
| 64 | 71 | 
| 65 bool RemoteEstimatorProxy::LatestEstimate(std::vector<unsigned int>* ssrcs, | 72 bool RemoteEstimatorProxy::LatestEstimate(std::vector<unsigned int>* ssrcs, | 
| 66 unsigned int* bitrate_bps) const { | 73 unsigned int* bitrate_bps) const { | 
| 67 return false; | 74 return false; | 
| 68 } | 75 } | 
| 69 | 76 | 
| 70 int64_t RemoteEstimatorProxy::TimeUntilNextProcess() { | 77 int64_t RemoteEstimatorProxy::TimeUntilNextProcess() { | 
| 71 int64_t now = clock_->TimeInMilliseconds(); | 78 int64_t now = clock_->TimeInMilliseconds(); | 
| 72 int64_t time_until_next = 0; | 79 int64_t time_until_next = 0; | 
| 73 if (last_process_time_ms_ != -1 && | 80 if (last_process_time_ms_ != -1) { | 
| 74 now - last_process_time_ms_ < kDefaultProcessIntervalMs) { | 81 uint32_t bitrate = 0; | 
| 75 time_until_next = (last_process_time_ms_ + kDefaultProcessIntervalMs - now); | 82 bitrate_controller_->AvailableBandwidth(&bitrate); | 
| 83 // Ipv4(20B) + UDP(8B) + SRTP(4B) + AverageTwccReport(20B) | |
| 
 
stefan-webrtc
2016/10/26 14:45:16
Is SRTP always 4B?
 
michaelt
2016/10/27 15:15:44
No i depends on the crypto. which is used. Will ta
 
stefan-webrtc
2016/10/31 08:54:36
Could you also add a short comment on how you deri
 
michaelt
2016/10/31 13:03:15
Did a mistake in the first measurement. I used the
 
stefan-webrtc
2016/10/31 14:04:19
I see. Could you just add a comment on that so tha
 
michaelt
2016/11/02 10:10:06
Done.
 
 | |
| 84 constexpr int kTwccReportSize = 20 + 8 + 4 + 20; | |
| 85 int send_interval_ms = | |
| 86 kTwccReportSize * 8.0 * 1000.0 / (0.05 * bitrate) + 0.5; | |
| 
 
stefan-webrtc
2016/10/26 14:45:16
You may have to explicitly cast to int.
 
michaelt
2016/10/27 15:15:44
Ok
 
 | |
| 87 send_interval_ms = std::min(std::max(send_interval_ms, kMinSendIntervalMs), | |
| 88 kMaxSendIntervalMs); | |
| 89 if (now - last_process_time_ms_ < send_interval_ms) | |
| 90 time_until_next = (last_process_time_ms_ + send_interval_ms - now); | |
| 76 } | 91 } | 
| 77 return time_until_next; | 92 return time_until_next; | 
| 78 } | 93 } | 
| 79 | 94 | 
| 80 void RemoteEstimatorProxy::Process() { | 95 void RemoteEstimatorProxy::Process() { | 
| 81 last_process_time_ms_ = clock_->TimeInMilliseconds(); | 96 last_process_time_ms_ = clock_->TimeInMilliseconds(); | 
| 82 | 97 | 
| 83 bool more_to_build = true; | 98 bool more_to_build = true; | 
| 84 while (more_to_build) { | 99 while (more_to_build) { | 
| 85 rtcp::TransportFeedback feedback_packet; | 100 rtcp::TransportFeedback feedback_packet; | 
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 // Note: Don't erase items from packet_arrival_times_ after sending, in case | 189 // Note: Don't erase items from packet_arrival_times_ after sending, in case | 
| 175 // they need to be re-sent after a reordering. Removal will be handled | 190 // they need to be re-sent after a reordering. Removal will be handled | 
| 176 // by OnPacketArrival once packets are too old. | 191 // by OnPacketArrival once packets are too old. | 
| 177 window_start_seq_ = it->first + 1; | 192 window_start_seq_ = it->first + 1; | 
| 178 } | 193 } | 
| 179 | 194 | 
| 180 return true; | 195 return true; | 
| 181 } | 196 } | 
| 182 | 197 | 
| 183 } // namespace webrtc | 198 } // namespace webrtc | 
| OLD | NEW |