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/events/rtc_event_probe_cluster_created.h" |
15 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 16 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
16 #include "webrtc/modules/pacing/paced_sender.h" | 17 #include "webrtc/modules/pacing/paced_sender.h" |
17 #include "webrtc/rtc_base/checks.h" | 18 #include "webrtc/rtc_base/checks.h" |
18 #include "webrtc/rtc_base/logging.h" | 19 #include "webrtc/rtc_base/logging.h" |
| 20 #include "webrtc/rtc_base/ptr_util.h" |
19 | 21 |
20 namespace webrtc { | 22 namespace webrtc { |
21 | 23 |
22 namespace { | 24 namespace { |
23 | 25 |
24 // A minimum interval between probes to allow scheduling to be feasible. | 26 // A minimum interval between probes to allow scheduling to be feasible. |
25 constexpr int kMinProbeDeltaMs = 1; | 27 constexpr int kMinProbeDeltaMs = 1; |
26 | 28 |
27 // The minimum number probing packets used. | 29 // The minimum number probing packets used. |
28 constexpr int kMinProbePacketsSent = 5; | 30 constexpr int kMinProbePacketsSent = 5; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 96 |
95 ProbeCluster cluster; | 97 ProbeCluster cluster; |
96 cluster.time_created_ms = now_ms; | 98 cluster.time_created_ms = now_ms; |
97 cluster.pace_info.probe_cluster_min_probes = kMinProbePacketsSent; | 99 cluster.pace_info.probe_cluster_min_probes = kMinProbePacketsSent; |
98 cluster.pace_info.probe_cluster_min_bytes = | 100 cluster.pace_info.probe_cluster_min_bytes = |
99 bitrate_bps * kMinProbeDurationMs / 8000; | 101 bitrate_bps * kMinProbeDurationMs / 8000; |
100 cluster.pace_info.send_bitrate_bps = bitrate_bps; | 102 cluster.pace_info.send_bitrate_bps = bitrate_bps; |
101 cluster.pace_info.probe_cluster_id = next_cluster_id_++; | 103 cluster.pace_info.probe_cluster_id = next_cluster_id_++; |
102 clusters_.push(cluster); | 104 clusters_.push(cluster); |
103 if (event_log_) | 105 if (event_log_) |
104 event_log_->LogProbeClusterCreated( | 106 event_log_->Log(rtc::MakeUnique<RtcEventProbeClusterCreated>( |
105 cluster.pace_info.probe_cluster_id, cluster.pace_info.send_bitrate_bps, | 107 cluster.pace_info.probe_cluster_id, cluster.pace_info.send_bitrate_bps, |
106 cluster.pace_info.probe_cluster_min_probes, | 108 cluster.pace_info.probe_cluster_min_probes, |
107 cluster.pace_info.probe_cluster_min_bytes); | 109 cluster.pace_info.probe_cluster_min_bytes)); |
108 | 110 |
109 LOG(LS_INFO) << "Probe cluster (bitrate:min bytes:min packets): (" | 111 LOG(LS_INFO) << "Probe cluster (bitrate:min bytes:min packets): (" |
110 << cluster.pace_info.send_bitrate_bps << ":" | 112 << cluster.pace_info.send_bitrate_bps << ":" |
111 << cluster.pace_info.probe_cluster_min_bytes << ":" | 113 << cluster.pace_info.probe_cluster_min_bytes << ":" |
112 << cluster.pace_info.probe_cluster_min_probes << ")"; | 114 << cluster.pace_info.probe_cluster_min_probes << ")"; |
113 // If we are already probing, continue to do so. Otherwise set it to | 115 // If we are already probing, continue to do so. Otherwise set it to |
114 // kInactive and wait for OnIncomingPacket to start the probing. | 116 // kInactive and wait for OnIncomingPacket to start the probing. |
115 if (probing_state_ != ProbingState::kActive) | 117 if (probing_state_ != ProbingState::kActive) |
116 probing_state_ = ProbingState::kInactive; | 118 probing_state_ = ProbingState::kInactive; |
117 } | 119 } |
(...skipping 76 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 | 196 // Compute the time delta from the cluster start to ensure probe bitrate stays |
195 // close to the target bitrate. Result is in milliseconds. | 197 // close to the target bitrate. Result is in milliseconds. |
196 int64_t delta_ms = | 198 int64_t delta_ms = |
197 (8000ll * cluster.sent_bytes + cluster.pace_info.send_bitrate_bps / 2) / | 199 (8000ll * cluster.sent_bytes + cluster.pace_info.send_bitrate_bps / 2) / |
198 cluster.pace_info.send_bitrate_bps; | 200 cluster.pace_info.send_bitrate_bps; |
199 return cluster.time_started_ms + delta_ms; | 201 return cluster.time_started_ms + delta_ms; |
200 } | 202 } |
201 | 203 |
202 | 204 |
203 } // namespace webrtc | 205 } // namespace webrtc |
OLD | NEW |