OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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/pacing/bitrate_prober.h" | 11 #include "webrtc/modules/pacing/bitrate_prober.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 | 14 |
15 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 15 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
16 #include "webrtc/modules/pacing/paced_sender.h" | 16 #include "webrtc/modules/pacing/paced_sender.h" |
17 #include "webrtc/rtc_base/checks.h" | 17 #include "webrtc/rtc_base/checks.h" |
18 #include "webrtc/rtc_base/logging.h" | 18 #include "webrtc/rtc_base/logging.h" |
| 19 #include "webrtc/system_wrappers/include/clock.h" |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // A minimum interval between probes to allow scheduling to be feasible. | 25 // A minimum interval between probes to allow scheduling to be feasible. |
25 constexpr int kMinProbeDeltaMs = 1; | 26 constexpr int kMinProbeDeltaMs = 1; |
26 | 27 |
27 // The minimum number probing packets used. | 28 // The minimum number probing packets used. |
28 constexpr int kMinProbePacketsSent = 5; | 29 constexpr int kMinProbePacketsSent = 5; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 bitrate_bps * kMinProbeDurationMs / 8000; | 100 bitrate_bps * kMinProbeDurationMs / 8000; |
100 cluster.pace_info.send_bitrate_bps = bitrate_bps; | 101 cluster.pace_info.send_bitrate_bps = bitrate_bps; |
101 cluster.pace_info.probe_cluster_id = next_cluster_id_++; | 102 cluster.pace_info.probe_cluster_id = next_cluster_id_++; |
102 clusters_.push(cluster); | 103 clusters_.push(cluster); |
103 if (event_log_) | 104 if (event_log_) |
104 event_log_->LogProbeClusterCreated( | 105 event_log_->LogProbeClusterCreated( |
105 cluster.pace_info.probe_cluster_id, cluster.pace_info.send_bitrate_bps, | 106 cluster.pace_info.probe_cluster_id, cluster.pace_info.send_bitrate_bps, |
106 cluster.pace_info.probe_cluster_min_probes, | 107 cluster.pace_info.probe_cluster_min_probes, |
107 cluster.pace_info.probe_cluster_min_bytes); | 108 cluster.pace_info.probe_cluster_min_bytes); |
108 | 109 |
109 LOG(LS_INFO) << "Probe cluster (bitrate:min bytes:min packets): (" | 110 std::stringstream ss; |
| 111 ss << "Probe cluster (id:bitrate:min bytes:min packets): (" |
| 112 << cluster.pace_info.probe_cluster_id << ":" |
| 113 << cluster.pace_info.send_bitrate_bps << ":" |
| 114 << cluster.pace_info.probe_cluster_min_bytes << ":" |
| 115 << cluster.pace_info.probe_cluster_min_probes << ")"; |
| 116 Print("%s", ss.str().c_str()); |
| 117 LOG(LS_INFO) << "Probe cluster (id:bitrate:min bytes:min packets): (" |
| 118 << cluster.pace_info.probe_cluster_id << ":" |
110 << cluster.pace_info.send_bitrate_bps << ":" | 119 << cluster.pace_info.send_bitrate_bps << ":" |
111 << cluster.pace_info.probe_cluster_min_bytes << ":" | 120 << cluster.pace_info.probe_cluster_min_bytes << ":" |
112 << cluster.pace_info.probe_cluster_min_probes << ")"; | 121 << cluster.pace_info.probe_cluster_min_probes << ")"; |
113 // If we are already probing, continue to do so. Otherwise set it to | 122 // If we are already probing, continue to do so. Otherwise set it to |
114 // kInactive and wait for OnIncomingPacket to start the probing. | 123 // kInactive and wait for OnIncomingPacket to start the probing. |
115 if (probing_state_ != ProbingState::kActive) | 124 if (probing_state_ != ProbingState::kActive) |
116 probing_state_ = ProbingState::kInactive; | 125 probing_state_ = ProbingState::kInactive; |
117 } | 126 } |
118 | 127 |
119 void BitrateProber::ResetState(int64_t now_ms) { | 128 void BitrateProber::ResetState(int64_t now_ms) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // Compute the time delta from the cluster start to ensure probe bitrate stays | 203 // Compute the time delta from the cluster start to ensure probe bitrate stays |
195 // close to the target bitrate. Result is in milliseconds. | 204 // close to the target bitrate. Result is in milliseconds. |
196 int64_t delta_ms = | 205 int64_t delta_ms = |
197 (8000ll * cluster.sent_bytes + cluster.pace_info.send_bitrate_bps / 2) / | 206 (8000ll * cluster.sent_bytes + cluster.pace_info.send_bitrate_bps / 2) / |
198 cluster.pace_info.send_bitrate_bps; | 207 cluster.pace_info.send_bitrate_bps; |
199 return cluster.time_started_ms + delta_ms; | 208 return cluster.time_started_ms + delta_ms; |
200 } | 209 } |
201 | 210 |
202 | 211 |
203 } // namespace webrtc | 212 } // namespace webrtc |
OLD | NEW |