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

Side by Side Diff: webrtc/voice_engine/transport_feedback_packet_loss_tracker.h

Issue 2579613003: Add TransportFeedbackPacketLossTracker. (Closed)
Patch Set: undo mocking Created 3 years, 11 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
kwiberg-webrtc 2017/01/23 14:04:36 2017! This probably applies to other files too.
minyue-webrtc 2017/01/23 14:29:38 Done.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_VOICE_ENGINE_TRANSPORT_FEEDBACK_PACKET_LOSS_TRACKER_H_
12 #define WEBRTC_VOICE_ENGINE_TRANSPORT_FEEDBACK_PACKET_LOSS_TRACKER_H_
13
14 #include <map>
15
16 #include "webrtc/base/optional.h"
17 #include "webrtc/modules/include/module_common_types.h"
18
19 namespace webrtc {
20
21 namespace rtcp {
22 class TransportFeedback;
23 }
24
25 class TransportFeedbackPacketLossTracker final {
26 public:
27 // Up to |max_window_size| latest packet statuses wil be used for calculating
28 // the packet loss metrics. When less than |min_window_size| samples are
29 // available for making a reliable estimation, GetPacketLossRates() will
30 // return false to indicate packet loss metrics are not ready.
31 TransportFeedbackPacketLossTracker(size_t min_window_size,
32 size_t max_window_size);
33
34 void OnReceivedTransportFeedback(const rtcp::TransportFeedback& feedback);
35
36 // Returns true if packet loss rate and packet loss episode duration are ready
37 // and assigns respective values to |*packet_loss_rate| and
38 // |*consecutive_packet_loss_rate|. Continuous packet loss rate is defined as
39 // the probability of losing two adjacent packets.
40 bool GetPacketLossRates(float* packet_loss_rate,
41 float* consecutive_packet_loss_rate) const;
42
43 // Verifies that the internal states are correct. Only used for tests.
44 void Validate() const;
45
46 private:
47 // PacketStatus is a map from sequence number to a boolean. The boolean is
48 // true if it is received.
kwiberg-webrtc 2017/01/23 14:04:36 What does false mean? What does not present mean?
minyue-webrtc 2017/01/23 14:29:38 updated the comment.
kwiberg-webrtc 2017/01/23 14:47:17 Excellent.
49 typedef std::map<uint16_t, bool> PacketStatus;
50 typedef PacketStatus::const_iterator PacketStatusIterator;
51
52 void Reset();
53 // ReferenceSequenceNumber() provides a sequence number that defines the
54 // order of packet reception info stored in |packet_status_window_|. In
55 // particular, given any sequence number |x|,
56 // (2^16 + x - ref_seq_num_) % 2^16 defines its actual position in
57 // |packet_status_window_|.
58 uint16_t ReferenceSequenceNumber() const;
59 bool IsOldSequenceNumber(uint16_t seq_num) const;
60 void InsertPacketStatus(uint16_t seq_num, bool received);
61 void RemoveOldestPacketStatus();
62 void ApplyPacketStatus(PacketStatusIterator it);
63 void UndoPacketStatus(PacketStatusIterator it);
64 PacketStatusIterator PreviousPacketStatus(PacketStatusIterator it);
65 PacketStatusIterator NextPacketStatus(PacketStatusIterator it);
66
67 const size_t min_window_size_;
68 const size_t max_window_size_;
69
70 PacketStatus packet_status_window_;
71 // |ref_packet_status_| points to the oldest item in |packet_status_window_|.
72 PacketStatusIterator ref_packet_status_;
73
74 size_t num_received_packets_;
75 size_t num_lost_packets_;
76 size_t num_consecutive_losses_;
77 size_t num_consecutive_old_reports_;
78 };
79
80 } // namespace webrtc
81
82 #endif // WEBRTC_VOICE_ENGINE_TRANSPORT_FEEDBACK_PACKET_LOSS_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698