Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_PROBE_BITRATE_ESTIMATOR_H_ | 11 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_PROBE_BITRATE_ESTIMATOR_H_ |
| 12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_PROBE_BITRATE_ESTIMATOR_H_ | 12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_PROBE_BITRATE_ESTIMATOR_H_ |
| 13 | 13 |
| 14 #include <limits> | |
| 14 #include <map> | 15 #include <map> |
| 15 #include <limits> | 16 #include <set> |
| 16 | 17 |
| 17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 18 | 19 |
| 19 namespace webrtc { | 20 namespace webrtc { |
| 20 | 21 |
| 21 struct ProbingResult { | 22 struct ProbingResult { |
| 22 static constexpr int kNoEstimate = -1; | 23 static constexpr int kNoEstimate = -1; |
| 23 | 24 |
| 24 ProbingResult(); | 25 ProbingResult(); |
| 25 ProbingResult(int bps, int64_t timestamp); | 26 ProbingResult(int bps, int64_t timestamp); |
| 26 bool valid() const; | 27 bool valid() const; |
| 27 | 28 |
| 28 int bps; | 29 int bps; |
| 29 int64_t timestamp; | 30 int64_t timestamp; |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 class ProbeBitrateEstimator { | 33 class ProbeBitrateEstimator { |
| 33 public: | 34 public: |
| 34 ProbeBitrateEstimator(); | 35 ProbeBitrateEstimator(); |
| 35 | 36 |
| 36 // Should be called for every packet we receive feedback about. If the | 37 // Should be called for every packet we receive feedback about. If the |
| 37 // packet was used for probing it will validate/calculate the resulting | 38 // packet was used for probing it will validate/calculate the resulting |
| 38 // bitrate and return the result. | 39 // bitrate and return the result. |
| 39 ProbingResult PacketFeedback(const PacketInfo& packet_info); | 40 ProbingResult PacketFeedback(const PacketInfo& packet_info); |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 struct AggregatedCluster { | 43 struct AggregatedCluster { |
| 43 int num_probes = 0; | 44 // Since sending padding can result in multiple packets being sent (all |
|
danilchap
2016/08/19 14:08:31
same send time is common, but not guaranteed (it i
| |
| 45 // with the same send time), we keep track of how many unique send times | |
| 46 // we have seen to make sure we don't count the same request to send padding | |
| 47 // as separate packets in the probing cluster. | |
| 48 std::set<int64_t> send_times_ms; | |
| 44 int64_t first_send_ms = std::numeric_limits<int64_t>::max(); | 49 int64_t first_send_ms = std::numeric_limits<int64_t>::max(); |
| 45 int64_t last_send_ms = 0; | 50 int64_t last_send_ms = 0; |
| 46 int64_t first_receive_ms = std::numeric_limits<int64_t>::max(); | 51 int64_t first_receive_ms = std::numeric_limits<int64_t>::max(); |
| 47 int64_t last_receive_ms = 0; | 52 int64_t last_receive_ms = 0; |
| 48 size_t size = 0; | 53 size_t size = 0; |
| 49 }; | 54 }; |
| 50 | 55 |
| 51 std::map<int, AggregatedCluster> clusters_; | 56 std::map<int, AggregatedCluster> clusters_; |
| 52 int last_valid_cluster_id_; | 57 int last_valid_cluster_id_; |
| 53 }; | 58 }; |
| 54 | 59 |
| 55 } // namespace webrtc | 60 } // namespace webrtc |
| 56 | 61 |
| 57 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_PROBE_BITRATE_ESTIMATOR_H_ | 62 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_PROBE_BITRATE_ESTIMATOR_H_ |
| OLD | NEW |