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 #ifndef WEBRTC_MODULES_PACING_BITRATE_PROBER_H_ | 11 #ifndef WEBRTC_MODULES_PACING_BITRATE_PROBER_H_ |
12 #define WEBRTC_MODULES_PACING_BITRATE_PROBER_H_ | 12 #define WEBRTC_MODULES_PACING_BITRATE_PROBER_H_ |
13 | 13 |
14 #include <cstddef> | |
15 #include <list> | |
16 #include <queue> | 14 #include <queue> |
17 | 15 |
| 16 #include "webrtc/base/basictypes.h" |
18 #include "webrtc/typedefs.h" | 17 #include "webrtc/typedefs.h" |
19 | 18 |
20 namespace webrtc { | 19 namespace webrtc { |
21 | 20 |
22 // Note that this class isn't thread-safe by itself and therefore relies | 21 // Note that this class isn't thread-safe by itself and therefore relies |
23 // on being protected by the caller. | 22 // on being protected by the caller. |
24 class BitrateProber { | 23 class BitrateProber { |
25 public: | 24 public: |
26 BitrateProber(); | 25 BitrateProber(); |
27 | 26 |
28 void SetEnabled(bool enable); | 27 void SetEnabled(bool enable); |
29 | 28 |
30 // Returns true if the prober is in a probing session, i.e., it currently | 29 // Returns true if the prober is in a probing session, i.e., it currently |
31 // wants packets to be sent out according to the time returned by | 30 // wants packets to be sent out according to the time returned by |
32 // TimeUntilNextProbe(). | 31 // TimeUntilNextProbe(). |
33 bool IsProbing() const; | 32 bool IsProbing() const; |
34 | 33 |
35 // Initializes a new probing session if the prober is allowed to probe. Does | 34 // Initializes a new probing session if the prober is allowed to probe. Does |
36 // not initialize the prober unless the packet size is large enough to probe | 35 // not initialize the prober unless the packet size is large enough to probe |
37 // with. | 36 // with. |
38 void OnIncomingPacket(uint32_t bitrate_bps, | 37 void OnIncomingPacket(size_t packet_size); |
39 size_t packet_size, | 38 |
40 int64_t now_ms); | 39 // Create a cluster used to probe for |bitrate_bps| with |num_packets| number |
| 40 // of packets. |
| 41 void ProbeAtBitrate(uint32_t bitrate_bps, int num_packets); |
41 | 42 |
42 // Returns the number of milliseconds until the next packet should be sent to | 43 // Returns the number of milliseconds until the next packet should be sent to |
43 // get accurate probing. | 44 // get accurate probing. |
44 int TimeUntilNextProbe(int64_t now_ms); | 45 int TimeUntilNextProbe(int64_t now_ms); |
45 | 46 |
46 // Which cluster that is currently being used for probing. | 47 // Which cluster that is currently being used for probing. |
47 int CurrentClusterId() const; | 48 int CurrentClusterId() const; |
48 | 49 |
49 // Returns the number of bytes that the prober recommends for the next probe | 50 // Returns the number of bytes that the prober recommends for the next probe |
50 // packet. | 51 // packet. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // the previous probe packet based on the size and time when that packet was | 84 // the previous probe packet based on the size and time when that packet was |
84 // sent. | 85 // sent. |
85 std::queue<ProbeCluster> clusters_; | 86 std::queue<ProbeCluster> clusters_; |
86 size_t packet_size_last_sent_; | 87 size_t packet_size_last_sent_; |
87 // The last time a probe was sent. | 88 // The last time a probe was sent. |
88 int64_t time_last_probe_sent_ms_; | 89 int64_t time_last_probe_sent_ms_; |
89 int next_cluster_id_; | 90 int next_cluster_id_; |
90 }; | 91 }; |
91 } // namespace webrtc | 92 } // namespace webrtc |
92 #endif // WEBRTC_MODULES_PACING_BITRATE_PROBER_H_ | 93 #endif // WEBRTC_MODULES_PACING_BITRATE_PROBER_H_ |
OLD | NEW |