Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: webrtc/modules/pacing/bitrate_prober.cc

Issue 1947873002: Reland of Remove SendPacer from ViEEncoder (patchset #13 id:240001 of https://codereview.we… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed CongestionController backwards compatibility Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/pacing/bitrate_prober.h ('k') | webrtc/modules/pacing/mock/mock_paced_sender.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <assert.h> 13 #include <assert.h>
14 #include <algorithm> 14 #include <algorithm>
15 #include <limits> 15 #include <limits>
16 #include <sstream> 16 #include <sstream>
17 17
18 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
19 #include "webrtc/modules/pacing/paced_sender.h" 19 #include "webrtc/modules/pacing/paced_sender.h"
20 20
21 namespace webrtc { 21 namespace webrtc {
22 22
23 namespace { 23 namespace {
24 int ComputeDeltaFromBitrate(size_t packet_size, int bitrate_bps) { 24 int ComputeDeltaFromBitrate(size_t packet_size, uint32_t bitrate_bps) {
25 assert(bitrate_bps > 0); 25 assert(bitrate_bps > 0);
26 // Compute the time delta needed to send packet_size bytes at bitrate_bps 26 // Compute the time delta needed to send packet_size bytes at bitrate_bps
27 // bps. Result is in milliseconds. 27 // bps. Result is in milliseconds.
28 return static_cast<int>(1000ll * static_cast<int64_t>(packet_size) * 8ll / 28 return static_cast<int>(1000ll * static_cast<int64_t>(packet_size) * 8ll /
29 bitrate_bps); 29 bitrate_bps);
30 } 30 }
31 } // namespace 31 } // namespace
32 32
33 BitrateProber::BitrateProber() 33 BitrateProber::BitrateProber()
34 : probing_state_(kDisabled), 34 : probing_state_(kDisabled),
(...skipping 10 matching lines...) Expand all
45 } else { 45 } else {
46 probing_state_ = kDisabled; 46 probing_state_ = kDisabled;
47 LOG(LS_INFO) << "Initial bandwidth probing disabled"; 47 LOG(LS_INFO) << "Initial bandwidth probing disabled";
48 } 48 }
49 } 49 }
50 50
51 bool BitrateProber::IsProbing() const { 51 bool BitrateProber::IsProbing() const {
52 return probing_state_ == kProbing; 52 return probing_state_ == kProbing;
53 } 53 }
54 54
55 void BitrateProber::OnIncomingPacket(int bitrate_bps, 55 void BitrateProber::OnIncomingPacket(uint32_t bitrate_bps,
56 size_t packet_size, 56 size_t packet_size,
57 int64_t now_ms) { 57 int64_t now_ms) {
58 // Don't initialize probing unless we have something large enough to start 58 // Don't initialize probing unless we have something large enough to start
59 // probing. 59 // probing.
60 if (packet_size < PacedSender::kMinProbePacketSize) 60 if (packet_size < PacedSender::kMinProbePacketSize)
61 return; 61 return;
62 if (probing_state_ != kAllowedToProbe) 62 if (probing_state_ != kAllowedToProbe)
63 return; 63 return;
64 probe_bitrates_.clear(); 64 probe_bitrates_.clear();
65 // Max number of packets used for probing. 65 // Max number of packets used for probing.
66 const int kMaxNumProbes = 2; 66 const int kMaxNumProbes = 2;
67 const int kPacketsPerProbe = 5; 67 const int kPacketsPerProbe = 5;
68 const float kProbeBitrateMultipliers[kMaxNumProbes] = {3, 6}; 68 const float kProbeBitrateMultipliers[kMaxNumProbes] = {3, 6};
69 int bitrates_bps[kMaxNumProbes]; 69 uint32_t bitrates_bps[kMaxNumProbes];
70 std::stringstream bitrate_log; 70 std::stringstream bitrate_log;
71 bitrate_log << "Start probing for bandwidth, bitrates:"; 71 bitrate_log << "Start probing for bandwidth, bitrates:";
72 for (int i = 0; i < kMaxNumProbes; ++i) { 72 for (int i = 0; i < kMaxNumProbes; ++i) {
73 bitrates_bps[i] = kProbeBitrateMultipliers[i] * bitrate_bps; 73 bitrates_bps[i] = kProbeBitrateMultipliers[i] * bitrate_bps;
74 bitrate_log << " " << bitrates_bps[i]; 74 bitrate_log << " " << bitrates_bps[i];
75 // We need one extra to get 5 deltas for the first probe. 75 // We need one extra to get 5 deltas for the first probe.
76 if (i == 0) 76 if (i == 0)
77 probe_bitrates_.push_back(bitrates_bps[i]); 77 probe_bitrates_.push_back(bitrates_bps[i]);
78 for (int j = 0; j < kPacketsPerProbe; ++j) 78 for (int j = 0; j < kPacketsPerProbe; ++j)
79 probe_bitrates_.push_back(bitrates_bps[i]); 79 probe_bitrates_.push_back(bitrates_bps[i]);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (packet_size < PacedSender::kMinProbePacketSize) 138 if (packet_size < PacedSender::kMinProbePacketSize)
139 return; 139 return;
140 packet_size_last_send_ = packet_size; 140 packet_size_last_send_ = packet_size;
141 time_last_send_ms_ = now_ms; 141 time_last_send_ms_ = now_ms;
142 if (probing_state_ != kProbing) 142 if (probing_state_ != kProbing)
143 return; 143 return;
144 if (!probe_bitrates_.empty()) 144 if (!probe_bitrates_.empty())
145 probe_bitrates_.pop_front(); 145 probe_bitrates_.pop_front();
146 } 146 }
147 } // namespace webrtc 147 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/bitrate_prober.h ('k') | webrtc/modules/pacing/mock/mock_paced_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698