Chromium Code Reviews| Index: webrtc/voice_engine/transport_feedback_packet_loss_tracker.h |
| diff --git a/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h b/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h |
| index e5626eb9b22a44d7961809f7f9a32f2f74938602..bfaeed8adc293e3b49977cd159b836c089513acd 100644 |
| --- a/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h |
| +++ b/webrtc/voice_engine/transport_feedback_packet_loss_tracker.h |
| @@ -24,21 +24,25 @@ class TransportFeedback; |
| class TransportFeedbackPacketLossTracker final { |
| public: |
| - // Up to |max_window_size| latest packet statuses wil be used for calculating |
| - // the packet loss metrics. When less than |min_window_size| samples are |
| - // available for making a reliable estimation, GetPacketLossRates() will |
| - // return false to indicate packet loss metrics are not ready. |
| - TransportFeedbackPacketLossTracker(size_t min_window_size, |
| - size_t max_window_size); |
| + // * Up to |max_window_size| latest packet statuses wil be used for |
|
minyue-webrtc
2017/01/30 09:30:23
wil -> will
elad.alon_webrtc.org
2017/01/30 16:37:13
Thanks.
|
| + // calculating the packet loss metrics. |
| + // * PLR (packet-loss-rate) is reliably computable once the status of |
|
minyue-webrtc
2017/01/30 09:30:23
status -> statuses
elad.alon_webrtc.org
2017/01/30 16:37:13
Done.
|
| + // |plr_min_num_packets| packets is known. |
|
minyue-webrtc
2017/01/30 09:30:23
is -> are
|
| + // * RPLR (recoverable-packet-loss-rate) is reliably computable once the |
| + // status of |rplr_min_num_pairs| pairs is known. |
|
minyue-webrtc
2017/01/30 09:30:23
statuses, are
|
| + TransportFeedbackPacketLossTracker(size_t max_window_size, |
| + size_t plr_min_num_packets, |
| + size_t rplr_min_num_pairs); |
| void OnReceivedTransportFeedback(const rtcp::TransportFeedback& feedback); |
| - // Returns true if packet loss rate and packet loss episode duration are ready |
| - // and assigns respective values to |*packet_loss_rate| and |
| - // |*consecutive_packet_loss_rate|. Continuous packet loss rate is defined as |
| - // the probability of losing two adjacent packets. |
| - bool GetPacketLossRates(float* packet_loss_rate, |
| - float* consecutive_packet_loss_rate) const; |
| + // Returns the packet loss rate, if the window has enough data to |
|
minyue-webrtc
2017/01/30 09:30:23
... if there are enough feedback statuses to relia
elad.alon_webrtc.org
2017/01/30 16:37:13
"Feedback statuses" is confusing to me. We get *fe
|
| + // reliably compute it. |
| + rtc::Optional<float> GetPacketLossRate() const; |
| + |
| + // Returns the first-order-FEC recoverable packet loss rate, if the window |
| + // has enough data to reliably compute it. |
|
minyue-webrtc
2017/01/30 09:30:24
... if there are enough feedback status pairs to r
elad.alon_webrtc.org
2017/01/30 16:37:13
Similarly.
|
| + rtc::Optional<float> GetRecoverablePacketLossRate() const; |
| // Verifies that the internal states are correct. Only used for tests. |
| void Validate() const; |
| @@ -51,6 +55,7 @@ class TransportFeedbackPacketLossTracker final { |
| typedef PacketStatus::const_iterator PacketStatusIterator; |
| void Reset(); |
| + |
| // ReferenceSequenceNumber() provides a sequence number that defines the |
| // order of packet reception info stored in |packet_status_window_|. In |
| // particular, given any sequence number |x|, |
| @@ -60,22 +65,59 @@ class TransportFeedbackPacketLossTracker final { |
| bool IsOldSequenceNumber(uint16_t seq_num) const; |
| void InsertPacketStatus(uint16_t seq_num, bool received); |
| void RemoveOldestPacketStatus(); |
| - void ApplyPacketStatus(PacketStatusIterator it); |
| - void UndoPacketStatus(PacketStatusIterator it); |
| + |
| + void UpdateMetrics(PacketStatusIterator it, bool apply /* false = undo */); |
| + void UpdatePlr(PacketStatusIterator it, bool apply /* false = undo */); |
| + void UpdateRplr(PacketStatusIterator it, bool apply /* false = undo */); |
| + |
| PacketStatusIterator PreviousPacketStatus(PacketStatusIterator it); |
| PacketStatusIterator NextPacketStatus(PacketStatusIterator it); |
| - const size_t min_window_size_; |
| const size_t max_window_size_; |
| PacketStatus packet_status_window_; |
| // |ref_packet_status_| points to the oldest item in |packet_status_window_|. |
| PacketStatusIterator ref_packet_status_; |
| - size_t num_received_packets_; |
| - size_t num_lost_packets_; |
| - size_t num_consecutive_losses_; |
| - size_t num_consecutive_old_reports_; |
| + // Packet-loss-rate calculation (lost / all-known-packets). |
| + struct PlrState { |
| + PlrState(size_t min_num_packets) |
| + : min_num_packets_(min_num_packets) { |
| + Reset(); |
| + } |
| + void Reset() { |
| + num_received_packets_ = 0; |
| + num_lost_packets_ = 0; |
| + } |
| + rtc::Optional<float> GetMetric() const; |
| + const size_t min_num_packets_; |
| + size_t num_received_packets_; |
| + size_t num_lost_packets_; |
| + } plr_state_; |
| + |
| + // Recoverable packet loss calculation (first-order-FEC recoverable). |
| + struct RplrState { |
| + RplrState(size_t min_num_pairs) |
| + : min_num_pairs_(min_num_pairs) { |
| + Reset(); |
| + } |
| + void Reset() { |
| + num_known_pairs_ = 0; |
|
minyue-webrtc
2017/01/30 09:30:23
ok if you change "known" to "ack" in the following
elad.alon_webrtc.org
2017/01/30 16:37:13
Sure, will do.
|
| + num_recoverable_losses_ = 0; |
| + } |
| + rtc::Optional<float> GetMetric() const; |
| + // Recoverable packets are those which were lost, but immediately followed |
| + // by a properly received packet. If that second packet carried FEC, |
| + // the data from lost packet that preceded it could be recovered. |
|
minyue-webrtc
2017/01/30 09:30:23
lost packet that preceded it -> the former lost pa
elad.alon_webrtc.org
2017/01/30 16:37:13
Done.
|
| + // The RPLR is calculated as the fraction of such pairs (lost-received) out |
| + // of all consecutive packet pairs, where the status (lost/received) of |
|
minyue-webrtc
2017/01/30 09:30:23
where the status (lost/received) of both packets i
elad.alon_webrtc.org
2017/01/30 16:37:13
I've employed a compromise phrasing which I hope w
minyue-webrtc
2017/01/31 08:28:11
yes, that is good.
|
| + // both packets is known. |
| + const size_t min_num_pairs_; |
| + size_t num_known_pairs_; |
| + size_t num_recoverable_losses_; |
| + } rplr_state_; |
| + |
| + size_t num_consecutive_old_reports_; // TODO(elad.alon): Upcoming CL removes. |
| }; |
| } // namespace webrtc |