Chromium Code Reviews| 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 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 | 57 |
| 58 void BitrateProber::OnIncomingPacket(size_t packet_size) { | 58 void BitrateProber::OnIncomingPacket(size_t packet_size) { |
| 59 // Don't initialize probing unless we have something large enough to start | 59 // Don't initialize probing unless we have something large enough to start |
| 60 // probing. | 60 // probing. |
| 61 if (probing_state_ == ProbingState::kInactive && | 61 if (probing_state_ == ProbingState::kInactive && |
| 62 packet_size >= PacedSender::kMinProbePacketSize) { | 62 packet_size >= PacedSender::kMinProbePacketSize) { |
| 63 probing_state_ = ProbingState::kActive; | 63 probing_state_ = ProbingState::kActive; |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void BitrateProber::ProbeAtBitrate(uint32_t bitrate_bps, int num_packets) { | 67 void BitrateProber::CreateProbeCluster(int bitrate_bps, int num_packets) { |
| 68 ProbeCluster cluster; | 68 ProbeCluster cluster; |
| 69 cluster.max_probe_packets = num_packets; | 69 cluster.max_probe_packets = num_packets; |
| 70 cluster.probe_bitrate_bps = bitrate_bps; | 70 cluster.probe_bitrate_bps = bitrate_bps; |
| 71 cluster.id = next_cluster_id_++; | 71 cluster.id = next_cluster_id_++; |
| 72 clusters_.push(cluster); | 72 clusters_.push(cluster); |
| 73 LOG(LS_INFO) << "Probe cluster (bitrate:packets): (" | 73 LOG(LS_INFO) << "Probe cluster (bitrate:packets): (" |
| 74 << cluster.probe_bitrate_bps << ":" << cluster.max_probe_packets | 74 << cluster.probe_bitrate_bps << ":" << cluster.max_probe_packets |
| 75 << ") "; | 75 << ") "; |
| 76 if (probing_state_ != ProbingState::kActive) | 76 if (probing_state_ != ProbingState::kActive) |
| 77 probing_state_ = ProbingState::kInactive; | 77 probing_state_ = ProbingState::kInactive; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void BitrateProber::ResetState() { | 80 void BitrateProber::ResetState() { |
| 81 time_last_probe_sent_ms_ = -1; | 81 time_last_probe_sent_ms_ = -1; |
| 82 packet_size_last_sent_ = 0; | 82 packet_size_last_sent_ = 0; |
| 83 | 83 |
| 84 // Recreate all probing clusters. | 84 // Recreate all probing clusters. |
| 85 std::queue<ProbeCluster> clusters; | 85 std::queue<ProbeCluster> clusters; |
| 86 clusters.swap(clusters_); | 86 clusters.swap(clusters_); |
| 87 while (!clusters.empty()) { | 87 while (!clusters.empty()) { |
| 88 ProbeAtBitrate(clusters.front().probe_bitrate_bps, | 88 CreateProbeCluster(clusters.front().probe_bitrate_bps, |
| 89 clusters.front().max_probe_packets); | 89 clusters.front().max_probe_packets); |
|
stefan-webrtc
2016/08/16 13:28:29
git cl format
| |
| 90 clusters.pop(); | 90 clusters.pop(); |
| 91 } | 91 } |
| 92 // If its enabled, reset to inactive. | 92 // If its enabled, reset to inactive. |
| 93 if (probing_state_ != ProbingState::kDisabled) | 93 if (probing_state_ != ProbingState::kDisabled) |
| 94 probing_state_ = ProbingState::kInactive; | 94 probing_state_ = ProbingState::kInactive; |
| 95 } | 95 } |
| 96 | 96 |
| 97 int BitrateProber::TimeUntilNextProbe(int64_t now_ms) { | 97 int BitrateProber::TimeUntilNextProbe(int64_t now_ms) { |
| 98 // Probing is not active or probing is already complete. | 98 // Probing is not active or probing is already complete. |
| 99 if (probing_state_ != ProbingState::kActive || clusters_.empty()) | 99 if (probing_state_ != ProbingState::kActive || clusters_.empty()) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 if (!clusters_.empty()) { | 155 if (!clusters_.empty()) { |
| 156 ProbeCluster* cluster = &clusters_.front(); | 156 ProbeCluster* cluster = &clusters_.front(); |
| 157 ++cluster->sent_probe_packets; | 157 ++cluster->sent_probe_packets; |
| 158 if (cluster->sent_probe_packets == cluster->max_probe_packets) | 158 if (cluster->sent_probe_packets == cluster->max_probe_packets) |
| 159 clusters_.pop(); | 159 clusters_.pop(); |
| 160 if (clusters_.empty()) | 160 if (clusters_.empty()) |
| 161 probing_state_ = ProbingState::kSuspended; | 161 probing_state_ = ProbingState::kSuspended; |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 } // namespace webrtc | 164 } // namespace webrtc |
| OLD | NEW |